Enum etherparse::IpHeader
source · pub enum IpHeader {
Version4(Ipv4Header, Ipv4Extensions),
Version6(Ipv6Header, Ipv6Extensions),
}
Expand description
Internet protocol headers version 4 & 6
Variants§
Version4(Ipv4Header, Ipv4Extensions)
Version6(Ipv6Header, Ipv6Extensions)
Implementations§
source§impl IpHeader
impl IpHeader
sourcepub fn read_from_slice(slice: &[u8]) -> Result<(IpHeader, u8, &[u8]), ReadError>
👎Deprecated since 0.10.1: Renamed to IpHeader::from_slice
pub fn read_from_slice(slice: &[u8]) -> Result<(IpHeader, u8, &[u8]), ReadError>
IpHeader::from_slice
Renamed to IpHeader::from_slice
sourcepub fn from_slice(slice: &[u8]) -> Result<(IpHeader, u8, &[u8]), ReadError>
pub fn from_slice(slice: &[u8]) -> Result<(IpHeader, u8, &[u8]), ReadError>
Read an IpvHeader from a slice and return the header & unused parts of the slice.
sourcepub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<(IpHeader, u8), ReadError>
pub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<(IpHeader, u8), ReadError>
Reads an IP (v4 or v6) header from the current position.
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 an IP (v4 or v6) header to the current position
sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Returns the size when the ip header & extensions are serialized
sourcepub fn next_header(&self) -> Result<u8, ValueError>
pub fn next_header(&self) -> Result<u8, ValueError>
Returns the last next header number following the ip header and header extensions.
sourcepub fn set_next_headers(&mut self, last_next_header: u8) -> EtherType
pub fn set_next_headers(&mut self, last_next_header: u8) -> EtherType
Sets all the next_header fields in the ipv4 & ipv6 header as well as in all extension headers and returns the ether type number.
The given number will be set as the last “next_header” or protocol number.
sourcepub fn set_payload_len(&mut self, len: usize) -> Result<(), ValueError>
pub fn set_payload_len(&mut self, len: usize) -> Result<(), ValueError>
Tries to set the length field in the ip header given the length of data after the ip header and extension header(s).
If the payload length is too large to be stored in the length fields of the ip header an error is returned.
Note that this function will automatically add the length of the extension headers is they are present.