Skip to main content

IpHeadersSlice

Enum IpHeadersSlice 

Source
pub enum IpHeadersSlice<'a> {
    Ipv4(Ipv4HeaderSlice<'a>, Ipv4ExtensionsSlice<'a>),
    Ipv6(Ipv6HeaderSlice<'a>, Ipv6ExtensionsSlice<'a>),
}
Expand description

Slice containing an IPv4 or IPv6 base header plus extension headers.

Variants§

§

Ipv4(Ipv4HeaderSlice<'a>, Ipv4ExtensionsSlice<'a>)

IPv4 base header and extension headers.

§

Ipv6(Ipv6HeaderSlice<'a>, Ipv6ExtensionsSlice<'a>)

IPv6 base header and extension headers.

Implementations§

Source§

impl<'a> IpHeadersSlice<'a>

Source

pub fn is_ipv4(&self) -> bool

Returns true if the slice contains an IPv4 header.

Source

pub fn is_ipv6(&self) -> bool

Returns true if the slice contains an IPv6 header.

Source

pub fn ipv4(&self) -> Option<Ipv4HeaderSlice<'a>>

Returns the IPv4 header slice if self contains one.

Source

pub fn ipv4_exts(&self) -> Option<Ipv4ExtensionsSlice<'a>>

Returns the IPv4 extension header slices if self contains one.

Source

pub fn ipv6(&self) -> Option<Ipv6HeaderSlice<'a>>

Returns the IPv6 header slice if self contains one.

Source

pub fn ipv6_exts(&self) -> Option<&Ipv6ExtensionsSlice<'a>>

Returns the IPv6 extension header slices if self contains one.

Source

pub fn slice(&self) -> &'a [u8]

Returns the underlying base-header slice.

Source

pub fn source_addr(&self) -> IpAddr

Returns the source IP address.

Source

pub fn destination_addr(&self) -> IpAddr

Returns the destination IP address.

Source

pub fn next_header(&self) -> IpNumber

Returns the protocol number stored in the base header.

For IPv4 this is the protocol field and for IPv6 this is the next_header field.

Source

pub fn payload_ip_number(&self) -> IpNumber

Returns the payload IP number after extension headers.

Source

pub fn version(&self) -> u8

Returns the IP version (4 or 6).

Source

pub fn header_len(&self) -> usize

Returns the serialized header length in bytes, including extensions.

Source

pub fn try_to_header(&self) -> Result<IpHeaders, HeaderSliceError>

Converts this sliced header representation into IpHeaders.

For IPv6 this conversion uses Ipv6Extensions::from_slice.

Note that Ipv6Extensions can only represent a subset of valid IPv6 extension chains. If more extension headers are present than can be represented, only the representable subset is converted.

Trait Implementations§

Source§

impl<'a> Clone for IpHeadersSlice<'a>

Source§

fn clone(&self) -> IpHeadersSlice<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for IpHeadersSlice<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<(Ipv4HeaderSlice<'a>, Ipv4ExtensionsSlice<'a>)> for IpHeadersSlice<'a>

Source§

fn from(value: (Ipv4HeaderSlice<'a>, Ipv4ExtensionsSlice<'a>)) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<(Ipv6HeaderSlice<'a>, Ipv6ExtensionsSlice<'a>)> for IpHeadersSlice<'a>

Source§

fn from(value: (Ipv6HeaderSlice<'a>, Ipv6ExtensionsSlice<'a>)) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Ipv4HeaderSlice<'a>> for IpHeadersSlice<'a>

Source§

fn from(value: Ipv4HeaderSlice<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Ipv6HeaderSlice<'a>> for IpHeadersSlice<'a>

Source§

fn from(value: Ipv6HeaderSlice<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> PartialEq for IpHeadersSlice<'a>

Source§

fn eq(&self, other: &IpHeadersSlice<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for IpHeadersSlice<'a>

Source§

impl<'a> StructuralPartialEq for IpHeadersSlice<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for IpHeadersSlice<'a>

§

impl<'a> RefUnwindSafe for IpHeadersSlice<'a>

§

impl<'a> Send for IpHeadersSlice<'a>

§

impl<'a> Sync for IpHeadersSlice<'a>

§

impl<'a> Unpin for IpHeadersSlice<'a>

§

impl<'a> UnsafeUnpin for IpHeadersSlice<'a>

§

impl<'a> UnwindSafe for IpHeadersSlice<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.