Struct capsules_extra::net::ipv6::IP6Header

source ·
#[repr(C, packed(1))]
pub struct IP6Header { pub version_class_flow: [u8; 4], pub payload_len: u16, pub next_header: u8, pub hop_limit: u8, pub src_addr: IPAddr, pub dst_addr: IPAddr, }
Expand description

This is the struct definition for an IPv6 header. It contains (in order) the same fields as a normal IPv6 header.

Fields§

§version_class_flow: [u8; 4]§payload_len: u16§next_header: u8§hop_limit: u8§src_addr: IPAddr§dst_addr: IPAddr

Implementations§

source§

impl IP6Header

source

pub fn new() -> IP6Header

This function returns an IP6Header struct initialized to the default values.

source

pub fn decode(buf: &[u8]) -> SResult<IP6Header>

This function is used to transform a raw buffer into an IP6Header struct. This is useful for deserializing a header upon reception.

§Arguments

buf - The serialized version of an IPv6 header

§Return Value

SResult<IP6Header> - The resulting decoded IP6Header struct wrapped in an SResult

source

pub fn encode(&self, buf: &mut [u8]) -> SResult<usize>

This function transforms the self instance of an IP6Header into a byte array

§Arguments

buf - A mutable array where the serialized version of the IP6Header struct is written to

§Return Value

SResult<usize> - The offset wrapped in an SResult

source

pub fn get_src_addr(&self) -> IPAddr

source

pub fn get_dst_addr(&self) -> IPAddr

source

pub fn get_version(&self) -> u8

source

pub fn get_traffic_class(&self) -> u8

source

pub fn set_traffic_class(&mut self, new_tc: u8)

source

pub fn get_dscp(&self) -> u8

source

pub fn set_dscp(&mut self, new_dscp: u8)

source

pub fn get_ecn(&self) -> u8

source

pub fn set_ecn(&mut self, new_ecn: u8)

source

pub fn get_flow_label(&self) -> u32

source

pub fn set_flow_label(&mut self, new_fl_val: u32)

source

pub fn get_payload_len(&self) -> u16

source

pub fn get_total_len(&self) -> u16

source

pub fn set_payload_len(&mut self, new_len: u16)

source

pub fn get_next_header(&self) -> u8

source

pub fn set_next_header(&mut self, new_nh: u8)

source

pub fn get_hop_limit(&self) -> u8

source

pub fn set_hop_limit(&mut self, new_hl: u8)

source

pub fn check_transport_checksum(&self, buf: &[u8]) -> Result<(), ErrorCode>

Utility function for verifying whether a transport layer checksum of a received packet is correct. Is called on the assocaite IPv6 Header, and passed the buffer containing the remainder of the packet.

Trait Implementations§

source§

impl Clone for IP6Header

source§

fn clone(&self) -> IP6Header

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for IP6Header

source§

fn default() -> IP6Header

Returns the “default value” for a type. Read more
source§

impl Copy for IP6Header

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.