blob: 890c4d4038b61bf4134100dd9b9b15046b0d3cc5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __LINUX_RTNETLINK_H
2#define __LINUX_RTNETLINK_H
3
4#include <linux/netlink.h>
5
6/****
7 * Routing/neighbour discovery messages.
8 ****/
9
10/* Types of messages */
11
12enum {
13 RTM_BASE = 16,
14#define RTM_BASE RTM_BASE
15
16 RTM_NEWLINK = 16,
17#define RTM_NEWLINK RTM_NEWLINK
18 RTM_DELLINK,
19#define RTM_DELLINK RTM_DELLINK
20 RTM_GETLINK,
21#define RTM_GETLINK RTM_GETLINK
22 RTM_SETLINK,
23#define RTM_SETLINK RTM_SETLINK
24
25 RTM_NEWADDR = 20,
26#define RTM_NEWADDR RTM_NEWADDR
27 RTM_DELADDR,
28#define RTM_DELADDR RTM_DELADDR
29 RTM_GETADDR,
30#define RTM_GETADDR RTM_GETADDR
31
32 RTM_NEWROUTE = 24,
33#define RTM_NEWROUTE RTM_NEWROUTE
34 RTM_DELROUTE,
35#define RTM_DELROUTE RTM_DELROUTE
36 RTM_GETROUTE,
37#define RTM_GETROUTE RTM_GETROUTE
38
39 RTM_NEWNEIGH = 28,
40#define RTM_NEWNEIGH RTM_NEWNEIGH
41 RTM_DELNEIGH,
42#define RTM_DELNEIGH RTM_DELNEIGH
43 RTM_GETNEIGH,
44#define RTM_GETNEIGH RTM_GETNEIGH
45
46 RTM_NEWRULE = 32,
47#define RTM_NEWRULE RTM_NEWRULE
48 RTM_DELRULE,
49#define RTM_DELRULE RTM_DELRULE
50 RTM_GETRULE,
51#define RTM_GETRULE RTM_GETRULE
52
53 RTM_NEWQDISC = 36,
54#define RTM_NEWQDISC RTM_NEWQDISC
55 RTM_DELQDISC,
56#define RTM_DELQDISC RTM_DELQDISC
57 RTM_GETQDISC,
58#define RTM_GETQDISC RTM_GETQDISC
59
60 RTM_NEWTCLASS = 40,
61#define RTM_NEWTCLASS RTM_NEWTCLASS
62 RTM_DELTCLASS,
63#define RTM_DELTCLASS RTM_DELTCLASS
64 RTM_GETTCLASS,
65#define RTM_GETTCLASS RTM_GETTCLASS
66
67 RTM_NEWTFILTER = 44,
68#define RTM_NEWTFILTER RTM_NEWTFILTER
69 RTM_DELTFILTER,
70#define RTM_DELTFILTER RTM_DELTFILTER
71 RTM_GETTFILTER,
72#define RTM_GETTFILTER RTM_GETTFILTER
73
74 RTM_NEWACTION = 48,
75#define RTM_NEWACTION RTM_NEWACTION
76 RTM_DELACTION,
77#define RTM_DELACTION RTM_DELACTION
78 RTM_GETACTION,
79#define RTM_GETACTION RTM_GETACTION
80
81 RTM_NEWPREFIX = 52,
82#define RTM_NEWPREFIX RTM_NEWPREFIX
83 RTM_GETPREFIX = 54,
84#define RTM_GETPREFIX RTM_GETPREFIX
85
86 RTM_GETMULTICAST = 58,
87#define RTM_GETMULTICAST RTM_GETMULTICAST
88
89 RTM_GETANYCAST = 62,
90#define RTM_GETANYCAST RTM_GETANYCAST
91
Thomas Grafc7fb64d2005-06-18 22:50:55 -070092 RTM_NEWNEIGHTBL = 64,
93#define RTM_NEWNEIGHTBL RTM_NEWNEIGHTBL
94 RTM_GETNEIGHTBL = 66,
95#define RTM_GETNEIGHTBL RTM_GETNEIGHTBL
96 RTM_SETNEIGHTBL,
97#define RTM_SETNEIGHTBL RTM_SETNEIGHTBL
98
Thomas Grafd775fc02005-05-03 14:27:35 -070099 __RTM_MAX,
100#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101};
102
Thomas Grafdb46edc2005-05-03 14:29:39 -0700103#define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
104#define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
Thomas Graff90a0a72005-05-03 14:29:00 -0700105#define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107/*
108 Generic structure for encapsulation of optional route information.
109 It is reminiscent of sockaddr, but with sa_family replaced
110 with attribute type.
111 */
112
113struct rtattr
114{
115 unsigned short rta_len;
116 unsigned short rta_type;
117};
118
119/* Macros to handle rtattributes */
120
121#define RTA_ALIGNTO 4
122#define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
123#define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \
124 (rta)->rta_len >= sizeof(struct rtattr) && \
125 (rta)->rta_len <= (len))
126#define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
127 (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
128#define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
129#define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len))
130#define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
131#define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
132
133
134
135
136/******************************************************************************
137 * Definitions used in routing table administration.
138 ****/
139
140struct rtmsg
141{
142 unsigned char rtm_family;
143 unsigned char rtm_dst_len;
144 unsigned char rtm_src_len;
145 unsigned char rtm_tos;
146
147 unsigned char rtm_table; /* Routing table id */
148 unsigned char rtm_protocol; /* Routing protocol; see below */
149 unsigned char rtm_scope; /* See below */
150 unsigned char rtm_type; /* See below */
151
152 unsigned rtm_flags;
153};
154
155/* rtm_type */
156
157enum
158{
159 RTN_UNSPEC,
160 RTN_UNICAST, /* Gateway or direct route */
161 RTN_LOCAL, /* Accept locally */
162 RTN_BROADCAST, /* Accept locally as broadcast,
163 send as broadcast */
164 RTN_ANYCAST, /* Accept locally as broadcast,
165 but send as unicast */
166 RTN_MULTICAST, /* Multicast route */
167 RTN_BLACKHOLE, /* Drop */
168 RTN_UNREACHABLE, /* Destination is unreachable */
169 RTN_PROHIBIT, /* Administratively prohibited */
170 RTN_THROW, /* Not in this table */
171 RTN_NAT, /* Translate this address */
172 RTN_XRESOLVE, /* Use external resolver */
173 __RTN_MAX
174};
175
176#define RTN_MAX (__RTN_MAX - 1)
177
178
179/* rtm_protocol */
180
181#define RTPROT_UNSPEC 0
182#define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects;
183 not used by current IPv4 */
184#define RTPROT_KERNEL 2 /* Route installed by kernel */
185#define RTPROT_BOOT 3 /* Route installed during boot */
186#define RTPROT_STATIC 4 /* Route installed by administrator */
187
188/* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
189 they are just passed from user and back as is.
190 It will be used by hypothetical multiple routing daemons.
191 Note that protocol values should be standardized in order to
192 avoid conflicts.
193 */
194
195#define RTPROT_GATED 8 /* Apparently, GateD */
196#define RTPROT_RA 9 /* RDISC/ND router advertisements */
197#define RTPROT_MRT 10 /* Merit MRT */
198#define RTPROT_ZEBRA 11 /* Zebra */
199#define RTPROT_BIRD 12 /* BIRD */
200#define RTPROT_DNROUTED 13 /* DECnet routing daemon */
201#define RTPROT_XORP 14 /* XORP */
Alpt99cae7f2006-03-20 22:26:17 -0800202#define RTPROT_NTK 15 /* Netsukuku */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
204/* rtm_scope
205
206 Really it is not scope, but sort of distance to the destination.
207 NOWHERE are reserved for not existing destinations, HOST is our
208 local addresses, LINK are destinations, located on directly attached
209 link and UNIVERSE is everywhere in the Universe.
210
211 Intermediate values are also possible f.e. interior routes
212 could be assigned a value between UNIVERSE and LINK.
213*/
214
215enum rt_scope_t
216{
217 RT_SCOPE_UNIVERSE=0,
218/* User defined values */
219 RT_SCOPE_SITE=200,
220 RT_SCOPE_LINK=253,
221 RT_SCOPE_HOST=254,
222 RT_SCOPE_NOWHERE=255
223};
224
225/* rtm_flags */
226
227#define RTM_F_NOTIFY 0x100 /* Notify user of route change */
228#define RTM_F_CLONED 0x200 /* This route is cloned */
229#define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */
230#define RTM_F_PREFIX 0x800 /* Prefix addresses */
231
232/* Reserved table identifiers */
233
234enum rt_class_t
235{
236 RT_TABLE_UNSPEC=0,
237/* User defined values */
238 RT_TABLE_DEFAULT=253,
239 RT_TABLE_MAIN=254,
240 RT_TABLE_LOCAL=255,
241 __RT_TABLE_MAX
242};
243#define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
244
245
246
247/* Routing message attributes */
248
249enum rtattr_type_t
250{
251 RTA_UNSPEC,
252 RTA_DST,
253 RTA_SRC,
254 RTA_IIF,
255 RTA_OIF,
256 RTA_GATEWAY,
257 RTA_PRIORITY,
258 RTA_PREFSRC,
259 RTA_METRICS,
260 RTA_MULTIPATH,
261 RTA_PROTOINFO,
262 RTA_FLOW,
263 RTA_CACHEINFO,
264 RTA_SESSION,
265 RTA_MP_ALGO,
266 __RTA_MAX
267};
268
269#define RTA_MAX (__RTA_MAX - 1)
270
271#define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
272#define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
273
274/* RTM_MULTIPATH --- array of struct rtnexthop.
275 *
276 * "struct rtnexthop" describes all necessary nexthop information,
277 * i.e. parameters of path to a destination via this nexthop.
278 *
279 * At the moment it is impossible to set different prefsrc, mtu, window
280 * and rtt for different paths from multipath.
281 */
282
283struct rtnexthop
284{
285 unsigned short rtnh_len;
286 unsigned char rtnh_flags;
287 unsigned char rtnh_hops;
288 int rtnh_ifindex;
289};
290
291/* rtnh_flags */
292
293#define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
294#define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
295#define RTNH_F_ONLINK 4 /* Gateway is forced on link */
296
297/* Macros to handle hexthops */
298
299#define RTNH_ALIGNTO 4
300#define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
301#define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
302 ((int)(rtnh)->rtnh_len) <= (len))
303#define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
304#define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
305#define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
306#define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
307
308/* RTM_CACHEINFO */
309
310struct rta_cacheinfo
311{
312 __u32 rta_clntref;
313 __u32 rta_lastuse;
314 __s32 rta_expires;
315 __u32 rta_error;
316 __u32 rta_used;
317
318#define RTNETLINK_HAVE_PEERINFO 1
319 __u32 rta_id;
320 __u32 rta_ts;
321 __u32 rta_tsage;
322};
323
324/* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
325
326enum
327{
328 RTAX_UNSPEC,
329#define RTAX_UNSPEC RTAX_UNSPEC
330 RTAX_LOCK,
331#define RTAX_LOCK RTAX_LOCK
332 RTAX_MTU,
333#define RTAX_MTU RTAX_MTU
334 RTAX_WINDOW,
335#define RTAX_WINDOW RTAX_WINDOW
336 RTAX_RTT,
337#define RTAX_RTT RTAX_RTT
338 RTAX_RTTVAR,
339#define RTAX_RTTVAR RTAX_RTTVAR
340 RTAX_SSTHRESH,
341#define RTAX_SSTHRESH RTAX_SSTHRESH
342 RTAX_CWND,
343#define RTAX_CWND RTAX_CWND
344 RTAX_ADVMSS,
345#define RTAX_ADVMSS RTAX_ADVMSS
346 RTAX_REORDERING,
347#define RTAX_REORDERING RTAX_REORDERING
348 RTAX_HOPLIMIT,
349#define RTAX_HOPLIMIT RTAX_HOPLIMIT
350 RTAX_INITCWND,
351#define RTAX_INITCWND RTAX_INITCWND
352 RTAX_FEATURES,
353#define RTAX_FEATURES RTAX_FEATURES
354 __RTAX_MAX
355};
356
357#define RTAX_MAX (__RTAX_MAX - 1)
358
359#define RTAX_FEATURE_ECN 0x00000001
360#define RTAX_FEATURE_SACK 0x00000002
361#define RTAX_FEATURE_TIMESTAMP 0x00000004
362#define RTAX_FEATURE_ALLFRAG 0x00000008
363
364struct rta_session
365{
366 __u8 proto;
Patrick McHardy8a470772005-06-28 12:56:45 -0700367 __u8 pad1;
368 __u16 pad2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369
370 union {
371 struct {
372 __u16 sport;
373 __u16 dport;
374 } ports;
375
376 struct {
377 __u8 type;
378 __u8 code;
379 __u16 ident;
380 } icmpt;
381
382 __u32 spi;
383 } u;
384};
385
386
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
388/**************************************************************
389 * Neighbour discovery.
390 ****/
391
392struct ndmsg
393{
394 unsigned char ndm_family;
395 unsigned char ndm_pad1;
396 unsigned short ndm_pad2;
397 int ndm_ifindex; /* Link index */
398 __u16 ndm_state;
399 __u8 ndm_flags;
400 __u8 ndm_type;
401};
402
403enum
404{
405 NDA_UNSPEC,
406 NDA_DST,
407 NDA_LLADDR,
408 NDA_CACHEINFO,
409 NDA_PROBES,
410 __NDA_MAX
411};
412
413#define NDA_MAX (__NDA_MAX - 1)
414
415#define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
416#define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
417
418/*
419 * Neighbor Cache Entry Flags
420 */
421
422#define NTF_PROXY 0x08 /* == ATF_PUBL */
423#define NTF_ROUTER 0x80
424
425/*
426 * Neighbor Cache Entry States.
427 */
428
429#define NUD_INCOMPLETE 0x01
430#define NUD_REACHABLE 0x02
431#define NUD_STALE 0x04
432#define NUD_DELAY 0x08
433#define NUD_PROBE 0x10
434#define NUD_FAILED 0x20
435
436/* Dummy states */
437#define NUD_NOARP 0x40
438#define NUD_PERMANENT 0x80
439#define NUD_NONE 0x00
440
441
442struct nda_cacheinfo
443{
444 __u32 ndm_confirmed;
445 __u32 ndm_used;
446 __u32 ndm_updated;
447 __u32 ndm_refcnt;
448};
449
Thomas Grafc7fb64d2005-06-18 22:50:55 -0700450
451/*****************************************************************
452 * Neighbour tables specific messages.
453 *
454 * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
455 * NLM_F_DUMP flag set. Every neighbour table configuration is
456 * spread over multiple messages to avoid running into message
457 * size limits on systems with many interfaces. The first message
458 * in the sequence transports all not device specific data such as
459 * statistics, configuration, and the default parameter set.
460 * This message is followed by 0..n messages carrying device
461 * specific parameter sets.
462 * Although the ordering should be sufficient, NDTA_NAME can be
463 * used to identify sequences. The initial message can be identified
464 * by checking for NDTA_CONFIG. The device specific messages do
465 * not contain this TLV but have NDTPA_IFINDEX set to the
466 * corresponding interface index.
467 *
468 * To change neighbour table attributes, send RTM_SETNEIGHTBL
469 * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
470 * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
471 * otherwise. Device specific parameter sets can be changed by
472 * setting NDTPA_IFINDEX to the interface index of the corresponding
473 * device.
474 ****/
475
476struct ndt_stats
477{
478 __u64 ndts_allocs;
479 __u64 ndts_destroys;
480 __u64 ndts_hash_grows;
481 __u64 ndts_res_failed;
482 __u64 ndts_lookups;
483 __u64 ndts_hits;
484 __u64 ndts_rcv_probes_mcast;
485 __u64 ndts_rcv_probes_ucast;
486 __u64 ndts_periodic_gc_runs;
487 __u64 ndts_forced_gc_runs;
488};
489
490enum {
491 NDTPA_UNSPEC,
492 NDTPA_IFINDEX, /* u32, unchangeable */
493 NDTPA_REFCNT, /* u32, read-only */
494 NDTPA_REACHABLE_TIME, /* u64, read-only, msecs */
495 NDTPA_BASE_REACHABLE_TIME, /* u64, msecs */
496 NDTPA_RETRANS_TIME, /* u64, msecs */
497 NDTPA_GC_STALETIME, /* u64, msecs */
498 NDTPA_DELAY_PROBE_TIME, /* u64, msecs */
499 NDTPA_QUEUE_LEN, /* u32 */
500 NDTPA_APP_PROBES, /* u32 */
501 NDTPA_UCAST_PROBES, /* u32 */
502 NDTPA_MCAST_PROBES, /* u32 */
503 NDTPA_ANYCAST_DELAY, /* u64, msecs */
504 NDTPA_PROXY_DELAY, /* u64, msecs */
505 NDTPA_PROXY_QLEN, /* u32 */
506 NDTPA_LOCKTIME, /* u64, msecs */
507 __NDTPA_MAX
508};
509#define NDTPA_MAX (__NDTPA_MAX - 1)
510
511struct ndtmsg
512{
513 __u8 ndtm_family;
514 __u8 ndtm_pad1;
515 __u16 ndtm_pad2;
516};
517
518struct ndt_config
519{
520 __u16 ndtc_key_len;
521 __u16 ndtc_entry_size;
522 __u32 ndtc_entries;
523 __u32 ndtc_last_flush; /* delta to now in msecs */
524 __u32 ndtc_last_rand; /* delta to now in msecs */
525 __u32 ndtc_hash_rnd;
526 __u32 ndtc_hash_mask;
527 __u32 ndtc_hash_chain_gc;
528 __u32 ndtc_proxy_qlen;
529};
530
531enum {
532 NDTA_UNSPEC,
533 NDTA_NAME, /* char *, unchangeable */
534 NDTA_THRESH1, /* u32 */
535 NDTA_THRESH2, /* u32 */
536 NDTA_THRESH3, /* u32 */
537 NDTA_CONFIG, /* struct ndt_config, read-only */
538 NDTA_PARMS, /* nested TLV NDTPA_* */
539 NDTA_STATS, /* struct ndt_stats, read-only */
540 NDTA_GC_INTERVAL, /* u64, msecs */
541 __NDTA_MAX
542};
543#define NDTA_MAX (__NDTA_MAX - 1)
544
545#define NDTA_RTA(r) ((struct rtattr*)(((char*)(r)) + \
546 NLMSG_ALIGN(sizeof(struct ndtmsg))))
547#define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))
548
549
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550/****
551 * General form of address family dependent message.
552 ****/
553
554struct rtgenmsg
555{
556 unsigned char rtgen_family;
557};
558
559/*****************************************************************
560 * Link layer specific messages.
561 ****/
562
563/* struct ifinfomsg
564 * passes link level specific information, not dependent
565 * on network protocol.
566 */
567
568struct ifinfomsg
569{
570 unsigned char ifi_family;
571 unsigned char __ifi_pad;
572 unsigned short ifi_type; /* ARPHRD_* */
573 int ifi_index; /* Link index */
574 unsigned ifi_flags; /* IFF_* flags */
575 unsigned ifi_change; /* IFF_* change mask */
576};
577
578/********************************************************************
579 * prefix information
580 ****/
581
582struct prefixmsg
583{
584 unsigned char prefix_family;
Patrick McHardy8a470772005-06-28 12:56:45 -0700585 unsigned char prefix_pad1;
586 unsigned short prefix_pad2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 int prefix_ifindex;
588 unsigned char prefix_type;
589 unsigned char prefix_len;
590 unsigned char prefix_flags;
Patrick McHardy8a470772005-06-28 12:56:45 -0700591 unsigned char prefix_pad3;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592};
593
594enum
595{
596 PREFIX_UNSPEC,
597 PREFIX_ADDRESS,
598 PREFIX_CACHEINFO,
599 __PREFIX_MAX
600};
601
602#define PREFIX_MAX (__PREFIX_MAX - 1)
603
604struct prefix_cacheinfo
605{
606 __u32 preferred_time;
607 __u32 valid_time;
608};
609
610/* The struct should be in sync with struct net_device_stats */
611struct rtnl_link_stats
612{
613 __u32 rx_packets; /* total packets received */
614 __u32 tx_packets; /* total packets transmitted */
615 __u32 rx_bytes; /* total bytes received */
616 __u32 tx_bytes; /* total bytes transmitted */
617 __u32 rx_errors; /* bad packets received */
618 __u32 tx_errors; /* packet transmit problems */
619 __u32 rx_dropped; /* no space in linux buffers */
620 __u32 tx_dropped; /* no space available in linux */
621 __u32 multicast; /* multicast packets received */
622 __u32 collisions;
623
624 /* detailed rx_errors: */
625 __u32 rx_length_errors;
626 __u32 rx_over_errors; /* receiver ring buff overflow */
627 __u32 rx_crc_errors; /* recved pkt with crc error */
628 __u32 rx_frame_errors; /* recv'd frame alignment error */
629 __u32 rx_fifo_errors; /* recv'r fifo overrun */
630 __u32 rx_missed_errors; /* receiver missed packet */
631
632 /* detailed tx_errors */
633 __u32 tx_aborted_errors;
634 __u32 tx_carrier_errors;
635 __u32 tx_fifo_errors;
636 __u32 tx_heartbeat_errors;
637 __u32 tx_window_errors;
638
639 /* for cslip etc */
640 __u32 rx_compressed;
641 __u32 tx_compressed;
642};
643
644/* The struct should be in sync with struct ifmap */
645struct rtnl_link_ifmap
646{
647 __u64 mem_start;
648 __u64 mem_end;
649 __u64 base_addr;
650 __u16 irq;
651 __u8 dma;
652 __u8 port;
653};
654
655enum
656{
657 IFLA_UNSPEC,
658 IFLA_ADDRESS,
659 IFLA_BROADCAST,
660 IFLA_IFNAME,
661 IFLA_MTU,
662 IFLA_LINK,
663 IFLA_QDISC,
664 IFLA_STATS,
665 IFLA_COST,
666#define IFLA_COST IFLA_COST
667 IFLA_PRIORITY,
668#define IFLA_PRIORITY IFLA_PRIORITY
669 IFLA_MASTER,
670#define IFLA_MASTER IFLA_MASTER
671 IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */
672#define IFLA_WIRELESS IFLA_WIRELESS
673 IFLA_PROTINFO, /* Protocol specific information for a link */
674#define IFLA_PROTINFO IFLA_PROTINFO
675 IFLA_TXQLEN,
676#define IFLA_TXQLEN IFLA_TXQLEN
677 IFLA_MAP,
678#define IFLA_MAP IFLA_MAP
679 IFLA_WEIGHT,
680#define IFLA_WEIGHT IFLA_WEIGHT
Stefan Rompfb00055a2006-03-20 17:09:11 -0800681 IFLA_OPERSTATE,
682 IFLA_LINKMODE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 __IFLA_MAX
684};
685
686
687#define IFLA_MAX (__IFLA_MAX - 1)
688
689#define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
690#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
691
692/* ifi_flags.
693
694 IFF_* flags.
695
696 The only change is:
697 IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
698 more not changeable by user. They describe link media
699 characteristics and set by device driver.
700
701 Comments:
702 - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
703 - If neither of these three flags are set;
704 the interface is NBMA.
705
706 - IFF_MULTICAST does not mean anything special:
707 multicasts can be used on all not-NBMA links.
708 IFF_MULTICAST means that this media uses special encapsulation
709 for multicast frames. Apparently, all IFF_POINTOPOINT and
710 IFF_BROADCAST devices are able to use multicasts too.
711 */
712
713/* IFLA_LINK.
714 For usual devices it is equal ifi_index.
715 If it is a "virtual interface" (f.e. tunnel), ifi_link
716 can point to real physical interface (f.e. for bandwidth calculations),
717 or maybe 0, what means, that real media is unknown (usual
718 for IPIP tunnels, when route to endpoint is allowed to change)
719 */
720
721/* Subtype attributes for IFLA_PROTINFO */
722enum
723{
724 IFLA_INET6_UNSPEC,
725 IFLA_INET6_FLAGS, /* link flags */
726 IFLA_INET6_CONF, /* sysctl parameters */
727 IFLA_INET6_STATS, /* statistics */
728 IFLA_INET6_MCAST, /* MC things. What of them? */
729 IFLA_INET6_CACHEINFO, /* time values and max reasm size */
730 __IFLA_INET6_MAX
731};
732
733#define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
734
735struct ifla_cacheinfo
736{
737 __u32 max_reasm_len;
738 __u32 tstamp; /* ipv6InterfaceTable updated timestamp */
739 __u32 reachable_time;
740 __u32 retrans_time;
741};
742
743/*****************************************************************
744 * Traffic control messages.
745 ****/
746
747struct tcmsg
748{
749 unsigned char tcm_family;
750 unsigned char tcm__pad1;
751 unsigned short tcm__pad2;
752 int tcm_ifindex;
753 __u32 tcm_handle;
754 __u32 tcm_parent;
755 __u32 tcm_info;
756};
757
758enum
759{
760 TCA_UNSPEC,
761 TCA_KIND,
762 TCA_OPTIONS,
763 TCA_STATS,
764 TCA_XSTATS,
765 TCA_RATE,
766 TCA_FCNT,
767 TCA_STATS2,
768 __TCA_MAX
769};
770
771#define TCA_MAX (__TCA_MAX - 1)
772
773#define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
774#define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
775
Patrick McHardyac6d4392005-08-14 19:29:52 -0700776#ifndef __KERNEL__
777/* RTnetlink multicast groups - backwards compatibility for userspace */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778#define RTMGRP_LINK 1
779#define RTMGRP_NOTIFY 2
780#define RTMGRP_NEIGH 4
781#define RTMGRP_TC 8
782
783#define RTMGRP_IPV4_IFADDR 0x10
784#define RTMGRP_IPV4_MROUTE 0x20
785#define RTMGRP_IPV4_ROUTE 0x40
Patrick McHardya5cdc032006-03-23 01:16:06 -0800786#define RTMGRP_IPV4_RULE 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787
788#define RTMGRP_IPV6_IFADDR 0x100
789#define RTMGRP_IPV6_MROUTE 0x200
790#define RTMGRP_IPV6_ROUTE 0x400
791#define RTMGRP_IPV6_IFINFO 0x800
792
793#define RTMGRP_DECnet_IFADDR 0x1000
794#define RTMGRP_DECnet_ROUTE 0x4000
795
796#define RTMGRP_IPV6_PREFIX 0x20000
Patrick McHardyac6d4392005-08-14 19:29:52 -0700797#endif
798
799/* RTnetlink multicast groups */
800enum rtnetlink_groups {
801 RTNLGRP_NONE,
802#define RTNLGRP_NONE RTNLGRP_NONE
803 RTNLGRP_LINK,
804#define RTNLGRP_LINK RTNLGRP_LINK
805 RTNLGRP_NOTIFY,
806#define RTNLGRP_NOTIFY RTNLGRP_NOTIFY
807 RTNLGRP_NEIGH,
808#define RTNLGRP_NEIGH RTNLGRP_NEIGH
809 RTNLGRP_TC,
810#define RTNLGRP_TC RTNLGRP_TC
811 RTNLGRP_IPV4_IFADDR,
812#define RTNLGRP_IPV4_IFADDR RTNLGRP_IPV4_IFADDR
813 RTNLGRP_IPV4_MROUTE,
814#define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
815 RTNLGRP_IPV4_ROUTE,
816#define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
Patrick McHardya5cdc032006-03-23 01:16:06 -0800817 RTNLGRP_IPV4_RULE,
818#define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
Patrick McHardyac6d4392005-08-14 19:29:52 -0700819 RTNLGRP_IPV6_IFADDR,
820#define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
821 RTNLGRP_IPV6_MROUTE,
822#define RTNLGRP_IPV6_MROUTE RTNLGRP_IPV6_MROUTE
823 RTNLGRP_IPV6_ROUTE,
824#define RTNLGRP_IPV6_ROUTE RTNLGRP_IPV6_ROUTE
825 RTNLGRP_IPV6_IFINFO,
826#define RTNLGRP_IPV6_IFINFO RTNLGRP_IPV6_IFINFO
827 RTNLGRP_DECnet_IFADDR,
828#define RTNLGRP_DECnet_IFADDR RTNLGRP_DECnet_IFADDR
Kristian Slavov6b80ebe2005-12-19 13:54:44 -0800829 RTNLGRP_NOP2,
Patrick McHardyac6d4392005-08-14 19:29:52 -0700830 RTNLGRP_DECnet_ROUTE,
831#define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE
Kristian Slavov6b80ebe2005-12-19 13:54:44 -0800832 RTNLGRP_NOP3,
833 RTNLGRP_NOP4,
Patrick McHardyac6d4392005-08-14 19:29:52 -0700834 RTNLGRP_IPV6_PREFIX,
835#define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX
Thomas Graf101367c2006-08-04 03:39:02 -0700836 RTNLGRP_IPV6_RULE,
837#define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE
Patrick McHardyac6d4392005-08-14 19:29:52 -0700838 __RTNLGRP_MAX
839};
840#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841
842/* TC action piece */
843struct tcamsg
844{
845 unsigned char tca_family;
846 unsigned char tca__pad1;
847 unsigned short tca__pad2;
848};
849#define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
850#define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
851#define TCA_ACT_TAB 1 /* attr type must be >=1 */
852#define TCAA_MAX 1
853
854/* End of information exported to user level */
855
856#ifdef __KERNEL__
857
Stephen Hemminger6756ae42006-03-20 22:23:58 -0800858#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859
860extern size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size);
861static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
862{
863 int len = strlen(str) + 1;
864 return len > rta->rta_len || memcmp(RTA_DATA(rta), str, len);
865}
866
867extern int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len);
868
869#define rtattr_parse_nested(tb, max, rta) \
870 rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta)))
871
872extern struct sock *rtnl;
873
874struct rtnetlink_link
875{
876 int (*doit)(struct sk_buff *, struct nlmsghdr*, void *attr);
877 int (*dumpit)(struct sk_buff *, struct netlink_callback *cb);
878};
879
880extern struct rtnetlink_link * rtnetlink_links[NPROTO];
881extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo);
882extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
883
884extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);
885
886#define RTA_PUT(skb, attrtype, attrlen, data) \
887({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
888 goto rtattr_failure; \
889 __rta_fill(skb, attrtype, attrlen, data); })
890
Thomas Grafd675c982005-06-23 21:00:58 -0700891#define RTA_APPEND(skb, attrlen, data) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892({ if (unlikely(skb_tailroom(skb) < (int)(attrlen))) \
893 goto rtattr_failure; \
Thomas Grafd675c982005-06-23 21:00:58 -0700894 memcpy(skb_put(skb, attrlen), data, attrlen); })
895
896#define RTA_PUT_NOHDR(skb, attrlen, data) \
Patrick McHardyb3563c42005-06-28 12:54:43 -0700897({ RTA_APPEND(skb, RTA_ALIGN(attrlen), data); \
898 memset(skb->tail - (RTA_ALIGN(attrlen) - attrlen), 0, \
899 RTA_ALIGN(attrlen) - attrlen); })
Thomas Graf00768242005-06-18 22:50:38 -0700900
Thomas Graf8f48bcd2005-06-18 22:52:36 -0700901#define RTA_PUT_U8(skb, attrtype, value) \
902({ u8 _tmp = (value); \
903 RTA_PUT(skb, attrtype, sizeof(u8), &_tmp); })
904
905#define RTA_PUT_U16(skb, attrtype, value) \
906({ u16 _tmp = (value); \
907 RTA_PUT(skb, attrtype, sizeof(u16), &_tmp); })
908
Thomas Graf00768242005-06-18 22:50:38 -0700909#define RTA_PUT_U32(skb, attrtype, value) \
910({ u32 _tmp = (value); \
911 RTA_PUT(skb, attrtype, sizeof(u32), &_tmp); })
912
913#define RTA_PUT_U64(skb, attrtype, value) \
914({ u64 _tmp = (value); \
915 RTA_PUT(skb, attrtype, sizeof(u64), &_tmp); })
916
917#define RTA_PUT_SECS(skb, attrtype, value) \
918 RTA_PUT_U64(skb, attrtype, (value) / HZ)
919
920#define RTA_PUT_MSECS(skb, attrtype, value) \
921 RTA_PUT_U64(skb, attrtype, jiffies_to_msecs(value))
922
923#define RTA_PUT_STRING(skb, attrtype, value) \
924 RTA_PUT(skb, attrtype, strlen(value) + 1, value)
925
Thomas Graf8f48bcd2005-06-18 22:52:36 -0700926#define RTA_PUT_FLAG(skb, attrtype) \
927 RTA_PUT(skb, attrtype, 0, NULL);
928
Thomas Graf00768242005-06-18 22:50:38 -0700929#define RTA_NEST(skb, type) \
930({ struct rtattr *__start = (struct rtattr *) (skb)->tail; \
931 RTA_PUT(skb, type, 0, NULL); \
932 __start; })
933
934#define RTA_NEST_END(skb, start) \
935({ (start)->rta_len = ((skb)->tail - (unsigned char *) (start)); \
936 (skb)->len; })
937
938#define RTA_NEST_CANCEL(skb, start) \
Thomas Grafc52a3f82005-06-18 22:51:26 -0700939({ if (start) \
940 skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
Thomas Graf00768242005-06-18 22:50:38 -0700941 -1; })
942
Thomas Graf8f48bcd2005-06-18 22:52:36 -0700943#define RTA_GET_U8(rta) \
944({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u8)) \
945 goto rtattr_failure; \
946 *(u8 *) RTA_DATA(rta); })
947
948#define RTA_GET_U16(rta) \
949({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u16)) \
950 goto rtattr_failure; \
951 *(u16 *) RTA_DATA(rta); })
952
Thomas Graf00768242005-06-18 22:50:38 -0700953#define RTA_GET_U32(rta) \
954({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u32)) \
955 goto rtattr_failure; \
956 *(u32 *) RTA_DATA(rta); })
957
958#define RTA_GET_U64(rta) \
959({ u64 _tmp; \
960 if (!rta || RTA_PAYLOAD(rta) < sizeof(u64)) \
961 goto rtattr_failure; \
962 memcpy(&_tmp, RTA_DATA(rta), sizeof(_tmp)); \
963 _tmp; })
964
Thomas Graf8f48bcd2005-06-18 22:52:36 -0700965#define RTA_GET_FLAG(rta) (!!(rta))
966
Thomas Graf00768242005-06-18 22:50:38 -0700967#define RTA_GET_SECS(rta) ((unsigned long) RTA_GET_U64(rta) * HZ)
968#define RTA_GET_MSECS(rta) (msecs_to_jiffies((unsigned long) RTA_GET_U64(rta)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969
970static inline struct rtattr *
971__rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
972{
973 struct rtattr *rta;
974 int size = RTA_LENGTH(attrlen);
975
976 rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
977 rta->rta_type = attrtype;
978 rta->rta_len = size;
Patrick McHardyb3563c42005-06-28 12:54:43 -0700979 memset(RTA_DATA(rta) + attrlen, 0, RTA_ALIGN(size) - size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 return rta;
981}
982
983#define __RTA_PUT(skb, attrtype, attrlen) \
984({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
985 goto rtattr_failure; \
986 __rta_reserve(skb, attrtype, attrlen); })
987
988extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
989
Stephen Hemminger6756ae42006-03-20 22:23:58 -0800990/* RTNL is used as a global lock for all changes to network configuration */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991extern void rtnl_lock(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992extern void rtnl_unlock(void);
Stephen Hemminger6756ae42006-03-20 22:23:58 -0800993extern int rtnl_trylock(void);
994
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995extern void rtnetlink_init(void);
Stephen Hemminger6756ae42006-03-20 22:23:58 -0800996extern void __rtnl_unlock(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997
998#define ASSERT_RTNL() do { \
Stephen Hemminger6756ae42006-03-20 22:23:58 -0800999 if (unlikely(rtnl_trylock())) { \
1000 rtnl_unlock(); \
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
1002 __FILE__, __LINE__); \
1003 dump_stack(); \
1004 } \
1005} while(0)
1006
1007#define BUG_TRAP(x) do { \
1008 if (unlikely(!(x))) { \
1009 printk(KERN_ERR "KERNEL: assertion (%s) failed at %s (%d)\n", \
1010 #x, __FILE__ , __LINE__); \
1011 } \
1012} while(0)
1013
1014#endif /* __KERNEL__ */
1015
1016
1017#endif /* __LINUX_RTNETLINK_H */