neli/consts/
nl.rs

1use neli_proc_macros::neli_enum;
2
3use crate::{
4    self as neli,
5    consts::{netfilter::NetfilterMsg, rtnl::Rtm},
6};
7
8impl_trait!(
9    /// Trait marking constants valid for use in
10    /// [`Nlmsghdr`][crate::nl::Nlmsghdr] field, `nl_type`.
11    pub NlType,
12    u16,
13    /// Wrapper that is usable with all values in
14    /// [`Nlmsghdr`][crate::nl::Nlmsghdr] field,
15    /// `nl_type`.
16    pub NlTypeWrapper,
17    Nlmsg,
18    GenlId,
19    Rtm,
20    NetfilterMsg
21);
22
23/// Values for `nl_type` in [`Nlmsghdr`][crate::nl::Nlmsghdr]
24#[neli_enum(serialized_type = "u16")]
25pub enum Nlmsg {
26    Noop = libc::NLMSG_NOOP as u16,
27    Error = libc::NLMSG_ERROR as u16,
28    Done = libc::NLMSG_DONE as u16,
29    Overrun = libc::NLMSG_OVERRUN as u16,
30}
31
32/// Values for `nl_type` in [`Nlmsghdr`][crate::nl::Nlmsghdr]
33#[neli_enum(serialized_type = "u16")]
34pub enum GenlId {
35    Ctrl = libc::GENL_ID_CTRL as u16,
36    #[cfg(target_env = "gnu")]
37    VfsDquot = libc::GENL_ID_VFS_DQUOT as u16,
38    #[cfg(target_env = "gnu")]
39    Pmcraid = libc::GENL_ID_PMCRAID as u16,
40}
41
42impl_flags!(
43    #[allow(missing_docs)]
44    pub NlmF: u16 {
45        /// This flag is required for all kernel requests
46        REQUEST = libc::NLM_F_REQUEST as u16,
47        MULTI = libc::NLM_F_MULTI as u16,
48        ACK = libc::NLM_F_ACK as u16,
49        ECHO = libc::NLM_F_ECHO as u16,
50        DUMP_INTR = libc::NLM_F_DUMP_INTR as u16,
51        DUMP_FILTERED = libc::NLM_F_DUMP_FILTERED as u16,
52        ROOT = libc::NLM_F_ROOT as u16,
53        MATCH = libc::NLM_F_MATCH as u16,
54        ATOMIC = libc::NLM_F_ATOMIC as u16,
55        DUMP = libc::NLM_F_DUMP as u16,
56        REPLACE = libc::NLM_F_REPLACE as u16,
57        EXCL = libc::NLM_F_EXCL as u16,
58        CREATE = libc::NLM_F_CREATE as u16,
59        APPEND = libc::NLM_F_APPEND as u16,
60        CAPPED = libc::NLM_F_CAPPED as u16,
61        ACK_TLVS = libc::NLM_F_ACK_TLVS as u16,
62    }
63);
64
65#[neli_enum(serialized_type = "u16")]
66pub enum NlmsgerrAttr {
67    Unused = 0,
68    /// Error message string (string)
69    Msg = 1,
70    /// Offset of the invalid attribute in the original
71    /// message, counting from the beginning of the
72    /// header (u32)
73    Offset = 2,
74    /// Arbitrary subsystem specific cookie to
75    /// be used - in the success case - to identify a created
76    /// object or operation or similar (binary)
77    Cookie = 3,
78    /// Policy for a rejected attribute
79    Policy = 4,
80}