libc/new/linux_uapi/linux/
netlink.rs

1//! Header: `uapi/linux/netlink.h`
2
3use crate::prelude::*;
4
5pub const NETLINK_ROUTE: c_int = 0;
6pub const NETLINK_UNUSED: c_int = 1;
7pub const NETLINK_USERSOCK: c_int = 2;
8pub const NETLINK_FIREWALL: c_int = 3;
9pub const NETLINK_SOCK_DIAG: c_int = 4;
10pub const NETLINK_NFLOG: c_int = 5;
11pub const NETLINK_XFRM: c_int = 6;
12pub const NETLINK_SELINUX: c_int = 7;
13pub const NETLINK_ISCSI: c_int = 8;
14pub const NETLINK_AUDIT: c_int = 9;
15pub const NETLINK_FIB_LOOKUP: c_int = 10;
16pub const NETLINK_CONNECTOR: c_int = 11;
17pub const NETLINK_NETFILTER: c_int = 12;
18pub const NETLINK_IP6_FW: c_int = 13;
19pub const NETLINK_DNRTMSG: c_int = 14;
20pub const NETLINK_KOBJECT_UEVENT: c_int = 15;
21pub const NETLINK_GENERIC: c_int = 16;
22pub const NETLINK_SCSITRANSPORT: c_int = 18;
23pub const NETLINK_ECRYPTFS: c_int = 19;
24pub const NETLINK_RDMA: c_int = 20;
25pub const NETLINK_CRYPTO: c_int = 21;
26
27pub const NETLINK_INET_DIAG: c_int = NETLINK_SOCK_DIAG;
28
29pub const MAX_LINKS: c_int = 32;
30
31s! {
32    pub struct sockaddr_nl {
33        pub nl_family: crate::sa_family_t,
34        nl_pad: Padding<c_ushort>,
35        pub nl_pid: u32,
36        pub nl_groups: u32,
37    }
38
39    pub struct nlmsghdr {
40        pub nlmsg_len: u32,
41        pub nlmsg_type: u16,
42        pub nlmsg_flags: u16,
43        pub nlmsg_seq: u32,
44        pub nlmsg_pid: u32,
45    }
46}
47
48pub const NLM_F_REQUEST: c_int = 1;
49pub const NLM_F_MULTI: c_int = 2;
50pub const NLM_F_ACK: c_int = 4;
51pub const NLM_F_ECHO: c_int = 8;
52pub const NLM_F_DUMP_INTR: c_int = 16;
53pub const NLM_F_DUMP_FILTERED: c_int = 32;
54
55pub const NLM_F_ROOT: c_int = 0x100;
56pub const NLM_F_MATCH: c_int = 0x200;
57pub const NLM_F_ATOMIC: c_int = 0x400;
58pub const NLM_F_DUMP: c_int = NLM_F_ROOT | NLM_F_MATCH;
59
60pub const NLM_F_REPLACE: c_int = 0x100;
61pub const NLM_F_EXCL: c_int = 0x200;
62pub const NLM_F_CREATE: c_int = 0x400;
63pub const NLM_F_APPEND: c_int = 0x800;
64
65pub const NLM_F_NONREC: c_int = 0x100;
66
67pub const NLM_F_CAPPED: c_int = 0x100;
68pub const NLM_F_ACK_TLVS: c_int = 0x200;
69
70pub const NLMSG_NOOP: c_int = 0x1;
71pub const NLMSG_ERROR: c_int = 0x2;
72pub const NLMSG_DONE: c_int = 0x3;
73pub const NLMSG_OVERRUN: c_int = 0x4;
74
75pub const NLMSG_MIN_TYPE: c_int = 0x10;
76
77s! {
78    pub struct nlmsgerr {
79        pub error: c_int,
80        pub msg: nlmsghdr,
81    }
82}
83
84pub const NETLINK_ADD_MEMBERSHIP: c_int = 1;
85pub const NETLINK_DROP_MEMBERSHIP: c_int = 2;
86pub const NETLINK_PKTINFO: c_int = 3;
87pub const NETLINK_BROADCAST_ERROR: c_int = 4;
88pub const NETLINK_NO_ENOBUFS: c_int = 5;
89pub const NETLINK_RX_RING: c_int = 6;
90pub const NETLINK_TX_RING: c_int = 7;
91pub const NETLINK_LISTEN_ALL_NSID: c_int = 8;
92pub const NETLINK_LIST_MEMBERSHIPS: c_int = 9;
93pub const NETLINK_CAP_ACK: c_int = 10;
94pub const NETLINK_EXT_ACK: c_int = 11;
95pub const NETLINK_GET_STRICT_CHK: c_int = 12;
96
97s! {
98    pub struct nl_pktinfo {
99        pub group: u32,
100    }
101
102    pub struct nl_mmap_req {
103        pub nm_block_size: c_uint,
104        pub nm_block_nr: c_uint,
105        pub nm_frame_size: c_uint,
106        pub nm_frame_nr: c_uint,
107    }
108
109    pub struct nl_mmap_hdr {
110        pub nm_status: c_uint,
111        pub nm_len: c_uint,
112        pub nm_group: u32,
113        pub nm_pid: u32,
114        pub nm_uid: u32,
115        pub nm_gid: u32,
116    }
117}
118
119s! {
120    pub struct nlattr {
121        pub nla_len: u16,
122        pub nla_type: u16,
123    }
124}
125
126pub const NLA_F_NESTED: c_int = 1 << 15;
127pub const NLA_F_NET_BYTEORDER: c_int = 1 << 14;
128pub const NLA_TYPE_MASK: c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);
129
130pub const NLA_ALIGNTO: c_int = 4;
131
132f! {
133    pub fn NLA_ALIGN(len: c_int) -> c_int {
134        return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1);
135    }
136}