pub enum IpAddr {
V4(Ipv4Addr),
V6(Ipv6Addr),
}Expand description
An internetworking address.
Variants§
Implementations§
Source§impl Address
impl Address
Sourcepub const fn v4(a0: u8, a1: u8, a2: u8, a3: u8) -> Address
pub const fn v4(a0: u8, a1: u8, a2: u8, a3: u8) -> Address
Create an address wrapping an IPv4 address with the given octets.
Sourcepub const fn v6(
a0: u16,
a1: u16,
a2: u16,
a3: u16,
a4: u16,
a5: u16,
a6: u16,
a7: u16,
) -> Address
pub const fn v6( a0: u16, a1: u16, a2: u16, a3: u16, a4: u16, a5: u16, a6: u16, a7: u16, ) -> Address
Create an address wrapping an IPv6 address with the given octets.
Sourcepub fn is_unicast(&self) -> bool
pub fn is_unicast(&self) -> bool
Query whether the address is a valid unicast address.
Sourcepub const fn is_multicast(&self) -> bool
pub const fn is_multicast(&self) -> bool
Query whether the address is a valid multicast address.
Sourcepub fn multicast_ethernet_addr(&self) -> EthernetAddress
pub fn multicast_ethernet_addr(&self) -> EthernetAddress
The Ethernet address this multicast address maps to.
IPv4 groups map per RFC 1112, IPv6 groups per RFC 2464. Both mappings drop part of the group address, so distinct groups can map to the same Ethernet address.
Only with the medium-ethernet feature.
§Panics
Panics if the address is not multicast.
Sourcepub fn is_broadcast(&self) -> bool
pub fn is_broadcast(&self) -> bool
Query whether the address is the broadcast address.
Sourcepub fn is_unspecified(&self) -> bool
pub fn is_unspecified(&self) -> bool
Query whether the address falls into the “unspecified” range.
Sourcepub fn prefix_len(&self) -> Option<u8>
pub fn prefix_len(&self) -> Option<u8>
If self is a CIDR-compatible subnet mask, return Some(prefix_len),
where prefix_len is the number of leading zeroes. Return None otherwise.