#[non_exhaustive]
pub enum IpRepr {
Unspecified {
src_addr: Address,
dst_addr: Address,
protocol: Protocol,
payload_len: usize,
hop_limit: u8,
},
Ipv4(Ipv4Repr),
Ipv6(Ipv6Repr),
}Expand description
An IP packet representation.
This enum abstracts the various versions of IP packets. It either contains a concrete
high-level representation for some IP protocol version, or an unspecified representation,
which permits the IpAddress::Unspecified addresses.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Unspecified
Ipv4(Ipv4Repr)
Ipv6(Ipv6Repr)
Implementations
sourceimpl Repr
impl Repr
sourcepub fn payload_len(&self) -> usize
pub fn payload_len(&self) -> usize
Return the payload length.
sourcepub fn set_payload_len(&mut self, length: usize)
pub fn set_payload_len(&mut self, length: usize)
Set the payload length.
sourcepub fn lower(&self, fallback_src_addrs: &[Cidr]) -> Result<Repr>
pub fn lower(&self, fallback_src_addrs: &[Cidr]) -> Result<Repr>
Convert an unspecified representation into a concrete one, or return
Err(Error::Unaddressable) if not possible.
Panics
This function panics if source and destination addresses belong to different families, or the destination address is unspecified, since this indicates a logic error.
sourcepub fn buffer_len(&self) -> usize
pub fn buffer_len(&self) -> usize
Return the length of a header that will be emitted from this high-level representation.
Panics
This function panics if invoked on an unspecified representation.
sourcepub fn emit<T: AsRef<[u8]> + AsMut<[u8]>>(
&self,
buffer: T,
_checksum_caps: &ChecksumCapabilities
)
pub fn emit<T: AsRef<[u8]> + AsMut<[u8]>>(
&self,
buffer: T,
_checksum_caps: &ChecksumCapabilities
)
Emit this high-level representation into a buffer.
Panics
This function panics if invoked on an unspecified representation.
Trait Implementations
impl Eq for Repr
impl StructuralEq for Repr
impl StructuralPartialEq for Repr
Auto Trait Implementations
impl RefUnwindSafe for Repr
impl Send for Repr
impl Sync for Repr
impl Unpin for Repr
impl UnwindSafe for Repr
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more