Lines Matching refs:packet
125 let packet = Self::new_unchecked(buffer); in new_checked() localVariable
126 packet.check_len()?; in new_checked()
127 Ok(packet) in new_checked()
792 packet: &Packet<&'a T>, in parse()
801 if packet.src_port() == 0 { in parse()
804 if packet.dst_port() == 0 { in parse()
808 if checksum_caps.tcp.rx() && !packet.verify_checksum(src_addr, dst_addr) { in parse()
812 let control = match (packet.syn(), packet.fin(), packet.rst(), packet.psh()) { in parse()
820 let ack_number = match packet.ack() { in parse()
821 true => Some(packet.ack_number()), in parse()
831 let mut options = packet.options(); in parse()
849 packet.src_port(), in parse()
851 packet.dst_port() in parse()
866 src_port: packet.src_port(), in parse()
867 dst_port: packet.dst_port(), in parse()
869 seq_number: packet.seq_number(), in parse()
871 window_len: packet.window_len(), in parse()
876 payload: packet.payload(), in parse()
917 packet: &mut Packet<&mut T>, in emit()
924 packet.set_src_port(self.src_port); in emit()
925 packet.set_dst_port(self.dst_port); in emit()
926 packet.set_seq_number(self.seq_number); in emit()
927 packet.set_ack_number(self.ack_number.unwrap_or(SeqNumber(0))); in emit()
928 packet.set_window_len(self.window_len); in emit()
929 packet.set_header_len(self.header_len() as u8); in emit()
930 packet.clear_flags(); in emit()
933 Control::Psh => packet.set_psh(true), in emit()
934 Control::Syn => packet.set_syn(true), in emit()
935 Control::Fin => packet.set_fin(true), in emit()
936 Control::Rst => packet.set_rst(true), in emit()
938 packet.set_ack(self.ack_number.is_some()); in emit()
940 let mut options = packet.options_mut(); in emit()
961 packet.set_urgent_at(0); in emit()
962 packet.payload_mut()[..self.payload.len()].copy_from_slice(self.payload); in emit()
965 packet.fill_checksum(src_addr, dst_addr) in emit()
969 packet.set_checksum(0); in emit()
1077 Ok(packet) => write!(f, "{indent}{packet}"), in pretty_print()
1108 let packet = Packet::new_unchecked(&PACKET_BYTES[..]); in test_deconstruct() localVariable
1109 assert_eq!(packet.src_port(), 48896); in test_deconstruct()
1110 assert_eq!(packet.dst_port(), 80); in test_deconstruct()
1111 assert_eq!(packet.seq_number(), SeqNumber(0x01234567)); in test_deconstruct()
1112 assert_eq!(packet.ack_number(), SeqNumber(0x89abcdefu32 as i32)); in test_deconstruct()
1113 assert_eq!(packet.header_len(), 24); in test_deconstruct()
1114 assert!(packet.fin()); in test_deconstruct()
1115 assert!(!packet.syn()); in test_deconstruct()
1116 assert!(packet.rst()); in test_deconstruct()
1117 assert!(!packet.psh()); in test_deconstruct()
1118 assert!(packet.ack()); in test_deconstruct()
1119 assert!(packet.urg()); in test_deconstruct()
1120 assert_eq!(packet.window_len(), 0x0123); in test_deconstruct()
1121 assert_eq!(packet.urgent_at(), 0x0201); in test_deconstruct()
1122 assert_eq!(packet.checksum(), 0x01b6); in test_deconstruct()
1123 assert_eq!(packet.options(), &OPTION_BYTES[..]); in test_deconstruct()
1124 assert_eq!(packet.payload(), &PAYLOAD_BYTES[..]); in test_deconstruct()
1125 assert!(packet.verify_checksum(&SRC_ADDR.into(), &DST_ADDR.into())); in test_deconstruct()
1132 let mut packet = Packet::new_unchecked(&mut bytes); in test_construct() localVariable
1133 packet.set_src_port(48896); in test_construct()
1134 packet.set_dst_port(80); in test_construct()
1135 packet.set_seq_number(SeqNumber(0x01234567)); in test_construct()
1136 packet.set_ack_number(SeqNumber(0x89abcdefu32 as i32)); in test_construct()
1137 packet.set_header_len(24); in test_construct()
1138 packet.clear_flags(); in test_construct()
1139 packet.set_fin(true); in test_construct()
1140 packet.set_syn(false); in test_construct()
1141 packet.set_rst(true); in test_construct()
1142 packet.set_psh(false); in test_construct()
1143 packet.set_ack(true); in test_construct()
1144 packet.set_urg(true); in test_construct()
1145 packet.set_window_len(0x0123); in test_construct()
1146 packet.set_urgent_at(0x0201); in test_construct()
1147 packet.set_checksum(0xEEEE); in test_construct()
1148 packet.options_mut().copy_from_slice(&OPTION_BYTES[..]); in test_construct()
1149 packet.payload_mut().copy_from_slice(&PAYLOAD_BYTES[..]); in test_construct()
1150 packet.fill_checksum(&SRC_ADDR.into(), &DST_ADDR.into()); in test_construct()
1151 assert_eq!(&*packet.into_inner(), &PACKET_BYTES[..]); in test_construct()
1157 let packet = Packet::new_unchecked(&PACKET_BYTES[..23]); in test_truncated() localVariable
1158 assert_eq!(packet.check_len(), Err(Error)); in test_truncated()
1164 let mut packet = Packet::new_unchecked(&mut bytes); in test_impossible_len() localVariable
1165 packet.set_header_len(10); in test_impossible_len()
1166 assert_eq!(packet.check_len(), Err(Error)); in test_impossible_len()
1195 let packet = Packet::new_unchecked(&SYN_PACKET_BYTES[..]); in test_parse() localVariable
1197 &packet, in test_parse()
1211 let mut packet = Packet::new_unchecked(&mut bytes); in test_emit() localVariable
1213 &mut packet, in test_emit()
1218 assert_eq!(&*packet.into_inner(), &SYN_PACKET_BYTES[..]); in test_emit()