#[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: IpProto,
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: IpProto§check: [u8; 2]§src_addr: [u8; 4]§dst_addr: [u8; 4]Implementations§
Source§impl Ipv4Hdr
impl Ipv4Hdr
pub const LEN: usize = 20usize
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§
Auto Trait Implementations§
impl Freeze for Ipv4Hdr
impl RefUnwindSafe for Ipv4Hdr
impl Send for Ipv4Hdr
impl Sync for Ipv4Hdr
impl Unpin 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