#[repr(C)]pub struct Ipv4Hdr {
pub vihl: u8,
pub tos: u8,
pub tot_len: [u8; 2],
pub id: [u8; 2],
pub frags: [u8; 2],
pub ttl: u8,
pub proto: u8,
pub check: [u8; 2],
pub src_addr: [u8; 4],
pub dst_addr: [u8; 4],
}Expand description
IPv4 header, which is present after the Ethernet header.
Fields§
§vihl: u8§tos: u8§tot_len: [u8; 2]§id: [u8; 2]§frags: [u8; 2]§ttl: u8§proto: u8§check: [u8; 2]§src_addr: [u8; 4]§dst_addr: [u8; 4]Implementations§
Source§impl Ipv4Hdr
impl Ipv4Hdr
pub const LEN: usize
Sourcepub fn options_len(&self) -> u8
pub fn options_len(&self) -> u8
Returns the length of the IP options in bytes.
Sourcepub fn set_vihl(&mut self, version: u8, ihl_in_bytes: u8)
pub fn set_vihl(&mut self, version: u8, ihl_in_bytes: u8)
Sets both the version and IHL fields.
Sourcepub fn set_tos(&mut self, dscp: u8, ecn: u8)
pub fn set_tos(&mut self, dscp: u8, ecn: u8)
Sets the TOS field with separate DSCP and ECN values.
Sourcepub fn set_tot_len(&mut self, len: u16)
pub fn set_tot_len(&mut self, len: u16)
Sets the total length of the IP packet.
Sourcepub fn frag_flags(&self) -> u8
pub fn frag_flags(&self) -> u8
Returns the fragmentation flags (3 bits).
Sourcepub fn frag_offset(&self) -> u16
pub fn frag_offset(&self) -> u16
Returns the fragmentation offset (13 bits).
Sourcepub fn set_frags(&mut self, flags: u8, offset: u16)
pub fn set_frags(&mut self, flags: u8, offset: u16)
Sets both the fragmentation flags and offset.
Sourcepub fn set_checksum(&mut self, checksum: u16)
pub fn set_checksum(&mut self, checksum: u16)
Sets the checksum field.
Sourcepub fn set_src_addr(&mut self, src: Ipv4Addr)
pub fn set_src_addr(&mut self, src: Ipv4Addr)
Sets the source address field.
Sourcepub fn set_dst_addr(&mut self, dst: Ipv4Addr)
pub fn set_dst_addr(&mut self, dst: Ipv4Addr)
Sets the destination address field.
Trait Implementations§
Source§impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for Ipv4Hdr
impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for Ipv4Hdr
Source§impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for Ipv4Hdr
impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for Ipv4Hdr
Source§impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for Ipv4Hdrwhere
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> u8: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> [u8; 2]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal> [u8; 4]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> Assert<{ _ }>: IsTrue,
impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for Ipv4Hdrwhere
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> u8: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal, '_wincode_internal, '_wincode_internal> [u8; 2]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal, '_wincode_internal> [u8; 4]: ZeroCopy<WincodeConfig>,
for<'_wincode_internal> Assert<{ _ }>: IsTrue,
Source§fn from_bytes<'de>(bytes: &'de [u8], config: C) -> Result<&'de Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
fn from_bytes<'de>(bytes: &'de [u8], config: C) -> Result<&'de Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
Like
crate::ZeroCopy::from_bytes, but allows the caller to provide a custom configuration.Source§fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> Result<&'de mut Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> Result<&'de mut Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
Like
crate::ZeroCopy::from_bytes_mut, but allows the caller to provide a custom configuration.impl Copy for Ipv4Hdr
Auto Trait Implementations§
impl Freeze for Ipv4Hdr
impl RefUnwindSafe for Ipv4Hdr
impl Send for Ipv4Hdr
impl Sync for Ipv4Hdr
impl Unpin for Ipv4Hdr
impl UnsafeUnpin for Ipv4Hdr
impl UnwindSafe for Ipv4Hdr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
Source§impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
Source§impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Deserialize from the given
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Deserialize from the given
Reader into dst.Source§impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Deserialize from the given
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Deserialize from the given
Reader into dst.Source§impl<T, C> Serialize<C> for T
impl<T, C> Serialize<C> for T
Source§fn serialize_into(
dst: impl Writer,
src: &Self::Src,
config: C,
) -> Result<(), WriteError>
fn serialize_into( dst: impl Writer, src: &Self::Src, config: C, ) -> Result<(), WriteError>
Serialize a serializable type into the given
Writer.Source§fn serialized_size(src: &Self::Src, config: C) -> Result<u64, WriteError>
fn serialized_size(src: &Self::Src, config: C) -> Result<u64, WriteError>
Get the size in bytes of the type when serialized.
Source§impl<T> Serialize for T
impl<T> Serialize for T
Source§fn serialize_into(dst: impl Writer, src: &Self::Src) -> Result<(), WriteError>
fn serialize_into(dst: impl Writer, src: &Self::Src) -> Result<(), WriteError>
Serialize a serializable type into the given byte buffer.
Source§fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>
fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>
Get the size in bytes of the type when serialized.