1#ifndef _UAPI__LINUX_RTNETLINK_H
2#define _UAPI__LINUX_RTNETLINK_H
3
4#include <linux/types.h>
5#include <linux/netlink.h>
6#include <linux/if_link.h>
7#include <linux/if_addr.h>
8#include <linux/neighbour.h>
9
10
11
12
13#define RTNL_FAMILY_IPMR 128
14#define RTNL_FAMILY_IP6MR 129
15#define RTNL_FAMILY_MAX 129
16
17
18
19
20
21
22
23enum {
24 RTM_BASE = 16,
25#define RTM_BASE RTM_BASE
26
27 RTM_NEWLINK = 16,
28#define RTM_NEWLINK RTM_NEWLINK
29 RTM_DELLINK,
30#define RTM_DELLINK RTM_DELLINK
31 RTM_GETLINK,
32#define RTM_GETLINK RTM_GETLINK
33 RTM_SETLINK,
34#define RTM_SETLINK RTM_SETLINK
35
36 RTM_NEWADDR = 20,
37#define RTM_NEWADDR RTM_NEWADDR
38 RTM_DELADDR,
39#define RTM_DELADDR RTM_DELADDR
40 RTM_GETADDR,
41#define RTM_GETADDR RTM_GETADDR
42
43 RTM_NEWROUTE = 24,
44#define RTM_NEWROUTE RTM_NEWROUTE
45 RTM_DELROUTE,
46#define RTM_DELROUTE RTM_DELROUTE
47 RTM_GETROUTE,
48#define RTM_GETROUTE RTM_GETROUTE
49
50 RTM_NEWNEIGH = 28,
51#define RTM_NEWNEIGH RTM_NEWNEIGH
52 RTM_DELNEIGH,
53#define RTM_DELNEIGH RTM_DELNEIGH
54 RTM_GETNEIGH,
55#define RTM_GETNEIGH RTM_GETNEIGH
56
57 RTM_NEWRULE = 32,
58#define RTM_NEWRULE RTM_NEWRULE
59 RTM_DELRULE,
60#define RTM_DELRULE RTM_DELRULE
61 RTM_GETRULE,
62#define RTM_GETRULE RTM_GETRULE
63
64 RTM_NEWQDISC = 36,
65#define RTM_NEWQDISC RTM_NEWQDISC
66 RTM_DELQDISC,
67#define RTM_DELQDISC RTM_DELQDISC
68 RTM_GETQDISC,
69#define RTM_GETQDISC RTM_GETQDISC
70
71 RTM_NEWTCLASS = 40,
72#define RTM_NEWTCLASS RTM_NEWTCLASS
73 RTM_DELTCLASS,
74#define RTM_DELTCLASS RTM_DELTCLASS
75 RTM_GETTCLASS,
76#define RTM_GETTCLASS RTM_GETTCLASS
77
78 RTM_NEWTFILTER = 44,
79#define RTM_NEWTFILTER RTM_NEWTFILTER
80 RTM_DELTFILTER,
81#define RTM_DELTFILTER RTM_DELTFILTER
82 RTM_GETTFILTER,
83#define RTM_GETTFILTER RTM_GETTFILTER
84
85 RTM_NEWACTION = 48,
86#define RTM_NEWACTION RTM_NEWACTION
87 RTM_DELACTION,
88#define RTM_DELACTION RTM_DELACTION
89 RTM_GETACTION,
90#define RTM_GETACTION RTM_GETACTION
91
92 RTM_NEWPREFIX = 52,
93#define RTM_NEWPREFIX RTM_NEWPREFIX
94
95 RTM_GETMULTICAST = 58,
96#define RTM_GETMULTICAST RTM_GETMULTICAST
97
98 RTM_GETANYCAST = 62,
99#define RTM_GETANYCAST RTM_GETANYCAST
100
101 RTM_NEWNEIGHTBL = 64,
102#define RTM_NEWNEIGHTBL RTM_NEWNEIGHTBL
103 RTM_GETNEIGHTBL = 66,
104#define RTM_GETNEIGHTBL RTM_GETNEIGHTBL
105 RTM_SETNEIGHTBL,
106#define RTM_SETNEIGHTBL RTM_SETNEIGHTBL
107
108 RTM_NEWNDUSEROPT = 68,
109#define RTM_NEWNDUSEROPT RTM_NEWNDUSEROPT
110
111 RTM_NEWADDRLABEL = 72,
112#define RTM_NEWADDRLABEL RTM_NEWADDRLABEL
113 RTM_DELADDRLABEL,
114#define RTM_DELADDRLABEL RTM_DELADDRLABEL
115 RTM_GETADDRLABEL,
116#define RTM_GETADDRLABEL RTM_GETADDRLABEL
117
118 RTM_GETDCB = 78,
119#define RTM_GETDCB RTM_GETDCB
120 RTM_SETDCB,
121#define RTM_SETDCB RTM_SETDCB
122
123 RTM_NEWNETCONF = 80,
124#define RTM_NEWNETCONF RTM_NEWNETCONF
125 RTM_GETNETCONF = 82,
126#define RTM_GETNETCONF RTM_GETNETCONF
127
128 RTM_NEWMDB = 84,
129#define RTM_NEWMDB RTM_NEWMDB
130 RTM_DELMDB = 85,
131#define RTM_DELMDB RTM_DELMDB
132 RTM_GETMDB = 86,
133#define RTM_GETMDB RTM_GETMDB
134
135 __RTM_MAX,
136#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
137};
138
139#define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
140#define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
141#define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
142
143
144
145
146
147
148
149struct rtattr {
150 unsigned short rta_len;
151 unsigned short rta_type;
152};
153
154
155
156#define RTA_ALIGNTO 4
157#define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
158#define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \
159 (rta)->rta_len >= sizeof(struct rtattr) && \
160 (rta)->rta_len <= (len))
161#define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
162 (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
163#define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
164#define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len))
165#define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
166#define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
167
168
169
170
171
172
173
174
175struct rtmsg {
176 unsigned char rtm_family;
177 unsigned char rtm_dst_len;
178 unsigned char rtm_src_len;
179 unsigned char rtm_tos;
180
181 unsigned char rtm_table;
182 unsigned char rtm_protocol;
183 unsigned char rtm_scope;
184 unsigned char rtm_type;
185
186 unsigned rtm_flags;
187};
188
189
190
191enum {
192 RTN_UNSPEC,
193 RTN_UNICAST,
194 RTN_LOCAL,
195 RTN_BROADCAST,
196
197 RTN_ANYCAST,
198
199 RTN_MULTICAST,
200 RTN_BLACKHOLE,
201 RTN_UNREACHABLE,
202 RTN_PROHIBIT,
203 RTN_THROW,
204 RTN_NAT,
205 RTN_XRESOLVE,
206 __RTN_MAX
207};
208
209#define RTN_MAX (__RTN_MAX - 1)
210
211
212
213
214#define RTPROT_UNSPEC 0
215#define RTPROT_REDIRECT 1
216
217#define RTPROT_KERNEL 2
218#define RTPROT_BOOT 3
219#define RTPROT_STATIC 4
220
221
222
223
224
225
226
227
228#define RTPROT_GATED 8
229#define RTPROT_RA 9
230#define RTPROT_MRT 10
231#define RTPROT_ZEBRA 11
232#define RTPROT_BIRD 12
233#define RTPROT_DNROUTED 13
234#define RTPROT_XORP 14
235#define RTPROT_NTK 15
236#define RTPROT_DHCP 16
237#define RTPROT_MROUTED 17
238
239
240
241
242
243
244
245
246
247
248
249
250enum rt_scope_t {
251 RT_SCOPE_UNIVERSE=0,
252
253 RT_SCOPE_SITE=200,
254 RT_SCOPE_LINK=253,
255 RT_SCOPE_HOST=254,
256 RT_SCOPE_NOWHERE=255
257};
258
259
260
261#define RTM_F_NOTIFY 0x100
262#define RTM_F_CLONED 0x200
263#define RTM_F_EQUALIZE 0x400
264#define RTM_F_PREFIX 0x800
265
266
267
268enum rt_class_t {
269 RT_TABLE_UNSPEC=0,
270
271 RT_TABLE_COMPAT=252,
272 RT_TABLE_DEFAULT=253,
273 RT_TABLE_MAIN=254,
274 RT_TABLE_LOCAL=255,
275 RT_TABLE_MAX=0xFFFFFFFF
276};
277
278
279
280
281enum rtattr_type_t {
282 RTA_UNSPEC,
283 RTA_DST,
284 RTA_SRC,
285 RTA_IIF,
286 RTA_OIF,
287 RTA_GATEWAY,
288 RTA_PRIORITY,
289 RTA_PREFSRC,
290 RTA_METRICS,
291 RTA_MULTIPATH,
292 RTA_PROTOINFO,
293 RTA_FLOW,
294 RTA_CACHEINFO,
295 RTA_SESSION,
296 RTA_MP_ALGO,
297 RTA_TABLE,
298 RTA_MARK,
299 RTA_MFC_STATS,
300 __RTA_MAX
301};
302
303#define RTA_MAX (__RTA_MAX - 1)
304
305#define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
306#define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
307
308
309
310
311
312
313
314
315
316
317struct rtnexthop {
318 unsigned short rtnh_len;
319 unsigned char rtnh_flags;
320 unsigned char rtnh_hops;
321 int rtnh_ifindex;
322};
323
324
325
326#define RTNH_F_DEAD 1
327#define RTNH_F_PERVASIVE 2
328#define RTNH_F_ONLINK 4
329
330
331
332#define RTNH_ALIGNTO 4
333#define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
334#define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
335 ((int)(rtnh)->rtnh_len) <= (len))
336#define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
337#define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
338#define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
339#define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
340
341
342
343struct rta_cacheinfo {
344 __u32 rta_clntref;
345 __u32 rta_lastuse;
346 __s32 rta_expires;
347 __u32 rta_error;
348 __u32 rta_used;
349
350#define RTNETLINK_HAVE_PEERINFO 1
351 __u32 rta_id;
352 __u32 rta_ts;
353 __u32 rta_tsage;
354};
355
356
357
358enum {
359 RTAX_UNSPEC,
360#define RTAX_UNSPEC RTAX_UNSPEC
361 RTAX_LOCK,
362#define RTAX_LOCK RTAX_LOCK
363 RTAX_MTU,
364#define RTAX_MTU RTAX_MTU
365 RTAX_WINDOW,
366#define RTAX_WINDOW RTAX_WINDOW
367 RTAX_RTT,
368#define RTAX_RTT RTAX_RTT
369 RTAX_RTTVAR,
370#define RTAX_RTTVAR RTAX_RTTVAR
371 RTAX_SSTHRESH,
372#define RTAX_SSTHRESH RTAX_SSTHRESH
373 RTAX_CWND,
374#define RTAX_CWND RTAX_CWND
375 RTAX_ADVMSS,
376#define RTAX_ADVMSS RTAX_ADVMSS
377 RTAX_REORDERING,
378#define RTAX_REORDERING RTAX_REORDERING
379 RTAX_HOPLIMIT,
380#define RTAX_HOPLIMIT RTAX_HOPLIMIT
381 RTAX_INITCWND,
382#define RTAX_INITCWND RTAX_INITCWND
383 RTAX_FEATURES,
384#define RTAX_FEATURES RTAX_FEATURES
385 RTAX_RTO_MIN,
386#define RTAX_RTO_MIN RTAX_RTO_MIN
387 RTAX_INITRWND,
388#define RTAX_INITRWND RTAX_INITRWND
389 RTAX_QUICKACK,
390#define RTAX_QUICKACK RTAX_QUICKACK
391 __RTAX_MAX
392};
393
394#define RTAX_MAX (__RTAX_MAX - 1)
395
396#define RTAX_FEATURE_ECN 0x00000001
397#define RTAX_FEATURE_SACK 0x00000002
398#define RTAX_FEATURE_TIMESTAMP 0x00000004
399#define RTAX_FEATURE_ALLFRAG 0x00000008
400
401struct rta_session {
402 __u8 proto;
403 __u8 pad1;
404 __u16 pad2;
405
406 union {
407 struct {
408 __u16 sport;
409 __u16 dport;
410 } ports;
411
412 struct {
413 __u8 type;
414 __u8 code;
415 __u16 ident;
416 } icmpt;
417
418 __u32 spi;
419 } u;
420};
421
422struct rta_mfc_stats {
423 __u64 mfcs_packets;
424 __u64 mfcs_bytes;
425 __u64 mfcs_wrong_if;
426};
427
428
429
430
431
432struct rtgenmsg {
433 unsigned char rtgen_family;
434};
435
436
437
438
439
440
441
442
443
444
445struct ifinfomsg {
446 unsigned char ifi_family;
447 unsigned char __ifi_pad;
448 unsigned short ifi_type;
449 int ifi_index;
450 unsigned ifi_flags;
451 unsigned ifi_change;
452};
453
454
455
456
457
458struct prefixmsg {
459 unsigned char prefix_family;
460 unsigned char prefix_pad1;
461 unsigned short prefix_pad2;
462 int prefix_ifindex;
463 unsigned char prefix_type;
464 unsigned char prefix_len;
465 unsigned char prefix_flags;
466 unsigned char prefix_pad3;
467};
468
469enum
470{
471 PREFIX_UNSPEC,
472 PREFIX_ADDRESS,
473 PREFIX_CACHEINFO,
474 __PREFIX_MAX
475};
476
477#define PREFIX_MAX (__PREFIX_MAX - 1)
478
479struct prefix_cacheinfo {
480 __u32 preferred_time;
481 __u32 valid_time;
482};
483
484
485
486
487
488
489struct tcmsg {
490 unsigned char tcm_family;
491 unsigned char tcm__pad1;
492 unsigned short tcm__pad2;
493 int tcm_ifindex;
494 __u32 tcm_handle;
495 __u32 tcm_parent;
496 __u32 tcm_info;
497};
498
499enum {
500 TCA_UNSPEC,
501 TCA_KIND,
502 TCA_OPTIONS,
503 TCA_STATS,
504 TCA_XSTATS,
505 TCA_RATE,
506 TCA_FCNT,
507 TCA_STATS2,
508 TCA_STAB,
509 __TCA_MAX
510};
511
512#define TCA_MAX (__TCA_MAX - 1)
513
514#define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
515#define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
516
517
518
519
520
521struct nduseroptmsg {
522 unsigned char nduseropt_family;
523 unsigned char nduseropt_pad1;
524 unsigned short nduseropt_opts_len;
525 int nduseropt_ifindex;
526 __u8 nduseropt_icmp_type;
527 __u8 nduseropt_icmp_code;
528 unsigned short nduseropt_pad2;
529 unsigned int nduseropt_pad3;
530
531};
532
533enum {
534 NDUSEROPT_UNSPEC,
535 NDUSEROPT_SRCADDR,
536 __NDUSEROPT_MAX
537};
538
539#define NDUSEROPT_MAX (__NDUSEROPT_MAX - 1)
540
541#ifndef __KERNEL__
542
543#define RTMGRP_LINK 1
544#define RTMGRP_NOTIFY 2
545#define RTMGRP_NEIGH 4
546#define RTMGRP_TC 8
547
548#define RTMGRP_IPV4_IFADDR 0x10
549#define RTMGRP_IPV4_MROUTE 0x20
550#define RTMGRP_IPV4_ROUTE 0x40
551#define RTMGRP_IPV4_RULE 0x80
552
553#define RTMGRP_IPV6_IFADDR 0x100
554#define RTMGRP_IPV6_MROUTE 0x200
555#define RTMGRP_IPV6_ROUTE 0x400
556#define RTMGRP_IPV6_IFINFO 0x800
557
558#define RTMGRP_DECnet_IFADDR 0x1000
559#define RTMGRP_DECnet_ROUTE 0x4000
560
561#define RTMGRP_IPV6_PREFIX 0x20000
562#endif
563
564
565enum rtnetlink_groups {
566 RTNLGRP_NONE,
567#define RTNLGRP_NONE RTNLGRP_NONE
568 RTNLGRP_LINK,
569#define RTNLGRP_LINK RTNLGRP_LINK
570 RTNLGRP_NOTIFY,
571#define RTNLGRP_NOTIFY RTNLGRP_NOTIFY
572 RTNLGRP_NEIGH,
573#define RTNLGRP_NEIGH RTNLGRP_NEIGH
574 RTNLGRP_TC,
575#define RTNLGRP_TC RTNLGRP_TC
576 RTNLGRP_IPV4_IFADDR,
577#define RTNLGRP_IPV4_IFADDR RTNLGRP_IPV4_IFADDR
578 RTNLGRP_IPV4_MROUTE,
579#define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
580 RTNLGRP_IPV4_ROUTE,
581#define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
582 RTNLGRP_IPV4_RULE,
583#define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
584 RTNLGRP_IPV6_IFADDR,
585#define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
586 RTNLGRP_IPV6_MROUTE,
587#define RTNLGRP_IPV6_MROUTE RTNLGRP_IPV6_MROUTE
588 RTNLGRP_IPV6_ROUTE,
589#define RTNLGRP_IPV6_ROUTE RTNLGRP_IPV6_ROUTE
590 RTNLGRP_IPV6_IFINFO,
591#define RTNLGRP_IPV6_IFINFO RTNLGRP_IPV6_IFINFO
592 RTNLGRP_DECnet_IFADDR,
593#define RTNLGRP_DECnet_IFADDR RTNLGRP_DECnet_IFADDR
594 RTNLGRP_NOP2,
595 RTNLGRP_DECnet_ROUTE,
596#define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE
597 RTNLGRP_DECnet_RULE,
598#define RTNLGRP_DECnet_RULE RTNLGRP_DECnet_RULE
599 RTNLGRP_NOP4,
600 RTNLGRP_IPV6_PREFIX,
601#define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX
602 RTNLGRP_IPV6_RULE,
603#define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE
604 RTNLGRP_ND_USEROPT,
605#define RTNLGRP_ND_USEROPT RTNLGRP_ND_USEROPT
606 RTNLGRP_PHONET_IFADDR,
607#define RTNLGRP_PHONET_IFADDR RTNLGRP_PHONET_IFADDR
608 RTNLGRP_PHONET_ROUTE,
609#define RTNLGRP_PHONET_ROUTE RTNLGRP_PHONET_ROUTE
610 RTNLGRP_DCB,
611#define RTNLGRP_DCB RTNLGRP_DCB
612 RTNLGRP_IPV4_NETCONF,
613#define RTNLGRP_IPV4_NETCONF RTNLGRP_IPV4_NETCONF
614 RTNLGRP_IPV6_NETCONF,
615#define RTNLGRP_IPV6_NETCONF RTNLGRP_IPV6_NETCONF
616 RTNLGRP_MDB,
617#define RTNLGRP_MDB RTNLGRP_MDB
618 __RTNLGRP_MAX
619};
620#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
621
622
623struct tcamsg {
624 unsigned char tca_family;
625 unsigned char tca__pad1;
626 unsigned short tca__pad2;
627};
628#define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
629#define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
630#define TCA_ACT_TAB 1
631#define TCAA_MAX 1
632
633
634#define RTEXT_FILTER_VF (1 << 0)
635#define RTEXT_FILTER_BRVLAN (1 << 1)
636
637
638
639
640
641#endif
642