Struct Ipv6Ref

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

Source

pub fn version(&self) -> u8

The Internet Protocol Version of the packet (should be equal to 6).

Source

pub fn traffic_class(&self) -> TrafficClass

The Traffic Class of the packet.

Source

pub fn flow_label(&self) -> FlowLabel

The Flow Label of the packet.

Source

pub fn data_length(&self) -> u16

The combined length of the IPv6 extension headers and payload.

Source

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.

Source

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.

Source

pub fn src(&self) -> Ipv6Addr

Available on crate feature std or rustc_1_77 only.

The source IP address of the packet.

Source

pub fn src_bytes(&self) -> [u8; 16]

The source IP address of the packet, in bytes.

Source

pub fn dst(&self) -> Ipv6Addr

Available on crate feature std or rustc_1_77 only.

The destination IP address of the packet.

Source

pub fn dst_bytes(&self) -> [u8; 16]

The destination IP address of the packet, in bytes.

Source

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

The payload of the packet, in raw bytes.

Trait Implementations§

Source§

impl<'a> Clone for Ipv6Ref<'a>

Source§

fn clone(&self) -> Ipv6Ref<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Ipv6Ref<'a>

Source§

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

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

impl From<&Ipv6Ref<'_>> for Ipv6

Source§

fn from(r: &Ipv6Ref<'_>) -> Self

Converts to this type from the input type.
Source§

impl From<Ipv6Ref<'_>> for Ipv6

Source§

fn from(value: Ipv6Ref<'_>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Ipv6Ref<'a>> for &'a [u8]

Source§

fn from(value: Ipv6Ref<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> FromBytesRef<'a> for Ipv6Ref<'a>

Source§

fn from_bytes_unchecked(packet: &'a [u8]) -> Self

Converts a slice of bytes into a LayerRef type. Read more
Source§

fn from_bytes(bytes: &'a [u8]) -> Result<Self, ValidationError>

Converts a slice of bytes into a LayerRef type, returning an error if the bytes would not form a valid layer.
Source§

impl<'a> IndexLayerRef<'a> for Ipv6Ref<'a>

Source§

fn get_layer<T: LayerRef<'a> + FromBytesRef<'a>>(&'a self) -> Option<T>

Retrieves a reference to the first sublayer of type T, if such a sublayer exists. Read more
Source§

fn get_nth_layer<T: LayerRef<'a> + FromBytesRef<'a> + BaseLayerMetadata>( &'a self, n: usize, ) -> Option<T>

Retrieves a reference to the nth sublayer of type T, if such a sublayer exists. Read more
Source§

fn index_layer<T: LayerRef<'a> + FromBytesRef<'a> + BaseLayerMetadata>( &'a self, ) -> T

Retrieves a reference to the first sublayer of type T. Read more
Source§

fn index_nth_layer<T: LayerRef<'a> + FromBytesRef<'a> + BaseLayerMetadata>( &'a self, n: usize, ) -> T

Retrieves a reference to the nth sublayer of type T. Read more
Source§

impl LayerIdentifier for Ipv6Ref<'_>

Source§

fn layer_id() -> LayerId

A unique identifier for the layer type. Read more
Source§

impl LayerLength for Ipv6Ref<'_>

Source§

fn len(&self) -> usize

The length (in bytes) of the layer. Read more
Source§

impl<'a> LayerObjectMetadata for Ipv6Ref<'a>

Source§

fn layer_metadata(&self) -> &dyn LayerMetadata

Static metadata associated with the given layer. This method is normally only used internally or when defining a custom Layer type.
Source§

impl<'a> LayerObjectName for Ipv6Ref<'a>

Source§

fn layer_name(&self) -> &'static str

The name of the layer, usually (though not guaranteed to be) the same as the name of the struct. Read more
Source§

impl<'a> ToBoxedLayer for Ipv6Ref<'a>

Available on crate feature alloc only.
Source§

fn to_boxed_layer(&self) -> Box<dyn LayerObject>

Clone the given instance in a Box and return it as a dyn Layer type.
Source§

impl ToLayer for Ipv6Ref<'_>

Available on crate feature alloc only.
Source§

type Owned = Ipv6

Source§

fn to_layer(&self) -> Self::Owned

Creates a new Layer out of the given layer instance.
Source§

impl Validate for Ipv6Ref<'_>

Source§

fn validate(bytes: &[u8]) -> Result<(), ValidationError>

Checks that bytes represents a valid serialization of the layer type. Read more
Source§

impl<'a> Copy for Ipv6Ref<'a>

Source§

impl<'a> LayerRef<'a> for Ipv6Ref<'a>

Source§

impl<'a> StatelessLayer for Ipv6Ref<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Ipv6Ref<'a>

§

impl<'a> RefUnwindSafe for Ipv6Ref<'a>

§

impl<'a> Send for Ipv6Ref<'a>

§

impl<'a> Sync for Ipv6Ref<'a>

§

impl<'a> Unpin for Ipv6Ref<'a>

§

impl<'a> UnwindSafe for Ipv6Ref<'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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Return a dyn Any reference to self.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Return a mutable dyn Any reference to self.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.