capsules_extra::net::ipv6

Struct 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§

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

🔬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>,

Source§

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>,

Source§

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.