mirror of
https://github.com/smoltcp-rs/smoltcp.git
synced 2025-10-02 15:15:05 +00:00
Add x_
prefix to all IP methods that collide with unstable core's.
This commit is contained in:
parent
803fa8734a
commit
b65e1b64dc
@ -70,7 +70,7 @@ impl InterfaceInner {
|
|||||||
|
|
||||||
/// Checks if an ipv4 address is unicast, taking into account subnet broadcast addresses
|
/// Checks if an ipv4 address is unicast, taking into account subnet broadcast addresses
|
||||||
fn is_unicast_v4(&self, address: Ipv4Address) -> bool {
|
fn is_unicast_v4(&self, address: Ipv4Address) -> bool {
|
||||||
address.is_unicast() && !self.is_broadcast_v4(address)
|
address.x_is_unicast() && !self.is_broadcast_v4(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the first IPv4 address of the interface.
|
/// Get the first IPv4 address of the interface.
|
||||||
@ -182,7 +182,7 @@ impl InterfaceInner {
|
|||||||
// Ignore IP packets not directed at us, or broadcast, or any of the multicast groups.
|
// Ignore IP packets not directed at us, or broadcast, or any of the multicast groups.
|
||||||
// If AnyIP is enabled, also check if the packet is routed locally.
|
// If AnyIP is enabled, also check if the packet is routed locally.
|
||||||
if !self.any_ip
|
if !self.any_ip
|
||||||
|| !ipv4_repr.dst_addr.is_unicast()
|
|| !ipv4_repr.dst_addr.x_is_unicast()
|
||||||
|| self
|
|| self
|
||||||
.routes
|
.routes
|
||||||
.lookup(&IpAddress::Ipv4(ipv4_repr.dst_addr), self.now)
|
.lookup(&IpAddress::Ipv4(ipv4_repr.dst_addr), self.now)
|
||||||
@ -260,7 +260,7 @@ impl InterfaceInner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Discard packets with non-unicast source addresses.
|
// Discard packets with non-unicast source addresses.
|
||||||
if !source_protocol_addr.is_unicast() || !source_hardware_addr.is_unicast() {
|
if !source_protocol_addr.x_is_unicast() || !source_hardware_addr.is_unicast() {
|
||||||
net_debug!("arp: non-unicast source address");
|
net_debug!("arp: non-unicast source address");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,9 @@ impl InterfaceInner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if dst_addr.is_multicast()
|
if dst_addr.is_multicast()
|
||||||
&& matches!(dst_addr.multicast_scope(), Ipv6MulticastScope::LinkLocal)
|
&& matches!(dst_addr.x_multicast_scope(), Ipv6MulticastScope::LinkLocal)
|
||||||
&& src_addr.is_multicast()
|
&& src_addr.is_multicast()
|
||||||
&& !matches!(src_addr.multicast_scope(), Ipv6MulticastScope::LinkLocal)
|
&& !matches!(src_addr.x_multicast_scope(), Ipv6MulticastScope::LinkLocal)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -111,15 +111,16 @@ impl InterfaceInner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rule 2: prefer appropriate scope.
|
// Rule 2: prefer appropriate scope.
|
||||||
if (candidate.address().multicast_scope() as u8)
|
if (candidate.address().x_multicast_scope() as u8)
|
||||||
< (addr.address().multicast_scope() as u8)
|
< (addr.address().x_multicast_scope() as u8)
|
||||||
{
|
{
|
||||||
if (candidate.address().multicast_scope() as u8)
|
if (candidate.address().x_multicast_scope() as u8)
|
||||||
< (dst_addr.multicast_scope() as u8)
|
< (dst_addr.x_multicast_scope() as u8)
|
||||||
{
|
{
|
||||||
candidate = addr;
|
candidate = addr;
|
||||||
}
|
}
|
||||||
} else if (addr.address().multicast_scope() as u8) > (dst_addr.multicast_scope() as u8)
|
} else if (addr.address().x_multicast_scope() as u8)
|
||||||
|
> (dst_addr.x_multicast_scope() as u8)
|
||||||
{
|
{
|
||||||
candidate = addr;
|
candidate = addr;
|
||||||
}
|
}
|
||||||
@ -192,7 +193,7 @@ impl InterfaceInner {
|
|||||||
) -> Option<Packet<'frame>> {
|
) -> Option<Packet<'frame>> {
|
||||||
let ipv6_repr = check!(Ipv6Repr::parse(ipv6_packet));
|
let ipv6_repr = check!(Ipv6Repr::parse(ipv6_packet));
|
||||||
|
|
||||||
if !ipv6_repr.src_addr.is_unicast() {
|
if !ipv6_repr.src_addr.x_is_unicast() {
|
||||||
// Discard packets with non-unicast source addresses.
|
// Discard packets with non-unicast source addresses.
|
||||||
net_debug!("non-unicast source address");
|
net_debug!("non-unicast source address");
|
||||||
return None;
|
return None;
|
||||||
@ -213,7 +214,7 @@ impl InterfaceInner {
|
|||||||
{
|
{
|
||||||
// If AnyIP is enabled, also check if the packet is routed locally.
|
// If AnyIP is enabled, also check if the packet is routed locally.
|
||||||
if !self.any_ip
|
if !self.any_ip
|
||||||
|| !ipv6_repr.dst_addr.is_unicast()
|
|| !ipv6_repr.dst_addr.x_is_unicast()
|
||||||
|| self
|
|| self
|
||||||
.routes
|
.routes
|
||||||
.lookup(&IpAddress::Ipv6(ipv6_repr.dst_addr), self.now)
|
.lookup(&IpAddress::Ipv6(ipv6_repr.dst_addr), self.now)
|
||||||
@ -230,7 +231,7 @@ impl InterfaceInner {
|
|||||||
let handled_by_raw_socket = false;
|
let handled_by_raw_socket = false;
|
||||||
|
|
||||||
#[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))]
|
#[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))]
|
||||||
if ipv6_repr.dst_addr.is_unicast() {
|
if ipv6_repr.dst_addr.x_is_unicast() {
|
||||||
self.neighbor_cache.reset_expiry_if_existing(
|
self.neighbor_cache.reset_expiry_if_existing(
|
||||||
IpAddress::Ipv6(ipv6_repr.src_addr),
|
IpAddress::Ipv6(ipv6_repr.src_addr),
|
||||||
source_hardware_addr,
|
source_hardware_addr,
|
||||||
@ -436,7 +437,7 @@ impl InterfaceInner {
|
|||||||
let ip_addr = ip_repr.src_addr.into();
|
let ip_addr = ip_repr.src_addr.into();
|
||||||
if let Some(lladdr) = lladdr {
|
if let Some(lladdr) = lladdr {
|
||||||
let lladdr = check!(lladdr.parse(self.caps.medium));
|
let lladdr = check!(lladdr.parse(self.caps.medium));
|
||||||
if !lladdr.is_unicast() || !target_addr.is_unicast() {
|
if !lladdr.is_unicast() || !target_addr.x_is_unicast() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if flags.contains(NdiscNeighborFlags::OVERRIDE)
|
if flags.contains(NdiscNeighborFlags::OVERRIDE)
|
||||||
@ -454,7 +455,7 @@ impl InterfaceInner {
|
|||||||
} => {
|
} => {
|
||||||
if let Some(lladdr) = lladdr {
|
if let Some(lladdr) = lladdr {
|
||||||
let lladdr = check!(lladdr.parse(self.caps.medium));
|
let lladdr = check!(lladdr.parse(self.caps.medium));
|
||||||
if !lladdr.is_unicast() || !target_addr.is_unicast() {
|
if !lladdr.is_unicast() || !target_addr.x_is_unicast() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
self.neighbor_cache
|
self.neighbor_cache
|
||||||
@ -492,7 +493,7 @@ impl InterfaceInner {
|
|||||||
let src_addr = ipv6_repr.dst_addr;
|
let src_addr = ipv6_repr.dst_addr;
|
||||||
let dst_addr = ipv6_repr.src_addr;
|
let dst_addr = ipv6_repr.src_addr;
|
||||||
|
|
||||||
let src_addr = if src_addr.is_unicast() {
|
let src_addr = if src_addr.x_is_unicast() {
|
||||||
src_addr
|
src_addr
|
||||||
} else {
|
} else {
|
||||||
self.get_source_address_ipv6(&dst_addr)
|
self.get_source_address_ipv6(&dst_addr)
|
||||||
|
@ -87,7 +87,6 @@ compile_error!("at least one socket needs to be enabled"); */
|
|||||||
#![allow(clippy::option_map_unit_fn)]
|
#![allow(clippy::option_map_unit_fn)]
|
||||||
#![allow(clippy::unit_arg)]
|
#![allow(clippy::unit_arg)]
|
||||||
#![allow(clippy::new_without_default)]
|
#![allow(clippy::new_without_default)]
|
||||||
#![allow(unstable_name_collisions)]
|
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
@ -366,7 +366,7 @@ impl<'a> Socket<'a> {
|
|||||||
|
|
||||||
match (&mut self.state, dhcp_repr.message_type) {
|
match (&mut self.state, dhcp_repr.message_type) {
|
||||||
(ClientState::Discovering(_state), DhcpMessageType::Offer) => {
|
(ClientState::Discovering(_state), DhcpMessageType::Offer) => {
|
||||||
if !dhcp_repr.your_ip.is_unicast() {
|
if !dhcp_repr.your_ip.x_is_unicast() {
|
||||||
net_debug!("DHCP ignoring OFFER because your_ip is not unicast");
|
net_debug!("DHCP ignoring OFFER because your_ip is not unicast");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -462,7 +462,7 @@ impl<'a> Socket<'a> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if !dhcp_repr.your_ip.is_unicast() {
|
if !dhcp_repr.your_ip.x_is_unicast() {
|
||||||
net_debug!("DHCP ignoring ACK because your_ip is not unicast");
|
net_debug!("DHCP ignoring ACK because your_ip is not unicast");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -483,7 +483,7 @@ impl<'a> Socket<'a> {
|
|||||||
.dns_servers
|
.dns_servers
|
||||||
.iter()
|
.iter()
|
||||||
.flatten()
|
.flatten()
|
||||||
.filter(|s| s.is_unicast())
|
.filter(|s| s.x_is_unicast())
|
||||||
.for_each(|a| {
|
.for_each(|a| {
|
||||||
// This will never produce an error, as both the arrays and `dns_servers`
|
// This will never produce an error, as both the arrays and `dns_servers`
|
||||||
// have length DHCP_MAX_DNS_SERVER_COUNT
|
// have length DHCP_MAX_DNS_SERVER_COUNT
|
||||||
|
@ -131,9 +131,9 @@ impl Address {
|
|||||||
pub fn is_unicast(&self) -> bool {
|
pub fn is_unicast(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
#[cfg(feature = "proto-ipv4")]
|
#[cfg(feature = "proto-ipv4")]
|
||||||
Address::Ipv4(addr) => addr.is_unicast(),
|
Address::Ipv4(addr) => addr.x_is_unicast(),
|
||||||
#[cfg(feature = "proto-ipv6")]
|
#[cfg(feature = "proto-ipv6")]
|
||||||
Address::Ipv6(addr) => addr.is_unicast(),
|
Address::Ipv6(addr) => addr.x_is_unicast(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,9 @@ pub(crate) trait AddressExt {
|
|||||||
fn from_bytes(data: &[u8]) -> Self;
|
fn from_bytes(data: &[u8]) -> Self;
|
||||||
|
|
||||||
/// Query whether the address is an unicast address.
|
/// Query whether the address is an unicast address.
|
||||||
fn is_unicast(&self) -> bool;
|
///
|
||||||
|
/// `x_` prefix is to avoid a collision with the still-unstable method in `core::ip`.
|
||||||
|
fn x_is_unicast(&self) -> bool;
|
||||||
|
|
||||||
/// If `self` is a CIDR-compatible subnet mask, return `Some(prefix_len)`,
|
/// If `self` is a CIDR-compatible subnet mask, return `Some(prefix_len)`,
|
||||||
/// where `prefix_len` is the number of leading zeroes. Return `None` otherwise.
|
/// where `prefix_len` is the number of leading zeroes. Return `None` otherwise.
|
||||||
@ -66,7 +68,7 @@ impl AddressExt for Address {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Query whether the address is an unicast address.
|
/// Query whether the address is an unicast address.
|
||||||
fn is_unicast(&self) -> bool {
|
fn x_is_unicast(&self) -> bool {
|
||||||
!(self.is_broadcast() || self.is_multicast() || self.is_unspecified())
|
!(self.is_broadcast() || self.is_multicast() || self.is_unspecified())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,9 @@ pub(crate) trait AddressExt {
|
|||||||
/// Query whether the IPv6 address is an [unicast address].
|
/// Query whether the IPv6 address is an [unicast address].
|
||||||
///
|
///
|
||||||
/// [unicast address]: https://tools.ietf.org/html/rfc4291#section-2.5
|
/// [unicast address]: https://tools.ietf.org/html/rfc4291#section-2.5
|
||||||
fn is_unicast(&self) -> bool;
|
///
|
||||||
|
/// `x_` prefix is to avoid a collision with the still-unstable method in `core::ip`.
|
||||||
|
fn x_is_unicast(&self) -> bool;
|
||||||
|
|
||||||
/// Query whether the IPv6 address is a [global unicast address].
|
/// Query whether the IPv6 address is a [global unicast address].
|
||||||
///
|
///
|
||||||
@ -101,7 +103,9 @@ pub(crate) trait AddressExt {
|
|||||||
/// Query whether the IPv6 address is a [Unique Local Address] (ULA).
|
/// Query whether the IPv6 address is a [Unique Local Address] (ULA).
|
||||||
///
|
///
|
||||||
/// [Unique Local Address]: https://tools.ietf.org/html/rfc4193
|
/// [Unique Local Address]: https://tools.ietf.org/html/rfc4193
|
||||||
fn is_unique_local(&self) -> bool;
|
///
|
||||||
|
/// `x_` prefix is to avoid a collision with the still-unstable method in `core::ip`.
|
||||||
|
fn x_is_unique_local(&self) -> bool;
|
||||||
|
|
||||||
/// Helper function used to mask an address given a prefix.
|
/// Helper function used to mask an address given a prefix.
|
||||||
///
|
///
|
||||||
@ -117,7 +121,9 @@ pub(crate) trait AddressExt {
|
|||||||
fn solicited_node(&self) -> Address;
|
fn solicited_node(&self) -> Address;
|
||||||
|
|
||||||
/// Return the scope of the address.
|
/// Return the scope of the address.
|
||||||
fn multicast_scope(&self) -> MulticastScope;
|
///
|
||||||
|
/// `x_` prefix is to avoid a collision with the still-unstable method in `core::ip`.
|
||||||
|
fn x_multicast_scope(&self) -> MulticastScope;
|
||||||
|
|
||||||
/// If `self` is a CIDR-compatible subnet mask, return `Some(prefix_len)`,
|
/// If `self` is a CIDR-compatible subnet mask, return `Some(prefix_len)`,
|
||||||
/// where `prefix_len` is the number of leading zeroes. Return `None` otherwise.
|
/// where `prefix_len` is the number of leading zeroes. Return `None` otherwise.
|
||||||
@ -131,7 +137,7 @@ impl AddressExt for Address {
|
|||||||
Address::from(bytes)
|
Address::from(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_unicast(&self) -> bool {
|
fn x_is_unicast(&self) -> bool {
|
||||||
!(self.is_multicast() || self.is_unspecified())
|
!(self.is_multicast() || self.is_unspecified())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +149,7 @@ impl AddressExt for Address {
|
|||||||
self.octets()[0..8] == [0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
self.octets()[0..8] == [0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_unique_local(&self) -> bool {
|
fn x_is_unique_local(&self) -> bool {
|
||||||
(self.octets()[0] & 0b1111_1110) == 0xfc
|
(self.octets()[0] & 0b1111_1110) == 0xfc
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +169,7 @@ impl AddressExt for Address {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn solicited_node(&self) -> Address {
|
fn solicited_node(&self) -> Address {
|
||||||
assert!(self.is_unicast());
|
assert!(self.x_is_unicast());
|
||||||
let o = self.octets();
|
let o = self.octets();
|
||||||
Address::from([
|
Address::from([
|
||||||
0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, o[13],
|
0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, o[13],
|
||||||
@ -171,14 +177,14 @@ impl AddressExt for Address {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn multicast_scope(&self) -> MulticastScope {
|
fn x_multicast_scope(&self) -> MulticastScope {
|
||||||
if self.is_multicast() {
|
if self.is_multicast() {
|
||||||
return MulticastScope::from(self.octets()[1] & 0b1111);
|
return MulticastScope::from(self.octets()[1] & 0b1111);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.is_link_local() {
|
if self.is_link_local() {
|
||||||
MulticastScope::LinkLocal
|
MulticastScope::LinkLocal
|
||||||
} else if self.is_unique_local() || self.is_global_unicast() {
|
} else if self.x_is_unique_local() || self.is_global_unicast() {
|
||||||
// ULA are considered global scope
|
// ULA are considered global scope
|
||||||
// https://www.rfc-editor.org/rfc/rfc6724#section-3.1
|
// https://www.rfc-editor.org/rfc/rfc6724#section-3.1
|
||||||
MulticastScope::Global
|
MulticastScope::Global
|
||||||
@ -680,13 +686,13 @@ pub(crate) mod test {
|
|||||||
assert!(LINK_LOCAL_ALL_ROUTERS.is_multicast());
|
assert!(LINK_LOCAL_ALL_ROUTERS.is_multicast());
|
||||||
assert!(!LINK_LOCAL_ALL_ROUTERS.is_link_local());
|
assert!(!LINK_LOCAL_ALL_ROUTERS.is_link_local());
|
||||||
assert!(!LINK_LOCAL_ALL_ROUTERS.is_loopback());
|
assert!(!LINK_LOCAL_ALL_ROUTERS.is_loopback());
|
||||||
assert!(!LINK_LOCAL_ALL_ROUTERS.is_unique_local());
|
assert!(!LINK_LOCAL_ALL_ROUTERS.x_is_unique_local());
|
||||||
assert!(!LINK_LOCAL_ALL_ROUTERS.is_global_unicast());
|
assert!(!LINK_LOCAL_ALL_ROUTERS.is_global_unicast());
|
||||||
assert!(!LINK_LOCAL_ALL_NODES.is_unspecified());
|
assert!(!LINK_LOCAL_ALL_NODES.is_unspecified());
|
||||||
assert!(LINK_LOCAL_ALL_NODES.is_multicast());
|
assert!(LINK_LOCAL_ALL_NODES.is_multicast());
|
||||||
assert!(!LINK_LOCAL_ALL_NODES.is_link_local());
|
assert!(!LINK_LOCAL_ALL_NODES.is_link_local());
|
||||||
assert!(!LINK_LOCAL_ALL_NODES.is_loopback());
|
assert!(!LINK_LOCAL_ALL_NODES.is_loopback());
|
||||||
assert!(!LINK_LOCAL_ALL_NODES.is_unique_local());
|
assert!(!LINK_LOCAL_ALL_NODES.x_is_unique_local());
|
||||||
assert!(!LINK_LOCAL_ALL_NODES.is_global_unicast());
|
assert!(!LINK_LOCAL_ALL_NODES.is_global_unicast());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,7 +702,7 @@ pub(crate) mod test {
|
|||||||
assert!(!LINK_LOCAL_ADDR.is_multicast());
|
assert!(!LINK_LOCAL_ADDR.is_multicast());
|
||||||
assert!(LINK_LOCAL_ADDR.is_link_local());
|
assert!(LINK_LOCAL_ADDR.is_link_local());
|
||||||
assert!(!LINK_LOCAL_ADDR.is_loopback());
|
assert!(!LINK_LOCAL_ADDR.is_loopback());
|
||||||
assert!(!LINK_LOCAL_ADDR.is_unique_local());
|
assert!(!LINK_LOCAL_ADDR.x_is_unique_local());
|
||||||
assert!(!LINK_LOCAL_ADDR.is_global_unicast());
|
assert!(!LINK_LOCAL_ADDR.is_global_unicast());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +712,7 @@ pub(crate) mod test {
|
|||||||
assert!(!Address::LOCALHOST.is_multicast());
|
assert!(!Address::LOCALHOST.is_multicast());
|
||||||
assert!(!Address::LOCALHOST.is_link_local());
|
assert!(!Address::LOCALHOST.is_link_local());
|
||||||
assert!(Address::LOCALHOST.is_loopback());
|
assert!(Address::LOCALHOST.is_loopback());
|
||||||
assert!(!Address::LOCALHOST.is_unique_local());
|
assert!(!Address::LOCALHOST.x_is_unique_local());
|
||||||
assert!(!Address::LOCALHOST.is_global_unicast());
|
assert!(!Address::LOCALHOST.is_global_unicast());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,7 +722,7 @@ pub(crate) mod test {
|
|||||||
assert!(!UNIQUE_LOCAL_ADDR.is_multicast());
|
assert!(!UNIQUE_LOCAL_ADDR.is_multicast());
|
||||||
assert!(!UNIQUE_LOCAL_ADDR.is_link_local());
|
assert!(!UNIQUE_LOCAL_ADDR.is_link_local());
|
||||||
assert!(!UNIQUE_LOCAL_ADDR.is_loopback());
|
assert!(!UNIQUE_LOCAL_ADDR.is_loopback());
|
||||||
assert!(UNIQUE_LOCAL_ADDR.is_unique_local());
|
assert!(UNIQUE_LOCAL_ADDR.x_is_unique_local());
|
||||||
assert!(!UNIQUE_LOCAL_ADDR.is_global_unicast());
|
assert!(!UNIQUE_LOCAL_ADDR.is_global_unicast());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -726,7 +732,7 @@ pub(crate) mod test {
|
|||||||
assert!(!GLOBAL_UNICAST_ADDR.is_multicast());
|
assert!(!GLOBAL_UNICAST_ADDR.is_multicast());
|
||||||
assert!(!GLOBAL_UNICAST_ADDR.is_link_local());
|
assert!(!GLOBAL_UNICAST_ADDR.is_link_local());
|
||||||
assert!(!GLOBAL_UNICAST_ADDR.is_loopback());
|
assert!(!GLOBAL_UNICAST_ADDR.is_loopback());
|
||||||
assert!(!GLOBAL_UNICAST_ADDR.is_unique_local());
|
assert!(!GLOBAL_UNICAST_ADDR.x_is_unique_local());
|
||||||
assert!(GLOBAL_UNICAST_ADDR.is_global_unicast());
|
assert!(GLOBAL_UNICAST_ADDR.is_global_unicast());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,46 +909,52 @@ pub(crate) mod test {
|
|||||||
fn test_scope() {
|
fn test_scope() {
|
||||||
use super::*;
|
use super::*;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Address::new(0xff01, 0, 0, 0, 0, 0, 0, 1).multicast_scope(),
|
Address::new(0xff01, 0, 0, 0, 0, 0, 0, 1).x_multicast_scope(),
|
||||||
MulticastScope::InterfaceLocal
|
MulticastScope::InterfaceLocal
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Address::new(0xff02, 0, 0, 0, 0, 0, 0, 1).multicast_scope(),
|
Address::new(0xff02, 0, 0, 0, 0, 0, 0, 1).x_multicast_scope(),
|
||||||
MulticastScope::LinkLocal
|
MulticastScope::LinkLocal
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Address::new(0xff03, 0, 0, 0, 0, 0, 0, 1).multicast_scope(),
|
Address::new(0xff03, 0, 0, 0, 0, 0, 0, 1).x_multicast_scope(),
|
||||||
MulticastScope::Unknown
|
MulticastScope::Unknown
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Address::new(0xff04, 0, 0, 0, 0, 0, 0, 1).multicast_scope(),
|
Address::new(0xff04, 0, 0, 0, 0, 0, 0, 1).x_multicast_scope(),
|
||||||
MulticastScope::AdminLocal
|
MulticastScope::AdminLocal
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Address::new(0xff05, 0, 0, 0, 0, 0, 0, 1).multicast_scope(),
|
Address::new(0xff05, 0, 0, 0, 0, 0, 0, 1).x_multicast_scope(),
|
||||||
MulticastScope::SiteLocal
|
MulticastScope::SiteLocal
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Address::new(0xff08, 0, 0, 0, 0, 0, 0, 1).multicast_scope(),
|
Address::new(0xff08, 0, 0, 0, 0, 0, 0, 1).x_multicast_scope(),
|
||||||
MulticastScope::OrganizationLocal
|
MulticastScope::OrganizationLocal
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Address::new(0xff0e, 0, 0, 0, 0, 0, 0, 1).multicast_scope(),
|
Address::new(0xff0e, 0, 0, 0, 0, 0, 0, 1).x_multicast_scope(),
|
||||||
MulticastScope::Global
|
MulticastScope::Global
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
LINK_LOCAL_ALL_NODES.multicast_scope(),
|
LINK_LOCAL_ALL_NODES.x_multicast_scope(),
|
||||||
MulticastScope::LinkLocal
|
MulticastScope::LinkLocal
|
||||||
);
|
);
|
||||||
|
|
||||||
// For source address selection, unicast addresses also have a scope:
|
// For source address selection, unicast addresses also have a scope:
|
||||||
assert_eq!(LINK_LOCAL_ADDR.multicast_scope(), MulticastScope::LinkLocal);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
GLOBAL_UNICAST_ADDR.multicast_scope(),
|
LINK_LOCAL_ADDR.x_multicast_scope(),
|
||||||
|
MulticastScope::LinkLocal
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
GLOBAL_UNICAST_ADDR.x_multicast_scope(),
|
||||||
|
MulticastScope::Global
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
UNIQUE_LOCAL_ADDR.x_multicast_scope(),
|
||||||
MulticastScope::Global
|
MulticastScope::Global
|
||||||
);
|
);
|
||||||
assert_eq!(UNIQUE_LOCAL_ADDR.multicast_scope(), MulticastScope::Global);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static REPR_PACKET_BYTES: [u8; 52] = [
|
static REPR_PACKET_BYTES: [u8; 52] = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user