GeneveHdr

Struct GeneveHdr 

Source
#[repr(C, packed(1))]
pub struct GeneveHdr { pub ver_opt_len: u8, pub o_c_rsvd: u8, pub protocol_type: [u8; 2], pub vni: [u8; 3], pub reserved2: u8, }
Expand description

Represents a Geneve (Generic Network Virtualization Encapsulation) header, according to RFC 8926. Geneve is an encapsulation protocol designed for network virtualization.

Fields§

§ver_opt_len: u8

Combined field: Version (2 bits) and Option Length (6 bits).

§o_c_rsvd: u8

Combined field: OAM flag (1 bit), Critical flag (1 bit), Reserved (6 bits).

§protocol_type: [u8; 2]

Protocol Type of the encapsulated payload (16 bits).

§vni: [u8; 3]

Virtual Network Identifier (VNI) (24 bits).

§reserved2: u8

Reserved field (8 bits). MUST be zero on transmission.

Implementations§

Source§

impl GeneveHdr

Source

pub const LEN: usize = 8usize

The length of the Geneve header in bytes.

Source

pub fn ver(&self) -> u8

Returns the Geneve protocol version (2 bits).

According to RFC 8926, the current version is 0.

Source

pub fn set_ver(&mut self, ver: u8)

Sets the Geneve protocol version (2 bits).

ver should be a 2-bit value (0-3).

Source

pub fn opt_len(&self) -> u8

Returns the length of the option fields in 4-byte multiples (6 bits).

Source

pub fn set_opt_len(&mut self, opt_len: u8)

Sets the length of the option fields (6 bits).

opt_len should be a 6-bit value (0-63).

Source

pub fn o_flag(&self) -> u8

Returns the OAM (Operations, Administration, and Maintenance) packet flag (1 bit).

If set (1), this packet is an OAM packet. Referred to as ‘O’ bit in RFC 8926.

Source

pub fn set_o_flag(&mut self, o_flag: u8)

Sets the OAM packet flag (1 bit).

o_flag should be a 1-bit value (0 or 1).

Source

pub fn c_flag(&self) -> u8

Returns the Critical Options Present flag (1 bit).

If set (1), one or more options are marked as critical. Referred to as ‘C’ bit in RFC 8926.

Source

pub fn set_c_flag(&mut self, c_flag: u8)

Sets the Critical Options Present flag (1 bit).

c_flag should be a 1-bit value (0 or 1).

Source

pub fn protocol_type(&self) -> u16

Returns the Protocol Type of the encapsulated payload (16 bits, network byte order).

This follows the Ethertype convention.

Source

pub fn set_protocol_type(&mut self, protocol_type: u16)

Sets the Protocol Type (16 bits).

The value is stored in network byte order.

Source

pub fn vni(&self) -> u32

Returns the Virtual Network Identifier (VNI) (24 bits).

Source

pub fn set_vni(&mut self, vni: u32)

Sets the Virtual Network Identifier (VNI) (24 bits).

vni should be a 24-bit value. Higher bits are masked. The value is stored in network byte order.

Trait Implementations§

Source§

impl Clone for GeneveHdr

Source§

fn clone(&self) -> GeneveHdr

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 GeneveHdr

Source§

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

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

impl Default for GeneveHdr

Source§

fn default() -> GeneveHdr

Returns the “default value” for a type. Read more
Source§

impl Copy for GeneveHdr

Auto Trait Implementations§

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.