Struct etherparse::IpAuthenticationHeader
source · pub struct IpAuthenticationHeader {
pub next_header: u8,
pub spi: u32,
pub sequence_number: u32,
/* private fields */
}
Expand description
IP Authentication Header (rfc4302)
Fields§
§next_header: u8
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> IpAuthenticationHeader
impl<'a> IpAuthenticationHeader
pub const MAX_ICV_LEN: usize = 1_016usize
sourcepub fn new(
next_header: u8,
spi: u32,
sequence_number: u32,
raw_icv: &'a [u8]
) -> Result<IpAuthenticationHeader, ValueError>
pub fn new(
next_header: u8,
spi: u32,
sequence_number: u32,
raw_icv: &'a [u8]
) -> Result<IpAuthenticationHeader, ValueError>
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
(IpAuthenticationHeader::MAX_ICV_LEN
). If the slice length does
not fullfill these requirements the value is not copied and an
Err(ValueError::IpAuthenticationHeaderBadIcvLength)
is returned.
If successfull an Ok(()) is returned.
sourcepub fn from_slice(
slice: &'a [u8]
) -> Result<(IpAuthenticationHeader, &'a [u8]), ReadError>
pub fn from_slice(
slice: &'a [u8]
) -> Result<(IpAuthenticationHeader, &'a [u8]), ReadError>
Read an authentication header from a slice and return the header & unused parts of the slice.
sourcepub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<IpAuthenticationHeader, ReadError>
pub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<IpAuthenticationHeader, ReadError>
Read an authentication header from the current reader position.
sourcepub fn set_raw_icv(&mut self, raw_icv: &[u8]) -> Result<(), ValueError>
pub fn set_raw_icv(&mut self, raw_icv: &[u8]) -> Result<(), ValueError>
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
(IpAuthenticationHeader::MAX_ICV_LEN
). If the slice length does
not fullfill these requirements the value is not copied and an
Err(ValueError::IpAuthenticationHeaderBadIcvLength)
is returned.
If successfull an Ok(()) is returned.
sourcepub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), WriteError>
pub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), WriteError>
Writes the given authentication header to the current position.
sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Length of the header in bytes.
Trait Implementations§
source§impl Clone for IpAuthenticationHeader
impl Clone for IpAuthenticationHeader
source§fn clone(&self) -> IpAuthenticationHeader
fn clone(&self) -> IpAuthenticationHeader
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more