#[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: u32Version (4 bits), Traffic Class (8 bits), Flow Label (20 bits) – network byte order
payload_length: u16Payload length in bytes (big-endian, does not include this header)
next_header: u8Next header protocol number (TCP=6, UDP=17, ICMPv6=58)
hop_limit: u8Hop limit (TTL equivalent)
source: [u8; 16]Source IPv6 address (16 bytes)
destination: [u8; 16]Destination IPv6 address (16 bytes)
Implementations§
Source§impl Ipv6Header
impl Ipv6Header
Sourcepub fn new(src: &Ipv6Address, dst: &Ipv6Address, next_header: u8) -> Self
pub fn new(src: &Ipv6Address, dst: &Ipv6Address, next_header: u8) -> Self
Create a new IPv6 header with default values
Sourcepub fn traffic_class(&self) -> u8
pub fn traffic_class(&self) -> u8
Get the traffic class field
Sourcepub fn flow_label(&self) -> u32
pub fn flow_label(&self) -> u32
Get the flow label field
Trait Implementations§
Source§impl Clone for Ipv6Header
impl Clone for Ipv6Header
Source§fn clone(&self) -> Ipv6Header
fn clone(&self) -> Ipv6Header
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Ipv6Header
impl Debug for Ipv6Header
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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)