Mpls

Struct Mpls 

Source
#[repr(C, packed(1))]
pub struct Mpls { pub lbl_tc_s: [u8; 3], pub ttl: u8, }
Expand description

Represents a Multiprotocol Label Switching (MPLS) header to RFC 3032 https://www.rfc-editor.org/rfc/rfc3032.html. This header format applies to all MPLS messages. 20 bits for Label - 3 for TC - 1 for S - 8 for TTL

Fields§

§lbl_tc_s: [u8; 3]

The first 3 bytes of the MPLS header containing Label (20 bits), Traffic Class (3 bits), and Bottom of Stack (1 bit) fields in network byte order

§ttl: u8

The Time to Live (TTL) field indicating maximum hop count

Implementations§

Source§

impl Mpls

Source

pub const LEN: usize = 4usize

Source

pub fn label(&self) -> u32

Gets the 20-bit Label value.

Source

pub fn set_label(&mut self, label: u32)

Sets the 20-bit Label value. Input label_value should be a 20-bit integer (0 to 0xFFFFF).

Source

pub fn tc(&self) -> u8

Gets the 3-bit Traffic Class value. Assumes self is a valid reference to an MPLS header.

Source

pub fn set_tc(&mut self, tc_value: u8)

Sets the 3-bit Traffic Class value. Input tc_value should be a 3-bit integer (0-7). Assumes self is a valid, mutable reference to an MPLS header.

Source

pub fn s(&self) -> u8

Gets the 1-bit Bottom of Stack flag. Returns 0 or 1. Assumes self is a valid reference to an MPLS header.

Source

pub fn set_s(&mut self, s_value: u8)

Sets the 1-bit Bottom of Stack flag. Input s_value should be 0 or 1. Assumes self is a valid, mutable reference to an MPLS header.

Source

pub fn ttl(&self) -> u8

Gets the 8-bit Time to Live value.

Source

pub fn set_ttl(&mut self, ttl_value: u8)

Sets the 8-bit Time to Live value. Input ttl_value is the new TTL value (0-255).

Trait Implementations§

Source§

impl Clone for Mpls

Source§

fn clone(&self) -> Mpls

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 Debug for Mpls

Source§

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

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

impl Copy for Mpls

Auto Trait Implementations§

§

impl Freeze for Mpls

§

impl RefUnwindSafe for Mpls

§

impl Send for Mpls

§

impl Sync for Mpls

§

impl Unpin for Mpls

§

impl UnwindSafe for Mpls

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> 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, 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.