Skip to main content

RuleMessage

Struct RuleMessage 

Source
#[non_exhaustive]
pub struct RuleMessage { /* private fields */ }
Expand description

Strongly-typed routing rule message with all attributes parsed.

Fields are pub(crate); consumers read via the per-field accessor methods (see Self::priority, Self::source, etc.). The struct is #[non_exhaustive] so the kernel can grow new attribute fields without it being a breaking change.

Implementations§

Source§

impl RuleMessage

Source

pub fn new() -> Self

Create a new empty rule message.

Source

pub fn family(&self) -> u8

Get the address family as the raw AF_* byte (kernel wire form).

Source

pub fn family_typed(&self) -> AddressFamily

Get the address family as a typed crate::AddressFamily (Plan 227).

Prefer this over the raw Self::family in new code — the typed form lets the caller compare against AddressFamily::v4() / AddressFamily::v6() without remembering AF_* magic numbers, and gracefully exposes unmodelled bytes via crate::AddressFamily::is_known.

Source

pub fn is_ipv4(&self) -> bool

Check if this is an IPv4 rule.

Source

pub fn is_ipv6(&self) -> bool

Check if this is an IPv6 rule.

Source

pub fn src_len(&self) -> u8

Get the source prefix length.

Source

pub fn dst_len(&self) -> u8

Get the destination prefix length.

Source

pub fn action(&self) -> FibRuleAction

Get the rule action.

Source

pub fn is_lookup(&self) -> bool

Check if this is a table lookup rule.

Source

pub fn is_blackhole(&self) -> bool

Check if this is a blackhole rule.

Source

pub fn is_unreachable(&self) -> bool

Check if this is an unreachable rule.

Source

pub fn is_prohibit(&self) -> bool

Check if this is a prohibit rule.

Source

pub fn table_id(&self) -> u32

Get the routing table ID.

Source

pub fn is_default(&self) -> bool

Check if this is a default rule (priority 0, 32766, or 32767).

Source

pub fn priority(&self) -> u32

Rule priority (FRA_PRIORITY). Returns 0 when the kernel did not set the attribute.

Source

pub fn source(&self) -> Option<IpAddr>

Source address (FRA_SRC), if present.

Source

pub fn destination(&self) -> Option<IpAddr>

Destination address (FRA_DST), if present.

Source

pub fn iifname(&self) -> Option<&str>

Input interface name (FRA_IIFNAME), if present.

Source

pub fn oifname(&self) -> Option<&str>

Output interface name (FRA_OIFNAME), if present.

Source

pub fn fwmark(&self) -> Option<u32>

Firewall mark (FRA_FWMARK), if present.

Source

pub fn fwmask(&self) -> Option<u32>

Firewall mark mask (FRA_FWMASK), if present.

Source

pub fn table(&self) -> u32

Routing table ID. Returns the 32-bit FRA_TABLE override when present, else the 8-bit header.table.

Source

pub fn goto(&self) -> Option<u32>

Goto target rule priority (FRA_GOTO), if present.

Source

pub fn flow(&self) -> Option<u32>

Flow classification ID (FRA_FLOW), if present.

Source

pub fn tun_id(&self) -> Option<u64>

Tunnel ID (FRA_TUN_ID), if present.

Source

pub fn suppress_ifgroup(&self) -> Option<u32>

Suppress interface group (FRA_SUPPRESS_IFGROUP), if present.

Source

pub fn suppress_prefixlen(&self) -> Option<u32>

Suppress prefix length (FRA_SUPPRESS_PREFIXLEN), if present.

Source

pub fn l3mdev(&self) -> Option<u8>

L3 master device flag (FRA_L3MDEV), if present.

Source

pub fn uid_range(&self) -> Option<FibRuleUidRange>

UID range (FRA_UID_RANGE), if present.

Source

pub fn protocol(&self) -> Option<u8>

Rule protocol (FRA_PROTOCOL), if present.

Source

pub fn ip_proto(&self) -> Option<u8>

IP protocol for port matching (FRA_IP_PROTO), if present.

Source

pub fn sport_range(&self) -> Option<FibRulePortRange>

Source port range (FRA_SPORT_RANGE), if present.

Source

pub fn dport_range(&self) -> Option<FibRulePortRange>

Destination port range (FRA_DPORT_RANGE), if present.

Trait Implementations§

Source§

impl Clone for RuleMessage

Source§

fn clone(&self) -> RuleMessage

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

Source§

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

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

impl Default for RuleMessage

Source§

fn default() -> RuleMessage

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

fn write_dump_header(buf: &mut Vec<u8>)

Write the header required for dump requests. This is appended to the netlink message after the nlmsghdr. Default implementation writes nothing (for messages that don’t need a header).
Source§

fn parse(input: &mut &[u8]) -> PResult<Self>

Parse from a mutable byte slice reference. The slice is advanced past the consumed bytes.
Source§

fn from_bytes(data: &[u8]) -> Result<Self>

Parse from a complete byte slice.
Source§

fn set_msg_type(&mut self, _msg_type: u16)

Record the nlmsg_type this message arrived with. 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> 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more