⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Ipv6Header

Struct Ipv6Header 

Source
#[repr(C)]
pub struct Ipv6Header { pub version_tc_flow: u32, pub payload_length: u16, pub next_header: u8, pub hop_limit: u8, pub source: [u8; 16], pub destination: [u8; 16], }
Expand description

IPv6 packet header (40 bytes fixed)

Layout:

  • version_tc_flow (4 bytes): 4-bit version, 8-bit traffic class, 20-bit flow label
  • payload_length (2 bytes): length of payload after this header (big-endian)
  • next_header (1 byte): identifies the type of header immediately following
  • hop_limit (1 byte): decremented by 1 at each forwarding node
  • source (16 bytes): source IPv6 address
  • destination (16 bytes): destination IPv6 address

Fields§

§version_tc_flow: u32

Version (4 bits), Traffic Class (8 bits), Flow Label (20 bits) – network byte order

§payload_length: u16

Payload length in bytes (big-endian, does not include this header)

§next_header: u8

Next header protocol number (TCP=6, UDP=17, ICMPv6=58)

§hop_limit: u8

Hop limit (TTL equivalent)

§source: [u8; 16]

Source IPv6 address (16 bytes)

§destination: [u8; 16]

Destination IPv6 address (16 bytes)

Implementations§

Source§

impl Ipv6Header

Source

pub fn new(src: &Ipv6Address, dst: &Ipv6Address, next_header: u8) -> Self

Create a new IPv6 header with default values

Source

pub fn version(&self) -> u8

Get the IP version field (should always be 6)

Source

pub fn traffic_class(&self) -> u8

Get the traffic class field

Source

pub fn flow_label(&self) -> u32

Get the flow label field

Source

pub fn to_bytes(&self) -> [u8; 40]

Serialize header to bytes (big-endian)

Trait Implementations§

Source§

impl Clone for Ipv6Header

Source§

fn clone(&self) -> Ipv6Header

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Ipv6Header

Source§

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

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

impl Copy for Ipv6Header

Auto Trait Implementations§

§

impl Freeze for Ipv6Header

§

impl RefUnwindSafe for Ipv6Header

§

impl Send for Ipv6Header

§

impl Sync for Ipv6Header

§

impl Unpin for Ipv6Header

§

impl UnwindSafe for Ipv6Header

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

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

Performs the conversion.