Lines Matching refs:packet
259 let packet = Self::new_unchecked(buffer); in new_checked() localVariable
260 packet.check_len()?; in new_checked()
261 Ok(packet) in new_checked()
546 packet: &Packet<&'a T>, in parse()
552 fn create_packet_from_payload<'a, T>(packet: &Packet<&'a T>) -> Result<(&'a [u8], Ipv6Repr)> in parse()
556 let ip_packet = Ipv6Packet::new_checked(packet.payload())?; in parse()
558 let payload = &packet.payload()[ip_packet.header_len()..]; in parse()
572 if checksum_caps.icmpv6.rx() && !packet.verify_checksum(src_addr, dst_addr) { in parse()
576 match (packet.msg_type(), packet.msg_code()) { in parse()
578 let (payload, repr) = create_packet_from_payload(packet)?; in parse()
586 let (payload, repr) = create_packet_from_payload(packet)?; in parse()
588 mtu: packet.pkt_too_big_mtu(), in parse()
594 let (payload, repr) = create_packet_from_payload(packet)?; in parse()
602 let (payload, repr) = create_packet_from_payload(packet)?; in parse()
605 pointer: packet.param_problem_ptr(), in parse()
611 ident: packet.echo_ident(), in parse()
612 seq_no: packet.echo_seq_no(), in parse()
613 data: packet.payload(), in parse()
616 ident: packet.echo_ident(), in parse()
617 seq_no: packet.echo_seq_no(), in parse()
618 data: packet.payload(), in parse()
621 (msg_type, 0) if msg_type.is_ndisc() => NdiscRepr::parse(packet).map(Repr::Ndisc), in parse()
622 (msg_type, 0) if msg_type.is_mld() => MldRepr::parse(packet).map(Repr::Mld), in parse()
651 packet: &mut Packet<&mut T>, in emit()
669 packet.set_msg_type(Message::DstUnreachable); in emit()
670 packet.set_msg_code(reason.into()); in emit()
672 emit_contained_packet(packet.payload_mut(), header, data); in emit()
676 packet.set_msg_type(Message::PktTooBig); in emit()
677 packet.set_msg_code(0); in emit()
678 packet.set_pkt_too_big_mtu(mtu); in emit()
680 emit_contained_packet(packet.payload_mut(), header, data); in emit()
688 packet.set_msg_type(Message::TimeExceeded); in emit()
689 packet.set_msg_code(reason.into()); in emit()
691 emit_contained_packet(packet.payload_mut(), header, data); in emit()
700 packet.set_msg_type(Message::ParamProblem); in emit()
701 packet.set_msg_code(reason.into()); in emit()
702 packet.set_param_problem_ptr(pointer); in emit()
704 emit_contained_packet(packet.payload_mut(), header, data); in emit()
712 packet.set_msg_type(Message::EchoRequest); in emit()
713 packet.set_msg_code(0); in emit()
714 packet.set_echo_ident(ident); in emit()
715 packet.set_echo_seq_no(seq_no); in emit()
716 let data_len = cmp::min(packet.payload_mut().len(), data.len()); in emit()
717 packet.payload_mut()[..data_len].copy_from_slice(&data[..data_len]) in emit()
725 packet.set_msg_type(Message::EchoReply); in emit()
726 packet.set_msg_code(0); in emit()
727 packet.set_echo_ident(ident); in emit()
728 packet.set_echo_seq_no(seq_no); in emit()
729 let data_len = cmp::min(packet.payload_mut().len(), data.len()); in emit()
730 packet.payload_mut()[..data_len].copy_from_slice(&data[..data_len]) in emit()
734 Repr::Ndisc(ndisc) => ndisc.emit(packet), in emit()
736 Repr::Mld(mld) => mld.emit(packet), in emit()
740 packet.fill_checksum(src_addr, dst_addr); in emit()
743 packet.set_checksum(0); in emit()
808 let packet = Packet::new_unchecked(&ECHO_PACKET_BYTES[..]); in test_echo_deconstruct() localVariable
809 assert_eq!(packet.msg_type(), Message::EchoRequest); in test_echo_deconstruct()
810 assert_eq!(packet.msg_code(), 0); in test_echo_deconstruct()
811 assert_eq!(packet.checksum(), 0x19b3); in test_echo_deconstruct()
812 assert_eq!(packet.echo_ident(), 0x1234); in test_echo_deconstruct()
813 assert_eq!(packet.echo_seq_no(), 0xabcd); in test_echo_deconstruct()
814 assert_eq!(packet.payload(), &ECHO_PACKET_PAYLOAD[..]); in test_echo_deconstruct()
815 assert!(packet.verify_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2)); in test_echo_deconstruct()
816 assert!(!packet.msg_type().is_error()); in test_echo_deconstruct()
822 let mut packet = Packet::new_unchecked(&mut bytes); in test_echo_construct() localVariable
823 packet.set_msg_type(Message::EchoRequest); in test_echo_construct()
824 packet.set_msg_code(0); in test_echo_construct()
825 packet.set_echo_ident(0x1234); in test_echo_construct()
826 packet.set_echo_seq_no(0xabcd); in test_echo_construct()
827 packet in test_echo_construct()
830 packet.fill_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2); in test_echo_construct()
831 assert_eq!(&*packet.into_inner(), &ECHO_PACKET_BYTES[..]); in test_echo_construct()
836 let packet = Packet::new_unchecked(&ECHO_PACKET_BYTES[..]); in test_echo_repr_parse() localVariable
840 &packet, in test_echo_repr_parse()
851 let mut packet = Packet::new_unchecked(&mut bytes); in test_echo_emit() localVariable
855 &mut packet, in test_echo_emit()
858 assert_eq!(&*packet.into_inner(), &ECHO_PACKET_BYTES[..]); in test_echo_emit()
863 let packet = Packet::new_unchecked(&PKT_TOO_BIG_BYTES[..]); in test_too_big_deconstruct() localVariable
864 assert_eq!(packet.msg_type(), Message::PktTooBig); in test_too_big_deconstruct()
865 assert_eq!(packet.msg_code(), 0); in test_too_big_deconstruct()
866 assert_eq!(packet.checksum(), 0x0fc9); in test_too_big_deconstruct()
867 assert_eq!(packet.pkt_too_big_mtu(), 1500); in test_too_big_deconstruct()
868 assert_eq!(packet.payload(), &PKT_TOO_BIG_IP_PAYLOAD[..]); in test_too_big_deconstruct()
869 assert!(packet.verify_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2)); in test_too_big_deconstruct()
870 assert!(packet.msg_type().is_error()); in test_too_big_deconstruct()
876 let mut packet = Packet::new_unchecked(&mut bytes); in test_too_big_construct() localVariable
877 packet.set_msg_type(Message::PktTooBig); in test_too_big_construct()
878 packet.set_msg_code(0); in test_too_big_construct()
879 packet.set_pkt_too_big_mtu(1500); in test_too_big_construct()
880 packet in test_too_big_construct()
883 packet.fill_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2); in test_too_big_construct()
884 assert_eq!(&*packet.into_inner(), &PKT_TOO_BIG_BYTES[..]); in test_too_big_construct()
889 let packet = Packet::new_unchecked(&PKT_TOO_BIG_BYTES[..]); in test_too_big_repr_parse() localVariable
893 &packet, in test_too_big_repr_parse()
904 let mut packet = Packet::new_unchecked(&mut bytes); in test_too_big_emit() localVariable
908 &mut packet, in test_too_big_emit()
911 assert_eq!(&*packet.into_inner(), &PKT_TOO_BIG_BYTES[..]); in test_too_big_emit()