Skip to main content

Message

Struct Message 

Source
pub struct Message {
    pub hdr: *mut Header,
    pub data: *mut u8,
    pub len: usize,
}
Expand description

Represents a netlink message container

This structure provides a view of a netlink message, containing both the header pointer and the data buffer.

Fields§

§hdr: *mut Header

Pointer to the netlink message header

§data: *mut u8

Pointer to the message data buffer

§len: usize

Length of the message in bytes

Implementations§

Source§

impl Message

Source

pub const REQUEST: u32 = 1

Flag for request messages

Source

pub const MULTI: u32 = 2

Flag for multipart messages (terminated by NLMSG_DONE)

Source

pub const ACK: u32 = 4

Flag for reply with acknowledgment

Source

pub const ECHO: u32 = 8

Flag to request echo of the message

Source

pub const DUMP_INTR: u32 = 16

Flag indicating dump was interrupted due to sequence change

Source

pub const ROOT: u32 = 0x100

Specifies tree root for GET requests

Source

pub const MATCH: u32 = 0x200

Returns all matching items for GET requests

Source

pub const ATOMIC: u32 = 0x400

Requests atomic GET operation

Source

pub const DUMP: u32

Combination of ROOT and MATCH flags for dump operations

Source

pub const REPLACE: u32 = 0x100

Override existing object if it exists

Source

pub const EXCLUDE: u32 = 0x200

Don’t touch object if it already exists

Source

pub const CREATE: u32 = 0x400

Create object if it doesn’t exist

Source

pub const APPEND: u32 = 0x800

Add to end of list

Source

pub const ALIGNTO: u32 = 4

Alignment boundary for netlink messages

Source

pub const NOOP: u16 = 0x1

No operation message

Source

pub const ERROR: u16 = 0x2

Error message

Source

pub const DONE: u16 = 0x3

End of dump marker

Source

pub const OVERRUN: u16 = 0x4

Data overflow indicator

Source

pub const MIN_TYPE: u16 = 0x10

Minimum user-defined message type

Source

pub const HDRLEN: usize

Size of the netlink message header, aligned

Source

pub const fn len(len: usize) -> usize

Calculates the total message length including header

§Parameters
  • len - Length of the payload
§Returns

Total message length including header

Source

pub fn space(&self) -> usize

Calculates the aligned space needed for this message

§Returns

The aligned message size

Source

pub fn data(nlh: *const Header) -> *mut u8

Gets a pointer to the message data (payload)

§Parameters
  • nlh - Pointer to the netlink header
§Returns

Pointer to the message payload

Source

pub fn next(&mut self) -> *const Header

Gets the next message in a sequence

Updates internal pointers and counters.

§Returns

Pointer to the next message header

Source

pub fn is_ok(&self) -> bool

Checks if the message structure is valid

Verifies that the message header and length are consistent with the buffer size.

§Returns

true if the message is valid, false otherwise

Source

pub fn payload(&self) -> u32

Gets the payload length of the message

§Returns

Length of the message payload in bytes

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Message

Source§

impl Debug for Message

Source§

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

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

impl Eq for Message

Source§

impl Hash for Message

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Message

Source§

fn cmp(&self, other: &Message) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Message) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Message

Source§

fn partial_cmp(&self, other: &Message) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Message

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