Struct IPv6Reader

Source
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>

Source

pub fn new(bytes: &'a [u8]) -> Result<Self, &'static str>

Creates a new IPv6Reader from the given data slice.

Source

pub fn version(&self) -> u8

Returns the version field.

Indicates the IP version number. Should be set to 6.

Source

pub fn traffic_class(&self) -> u8

Returns the traffic class field.

Specifies the priority of the packet.

Source

pub fn flow_label(&self) -> u32

Returns the flow label field.

Identifies packets belonging to the same flow (group of packets).

Source

pub fn payload_length(&self) -> u16

Returns the payload length field.

Specifies the length of the payload in bytes.

Source

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.

Source

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.

Source

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.

Source

pub fn src_addr(&self) -> &[u8]

Returns the source address field.

Unicast IPv6 address of the sender.

Source

pub fn dest_addr(&self) -> &[u8]

Returns the destination address field.

Unicast or multicast IPv6 address of the intended recipient.

Source

pub fn header_len(&self) -> usize

Returns the actual header length in bytes.

Does not include extension headers.

Source

pub fn header(&self) -> &'a [u8]

Returns a reference to the header.

Source

pub fn payload(&self) -> &'a [u8]

Returns a reference to the payload.

May contain extension headers.

Source

pub fn upper_layer_payload(&self) -> &'a [u8]

Returns the payload after the extension headers.

This is the encapsulated protocol (e.g. TCP, UDP).

Trait Implementations§

Source§

impl Debug for IPv6Reader<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> ParseReader<'a> for IPv6Reader<'a>

Source§

fn parse(bytes: &'a [u8]) -> Result<Self, &'static str>

Parses an IPv6 packet from a byte slice.

Validates the IPv6 version field.

Note: IPv6 does not have a checksum field.

Source§

impl<'a> VerifyReader<'a> for IPv6Reader<'a>

Source§

fn verify_checksum(&self) -> Result<(), &'static str>

Verifies the checksum of an encapsulated protocol in an IPv6 packet.

Computes the pseudo-header checksum and verifies it with the encapsulated payload.

Auto Trait Implementations§

§

impl<'a> Freeze for IPv6Reader<'a>

§

impl<'a> RefUnwindSafe for IPv6Reader<'a>

§

impl<'a> Send for IPv6Reader<'a>

§

impl<'a> Sync for IPv6Reader<'a>

§

impl<'a> Unpin for IPv6Reader<'a>

§

impl<'a> UnwindSafe for IPv6Reader<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.