pub struct Ipv6Layer {
pub index: LayerIndex,
}Expand description
A view into an IPv6 packet header.
Uses the “Lazy Zero-Copy View” pattern: holds only layer boundaries and reads fields directly from the buffer on demand.
Fields§
§index: LayerIndexImplementations§
Source§impl Ipv6Layer
impl Ipv6Layer
Sourcepub const fn new(start: usize, end: usize) -> Self
pub const fn new(start: usize, end: usize) -> Self
Create a new IPv6 layer view with specified bounds.
Sourcepub fn traffic_class(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn traffic_class(&self, buf: &[u8]) -> Result<u8, FieldError>
Read the Traffic Class field (8 bits).
Sourcepub fn flow_label(&self, buf: &[u8]) -> Result<u32, FieldError>
pub fn flow_label(&self, buf: &[u8]) -> Result<u32, FieldError>
Read the Flow Label field (20 bits).
Sourcepub fn payload_len(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn payload_len(&self, buf: &[u8]) -> Result<u16, FieldError>
Read the Payload Length field (16 bits).
Sourcepub fn next_header(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn next_header(&self, buf: &[u8]) -> Result<u8, FieldError>
Read the Next Header field (8 bits).
Sourcepub fn hop_limit(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn hop_limit(&self, buf: &[u8]) -> Result<u8, FieldError>
Read the Hop Limit field (8 bits).
Sourcepub fn dst(&self, buf: &[u8]) -> Result<Ipv6Addr, FieldError>
pub fn dst(&self, buf: &[u8]) -> Result<Ipv6Addr, FieldError>
Read the Destination IPv6 address.
Sourcepub fn set_version(&self, buf: &mut [u8], version: u8) -> Result<(), FieldError>
pub fn set_version(&self, buf: &mut [u8], version: u8) -> Result<(), FieldError>
Set the version field (high 4 bits of byte 0).
Sourcepub fn set_traffic_class(
&self,
buf: &mut [u8],
tc: u8,
) -> Result<(), FieldError>
pub fn set_traffic_class( &self, buf: &mut [u8], tc: u8, ) -> Result<(), FieldError>
Set the Traffic Class field.
Sourcepub fn set_flow_label(&self, buf: &mut [u8], fl: u32) -> Result<(), FieldError>
pub fn set_flow_label(&self, buf: &mut [u8], fl: u32) -> Result<(), FieldError>
Set the Flow Label field (20 bits).
Sourcepub fn set_payload_len(
&self,
buf: &mut [u8],
len: u16,
) -> Result<(), FieldError>
pub fn set_payload_len( &self, buf: &mut [u8], len: u16, ) -> Result<(), FieldError>
Set the Payload Length field.
Sourcepub fn set_next_header(&self, buf: &mut [u8], nh: u8) -> Result<(), FieldError>
pub fn set_next_header(&self, buf: &mut [u8], nh: u8) -> Result<(), FieldError>
Set the Next Header field.
Sourcepub fn set_hop_limit(&self, buf: &mut [u8], hlim: u8) -> Result<(), FieldError>
pub fn set_hop_limit(&self, buf: &mut [u8], hlim: u8) -> Result<(), FieldError>
Set the Hop Limit field.
Sourcepub fn set_src(&self, buf: &mut [u8], src: Ipv6Addr) -> Result<(), FieldError>
pub fn set_src(&self, buf: &mut [u8], src: Ipv6Addr) -> Result<(), FieldError>
Set the source IPv6 address.
Sourcepub fn set_dst(&self, buf: &mut [u8], dst: Ipv6Addr) -> Result<(), FieldError>
pub fn set_dst(&self, buf: &mut [u8], dst: Ipv6Addr) -> Result<(), FieldError>
Set the destination IPv6 address.
Sourcepub fn get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
pub fn get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Get a field value by name.
Sourcepub fn set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
pub fn set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Set a field value by name.
Sourcepub fn field_names() -> &'static [&'static str]
pub fn field_names() -> &'static [&'static str]
Get the list of field names for this layer.
Sourcepub fn header_len(&self, _buf: &[u8]) -> usize
pub fn header_len(&self, _buf: &[u8]) -> usize
Get the header length (always 40 for IPv6 base header).
Sourcepub fn next_layer(&self, buf: &[u8]) -> Option<LayerKind>
pub fn next_layer(&self, buf: &[u8]) -> Option<LayerKind>
Determine the next layer kind based on next header value.
Trait Implementations§
Source§impl Layer for Ipv6Layer
impl Layer for Ipv6Layer
Source§fn header_len(&self, data: &[u8]) -> usize
fn header_len(&self, data: &[u8]) -> usize
Source§fn answers(&self, data: &[u8], other: &Self, other_data: &[u8]) -> bool
fn answers(&self, data: &[u8], other: &Self, other_data: &[u8]) -> bool
Source§fn field_names(&self) -> &'static [&'static str]
fn field_names(&self) -> &'static [&'static str]
Source§impl LayerDispatch for Ipv6Layer
impl LayerDispatch for Ipv6Layer
Source§fn dispatch_kind(&self) -> LayerKind
fn dispatch_kind(&self) -> LayerKind
Source§fn dispatch_index(&self) -> &LayerIndex
fn dispatch_index(&self) -> &LayerIndex
Source§fn dispatch_summary(&self, buf: &[u8]) -> String
fn dispatch_summary(&self, buf: &[u8]) -> String
Source§fn dispatch_header_len(&self, buf: &[u8]) -> usize
fn dispatch_header_len(&self, buf: &[u8]) -> usize
Source§fn dispatch_field_names(&self) -> &'static [&'static str]
fn dispatch_field_names(&self) -> &'static [&'static str]
Source§fn dispatch_get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
fn dispatch_get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Source§fn dispatch_set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
fn dispatch_set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Auto Trait Implementations§
impl Freeze for Ipv6Layer
impl RefUnwindSafe for Ipv6Layer
impl Send for Ipv6Layer
impl Sync for Ipv6Layer
impl Unpin for Ipv6Layer
impl UnsafeUnpin for Ipv6Layer
impl UnwindSafe for Ipv6Layer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more