pub struct IPv6Reader<'a> {
pub bytes: &'a [u8],
pub extension_headers: Option<ExtensionHeaders<'a>>,
pub extension_headers_len: usize,
}
Expand description
Reads IPv6 header fields.
May contain extension headers.
Fields§
§bytes: &'a [u8]
§extension_headers: Option<ExtensionHeaders<'a>>
§extension_headers_len: usize
Implementations§
Source§impl<'a> IPv6Reader<'a>
impl<'a> IPv6Reader<'a>
Sourcepub fn new(bytes: &'a [u8]) -> Result<Self, &'static str>
pub fn new(bytes: &'a [u8]) -> Result<Self, &'static str>
Creates a new IPv6Reader
from the given data slice.
Sourcepub fn version(&self) -> u8
pub fn version(&self) -> u8
Returns the version field.
Indicates the IP version number. Should be set to 6.
Sourcepub fn traffic_class(&self) -> u8
pub fn traffic_class(&self) -> u8
Returns the traffic class field.
Specifies the priority of the packet.
Sourcepub fn flow_label(&self) -> u32
pub fn flow_label(&self) -> u32
Returns the flow label field.
Identifies packets belonging to the same flow (group of packets).
Sourcepub fn payload_length(&self) -> u16
pub fn payload_length(&self) -> u16
Returns the payload length field.
Specifies the length of the payload in bytes.
Sourcepub fn next_header(&self) -> u8
pub fn next_header(&self) -> u8
Returns the next header field.
Specifies the type of the next header, usually a transport protocol.
Shares the same values as the protocol field in an IPv4 header.
Sourcepub fn final_next_header(&self) -> u8
pub fn final_next_header(&self) -> u8
Returns the final next header field, which is the encapsulated protocol.
If there are extension headers, the last next header in the chain is returned.
Otherwise, the next header field of the IPv6 header is returned.
Sourcepub fn hop_limit(&self) -> u8
pub fn hop_limit(&self) -> u8
Returns the hop limit field.
Replaces the time-to-live field in IPv4.
The value is decremented each time the packet is forwarded by a router.
When the value reaches 0, the packet is discarded, unless it has reached its destination.
Sourcepub fn src_addr(&self) -> &[u8]
pub fn src_addr(&self) -> &[u8]
Returns the source address field.
Unicast IPv6 address of the sender.
Sourcepub fn dest_addr(&self) -> &[u8]
pub fn dest_addr(&self) -> &[u8]
Returns the destination address field.
Unicast or multicast IPv6 address of the intended recipient.
Sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Returns the actual header length in bytes.
Does not include extension headers.
Sourcepub fn payload(&self) -> &'a [u8]
pub fn payload(&self) -> &'a [u8]
Returns a reference to the payload.
May contain extension headers.
Sourcepub fn upper_layer_payload(&self) -> &'a [u8]
pub fn upper_layer_payload(&self) -> &'a [u8]
Returns the payload after the extension headers.
This is the encapsulated protocol (e.g. TCP, UDP).