pub enum Ipv4SourceAddr {
Specified(NonMulticastAddr<SpecifiedAddr<Ipv4Addr>>),
Unspecified,
}Expand description
The source address from an IPv4 packet.
An Ipv4SourceAddr represents the source address from an IPv4 packet which
may only be either:
- specified and non-multicast, or
- unspecified.
Variants§
Specified(NonMulticastAddr<SpecifiedAddr<Ipv4Addr>>)
Unspecified
Implementations§
Source§impl Ipv4SourceAddr
impl Ipv4SourceAddr
Sourcepub fn new(addr: Ipv4Addr) -> Option<Ipv4SourceAddr>
pub fn new(addr: Ipv4Addr) -> Option<Ipv4SourceAddr>
Constructs a new Ipv4SourceAddr.
Returns None if addr does not satisfy the properties required of an
Ipv4SourceAddr.
Methods from Deref<Target = Ipv4Addr>§
Sourcepub fn ipv4_bytes(self) -> [u8; 4]
pub fn ipv4_bytes(self) -> [u8; 4]
Gets the bytes of the IPv4 address.
Sourcepub fn is_limited_broadcast(self) -> bool
pub fn is_limited_broadcast(self) -> bool
Is this the limited broadcast address?
is_limited_broadcast is a shorthand for comparing against
Ipv4::LIMITED_BROADCAST_ADDRESS.
Sourcepub fn is_class_e(self) -> bool
pub fn is_class_e(self) -> bool
Is this a Class E address?
is_class_e is a shorthand for checking membership in
Ipv4::CLASS_E_SUBNET.
Sourcepub fn to_ipv6_compatible(self) -> Ipv6Addr
pub fn to_ipv6_compatible(self) -> Ipv6Addr
Converts the address to an IPv4-compatible IPv6 address according to RFC 4291 Section 2.5.5.1.
IPv4-compatible IPv6 addresses were defined to assist in the IPv6 transition, and are now specified in RFC 4291 Section 2.5.5.1. The lowest-order 32 bits carry an IPv4 address, while the highest-order 96 bits are all set to 0 as in this diagram from the RFC:
| 80 bits | 16 | 32 bits |
+--------------------------------------+--------------------------+
|0000..............................0000|0000| IPv4 address |
+--------------------------------------+----+---------------------+Per RFC 4291:
The ‘IPv4-Compatible IPv6 address’ is now deprecated because the current IPv6 transition mechanisms no longer use these addresses. New or updated implementations are not required to support this address type.
The more modern embedding format is IPv4-mapped IPv6 addressing - see
to_ipv6_mapped.
Sourcepub fn to_ipv6_mapped(self) -> SpecifiedAddr<Ipv6Addr>
pub fn to_ipv6_mapped(self) -> SpecifiedAddr<Ipv6Addr>
Converts the address to an IPv4-mapped IPv6 address according to RFC 4291 Section 2.5.5.2.
IPv4-mapped IPv6 addresses are used to represent the addresses of IPv4 nodes as IPv6 addresses, and are defined in RFC 4291 Section 2.5.5.2. The lowest-order 32 bits carry an IPv4 address, the middle order 16 bits carry the literal 0xFFFF, and the highest order 80 bits are set to 0 as in this diagram from the RFC:
| 80 bits | 16 | 32 bits |
+--------------------------------------+--------------------------+
|0000..............................0000|FFFF| IPv4 address |
+--------------------------------------+----+---------------------+Sourcepub fn class(&self) -> Ipv4AddressClass
pub fn class(&self) -> Ipv4AddressClass
Returns the address’s class according to the obsoleted classful addressing architecture.
Trait Implementations§
Source§impl AsRef<Ipv4Addr> for Ipv4SourceAddr
impl AsRef<Ipv4Addr> for Ipv4SourceAddr
Source§impl Clone for Ipv4SourceAddr
impl Clone for Ipv4SourceAddr
impl Copy for Ipv4SourceAddr
Source§impl Debug for Ipv4SourceAddr
impl Debug for Ipv4SourceAddr
Source§impl Deref for Ipv4SourceAddr
impl Deref for Ipv4SourceAddr
Source§impl Display for Ipv4SourceAddr
impl Display for Ipv4SourceAddr
impl Eq for Ipv4SourceAddr
Source§impl From<Ipv4SourceAddr> for Ipv4Addr
impl From<Ipv4SourceAddr> for Ipv4Addr
Source§fn from(addr: Ipv4SourceAddr) -> Ipv4Addr
fn from(addr: Ipv4SourceAddr) -> Ipv4Addr
Source§impl PartialEq for Ipv4SourceAddr
impl PartialEq for Ipv4SourceAddr
impl StructuralPartialEq for Ipv4SourceAddr
Source§impl Witness<Ipv4Addr> for Ipv4SourceAddr
impl Witness<Ipv4Addr> for Ipv4SourceAddr
Source§unsafe fn new_unchecked(addr: Ipv4Addr) -> Ipv4SourceAddr
unsafe fn new_unchecked(addr: Ipv4Addr) -> Ipv4SourceAddr
addr actually
satisfies the required property. Read more