Fix clippy lints

This commit is contained in:
Thibaut Vandervelden 2021-08-18 09:29:29 +02:00 committed by Dario Nieuwenhuis
parent 5b08ac41be
commit 6a27136047
18 changed files with 88 additions and 151 deletions

View File

@ -1086,7 +1086,7 @@ impl<'a> InterfaceInner<'a> {
continue; continue;
} }
match raw_socket.process(cx, &ip_repr, ip_payload) { match raw_socket.process(cx, ip_repr, ip_payload) {
// The packet is valid and handled by socket. // The packet is valid and handled by socket.
Ok(()) => handled_by_raw_socket = true, Ok(()) => handled_by_raw_socket = true,
// The socket buffer is full or the packet was truncated // The socket buffer is full or the packet was truncated
@ -1188,7 +1188,7 @@ impl<'a> InterfaceInner<'a> {
sockets: &mut SocketSet, sockets: &mut SocketSet,
ipv4_packet: &Ipv4Packet<&'frame T>, ipv4_packet: &Ipv4Packet<&'frame T>,
) -> Result<Option<IpPacket<'frame>>> { ) -> Result<Option<IpPacket<'frame>>> {
let ipv4_repr = Ipv4Repr::parse(&ipv4_packet, &cx.caps.checksum)?; let ipv4_repr = Ipv4Repr::parse(ipv4_packet, &cx.caps.checksum)?;
if !self.is_unicast_v4(ipv4_repr.src_addr) { if !self.is_unicast_v4(ipv4_repr.src_addr) {
// Discard packets with non-unicast source addresses. // Discard packets with non-unicast source addresses.
@ -2296,17 +2296,15 @@ mod test {
}); });
}); });
assert_eq!( assert!(
iface iface
.inner .inner
.is_subnet_broadcast(Ipv4Address([192, 168, 1, 255])), .is_subnet_broadcast(Ipv4Address([192, 168, 1, 255])),
true
); );
assert_eq!( assert!(
iface !iface
.inner .inner
.is_subnet_broadcast(Ipv4Address([192, 168, 1, 254])), .is_subnet_broadcast(Ipv4Address([192, 168, 1, 254])),
false
); );
iface.update_ip_addrs(|addrs| { iface.update_ip_addrs(|addrs| {
@ -2314,29 +2312,25 @@ mod test {
*addr = IpCidr::Ipv4(Ipv4Cidr::new(Ipv4Address([192, 168, 23, 24]), 16)); *addr = IpCidr::Ipv4(Ipv4Cidr::new(Ipv4Address([192, 168, 23, 24]), 16));
}); });
}); });
assert_eq!( assert!(
iface !iface
.inner .inner
.is_subnet_broadcast(Ipv4Address([192, 168, 23, 255])), .is_subnet_broadcast(Ipv4Address([192, 168, 23, 255])),
false
); );
assert_eq!( assert!(
iface !iface
.inner .inner
.is_subnet_broadcast(Ipv4Address([192, 168, 23, 254])), .is_subnet_broadcast(Ipv4Address([192, 168, 23, 254])),
false
); );
assert_eq!( assert!(
iface !iface
.inner .inner
.is_subnet_broadcast(Ipv4Address([192, 168, 255, 254])), .is_subnet_broadcast(Ipv4Address([192, 168, 255, 254])),
false
); );
assert_eq!( assert!(
iface iface
.inner .inner
.is_subnet_broadcast(Ipv4Address([192, 168, 255, 255])), .is_subnet_broadcast(Ipv4Address([192, 168, 255, 255])),
true
); );
iface.update_ip_addrs(|addrs| { iface.update_ip_addrs(|addrs| {
@ -2344,29 +2338,25 @@ mod test {
*addr = IpCidr::Ipv4(Ipv4Cidr::new(Ipv4Address([192, 168, 23, 24]), 8)); *addr = IpCidr::Ipv4(Ipv4Cidr::new(Ipv4Address([192, 168, 23, 24]), 8));
}); });
}); });
assert_eq!( assert!(
iface !iface
.inner .inner
.is_subnet_broadcast(Ipv4Address([192, 23, 1, 255])), .is_subnet_broadcast(Ipv4Address([192, 23, 1, 255])),
false
); );
assert_eq!( assert!(
iface !iface
.inner .inner
.is_subnet_broadcast(Ipv4Address([192, 23, 1, 254])), .is_subnet_broadcast(Ipv4Address([192, 23, 1, 254])),
false
); );
assert_eq!( assert!(
iface !iface
.inner .inner
.is_subnet_broadcast(Ipv4Address([192, 255, 255, 254])), .is_subnet_broadcast(Ipv4Address([192, 255, 255, 254])),
false
); );
assert_eq!( assert!(
iface iface
.inner .inner
.is_subnet_broadcast(Ipv4Address([192, 255, 255, 255])), .is_subnet_broadcast(Ipv4Address([192, 255, 255, 255])),
true
); );
} }
@ -2419,7 +2409,7 @@ mod test {
payload_len: udp_repr.header_len() + UDP_PAYLOAD.len(), payload_len: udp_repr.header_len() + UDP_PAYLOAD.len(),
hop_limit: 64, hop_limit: 64,
}, },
data: &data, data: data,
}; };
let expected_repr = IpPacket::Icmpv4(( let expected_repr = IpPacket::Icmpv4((
Ipv4Repr { Ipv4Repr {
@ -3002,7 +2992,7 @@ mod test {
assert_eq!( assert_eq!(
socket.recv(), socket.recv(),
Ok(( Ok((
&icmp_data[..], icmp_data,
IpAddress::Ipv4(Ipv4Address::new(0x7f, 0x00, 0x00, 0x02)) IpAddress::Ipv4(Ipv4Address::new(0x7f, 0x00, 0x00, 0x02))
)) ))
); );
@ -3060,7 +3050,7 @@ mod test {
hbh_pkt.set_header_len(0); hbh_pkt.set_header_len(0);
offset += 8; offset += 8;
{ {
let mut pad_pkt = Ipv6Option::new_unchecked(&mut hbh_pkt.options_mut()[..]); let mut pad_pkt = Ipv6Option::new_unchecked(&mut *hbh_pkt.options_mut());
Ipv6OptionRepr::PadN(3).emit(&mut pad_pkt); Ipv6OptionRepr::PadN(3).emit(&mut pad_pkt);
} }
{ {
@ -3118,7 +3108,7 @@ mod test {
#[cfg(feature = "medium-ip")] #[cfg(feature = "medium-ip")]
Medium::Ip => Ipv4Packet::new_checked(&frame[..]).ok()?, Medium::Ip => Ipv4Packet::new_checked(&frame[..]).ok()?,
}; };
let ipv4_repr = Ipv4Repr::parse(&ipv4_packet, &checksum_caps).ok()?; let ipv4_repr = Ipv4Repr::parse(&ipv4_packet, checksum_caps).ok()?;
let ip_payload = ipv4_packet.payload(); let ip_payload = ipv4_packet.payload();
let igmp_packet = IgmpPacket::new_checked(ip_payload).ok()?; let igmp_packet = IgmpPacket::new_checked(ip_payload).ok()?;
let igmp_repr = IgmpRepr::parse(&igmp_packet).ok()?; let igmp_repr = IgmpRepr::parse(&igmp_packet).ok()?;

View File

@ -227,47 +227,26 @@ mod test {
let mut cache_storage = [Default::default(); 3]; let mut cache_storage = [Default::default(); 3];
let mut cache = Cache::new(&mut cache_storage[..]); let mut cache = Cache::new(&mut cache_storage[..]);
assert_eq!( assert!(!cache.lookup(&MOCK_IP_ADDR_1, Instant::from_millis(0)).found());
cache assert!(!cache.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0)).found());
.lookup(&MOCK_IP_ADDR_1, Instant::from_millis(0))
.found(),
false
);
assert_eq!(
cache
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0))
.found(),
false
);
cache.fill(MOCK_IP_ADDR_1, HADDR_A, Instant::from_millis(0)); cache.fill(MOCK_IP_ADDR_1, HADDR_A, Instant::from_millis(0));
assert_eq!( assert_eq!(
cache.lookup(&MOCK_IP_ADDR_1, Instant::from_millis(0)), cache.lookup(&MOCK_IP_ADDR_1, Instant::from_millis(0)),
Answer::Found(HADDR_A) Answer::Found(HADDR_A)
); );
assert_eq!( assert!(!cache.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0)).found());
cache assert!(
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0)) !cache
.found(),
false
);
assert_eq!(
cache
.lookup( .lookup(
&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_1,
Instant::from_millis(0) + Cache::ENTRY_LIFETIME * 2 Instant::from_millis(0) + Cache::ENTRY_LIFETIME * 2
) )
.found(), .found(),
false
); );
cache.fill(MOCK_IP_ADDR_1, HADDR_A, Instant::from_millis(0)); cache.fill(MOCK_IP_ADDR_1, HADDR_A, Instant::from_millis(0));
assert_eq!( assert!(!cache.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0)).found());
cache
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0))
.found(),
false
);
} }
#[test] #[test]
@ -280,14 +259,13 @@ mod test {
cache.lookup(&MOCK_IP_ADDR_1, Instant::from_millis(0)), cache.lookup(&MOCK_IP_ADDR_1, Instant::from_millis(0)),
Answer::Found(HADDR_A) Answer::Found(HADDR_A)
); );
assert_eq!( assert!(
cache !cache
.lookup( .lookup(
&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_1,
Instant::from_millis(0) + Cache::ENTRY_LIFETIME * 2 Instant::from_millis(0) + Cache::ENTRY_LIFETIME * 2
) )
.found(), .found(),
false
); );
} }
@ -343,20 +321,10 @@ mod test {
cache.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(1000)), cache.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(1000)),
Answer::Found(HADDR_B) Answer::Found(HADDR_B)
); );
assert_eq!( assert!(!cache.lookup(&MOCK_IP_ADDR_4, Instant::from_millis(1000)).found());
cache
.lookup(&MOCK_IP_ADDR_4, Instant::from_millis(1000))
.found(),
false
);
cache.fill(MOCK_IP_ADDR_4, HADDR_D, Instant::from_millis(300)); cache.fill(MOCK_IP_ADDR_4, HADDR_D, Instant::from_millis(300));
assert_eq!( assert!(!cache.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(1000)).found());
cache
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(1000))
.found(),
false
);
assert_eq!( assert_eq!(
cache.lookup(&MOCK_IP_ADDR_4, Instant::from_millis(1000)), cache.lookup(&MOCK_IP_ADDR_4, Instant::from_millis(1000)),
Answer::Found(HADDR_D) Answer::Found(HADDR_D)

View File

@ -501,8 +501,8 @@ impl Dhcpv4Socket {
} }
} }
impl<'a> Into<Socket<'a>> for Dhcpv4Socket { impl<'a> From<Dhcpv4Socket> for Socket<'a> {
fn into(self) -> Socket<'a> { fn from(val: Dhcpv4Socket) -> Self {
Socket::Dhcpv4(self) Socket::Dhcpv4(val)
} }
} }

View File

@ -515,9 +515,9 @@ impl<'a> IcmpSocket<'a> {
} }
} }
impl<'a> Into<Socket<'a>> for IcmpSocket<'a> { impl<'a> From<IcmpSocket<'a>> for Socket<'a> {
fn into(self) -> Socket<'a> { fn from(val: IcmpSocket<'a>) -> Self {
Socket::Icmp(self) Socket::Icmp(val)
} }
} }
@ -711,7 +711,7 @@ mod test_ipv4 {
Err(Error::Exhausted) Err(Error::Exhausted)
); );
assert_eq!(socket.recv(), Ok((&data[..], REMOTE_IPV4.into()))); assert_eq!(socket.recv(), Ok((data, REMOTE_IPV4.into())));
assert!(!socket.can_recv()); assert!(!socket.can_recv());
} }
@ -972,7 +972,7 @@ mod test_ipv6 {
Err(Error::Exhausted) Err(Error::Exhausted)
); );
assert_eq!(socket.recv(), Ok((&data[..], REMOTE_IPV6.into()))); assert_eq!(socket.recv(), Ok((data, REMOTE_IPV6.into())));
assert!(!socket.can_recv()); assert!(!socket.can_recv());
} }

View File

@ -330,9 +330,9 @@ impl<'a> RawSocket<'a> {
} }
} }
impl<'a> Into<Socket<'a>> for RawSocket<'a> { impl<'a> From<RawSocket<'a>> for Socket<'a> {
fn into(self) -> Socket<'a> { fn from(val: RawSocket<'a>) -> Self {
Socket::Raw(self) Socket::Raw(val)
} }
} }

View File

@ -1490,7 +1490,7 @@ impl<'a> TcpSocket<'a> {
self.timer.set_for_close(cx.now); self.timer.set_for_close(cx.now);
} }
return Ok(Some(self.ack_reply(ip_repr, &repr))); return Ok(Some(self.ack_reply(ip_repr, repr)));
} }
} }
} }
@ -1929,7 +1929,7 @@ impl<'a> TcpSocket<'a> {
self.local_endpoint, self.local_endpoint,
self.remote_endpoint self.remote_endpoint
); );
Ok(Some(self.ack_reply(ip_repr, &repr))) Ok(Some(self.ack_reply(ip_repr, repr)))
} else { } else {
Ok(None) Ok(None)
} }
@ -2392,9 +2392,9 @@ impl<'a> TcpSocket<'a> {
} }
} }
impl<'a> Into<Socket<'a>> for TcpSocket<'a> { impl<'a> From<TcpSocket<'a>> for Socket<'a> {
fn into(self) -> Socket<'a> { fn from(val: TcpSocket<'a>) -> Self {
Socket::Tcp(self) Socket::Tcp(val)
} }
} }

View File

@ -398,9 +398,9 @@ impl<'a> UdpSocket<'a> {
} }
} }
impl<'a> Into<Socket<'a>> for UdpSocket<'a> { impl<'a> From<UdpSocket<'a>> for Socket<'a> {
fn into(self) -> Socket<'a> { fn from(val: UdpSocket<'a>) -> Self {
Socket::Udp(self) Socket::Udp(val)
} }
} }

View File

@ -292,17 +292,17 @@ mod test {
#[test] #[test]
fn test_metadata_full_empty() { fn test_metadata_full_empty() {
let mut buffer = buffer(); let mut buffer = buffer();
assert_eq!(buffer.is_empty(), true); assert!(buffer.is_empty());
assert_eq!(buffer.is_full(), false); assert!(!buffer.is_full());
assert!(buffer.enqueue(1, ()).is_ok()); assert!(buffer.enqueue(1, ()).is_ok());
assert_eq!(buffer.is_empty(), false); assert!(!buffer.is_empty());
assert!(buffer.enqueue(1, ()).is_ok()); assert!(buffer.enqueue(1, ()).is_ok());
assert!(buffer.enqueue(1, ()).is_ok()); assert!(buffer.enqueue(1, ()).is_ok());
assert_eq!(buffer.is_full(), false); assert!(!buffer.is_full());
assert_eq!(buffer.is_empty(), false); assert!(!buffer.is_empty());
assert!(buffer.enqueue(1, ()).is_ok()); assert!(buffer.enqueue(1, ()).is_ok());
assert_eq!(buffer.is_full(), true); assert!(buffer.is_full());
assert_eq!(buffer.is_empty(), false); assert!(!buffer.is_empty());
assert_eq!(buffer.metadata_ring.len(), 4); assert_eq!(buffer.metadata_ring.len(), 4);
assert_eq!(buffer.enqueue(1, ()), Err(Error::Exhausted)); assert_eq!(buffer.enqueue(1, ()), Err(Error::Exhausted));
} }

View File

@ -97,9 +97,9 @@ impl From<::std::time::SystemTime> for Instant {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
impl Into<::std::time::SystemTime> for Instant { impl From<Instant> for ::std::time::SystemTime {
fn into(self) -> ::std::time::SystemTime { fn from(val: Instant) -> Self {
::std::time::UNIX_EPOCH + ::std::time::Duration::from_millis(self.millis as u64) ::std::time::UNIX_EPOCH + ::std::time::Duration::from_millis(val.millis as u64)
} }
} }
@ -284,9 +284,9 @@ impl From<::core::time::Duration> for Duration {
} }
} }
impl Into<::core::time::Duration> for Duration { impl From<Duration> for ::core::time::Duration {
fn into(self) -> ::core::time::Duration { fn from(val: Duration) -> Self {
::core::time::Duration::from_millis(self.total_millis()) ::core::time::Duration::from_millis(val.total_millis())
} }
} }

View File

@ -592,7 +592,7 @@ mod test {
assert_eq!(packet.echo_ident(), 0x1234); assert_eq!(packet.echo_ident(), 0x1234);
assert_eq!(packet.echo_seq_no(), 0xabcd); assert_eq!(packet.echo_seq_no(), 0xabcd);
assert_eq!(packet.data(), &ECHO_DATA_BYTES[..]); assert_eq!(packet.data(), &ECHO_DATA_BYTES[..]);
assert_eq!(packet.verify_checksum(), true); assert!(packet.verify_checksum());
} }
#[test] #[test]

View File

@ -812,10 +812,7 @@ mod test {
assert_eq!(packet.echo_ident(), 0x1234); assert_eq!(packet.echo_ident(), 0x1234);
assert_eq!(packet.echo_seq_no(), 0xabcd); assert_eq!(packet.echo_seq_no(), 0xabcd);
assert_eq!(packet.payload(), &ECHO_PACKET_PAYLOAD[..]); assert_eq!(packet.payload(), &ECHO_PACKET_PAYLOAD[..]);
assert_eq!( assert!(packet.verify_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2));
packet.verify_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2),
true
);
assert!(!packet.msg_type().is_error()); assert!(!packet.msg_type().is_error());
} }
@ -869,10 +866,7 @@ mod test {
assert_eq!(packet.checksum(), 0x0fc9); assert_eq!(packet.checksum(), 0x0fc9);
assert_eq!(packet.pkt_too_big_mtu(), 1500); assert_eq!(packet.pkt_too_big_mtu(), 1500);
assert_eq!(packet.payload(), &PKT_TOO_BIG_IP_PAYLOAD[..]); assert_eq!(packet.payload(), &PKT_TOO_BIG_IP_PAYLOAD[..]);
assert_eq!( assert!(packet.verify_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2));
packet.verify_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2),
true
);
assert!(packet.msg_type().is_error()); assert!(packet.msg_type().is_error());
} }

View File

@ -393,7 +393,7 @@ mod test {
packet.group_addr(), packet.group_addr(),
Ipv4Address::from_bytes(&[224, 0, 6, 150]) Ipv4Address::from_bytes(&[224, 0, 6, 150])
); );
assert_eq!(packet.verify_checksum(), true); assert!(packet.verify_checksum());
} }
#[test] #[test]
@ -406,7 +406,7 @@ mod test {
packet.group_addr(), packet.group_addr(),
Ipv4Address::from_bytes(&[225, 0, 0, 37]) Ipv4Address::from_bytes(&[225, 0, 0, 37])
); );
assert_eq!(packet.verify_checksum(), true); assert!(packet.verify_checksum());
} }
#[test] #[test]

View File

@ -773,15 +773,15 @@ mod test {
assert_eq!(packet.ecn(), 0); assert_eq!(packet.ecn(), 0);
assert_eq!(packet.total_len(), 30); assert_eq!(packet.total_len(), 30);
assert_eq!(packet.ident(), 0x102); assert_eq!(packet.ident(), 0x102);
assert_eq!(packet.more_frags(), true); assert!(packet.more_frags());
assert_eq!(packet.dont_frag(), true); assert!(packet.dont_frag());
assert_eq!(packet.frag_offset(), 0x203 * 8); assert_eq!(packet.frag_offset(), 0x203 * 8);
assert_eq!(packet.hop_limit(), 0x1a); assert_eq!(packet.hop_limit(), 0x1a);
assert_eq!(packet.protocol(), Protocol::Icmp); assert_eq!(packet.protocol(), Protocol::Icmp);
assert_eq!(packet.checksum(), 0xd56e); assert_eq!(packet.checksum(), 0xd56e);
assert_eq!(packet.src_addr(), Address([0x11, 0x12, 0x13, 0x14])); assert_eq!(packet.src_addr(), Address([0x11, 0x12, 0x13, 0x14]));
assert_eq!(packet.dst_addr(), Address([0x21, 0x22, 0x23, 0x24])); assert_eq!(packet.dst_addr(), Address([0x21, 0x22, 0x23, 0x24]));
assert_eq!(packet.verify_checksum(), true); assert!(packet.verify_checksum());
assert_eq!(packet.payload(), &PAYLOAD_BYTES[..]); assert_eq!(packet.payload(), &PAYLOAD_BYTES[..]);
} }
@ -969,14 +969,8 @@ mod test {
#[test] #[test]
fn test_cidr_from_netmask() { fn test_cidr_from_netmask() {
assert_eq!( assert!(Cidr::from_netmask(Address([0, 0, 0, 0]), Address([1, 0, 2, 0])).is_err());
Cidr::from_netmask(Address([0, 0, 0, 0]), Address([1, 0, 2, 0])).is_err(), assert!(Cidr::from_netmask(Address([0, 0, 0, 0]), Address([0, 0, 0, 0])).is_err());
true
);
assert_eq!(
Cidr::from_netmask(Address([0, 0, 0, 0]), Address([0, 0, 0, 0])).is_err(),
true
);
assert_eq!( assert_eq!(
Cidr::from_netmask(Address([0, 0, 0, 1]), Address([255, 255, 255, 0])).unwrap(), Cidr::from_netmask(Address([0, 0, 0, 1]), Address([255, 255, 255, 0])).unwrap(),
Cidr::new(Address([0, 0, 0, 1]), 24) Cidr::new(Address([0, 0, 0, 1]), 24)

View File

@ -849,11 +849,8 @@ mod test {
#[cfg(feature = "proto-ipv4")] #[cfg(feature = "proto-ipv4")]
#[test] #[test]
fn test_is_ipv4_mapped() { fn test_is_ipv4_mapped() {
assert_eq!(false, Address::UNSPECIFIED.is_ipv4_mapped()); assert!(!Address::UNSPECIFIED.is_ipv4_mapped());
assert_eq!( assert!(Address::from(Ipv4Address::new(192, 168, 1, 1)).is_ipv4_mapped());
true,
Address::from(Ipv4Address::new(192, 168, 1, 1)).is_ipv4_mapped()
);
} }
#[cfg(feature = "proto-ipv4")] #[cfg(feature = "proto-ipv4")]

View File

@ -241,13 +241,13 @@ mod test {
let header = Header::new_unchecked(&BYTES_HEADER_MORE_FRAG); let header = Header::new_unchecked(&BYTES_HEADER_MORE_FRAG);
assert_eq!(header.next_header(), Protocol::Tcp); assert_eq!(header.next_header(), Protocol::Tcp);
assert_eq!(header.frag_offset(), 0); assert_eq!(header.frag_offset(), 0);
assert_eq!(header.more_frags(), true); assert!(header.more_frags());
assert_eq!(header.ident(), 12345); assert_eq!(header.ident(), 12345);
let header = Header::new_unchecked(&BYTES_HEADER_LAST_FRAG); let header = Header::new_unchecked(&BYTES_HEADER_LAST_FRAG);
assert_eq!(header.next_header(), Protocol::Tcp); assert_eq!(header.next_header(), Protocol::Tcp);
assert_eq!(header.frag_offset(), 320); assert_eq!(header.frag_offset(), 320);
assert_eq!(header.more_frags(), false); assert!(!header.more_frags());
assert_eq!(header.ident(), 67890); assert_eq!(header.ident(), 67890);
} }

View File

@ -448,7 +448,7 @@ mod test {
assert_eq!(packet.checksum(), 0x7374); assert_eq!(packet.checksum(), 0x7374);
assert_eq!(packet.max_resp_code(), 0x0400); assert_eq!(packet.max_resp_code(), 0x0400);
assert_eq!(packet.mcast_addr(), Ipv6Address::LINK_LOCAL_ALL_NODES); assert_eq!(packet.mcast_addr(), Ipv6Address::LINK_LOCAL_ALL_NODES);
assert_eq!(packet.s_flag(), true); assert!(packet.s_flag());
assert_eq!(packet.qrv(), 0x02); assert_eq!(packet.qrv(), 0x02);
assert_eq!(packet.qqic(), 0x12); assert_eq!(packet.qqic(), 0x12);
assert_eq!(packet.num_srcs(), 0x01); assert_eq!(packet.num_srcs(), 0x01);

View File

@ -1113,21 +1113,18 @@ mod test {
assert_eq!(packet.seq_number(), SeqNumber(0x01234567)); assert_eq!(packet.seq_number(), SeqNumber(0x01234567));
assert_eq!(packet.ack_number(), SeqNumber(0x89abcdefu32 as i32)); assert_eq!(packet.ack_number(), SeqNumber(0x89abcdefu32 as i32));
assert_eq!(packet.header_len(), 24); assert_eq!(packet.header_len(), 24);
assert_eq!(packet.fin(), true); assert!(packet.fin());
assert_eq!(packet.syn(), false); assert!(!packet.syn());
assert_eq!(packet.rst(), true); assert!(packet.rst());
assert_eq!(packet.psh(), false); assert!(!packet.psh());
assert_eq!(packet.ack(), true); assert!(packet.ack());
assert_eq!(packet.urg(), true); assert!(packet.urg());
assert_eq!(packet.window_len(), 0x0123); assert_eq!(packet.window_len(), 0x0123);
assert_eq!(packet.urgent_at(), 0x0201); assert_eq!(packet.urgent_at(), 0x0201);
assert_eq!(packet.checksum(), 0x01b6); assert_eq!(packet.checksum(), 0x01b6);
assert_eq!(packet.options(), &OPTION_BYTES[..]); assert_eq!(packet.options(), &OPTION_BYTES[..]);
assert_eq!(packet.payload(), &PAYLOAD_BYTES[..]); assert_eq!(packet.payload(), &PAYLOAD_BYTES[..]);
assert_eq!( assert!(packet.verify_checksum(&SRC_ADDR.into(), &DST_ADDR.into()));
packet.verify_checksum(&SRC_ADDR.into(), &DST_ADDR.into()),
true
);
} }
#[test] #[test]

View File

@ -338,10 +338,7 @@ mod test {
assert_eq!(packet.len(), 12); assert_eq!(packet.len(), 12);
assert_eq!(packet.checksum(), 0x124d); assert_eq!(packet.checksum(), 0x124d);
assert_eq!(packet.payload(), &PAYLOAD_BYTES[..]); assert_eq!(packet.payload(), &PAYLOAD_BYTES[..]);
assert_eq!( assert!(packet.verify_checksum(&SRC_ADDR.into(), &DST_ADDR.into()));
packet.verify_checksum(&SRC_ADDR.into(), &DST_ADDR.into()),
true
);
} }
#[test] #[test]