Ipv6Hdr

Struct Ipv6Hdr 

Source
#[repr(C)]
pub struct Ipv6Hdr { pub vcf: [u8; 4], pub payload_len: [u8; 2], pub next_hdr: IpProto, pub hop_limit: u8, pub src_addr: [u8; 16], pub dst_addr: [u8; 16], }
Expand description

IPv6 header, which is present after the Ethernet header.

Fields§

§vcf: [u8; 4]

First 4 bytes containing Version (4 bits), Traffic Class (8 bits), and Flow Label (20 bits)

§payload_len: [u8; 2]

Payload length (excluding the IPv6 header)

§next_hdr: IpProto

Next header protocol

§hop_limit: u8

Hop limit (similar to TTL in IPv4)

§src_addr: [u8; 16]

Source IPv6 address (16 bytes)

§dst_addr: [u8; 16]

Destination IPv6 address (16 bytes)

Implementations§

Source§

impl Ipv6Hdr

Source

pub const LEN: usize = 40usize

Source

pub fn version(&self) -> u8

Returns the IP version field (should be 6).

Source

pub fn set_version(&mut self, version: u8)

Sets the version field.

Source

pub fn dscp(&self) -> u8

Returns the DSCP (Differentiated Services Code Point) field.

Source

pub fn ecn(&self) -> u8

Returns the ECN (Explicit Congestion Notification) field.

Source

pub fn flow_label(&self) -> u32

Returns the flow label field (20 bits).

Source

pub fn set_dscp_ecn(&mut self, dscp: u8, ecn: u8)

Sets the DSCP and ECN fields.

Source

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

Sets the flow label field (20 bits).

Source

pub fn set_vcf(&mut self, version: u8, dscp: u8, ecn: u8, flow_label: u32)

Sets the version, DSCP, ECN, and flow label in one operation.

Source

pub fn payload_len(&self) -> u16

Returns the payload length.

Source

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

Sets the payload length.

Source

pub fn src_addr(&self) -> Ipv6Addr

Returns the source address field.

Source

pub fn dst_addr(&self) -> Ipv6Addr

Returns the destination address field.

Source

pub fn set_src_addr(&mut self, src: Ipv6Addr)

Sets the source address field.

Source

pub fn set_dst_addr(&mut self, dst: Ipv6Addr)

Sets the destination address field.

Trait Implementations§

Source§

impl Clone for Ipv6Hdr

Source§

fn clone(&self) -> Ipv6Hdr

Returns a duplicate 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 Debug for Ipv6Hdr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for Ipv6Hdr

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.