pub struct Ipv6Ref<'a> { /* private fields */ }Expand description
An IPv6 (Internet Protocol version 6) packet.
§Packet Layout
. Octet 0 . Octet 1 . Octet 2 . Octet 3 .
|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 |Version| Traffic Class | Flow Label |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4 | Options & Payload Length | Next Hdr Type | Hop Limit |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
8 | Source Address |
| |
| |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24 | Destination Address |
| |
| |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 Z Payload (or next Extension Header) Z
Z Z
.. . ... .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Implementations§
Source§impl<'a> Ipv6Ref<'a>
impl<'a> Ipv6Ref<'a>
Sourcepub fn version(&self) -> u8
pub fn version(&self) -> u8
The Internet Protocol Version of the packet (should be equal to 6).
Sourcepub fn traffic_class(&self) -> TrafficClass
pub fn traffic_class(&self) -> TrafficClass
The Traffic Class of the packet.
Sourcepub fn flow_label(&self) -> FlowLabel
pub fn flow_label(&self) -> FlowLabel
The Flow Label of the packet.
Sourcepub fn data_length(&self) -> u16
pub fn data_length(&self) -> u16
The combined length of the IPv6 extension headers and payload.
Sourcepub fn next_header(&self) -> u8
pub fn next_header(&self) -> u8
A single byte value indicating the next header type following the IPv6 header.
If any IPv6 Extension Headers are present in the packet, the Next Header Type field will indicate the type of the first Extension Header. That option then contains a Next Header field that indicates the type of the next header after it, and so on; the final header in the IPv6 packet indicates the type of the payload.
The pkts library treats each of these Extension Headers as a distinct Layer type.
Sourcepub fn hop_limit(&self) -> u8
pub fn hop_limit(&self) -> u8
The hop limit of the packet.
Similar to Ipv4::ttl(), this field indicates the number of routing hops the
message should be permitted to traverse before being dropped.
When a router receives an IPv6 packet, it checks the Hop Limit field of the packet. If the hop limit is 0, the router drops the packet and optionally sends an ICMP “Time Exceeded” packet back to the address that sent the packet; otherwise, it decrements the value of the hop limit by 1 and routes the packet to its next hop.
the Hop Limit field is primarily used to avoid resource exhaustion in the event
that a routing loop forms, though tools like traceroute also use its functionality
to identify routing paths across a network.
Sourcepub fn src(&self) -> Ipv6Addr
Available on crate feature std or rustc_1_77 only.
pub fn src(&self) -> Ipv6Addr
std or rustc_1_77 only.The source IP address of the packet.
Sourcepub fn dst(&self) -> Ipv6Addr
Available on crate feature std or rustc_1_77 only.
pub fn dst(&self) -> Ipv6Addr
std or rustc_1_77 only.The destination IP address of the packet.
Sourcepub fn payload_raw(&self) -> &[u8] ⓘ
pub fn payload_raw(&self) -> &[u8] ⓘ
The payload of the packet, in raw bytes.
Trait Implementations§
Source§impl<'a> FromBytesRef<'a> for Ipv6Ref<'a>
impl<'a> FromBytesRef<'a> for Ipv6Ref<'a>
Source§fn from_bytes_unchecked(packet: &'a [u8]) -> Self
fn from_bytes_unchecked(packet: &'a [u8]) -> Self
Source§fn from_bytes(bytes: &'a [u8]) -> Result<Self, ValidationError>
fn from_bytes(bytes: &'a [u8]) -> Result<Self, ValidationError>
LayerRef type, returning an error if the bytes would
not form a valid layer.Source§impl<'a> IndexLayerRef<'a> for Ipv6Ref<'a>
impl<'a> IndexLayerRef<'a> for Ipv6Ref<'a>
Source§fn get_layer<T: LayerRef<'a> + FromBytesRef<'a>>(&'a self) -> Option<T>
fn get_layer<T: LayerRef<'a> + FromBytesRef<'a>>(&'a self) -> Option<T>
T, if such a sublayer exists. Read moreSource§fn get_nth_layer<T: LayerRef<'a> + FromBytesRef<'a> + BaseLayerMetadata>(
&'a self,
n: usize,
) -> Option<T>
fn get_nth_layer<T: LayerRef<'a> + FromBytesRef<'a> + BaseLayerMetadata>( &'a self, n: usize, ) -> Option<T>
Source§fn index_layer<T: LayerRef<'a> + FromBytesRef<'a> + BaseLayerMetadata>(
&'a self,
) -> T
fn index_layer<T: LayerRef<'a> + FromBytesRef<'a> + BaseLayerMetadata>( &'a self, ) -> T
T. Read moreSource§fn index_nth_layer<T: LayerRef<'a> + FromBytesRef<'a> + BaseLayerMetadata>(
&'a self,
n: usize,
) -> T
fn index_nth_layer<T: LayerRef<'a> + FromBytesRef<'a> + BaseLayerMetadata>( &'a self, n: usize, ) -> T
Source§impl LayerIdentifier for Ipv6Ref<'_>
impl LayerIdentifier for Ipv6Ref<'_>
Source§impl LayerLength for Ipv6Ref<'_>
impl LayerLength for Ipv6Ref<'_>
Source§impl<'a> LayerObjectMetadata for Ipv6Ref<'a>
impl<'a> LayerObjectMetadata for Ipv6Ref<'a>
Source§fn layer_metadata(&self) -> &dyn LayerMetadata
fn layer_metadata(&self) -> &dyn LayerMetadata
Layer type.Source§impl<'a> LayerObjectName for Ipv6Ref<'a>
impl<'a> LayerObjectName for Ipv6Ref<'a>
Source§fn layer_name(&self) -> &'static str
fn layer_name(&self) -> &'static str
Source§impl<'a> ToBoxedLayer for Ipv6Ref<'a>
Available on crate feature alloc only.
impl<'a> ToBoxedLayer for Ipv6Ref<'a>
alloc only.Source§fn to_boxed_layer(&self) -> Box<dyn LayerObject>
fn to_boxed_layer(&self) -> Box<dyn LayerObject>
Box and return it as a dyn Layer type.