Struct Message

Source
pub struct Message { /* private fields */ }
Expand description

Opaque struct Message: abstracts NFLOG data representing a packet data and metadata

Implementations§

Source§

impl Message

Source

pub fn get_id(&self) -> u32

Returns the unique ID of the packet

Source

pub fn get_nfmark(&self) -> u32

Get the packet mark

Source

pub fn get_timestamp(&self) -> Result<timeval, NfqueueError>

Get the packet timestamp

Source

pub fn get_indev(&self) -> u32

Get the interface that the packet was received through

Returns the index of the device the packet was received via. If the returned index is 0, the packet was locally generated or the input interface is not known (ie. POSTROUTING?).

Source

pub fn get_physindev(&self) -> u32

Get the physical interface that the packet was received through

Returns the index of the physical device the packet was received via. If the returned index is 0, the packet was locally generated or the physical input interface is no longer known (ie. POSTROUTING?).

Source

pub fn get_outdev(&self) -> u32

Get the interface that the packet will be routed out

Returns the index of the device the packet will be sent out. If the returned index is 0, the packet is destined to localhost or the output interface is not yet known (ie. PREROUTING?).

Source

pub fn get_physoutdev(&self) -> u32

Get the physical interface that the packet will be routed out

Returns the index of the physical device the packet will be sent out. If the returned index is 0, the packet is destined to localhost or the physical output interface is not yet known (ie. PREROUTING?).

Source

pub fn get_packet_hw<'a>(&'a self) -> Result<HwAddr<'a>, NfqueueError>

Get hardware address

Retrieves the hardware address associated with the given packet.

For ethernet packets, the hardware address returned (if any) will be the MAC address of the packet source host.

The destination MAC address is not known until after POSTROUTING and a successful ARP request, so cannot currently be retrieved.

Source

pub fn set_verdict(&self, verdict: Verdict)

Issue a verdict on a packet

Notifies netfilter of the userspace verdict for the given packet.

Every queued packet must have a verdict specified by userspace, either by calling this function, or by calling any other set_verdict_* function.

Arguments

  • verdict: verdict to return to netfilter (Verdict::Accept, Verdict::Drop, …)
Source

pub fn set_verdict_mark(&self, verdict: Verdict, mark: u32)

Issue a verdict on a packet, with a mark

Notifies netfilter of the userspace verdict for the given packet.

Every queued packet must have a verdict specified by userspace, either by calling this function, or by calling any other set_verdict_* function.

Arguments

  • verdict: verdict to return to netfilter (Verdict::Accept, Verdict::Drop, …)
  • mark: the mark to put on the packet, in network-byte order
Source

pub fn set_verdict_full(&self, verdict: Verdict, mark: u32, data: &[u8])

Issue a verdict on a packet, with a mark and new data

Notifies netfilter of the userspace verdict for the given packet. The new packet will replace the one that was queued.

Every queued packet must have a verdict specified by userspace, either by calling this function, or by calling any other set_verdict_* function.

Arguments

  • verdict: verdict to return to netfilter (Verdict::Accept, Verdict::Drop, …)
  • mark: the mark to put on the packet, in network-byte order
  • data: the new packet
Source

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

Get payload

Depending on set_mode, we may not have a payload. The actual amount and type of data retrieved by this function will depend on the mode set with the set_mode() function.

Source

pub fn as_xml_str(&self, flags: &[XMLFormatFlags]) -> Result<String, Utf8Error>

Print the queued packet in XML format into a buffer

Trait Implementations§

Source§

impl Display for Message

Source§

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

Formats the value using the given formatter. Read more

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.