Struct etherparse::Ipv4Header [−][src]
pub struct Ipv4Header {
pub header_length: u8,
pub differentiated_services_code_point: u8,
pub explicit_congestion_notification: u8,
pub total_length: u16,
pub identification: u16,
pub dont_fragment: bool,
pub more_fragments: bool,
pub fragments_offset: u16,
pub time_to_live: u8,
pub protocol: u8,
pub header_checksum: u16,
pub source: [u8; 4],
pub destination: [u8; 4],
}IPv4 header without options.
Fields
header_length: u8
differentiated_services_code_point: u8
explicit_congestion_notification: u8
total_length: u16
identification: u16
dont_fragment: bool
more_fragments: bool
fragments_offset: u16
time_to_live: u8
protocol: u8
header_checksum: u16
source: [u8; 4]
destination: [u8; 4]
Methods
impl Ipv4Header[src]
impl Ipv4Headerpub fn new(
payload_and_options_length: usize,
time_to_live: u8,
protocol: IpTrafficClass,
source: [u8; 4],
destination: [u8; 4]
) -> Result<Ipv4Header, ValueError>[src]
pub fn new(
payload_and_options_length: usize,
time_to_live: u8,
protocol: IpTrafficClass,
source: [u8; 4],
destination: [u8; 4]
) -> Result<Ipv4Header, ValueError>Constructs an Ipv4Header with standard values for non specified values. Note: This header calculates the checksum assuming that there are no ipv4 options. In case there are calculate the checksum using the "calc_header_checksum" method.
pub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<Ipv4Header, ReadError>[src]
pub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<Ipv4Header, ReadError>Reads an IPv4 header from the current position.
pub fn read_without_version<T: Read + Seek + Sized>(
reader: &mut T,
version_rest: u8
) -> Result<Ipv4Header, Error>[src]
pub fn read_without_version<T: Read + Seek + Sized>(
reader: &mut T,
version_rest: u8
) -> Result<Ipv4Header, Error>Reads an IPv4 header assuming the version & ihl field have already been read.
pub fn skip_options<T: Read + Seek + Sized>(
&self,
reader: &mut T
) -> Result<(), ReadError>[src]
pub fn skip_options<T: Read + Seek + Sized>(
&self,
reader: &mut T
) -> Result<(), ReadError>Skips the ipv4 header options based on the header length.
pub fn write<T: Write + Sized>(
&self,
writer: &mut T,
options: &[u8]
) -> Result<(), WriteError>[src]
pub fn write<T: Write + Sized>(
&self,
writer: &mut T,
options: &[u8]
) -> Result<(), WriteError>Writes a given IPv4 header to the current position (this method automatically calculates the header length and checksum).
pub fn write_raw<T: Write + Sized>(
&self,
writer: &mut T,
options: &[u8]
) -> Result<(), WriteError>[src]
pub fn write_raw<T: Write + Sized>(
&self,
writer: &mut T,
options: &[u8]
) -> Result<(), WriteError>Writes a given IPv4 header to the current position (this method just writes the specified checksum and header_length and does note compute it).
pub fn calc_header_checksum(&self, options: &[u8]) -> Result<u16, ValueError>[src]
pub fn calc_header_checksum(&self, options: &[u8]) -> Result<u16, ValueError>Calculate header checksum of the current ipv4 header.
pub fn set_payload_and_options_length(
&mut self,
size: usize
) -> Result<(), ValueError>[src]
pub fn set_payload_and_options_length(
&mut self,
size: usize
) -> Result<(), ValueError>Sets the field total_length based on the size of the payload and the options. Returns an error if the payload is too big to fit.
Trait Implementations
impl Clone for Ipv4Header[src]
impl Clone for Ipv4Headerfn clone(&self) -> Ipv4Header[src]
fn clone(&self) -> Ipv4HeaderReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Debug for Ipv4Header[src]
impl Debug for Ipv4Headerfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Eq for Ipv4Header[src]
impl Eq for Ipv4Headerimpl PartialEq for Ipv4Header[src]
impl PartialEq for Ipv4Headerfn eq(&self, other: &Ipv4Header) -> bool[src]
fn eq(&self, other: &Ipv4Header) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Ipv4Header) -> bool[src]
fn ne(&self, other: &Ipv4Header) -> boolThis method tests for !=.
impl SerializedSize for Ipv4Header[src]
impl SerializedSize for Ipv4Headerconst SERIALIZED_SIZE: usize
SERIALIZED_SIZE: usize = 20
Size of the header itself (without options) in bytes.
Auto Trait Implementations
impl Send for Ipv4Header
impl Send for Ipv4Headerimpl Sync for Ipv4Header
impl Sync for Ipv4Header