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.