Merge pull request #519 from thibautvdv/fix_clippy
Fixes all the clippy lints
This commit is contained in:
commit
5c36964d13
|
@ -1086,7 +1086,7 @@ impl<'a> InterfaceInner<'a> {
|
|||
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.
|
||||
Ok(()) => handled_by_raw_socket = true,
|
||||
// The socket buffer is full or the packet was truncated
|
||||
|
@ -1188,7 +1188,7 @@ impl<'a> InterfaceInner<'a> {
|
|||
sockets: &mut SocketSet,
|
||||
ipv4_packet: &Ipv4Packet<&'frame T>,
|
||||
) -> 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) {
|
||||
// Discard packets with non-unicast source addresses.
|
||||
|
@ -2296,78 +2296,48 @@ mod test {
|
|||
});
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 1, 255])),
|
||||
true
|
||||
);
|
||||
assert_eq!(
|
||||
iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 1, 254])),
|
||||
false
|
||||
);
|
||||
assert!(iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 1, 255])),);
|
||||
assert!(!iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 1, 254])),);
|
||||
|
||||
iface.update_ip_addrs(|addrs| {
|
||||
addrs.iter_mut().next().map(|addr| {
|
||||
*addr = IpCidr::Ipv4(Ipv4Cidr::new(Ipv4Address([192, 168, 23, 24]), 16));
|
||||
});
|
||||
});
|
||||
assert_eq!(
|
||||
iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 23, 255])),
|
||||
false
|
||||
);
|
||||
assert_eq!(
|
||||
iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 23, 254])),
|
||||
false
|
||||
);
|
||||
assert_eq!(
|
||||
iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 255, 254])),
|
||||
false
|
||||
);
|
||||
assert_eq!(
|
||||
iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 255, 255])),
|
||||
true
|
||||
);
|
||||
assert!(!iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 23, 255])),);
|
||||
assert!(!iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 23, 254])),);
|
||||
assert!(!iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 255, 254])),);
|
||||
assert!(iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 168, 255, 255])),);
|
||||
|
||||
iface.update_ip_addrs(|addrs| {
|
||||
addrs.iter_mut().next().map(|addr| {
|
||||
*addr = IpCidr::Ipv4(Ipv4Cidr::new(Ipv4Address([192, 168, 23, 24]), 8));
|
||||
});
|
||||
});
|
||||
assert_eq!(
|
||||
iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 23, 1, 255])),
|
||||
false
|
||||
);
|
||||
assert_eq!(
|
||||
iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 23, 1, 254])),
|
||||
false
|
||||
);
|
||||
assert_eq!(
|
||||
iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 255, 255, 254])),
|
||||
false
|
||||
);
|
||||
assert_eq!(
|
||||
iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 255, 255, 255])),
|
||||
true
|
||||
);
|
||||
assert!(!iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 23, 1, 255])),);
|
||||
assert!(!iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 23, 1, 254])),);
|
||||
assert!(!iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 255, 255, 254])),);
|
||||
assert!(iface
|
||||
.inner
|
||||
.is_subnet_broadcast(Ipv4Address([192, 255, 255, 255])),);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2419,7 +2389,7 @@ mod test {
|
|||
payload_len: udp_repr.header_len() + UDP_PAYLOAD.len(),
|
||||
hop_limit: 64,
|
||||
},
|
||||
data: &data,
|
||||
data: data,
|
||||
};
|
||||
let expected_repr = IpPacket::Icmpv4((
|
||||
Ipv4Repr {
|
||||
|
@ -3002,7 +2972,7 @@ mod test {
|
|||
assert_eq!(
|
||||
socket.recv(),
|
||||
Ok((
|
||||
&icmp_data[..],
|
||||
icmp_data,
|
||||
IpAddress::Ipv4(Ipv4Address::new(0x7f, 0x00, 0x00, 0x02))
|
||||
))
|
||||
);
|
||||
|
@ -3060,7 +3030,7 @@ mod test {
|
|||
hbh_pkt.set_header_len(0);
|
||||
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);
|
||||
}
|
||||
{
|
||||
|
@ -3118,7 +3088,7 @@ mod test {
|
|||
#[cfg(feature = "medium-ip")]
|
||||
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 igmp_packet = IgmpPacket::new_checked(ip_payload).ok()?;
|
||||
let igmp_repr = IgmpRepr::parse(&igmp_packet).ok()?;
|
||||
|
|
|
@ -227,47 +227,32 @@ mod test {
|
|||
let mut cache_storage = [Default::default(); 3];
|
||||
let mut cache = Cache::new(&mut cache_storage[..]);
|
||||
|
||||
assert_eq!(
|
||||
cache
|
||||
.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
|
||||
);
|
||||
assert!(!cache
|
||||
.lookup(&MOCK_IP_ADDR_1, Instant::from_millis(0))
|
||||
.found());
|
||||
assert!(!cache
|
||||
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0))
|
||||
.found());
|
||||
|
||||
cache.fill(MOCK_IP_ADDR_1, HADDR_A, Instant::from_millis(0));
|
||||
assert_eq!(
|
||||
cache.lookup(&MOCK_IP_ADDR_1, Instant::from_millis(0)),
|
||||
Answer::Found(HADDR_A)
|
||||
);
|
||||
assert_eq!(
|
||||
cache
|
||||
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0))
|
||||
.found(),
|
||||
false
|
||||
);
|
||||
assert_eq!(
|
||||
cache
|
||||
.lookup(
|
||||
&MOCK_IP_ADDR_1,
|
||||
Instant::from_millis(0) + Cache::ENTRY_LIFETIME * 2
|
||||
)
|
||||
.found(),
|
||||
false
|
||||
);
|
||||
assert!(!cache
|
||||
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0))
|
||||
.found());
|
||||
assert!(!cache
|
||||
.lookup(
|
||||
&MOCK_IP_ADDR_1,
|
||||
Instant::from_millis(0) + Cache::ENTRY_LIFETIME * 2
|
||||
)
|
||||
.found(),);
|
||||
|
||||
cache.fill(MOCK_IP_ADDR_1, HADDR_A, Instant::from_millis(0));
|
||||
assert_eq!(
|
||||
cache
|
||||
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0))
|
||||
.found(),
|
||||
false
|
||||
);
|
||||
assert!(!cache
|
||||
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(0))
|
||||
.found());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -280,15 +265,12 @@ mod test {
|
|||
cache.lookup(&MOCK_IP_ADDR_1, Instant::from_millis(0)),
|
||||
Answer::Found(HADDR_A)
|
||||
);
|
||||
assert_eq!(
|
||||
cache
|
||||
.lookup(
|
||||
&MOCK_IP_ADDR_1,
|
||||
Instant::from_millis(0) + Cache::ENTRY_LIFETIME * 2
|
||||
)
|
||||
.found(),
|
||||
false
|
||||
);
|
||||
assert!(!cache
|
||||
.lookup(
|
||||
&MOCK_IP_ADDR_1,
|
||||
Instant::from_millis(0) + Cache::ENTRY_LIFETIME * 2
|
||||
)
|
||||
.found(),);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -343,20 +325,14 @@ mod test {
|
|||
cache.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(1000)),
|
||||
Answer::Found(HADDR_B)
|
||||
);
|
||||
assert_eq!(
|
||||
cache
|
||||
.lookup(&MOCK_IP_ADDR_4, Instant::from_millis(1000))
|
||||
.found(),
|
||||
false
|
||||
);
|
||||
assert!(!cache
|
||||
.lookup(&MOCK_IP_ADDR_4, Instant::from_millis(1000))
|
||||
.found());
|
||||
|
||||
cache.fill(MOCK_IP_ADDR_4, HADDR_D, Instant::from_millis(300));
|
||||
assert_eq!(
|
||||
cache
|
||||
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(1000))
|
||||
.found(),
|
||||
false
|
||||
);
|
||||
assert!(!cache
|
||||
.lookup(&MOCK_IP_ADDR_2, Instant::from_millis(1000))
|
||||
.found());
|
||||
assert_eq!(
|
||||
cache.lookup(&MOCK_IP_ADDR_4, Instant::from_millis(1000)),
|
||||
Answer::Found(HADDR_D)
|
||||
|
|
|
@ -501,8 +501,8 @@ impl Dhcpv4Socket {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Into<Socket<'a>> for Dhcpv4Socket {
|
||||
fn into(self) -> Socket<'a> {
|
||||
Socket::Dhcpv4(self)
|
||||
impl<'a> From<Dhcpv4Socket> for Socket<'a> {
|
||||
fn from(val: Dhcpv4Socket) -> Self {
|
||||
Socket::Dhcpv4(val)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -515,9 +515,9 @@ impl<'a> IcmpSocket<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Into<Socket<'a>> for IcmpSocket<'a> {
|
||||
fn into(self) -> Socket<'a> {
|
||||
Socket::Icmp(self)
|
||||
impl<'a> From<IcmpSocket<'a>> for Socket<'a> {
|
||||
fn from(val: IcmpSocket<'a>) -> Self {
|
||||
Socket::Icmp(val)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -711,7 +711,7 @@ mod test_ipv4 {
|
|||
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());
|
||||
}
|
||||
|
||||
|
@ -972,7 +972,7 @@ mod test_ipv6 {
|
|||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -330,9 +330,9 @@ impl<'a> RawSocket<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Into<Socket<'a>> for RawSocket<'a> {
|
||||
fn into(self) -> Socket<'a> {
|
||||
Socket::Raw(self)
|
||||
impl<'a> From<RawSocket<'a>> for Socket<'a> {
|
||||
fn from(val: RawSocket<'a>) -> Self {
|
||||
Socket::Raw(val)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1490,7 +1490,7 @@ impl<'a> TcpSocket<'a> {
|
|||
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.remote_endpoint
|
||||
);
|
||||
Ok(Some(self.ack_reply(ip_repr, &repr)))
|
||||
Ok(Some(self.ack_reply(ip_repr, repr)))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
@ -2392,9 +2392,9 @@ impl<'a> TcpSocket<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Into<Socket<'a>> for TcpSocket<'a> {
|
||||
fn into(self) -> Socket<'a> {
|
||||
Socket::Tcp(self)
|
||||
impl<'a> From<TcpSocket<'a>> for Socket<'a> {
|
||||
fn from(val: TcpSocket<'a>) -> Self {
|
||||
Socket::Tcp(val)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -398,9 +398,9 @@ impl<'a> UdpSocket<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Into<Socket<'a>> for UdpSocket<'a> {
|
||||
fn into(self) -> Socket<'a> {
|
||||
Socket::Udp(self)
|
||||
impl<'a> From<UdpSocket<'a>> for Socket<'a> {
|
||||
fn from(val: UdpSocket<'a>) -> Self {
|
||||
Socket::Udp(val)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -292,17 +292,17 @@ mod test {
|
|||
#[test]
|
||||
fn test_metadata_full_empty() {
|
||||
let mut buffer = buffer();
|
||||
assert_eq!(buffer.is_empty(), true);
|
||||
assert_eq!(buffer.is_full(), false);
|
||||
assert!(buffer.is_empty());
|
||||
assert!(!buffer.is_full());
|
||||
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_eq!(buffer.is_full(), false);
|
||||
assert_eq!(buffer.is_empty(), false);
|
||||
assert!(!buffer.is_full());
|
||||
assert!(!buffer.is_empty());
|
||||
assert!(buffer.enqueue(1, ()).is_ok());
|
||||
assert_eq!(buffer.is_full(), true);
|
||||
assert_eq!(buffer.is_empty(), false);
|
||||
assert!(buffer.is_full());
|
||||
assert!(!buffer.is_empty());
|
||||
assert_eq!(buffer.metadata_ring.len(), 4);
|
||||
assert_eq!(buffer.enqueue(1, ()), Err(Error::Exhausted));
|
||||
}
|
||||
|
|
12
src/time.rs
12
src/time.rs
|
@ -97,9 +97,9 @@ impl From<::std::time::SystemTime> for Instant {
|
|||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl Into<::std::time::SystemTime> for Instant {
|
||||
fn into(self) -> ::std::time::SystemTime {
|
||||
::std::time::UNIX_EPOCH + ::std::time::Duration::from_millis(self.millis as u64)
|
||||
impl From<Instant> for ::std::time::SystemTime {
|
||||
fn from(val: Instant) -> Self {
|
||||
::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 {
|
||||
fn into(self) -> ::core::time::Duration {
|
||||
::core::time::Duration::from_millis(self.total_millis())
|
||||
impl From<Duration> for ::core::time::Duration {
|
||||
fn from(val: Duration) -> Self {
|
||||
::core::time::Duration::from_millis(val.total_millis())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -592,7 +592,7 @@ mod test {
|
|||
assert_eq!(packet.echo_ident(), 0x1234);
|
||||
assert_eq!(packet.echo_seq_no(), 0xabcd);
|
||||
assert_eq!(packet.data(), &ECHO_DATA_BYTES[..]);
|
||||
assert_eq!(packet.verify_checksum(), true);
|
||||
assert!(packet.verify_checksum());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -812,10 +812,7 @@ mod test {
|
|||
assert_eq!(packet.echo_ident(), 0x1234);
|
||||
assert_eq!(packet.echo_seq_no(), 0xabcd);
|
||||
assert_eq!(packet.payload(), &ECHO_PACKET_PAYLOAD[..]);
|
||||
assert_eq!(
|
||||
packet.verify_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2),
|
||||
true
|
||||
);
|
||||
assert!(packet.verify_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2));
|
||||
assert!(!packet.msg_type().is_error());
|
||||
}
|
||||
|
||||
|
@ -869,10 +866,7 @@ mod test {
|
|||
assert_eq!(packet.checksum(), 0x0fc9);
|
||||
assert_eq!(packet.pkt_too_big_mtu(), 1500);
|
||||
assert_eq!(packet.payload(), &PKT_TOO_BIG_IP_PAYLOAD[..]);
|
||||
assert_eq!(
|
||||
packet.verify_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2),
|
||||
true
|
||||
);
|
||||
assert!(packet.verify_checksum(&MOCK_IP_ADDR_1, &MOCK_IP_ADDR_2));
|
||||
assert!(packet.msg_type().is_error());
|
||||
}
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ mod test {
|
|||
packet.group_addr(),
|
||||
Ipv4Address::from_bytes(&[224, 0, 6, 150])
|
||||
);
|
||||
assert_eq!(packet.verify_checksum(), true);
|
||||
assert!(packet.verify_checksum());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -406,7 +406,7 @@ mod test {
|
|||
packet.group_addr(),
|
||||
Ipv4Address::from_bytes(&[225, 0, 0, 37])
|
||||
);
|
||||
assert_eq!(packet.verify_checksum(), true);
|
||||
assert!(packet.verify_checksum());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -773,15 +773,15 @@ mod test {
|
|||
assert_eq!(packet.ecn(), 0);
|
||||
assert_eq!(packet.total_len(), 30);
|
||||
assert_eq!(packet.ident(), 0x102);
|
||||
assert_eq!(packet.more_frags(), true);
|
||||
assert_eq!(packet.dont_frag(), true);
|
||||
assert!(packet.more_frags());
|
||||
assert!(packet.dont_frag());
|
||||
assert_eq!(packet.frag_offset(), 0x203 * 8);
|
||||
assert_eq!(packet.hop_limit(), 0x1a);
|
||||
assert_eq!(packet.protocol(), Protocol::Icmp);
|
||||
assert_eq!(packet.checksum(), 0xd56e);
|
||||
assert_eq!(packet.src_addr(), Address([0x11, 0x12, 0x13, 0x14]));
|
||||
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[..]);
|
||||
}
|
||||
|
||||
|
@ -969,14 +969,8 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_cidr_from_netmask() {
|
||||
assert_eq!(
|
||||
Cidr::from_netmask(Address([0, 0, 0, 0]), Address([1, 0, 2, 0])).is_err(),
|
||||
true
|
||||
);
|
||||
assert_eq!(
|
||||
Cidr::from_netmask(Address([0, 0, 0, 0]), Address([0, 0, 0, 0])).is_err(),
|
||||
true
|
||||
);
|
||||
assert!(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());
|
||||
assert_eq!(
|
||||
Cidr::from_netmask(Address([0, 0, 0, 1]), Address([255, 255, 255, 0])).unwrap(),
|
||||
Cidr::new(Address([0, 0, 0, 1]), 24)
|
||||
|
|
|
@ -849,11 +849,8 @@ mod test {
|
|||
#[cfg(feature = "proto-ipv4")]
|
||||
#[test]
|
||||
fn test_is_ipv4_mapped() {
|
||||
assert_eq!(false, Address::UNSPECIFIED.is_ipv4_mapped());
|
||||
assert_eq!(
|
||||
true,
|
||||
Address::from(Ipv4Address::new(192, 168, 1, 1)).is_ipv4_mapped()
|
||||
);
|
||||
assert!(!Address::UNSPECIFIED.is_ipv4_mapped());
|
||||
assert!(Address::from(Ipv4Address::new(192, 168, 1, 1)).is_ipv4_mapped());
|
||||
}
|
||||
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
|
|
|
@ -241,13 +241,13 @@ mod test {
|
|||
let header = Header::new_unchecked(&BYTES_HEADER_MORE_FRAG);
|
||||
assert_eq!(header.next_header(), Protocol::Tcp);
|
||||
assert_eq!(header.frag_offset(), 0);
|
||||
assert_eq!(header.more_frags(), true);
|
||||
assert!(header.more_frags());
|
||||
assert_eq!(header.ident(), 12345);
|
||||
|
||||
let header = Header::new_unchecked(&BYTES_HEADER_LAST_FRAG);
|
||||
assert_eq!(header.next_header(), Protocol::Tcp);
|
||||
assert_eq!(header.frag_offset(), 320);
|
||||
assert_eq!(header.more_frags(), false);
|
||||
assert!(!header.more_frags());
|
||||
assert_eq!(header.ident(), 67890);
|
||||
}
|
||||
|
||||
|
|
|
@ -448,7 +448,7 @@ mod test {
|
|||
assert_eq!(packet.checksum(), 0x7374);
|
||||
assert_eq!(packet.max_resp_code(), 0x0400);
|
||||
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.qqic(), 0x12);
|
||||
assert_eq!(packet.num_srcs(), 0x01);
|
||||
|
|
|
@ -1113,21 +1113,18 @@ mod test {
|
|||
assert_eq!(packet.seq_number(), SeqNumber(0x01234567));
|
||||
assert_eq!(packet.ack_number(), SeqNumber(0x89abcdefu32 as i32));
|
||||
assert_eq!(packet.header_len(), 24);
|
||||
assert_eq!(packet.fin(), true);
|
||||
assert_eq!(packet.syn(), false);
|
||||
assert_eq!(packet.rst(), true);
|
||||
assert_eq!(packet.psh(), false);
|
||||
assert_eq!(packet.ack(), true);
|
||||
assert_eq!(packet.urg(), true);
|
||||
assert!(packet.fin());
|
||||
assert!(!packet.syn());
|
||||
assert!(packet.rst());
|
||||
assert!(!packet.psh());
|
||||
assert!(packet.ack());
|
||||
assert!(packet.urg());
|
||||
assert_eq!(packet.window_len(), 0x0123);
|
||||
assert_eq!(packet.urgent_at(), 0x0201);
|
||||
assert_eq!(packet.checksum(), 0x01b6);
|
||||
assert_eq!(packet.options(), &OPTION_BYTES[..]);
|
||||
assert_eq!(packet.payload(), &PAYLOAD_BYTES[..]);
|
||||
assert_eq!(
|
||||
packet.verify_checksum(&SRC_ADDR.into(), &DST_ADDR.into()),
|
||||
true
|
||||
);
|
||||
assert!(packet.verify_checksum(&SRC_ADDR.into(), &DST_ADDR.into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -338,10 +338,7 @@ mod test {
|
|||
assert_eq!(packet.len(), 12);
|
||||
assert_eq!(packet.checksum(), 0x124d);
|
||||
assert_eq!(packet.payload(), &PAYLOAD_BYTES[..]);
|
||||
assert_eq!(
|
||||
packet.verify_checksum(&SRC_ADDR.into(), &DST_ADDR.into()),
|
||||
true
|
||||
);
|
||||
assert!(packet.verify_checksum(&SRC_ADDR.into(), &DST_ADDR.into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in New Issue