pub struct IpAuthHeader {
    pub next_header: IpNumber,
    pub spi: u32,
    pub sequence_number: u32,
    /* private fields */
}
Expand description

IP Authentication Header (rfc4302)

Fields§

§next_header: IpNumber

IP protocol number specifying the next header or transport layer protocol.

See IpNumber or ip_number for a definition of the known values.

§spi: u32

Security Parameters Index

§sequence_number: u32

This unsigned 32-bit field contains a counter value that increases by one for each packet sent.

Implementations§

source§

impl<'a> IpAuthHeader

source

pub const MIN_LEN: usize = 12usize

Minimum length of an IP authentication header in bytes/octets.

source

pub const MAX_LEN: usize = 1_028usize

Maximum length of an IP authentication header in bytes/octets.

This number is calculated by taking the maximum value that the “payload length” field supports (0xff) adding 2 and multiplying the sum by 4 as the “payload length” specifies how many 4 bytes words are present in the header.

source

pub const MAX_ICV_LEN: usize = 1_016usize

The maximum amount of bytes/octets that can be stored in the ICV part of an IP authentication header.

source

pub fn new( next_header: IpNumber, spi: u32, sequence_number: u32, raw_icv: &'a [u8] ) -> Result<IpAuthHeader, IcvLenError>

Create a new authentication header with the given parameters.

Note: The length of the raw_icv slice must be a multiple of 4 and the maximum allowed length is 1016 bytes (IpAuthHeader::MAX_ICV_LEN). If the slice length does not fulfill these requirements the value is not copied and an crate::err::ip_auth::IcvLenError is returned. If successful an Ok(()) is returned.

source

pub fn from_slice( slice: &'a [u8] ) -> Result<(IpAuthHeader, &'a [u8]), HeaderSliceError>

Read an authentication header from a slice and return the header & unused parts of the slice.

source

pub fn read<T: Read + Sized>( reader: &mut T ) -> Result<IpAuthHeader, HeaderReadError>

Available on crate feature std only.

Read an authentication header from the current reader position.

source

pub fn read_limited<T: Read + Sized>( reader: &mut LimitedReader<T> ) -> Result<IpAuthHeader, HeaderLimitedReadError>

Available on crate feature std only.

Read an authentication header from the current reader position with a limited reader.

source

pub fn raw_icv(&self) -> &[u8]

Returns a slice the raw icv value.

source

pub fn set_raw_icv(&mut self, raw_icv: &[u8]) -> Result<(), IcvLenError>

Sets the icv value to the given raw value. The length of the slice must be a multiple of 4 and the maximum allowed length is 1016 bytes (IpAuthHeader::MAX_ICV_LEN). If the slice length does not fulfill these requirements the value is not copied and an crate::err::ip_auth::IcvLenError is returned. If successful an Ok(()) is returned.

source

pub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), Error>

Available on crate feature std only.

Writes the given authentication header to the current position.

source

pub fn header_len(&self) -> usize

Length of the header in bytes.

source

pub fn to_bytes(&self) -> ArrayVec<u8, { IpAuthHeader::MAX_LEN }>

Returns the serialized header.

Trait Implementations§

source§

impl Clone for IpAuthHeader

source§

fn clone(&self) -> IpAuthHeader

Returns a copy 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 Debug for IpAuthHeader

source§

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

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

impl Default for IpAuthHeader

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for IpAuthHeader

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for IpAuthHeader

Auto Trait Implementations§

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> 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,

§

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>,

§

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>,

§

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.