1use errno::Errno;
2use libc;
3use mnl::{Attr, AttrTbl, MsgVec, Result};
4use std::net::{Ipv4Addr, Ipv6Addr};
5
6#[repr(C)]
7#[derive(Debug, Copy, Clone)]
8pub struct Ndmsg {
9 pub ndm_family: u8,
10 pub ndm_pad1: u8,
11 pub ndm_pad2: u16,
12 pub ndm_ifindex: i32,
13 pub ndm_state: u16,
14 pub ndm_flags: u8,
15 pub ndm_type: u8,
16}
17
18#[repr(u16)]
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
20#[tbname = "NdaTbl"]
21pub enum Nda {
22 Unspec,
23
24 #[nla_type(Ipv4Addr, v4dst)]
25 #[nla_type(Ipv6Addr, v6dst)]
26 Dst,
27
28 #[nla_type(bytes, lladdr)]
29 Lladdr,
30
31 #[nla_type(NdaCacheinfo, cacheinfo)]
32 Cacheinfo,
33
34 #[nla_type(u32, probes)]
35 Probes,
36
37 #[nla_type(u16, vlan)]
38 Vlan,
39
40 #[nla_type(u16, port)]
41 Port,
42
43 #[nla_type(u32, vni)]
44 Vni,
45
46 #[nla_type(u32, ifindex)]
47 Ifindex,
48
49 #[nla_type(u32, master)]
50 Master,
51
52 #[nla_type(i32, link_netnsid)]
53 LinkNetnsid,
54
55 #[nla_type(u32, src_vni)]
56 SrcVni,
57
58 #[nla_type(u8, protocol)]
59 Protocol,
60
61 #[nla_type(u32, nh_id)]
62 NhId,
63
64 #[nla_nest(NfeaTbl, fdb_ext_attrs)]
65 FdbExtAttrs,
66
67 _MAX,
68}
69
70pub const NTF_USE: u8 = 0x01;
74pub const NTF_SELF: u8 = 0x02;
75pub const NTF_MASTER: u8 = 0x04;
76pub const NTF_PROXY: u8 = 0x08 ;
77pub const NTF_EXT_LEARNED: u8 = 0x10;
78pub const NTF_OFFLOADED: u8 = 0x20;
79pub const NTF_STICKY: u8 = 0x40;
80pub const NTF_ROUTER: u8 = 0x80;
81
82pub const NUD_INCOMPLETE: u8 = 0x01;
86pub const NUD_REACHABLE: u8 = 0x02;
87pub const NUD_STALE: u8 = 0x04;
88pub const NUD_DELAY: u8 = 0x08;
89pub const NUD_PROBE: u8 = 0x10;
90pub const NUD_FAILED: u8 = 0x20;
91
92pub const NUD_NOARP: u8 = 0x40;
94pub const NUD_PERMANENT: u8 = 0x80;
95pub const NUD_NONE: u8 = 0x00;
96
97#[repr(C)]
106#[derive(Debug, Copy, Clone)]
107pub struct NdaCacheinfo {
108 pub ndm_confirmed: u32,
109 pub ndm_used: u32,
110 pub ndm_updated: u32,
111 pub ndm_refcnt: u32,
112}
113
114#[repr(C)]
139#[derive(Debug, Copy, Clone)]
140pub struct NdtStats {
141 pub ndts_allocs: u64,
142 pub ndts_destroys: u64,
143 pub ndts_hash_grows: u64,
144 pub ndts_res_failed: u64,
145 pub ndts_lookups: u64,
146 pub ndts_hits: u64,
147 pub ndts_rcv_probes_mcast: u64,
148 pub ndts_rcv_probes_ucast: u64,
149 pub ndts_periodic_gc_runs: u64,
150 pub ndts_forced_gc_runs: u64,
151 pub ndts_table_fulls: u64,
152}
153
154#[repr(u16)]
155#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
156#[tbname = "NdtpaTbl"]
157pub enum Ndtpa {
158 Unspec,
159
160 #[nla_type(u32, ifindex)]
161 Ifindex, #[nla_type(u32, refcnt)]
164 Refcnt, #[nla_type(u64, reachable_time)]
167 ReachableTime, #[nla_type(u64, base_reachable_time)]
170 BaseReachableTime, #[nla_type(u64, retrans_time)]
173 RetransTime, #[nla_type(u64, gc_staletime)]
176 GcStaletime, #[nla_type(u64, delay_probe_time)]
179 DelayProbeTime, #[nla_type(u64, queue_len)]
182 QueueLen, #[nla_type(u64, app_probes)]
185 AppProbes, #[nla_type(u32, ucast_probes)]
188 UcastProbes, #[nla_type(u32, mcast_probes)]
191 McastProbes, #[nla_type(u64, anycast_delay)]
194 AnycastDelay, #[nla_type(u64, proxy_delay)]
197 ProxyDelay, #[nla_type(u32, proxy_qlen)]
200 ProxyQlen, #[nla_type(u64, locktime)]
203 Locktime, #[nla_type(u32, queue_lenbytes)]
206 QueueLenbytes, #[nla_type(u32, mcast_reprobes)]
209 McastReprobes, PAD,
212 _MAX,
213}
214
215#[repr(C)]
216#[derive(Debug, Copy, Clone)]
217pub struct Ndtmsg {
218 pub ndtm_family: u8,
219 pub ndtm_pad1: u8,
220 pub ndtm_pad2: u16,
221}
222
223#[repr(C)]
224#[derive(Debug, Copy, Clone)]
225pub struct NdtConfig {
226 pub ndtc_key_len: u16,
227 pub ndtc_entry_size: u16,
228 pub ndtc_entries: u32,
229 pub ndtc_last_flush: u32, pub ndtc_last_rand: u32,
231 pub ndtc_hash_rnd: u32,
232 pub ndtc_hash_mask: u32,
233 pub ndtc_hash_chain_gc: u32,
234 pub ndtc_proxy_qlen: u32,
235}
236
237#[repr(u16)]
238#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
239#[tbname = "NdtaTbl"]
240pub enum Ndta {
241 Unspec,
242
243 #[nla_type(str, name)]
244 Name,
245
246 #[nla_type(u32, thresh1)]
247 Thresh1,
248
249 #[nla_type(u32, thresh2)]
250 Thresh2,
251
252 #[nla_type(u32, thresh3)]
253 Thresh3,
254
255 #[nla_type(NdtConfig, config)]
256 Config,
257
258 #[nla_nest(NdtpaTbl, parms)]
259 Parms,
260
261 #[nla_type(NdtStats, stats)]
262 Stats,
263
264 #[nla_type(u64, gc_interval)]
265 GcInterval,
266 Pad,
267 _MAX,
268}
269
270#[repr(u8)]
274#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
275pub enum Fdb {
276 NotifyBit = 1 << 0,
277 NotifyInactiveBit = 1 << 1,
278 _MAX,
279}
280
281#[repr(u16)]
287#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, NlaType)]
288#[tbname = "NfeaTbl"]
289pub enum Nfea {
290 Unspec,
291
292 #[nla_type(u8, activity_notify)]
293 ActivityNotify,
294
295 #[nla_type(flag, dont_refresh)]
296 DontRefresh,
297
298 _MAX,
299}