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]
pub fn new(
payload_and_options_length: usize,
time_to_live: u8,
protocol: IpTrafficClass,
source: [u8; 4],
destination: [u8; 4]
) -> Result<Ipv4Header, ValueError>
[src]
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]
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]
reader: &mut T,
version_rest: u8
) -> Result<Ipv4Header, Error>
Reads an IPv4 header assuming the version & ihl field have already been read.
pub fn write<T: Write + Sized>(
&self,
writer: &mut T,
options: &[u8]
) -> Result<(), WriteError>
[src]
&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]
&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]
Calculate header checksum of the current ipv4 header.
pub fn set_payload_and_options_length(
&mut self,
size: usize
) -> Result<(), ValueError>
[src]
&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]
fn clone(&self) -> Ipv4Header
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Ipv4Header
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Eq for Ipv4Header
[src]
impl PartialEq for Ipv4Header
[src]
fn eq(&self, __arg_0: &Ipv4Header) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Ipv4Header) -> bool
[src]
This method tests for !=
.
impl SerializedSize for Ipv4Header
[src]
const SERIALIZED_SIZE: usize
SERIALIZED_SIZE: usize = 20
Size of the header itself (without options) in bytes.