Automatic merge of rsync://rsync.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2...
[sfrench/cifs-2.6.git] / include / linux / rtnetlink.h
1 #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
12 enum {
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
92         __RTM_MAX,
93 #define RTM_MAX         (((__RTM_MAX + 3) & ~3) - 1)
94 };
95
96 #define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
97 #define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
98 #define RTM_FAM(cmd)    (((cmd) - RTM_BASE) >> 2)
99
100 /* 
101    Generic structure for encapsulation of optional route information.
102    It is reminiscent of sockaddr, but with sa_family replaced
103    with attribute type.
104  */
105
106 struct rtattr
107 {
108         unsigned short  rta_len;
109         unsigned short  rta_type;
110 };
111
112 /* Macros to handle rtattributes */
113
114 #define RTA_ALIGNTO     4
115 #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
116 #define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \
117                          (rta)->rta_len >= sizeof(struct rtattr) && \
118                          (rta)->rta_len <= (len))
119 #define RTA_NEXT(rta,attrlen)   ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
120                                  (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
121 #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
122 #define RTA_SPACE(len)  RTA_ALIGN(RTA_LENGTH(len))
123 #define RTA_DATA(rta)   ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
124 #define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
125
126
127
128
129 /******************************************************************************
130  *              Definitions used in routing table administration.
131  ****/
132
133 struct rtmsg
134 {
135         unsigned char           rtm_family;
136         unsigned char           rtm_dst_len;
137         unsigned char           rtm_src_len;
138         unsigned char           rtm_tos;
139
140         unsigned char           rtm_table;      /* Routing table id */
141         unsigned char           rtm_protocol;   /* Routing protocol; see below  */
142         unsigned char           rtm_scope;      /* See below */ 
143         unsigned char           rtm_type;       /* See below    */
144
145         unsigned                rtm_flags;
146 };
147
148 /* rtm_type */
149
150 enum
151 {
152         RTN_UNSPEC,
153         RTN_UNICAST,            /* Gateway or direct route      */
154         RTN_LOCAL,              /* Accept locally               */
155         RTN_BROADCAST,          /* Accept locally as broadcast,
156                                    send as broadcast */
157         RTN_ANYCAST,            /* Accept locally as broadcast,
158                                    but send as unicast */
159         RTN_MULTICAST,          /* Multicast route              */
160         RTN_BLACKHOLE,          /* Drop                         */
161         RTN_UNREACHABLE,        /* Destination is unreachable   */
162         RTN_PROHIBIT,           /* Administratively prohibited  */
163         RTN_THROW,              /* Not in this table            */
164         RTN_NAT,                /* Translate this address       */
165         RTN_XRESOLVE,           /* Use external resolver        */
166         __RTN_MAX
167 };
168
169 #define RTN_MAX (__RTN_MAX - 1)
170
171
172 /* rtm_protocol */
173
174 #define RTPROT_UNSPEC   0
175 #define RTPROT_REDIRECT 1       /* Route installed by ICMP redirects;
176                                    not used by current IPv4 */
177 #define RTPROT_KERNEL   2       /* Route installed by kernel            */
178 #define RTPROT_BOOT     3       /* Route installed during boot          */
179 #define RTPROT_STATIC   4       /* Route installed by administrator     */
180
181 /* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
182    they are just passed from user and back as is.
183    It will be used by hypothetical multiple routing daemons.
184    Note that protocol values should be standardized in order to
185    avoid conflicts.
186  */
187
188 #define RTPROT_GATED    8       /* Apparently, GateD */
189 #define RTPROT_RA       9       /* RDISC/ND router advertisements */
190 #define RTPROT_MRT      10      /* Merit MRT */
191 #define RTPROT_ZEBRA    11      /* Zebra */
192 #define RTPROT_BIRD     12      /* BIRD */
193 #define RTPROT_DNROUTED 13      /* DECnet routing daemon */
194 #define RTPROT_XORP     14      /* XORP */
195
196 /* rtm_scope
197
198    Really it is not scope, but sort of distance to the destination.
199    NOWHERE are reserved for not existing destinations, HOST is our
200    local addresses, LINK are destinations, located on directly attached
201    link and UNIVERSE is everywhere in the Universe.
202
203    Intermediate values are also possible f.e. interior routes
204    could be assigned a value between UNIVERSE and LINK.
205 */
206
207 enum rt_scope_t
208 {
209         RT_SCOPE_UNIVERSE=0,
210 /* User defined values  */
211         RT_SCOPE_SITE=200,
212         RT_SCOPE_LINK=253,
213         RT_SCOPE_HOST=254,
214         RT_SCOPE_NOWHERE=255
215 };
216
217 /* rtm_flags */
218
219 #define RTM_F_NOTIFY            0x100   /* Notify user of route change  */
220 #define RTM_F_CLONED            0x200   /* This route is cloned         */
221 #define RTM_F_EQUALIZE          0x400   /* Multipath equalizer: NI      */
222 #define RTM_F_PREFIX            0x800   /* Prefix addresses             */
223
224 /* Reserved table identifiers */
225
226 enum rt_class_t
227 {
228         RT_TABLE_UNSPEC=0,
229 /* User defined values */
230         RT_TABLE_DEFAULT=253,
231         RT_TABLE_MAIN=254,
232         RT_TABLE_LOCAL=255,
233         __RT_TABLE_MAX
234 };
235 #define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
236
237
238
239 /* Routing message attributes */
240
241 enum rtattr_type_t
242 {
243         RTA_UNSPEC,
244         RTA_DST,
245         RTA_SRC,
246         RTA_IIF,
247         RTA_OIF,
248         RTA_GATEWAY,
249         RTA_PRIORITY,
250         RTA_PREFSRC,
251         RTA_METRICS,
252         RTA_MULTIPATH,
253         RTA_PROTOINFO,
254         RTA_FLOW,
255         RTA_CACHEINFO,
256         RTA_SESSION,
257         RTA_MP_ALGO,
258         __RTA_MAX
259 };
260
261 #define RTA_MAX (__RTA_MAX - 1)
262
263 #define RTM_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
264 #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
265
266 /* RTM_MULTIPATH --- array of struct rtnexthop.
267  *
268  * "struct rtnexthop" describes all necessary nexthop information,
269  * i.e. parameters of path to a destination via this nexthop.
270  *
271  * At the moment it is impossible to set different prefsrc, mtu, window
272  * and rtt for different paths from multipath.
273  */
274
275 struct rtnexthop
276 {
277         unsigned short          rtnh_len;
278         unsigned char           rtnh_flags;
279         unsigned char           rtnh_hops;
280         int                     rtnh_ifindex;
281 };
282
283 /* rtnh_flags */
284
285 #define RTNH_F_DEAD             1       /* Nexthop is dead (used by multipath)  */
286 #define RTNH_F_PERVASIVE        2       /* Do recursive gateway lookup  */
287 #define RTNH_F_ONLINK           4       /* Gateway is forced on link    */
288
289 /* Macros to handle hexthops */
290
291 #define RTNH_ALIGNTO    4
292 #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
293 #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
294                            ((int)(rtnh)->rtnh_len) <= (len))
295 #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
296 #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
297 #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
298 #define RTNH_DATA(rtnh)   ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
299
300 /* RTM_CACHEINFO */
301
302 struct rta_cacheinfo
303 {
304         __u32   rta_clntref;
305         __u32   rta_lastuse;
306         __s32   rta_expires;
307         __u32   rta_error;
308         __u32   rta_used;
309
310 #define RTNETLINK_HAVE_PEERINFO 1
311         __u32   rta_id;
312         __u32   rta_ts;
313         __u32   rta_tsage;
314 };
315
316 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
317
318 enum
319 {
320         RTAX_UNSPEC,
321 #define RTAX_UNSPEC RTAX_UNSPEC
322         RTAX_LOCK,
323 #define RTAX_LOCK RTAX_LOCK
324         RTAX_MTU,
325 #define RTAX_MTU RTAX_MTU
326         RTAX_WINDOW,
327 #define RTAX_WINDOW RTAX_WINDOW
328         RTAX_RTT,
329 #define RTAX_RTT RTAX_RTT
330         RTAX_RTTVAR,
331 #define RTAX_RTTVAR RTAX_RTTVAR
332         RTAX_SSTHRESH,
333 #define RTAX_SSTHRESH RTAX_SSTHRESH
334         RTAX_CWND,
335 #define RTAX_CWND RTAX_CWND
336         RTAX_ADVMSS,
337 #define RTAX_ADVMSS RTAX_ADVMSS
338         RTAX_REORDERING,
339 #define RTAX_REORDERING RTAX_REORDERING
340         RTAX_HOPLIMIT,
341 #define RTAX_HOPLIMIT RTAX_HOPLIMIT
342         RTAX_INITCWND,
343 #define RTAX_INITCWND RTAX_INITCWND
344         RTAX_FEATURES,
345 #define RTAX_FEATURES RTAX_FEATURES
346         __RTAX_MAX
347 };
348
349 #define RTAX_MAX (__RTAX_MAX - 1)
350
351 #define RTAX_FEATURE_ECN        0x00000001
352 #define RTAX_FEATURE_SACK       0x00000002
353 #define RTAX_FEATURE_TIMESTAMP  0x00000004
354 #define RTAX_FEATURE_ALLFRAG    0x00000008
355
356 struct rta_session
357 {
358         __u8    proto;
359
360         union {
361                 struct {
362                         __u16   sport;
363                         __u16   dport;
364                 } ports;
365
366                 struct {
367                         __u8    type;
368                         __u8    code;
369                         __u16   ident;
370                 } icmpt;
371
372                 __u32           spi;
373         } u;
374 };
375
376
377 /*********************************************************
378  *              Interface address.
379  ****/
380
381 struct ifaddrmsg
382 {
383         unsigned char   ifa_family;
384         unsigned char   ifa_prefixlen;  /* The prefix length            */
385         unsigned char   ifa_flags;      /* Flags                        */
386         unsigned char   ifa_scope;      /* See above                    */
387         int             ifa_index;      /* Link index                   */
388 };
389
390 enum
391 {
392         IFA_UNSPEC,
393         IFA_ADDRESS,
394         IFA_LOCAL,
395         IFA_LABEL,
396         IFA_BROADCAST,
397         IFA_ANYCAST,
398         IFA_CACHEINFO,
399         IFA_MULTICAST,
400         __IFA_MAX
401 };
402
403 #define IFA_MAX (__IFA_MAX - 1)
404
405 /* ifa_flags */
406
407 #define IFA_F_SECONDARY         0x01
408 #define IFA_F_TEMPORARY         IFA_F_SECONDARY
409
410 #define IFA_F_DEPRECATED        0x20
411 #define IFA_F_TENTATIVE         0x40
412 #define IFA_F_PERMANENT         0x80
413
414 struct ifa_cacheinfo
415 {
416         __u32   ifa_prefered;
417         __u32   ifa_valid;
418         __u32   cstamp; /* created timestamp, hundredths of seconds */
419         __u32   tstamp; /* updated timestamp, hundredths of seconds */
420 };
421
422
423 #define IFA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
424 #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
425
426 /*
427    Important comment:
428    IFA_ADDRESS is prefix address, rather than local interface address.
429    It makes no difference for normally configured broadcast interfaces,
430    but for point-to-point IFA_ADDRESS is DESTINATION address,
431    local address is supplied in IFA_LOCAL attribute.
432  */
433
434 /**************************************************************
435  *              Neighbour discovery.
436  ****/
437
438 struct ndmsg
439 {
440         unsigned char   ndm_family;
441         unsigned char   ndm_pad1;
442         unsigned short  ndm_pad2;
443         int             ndm_ifindex;    /* Link index                   */
444         __u16           ndm_state;
445         __u8            ndm_flags;
446         __u8            ndm_type;
447 };
448
449 enum
450 {
451         NDA_UNSPEC,
452         NDA_DST,
453         NDA_LLADDR,
454         NDA_CACHEINFO,
455         NDA_PROBES,
456         __NDA_MAX
457 };
458
459 #define NDA_MAX (__NDA_MAX - 1)
460
461 #define NDA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
462 #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
463
464 /*
465  *      Neighbor Cache Entry Flags
466  */
467
468 #define NTF_PROXY       0x08    /* == ATF_PUBL */
469 #define NTF_ROUTER      0x80
470
471 /*
472  *      Neighbor Cache Entry States.
473  */
474
475 #define NUD_INCOMPLETE  0x01
476 #define NUD_REACHABLE   0x02
477 #define NUD_STALE       0x04
478 #define NUD_DELAY       0x08
479 #define NUD_PROBE       0x10
480 #define NUD_FAILED      0x20
481
482 /* Dummy states */
483 #define NUD_NOARP       0x40
484 #define NUD_PERMANENT   0x80
485 #define NUD_NONE        0x00
486
487
488 struct nda_cacheinfo
489 {
490         __u32           ndm_confirmed;
491         __u32           ndm_used;
492         __u32           ndm_updated;
493         __u32           ndm_refcnt;
494 };
495
496 /****
497  *              General form of address family dependent message.
498  ****/
499
500 struct rtgenmsg
501 {
502         unsigned char           rtgen_family;
503 };
504
505 /*****************************************************************
506  *              Link layer specific messages.
507  ****/
508
509 /* struct ifinfomsg
510  * passes link level specific information, not dependent
511  * on network protocol.
512  */
513
514 struct ifinfomsg
515 {
516         unsigned char   ifi_family;
517         unsigned char   __ifi_pad;
518         unsigned short  ifi_type;               /* ARPHRD_* */
519         int             ifi_index;              /* Link index   */
520         unsigned        ifi_flags;              /* IFF_* flags  */
521         unsigned        ifi_change;             /* IFF_* change mask */
522 };
523
524 /********************************************************************
525  *              prefix information 
526  ****/
527
528 struct prefixmsg
529 {
530         unsigned char   prefix_family;
531         int             prefix_ifindex;
532         unsigned char   prefix_type;
533         unsigned char   prefix_len;
534         unsigned char   prefix_flags;
535 };
536
537 enum 
538 {
539         PREFIX_UNSPEC,
540         PREFIX_ADDRESS,
541         PREFIX_CACHEINFO,
542         __PREFIX_MAX
543 };
544
545 #define PREFIX_MAX      (__PREFIX_MAX - 1)
546
547 struct prefix_cacheinfo
548 {
549         __u32   preferred_time;
550         __u32   valid_time;
551 };
552
553 /* The struct should be in sync with struct net_device_stats */
554 struct rtnl_link_stats
555 {
556         __u32   rx_packets;             /* total packets received       */
557         __u32   tx_packets;             /* total packets transmitted    */
558         __u32   rx_bytes;               /* total bytes received         */
559         __u32   tx_bytes;               /* total bytes transmitted      */
560         __u32   rx_errors;              /* bad packets received         */
561         __u32   tx_errors;              /* packet transmit problems     */
562         __u32   rx_dropped;             /* no space in linux buffers    */
563         __u32   tx_dropped;             /* no space available in linux  */
564         __u32   multicast;              /* multicast packets received   */
565         __u32   collisions;
566
567         /* detailed rx_errors: */
568         __u32   rx_length_errors;
569         __u32   rx_over_errors;         /* receiver ring buff overflow  */
570         __u32   rx_crc_errors;          /* recved pkt with crc error    */
571         __u32   rx_frame_errors;        /* recv'd frame alignment error */
572         __u32   rx_fifo_errors;         /* recv'r fifo overrun          */
573         __u32   rx_missed_errors;       /* receiver missed packet       */
574
575         /* detailed tx_errors */
576         __u32   tx_aborted_errors;
577         __u32   tx_carrier_errors;
578         __u32   tx_fifo_errors;
579         __u32   tx_heartbeat_errors;
580         __u32   tx_window_errors;
581         
582         /* for cslip etc */
583         __u32   rx_compressed;
584         __u32   tx_compressed;
585 };
586
587 /* The struct should be in sync with struct ifmap */
588 struct rtnl_link_ifmap
589 {
590         __u64   mem_start;
591         __u64   mem_end;
592         __u64   base_addr;
593         __u16   irq;
594         __u8    dma;
595         __u8    port;
596 };
597
598 enum
599 {
600         IFLA_UNSPEC,
601         IFLA_ADDRESS,
602         IFLA_BROADCAST,
603         IFLA_IFNAME,
604         IFLA_MTU,
605         IFLA_LINK,
606         IFLA_QDISC,
607         IFLA_STATS,
608         IFLA_COST,
609 #define IFLA_COST IFLA_COST
610         IFLA_PRIORITY,
611 #define IFLA_PRIORITY IFLA_PRIORITY
612         IFLA_MASTER,
613 #define IFLA_MASTER IFLA_MASTER
614         IFLA_WIRELESS,          /* Wireless Extension event - see wireless.h */
615 #define IFLA_WIRELESS IFLA_WIRELESS
616         IFLA_PROTINFO,          /* Protocol specific information for a link */
617 #define IFLA_PROTINFO IFLA_PROTINFO
618         IFLA_TXQLEN,
619 #define IFLA_TXQLEN IFLA_TXQLEN
620         IFLA_MAP,
621 #define IFLA_MAP IFLA_MAP
622         IFLA_WEIGHT,
623 #define IFLA_WEIGHT IFLA_WEIGHT
624         __IFLA_MAX
625 };
626
627
628 #define IFLA_MAX (__IFLA_MAX - 1)
629
630 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
631 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
632
633 /* ifi_flags.
634
635    IFF_* flags.
636
637    The only change is:
638    IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
639    more not changeable by user. They describe link media
640    characteristics and set by device driver.
641
642    Comments:
643    - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
644    - If neither of these three flags are set;
645      the interface is NBMA.
646
647    - IFF_MULTICAST does not mean anything special:
648    multicasts can be used on all not-NBMA links.
649    IFF_MULTICAST means that this media uses special encapsulation
650    for multicast frames. Apparently, all IFF_POINTOPOINT and
651    IFF_BROADCAST devices are able to use multicasts too.
652  */
653
654 /* IFLA_LINK.
655    For usual devices it is equal ifi_index.
656    If it is a "virtual interface" (f.e. tunnel), ifi_link
657    can point to real physical interface (f.e. for bandwidth calculations),
658    or maybe 0, what means, that real media is unknown (usual
659    for IPIP tunnels, when route to endpoint is allowed to change)
660  */
661
662 /* Subtype attributes for IFLA_PROTINFO */
663 enum
664 {
665         IFLA_INET6_UNSPEC,
666         IFLA_INET6_FLAGS,       /* link flags                   */
667         IFLA_INET6_CONF,        /* sysctl parameters            */
668         IFLA_INET6_STATS,       /* statistics                   */
669         IFLA_INET6_MCAST,       /* MC things. What of them?     */
670         IFLA_INET6_CACHEINFO,   /* time values and max reasm size */
671         __IFLA_INET6_MAX
672 };
673
674 #define IFLA_INET6_MAX  (__IFLA_INET6_MAX - 1)
675
676 struct ifla_cacheinfo
677 {
678         __u32   max_reasm_len;
679         __u32   tstamp;         /* ipv6InterfaceTable updated timestamp */
680         __u32   reachable_time;
681         __u32   retrans_time;
682 };
683
684 /*****************************************************************
685  *              Traffic control messages.
686  ****/
687
688 struct tcmsg
689 {
690         unsigned char   tcm_family;
691         unsigned char   tcm__pad1;
692         unsigned short  tcm__pad2;
693         int             tcm_ifindex;
694         __u32           tcm_handle;
695         __u32           tcm_parent;
696         __u32           tcm_info;
697 };
698
699 enum
700 {
701         TCA_UNSPEC,
702         TCA_KIND,
703         TCA_OPTIONS,
704         TCA_STATS,
705         TCA_XSTATS,
706         TCA_RATE,
707         TCA_FCNT,
708         TCA_STATS2,
709         __TCA_MAX
710 };
711
712 #define TCA_MAX (__TCA_MAX - 1)
713
714 #define TCA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
715 #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
716
717
718 /* RTnetlink multicast groups */
719
720 #define RTMGRP_LINK             1
721 #define RTMGRP_NOTIFY           2
722 #define RTMGRP_NEIGH            4
723 #define RTMGRP_TC               8
724
725 #define RTMGRP_IPV4_IFADDR      0x10
726 #define RTMGRP_IPV4_MROUTE      0x20
727 #define RTMGRP_IPV4_ROUTE       0x40
728
729 #define RTMGRP_IPV6_IFADDR      0x100
730 #define RTMGRP_IPV6_MROUTE      0x200
731 #define RTMGRP_IPV6_ROUTE       0x400
732 #define RTMGRP_IPV6_IFINFO      0x800
733
734 #define RTMGRP_DECnet_IFADDR    0x1000
735 #define RTMGRP_DECnet_ROUTE     0x4000
736
737 #define RTMGRP_IPV6_PREFIX      0x20000
738
739 /* TC action piece */
740 struct tcamsg
741 {
742         unsigned char   tca_family;
743         unsigned char   tca__pad1;
744         unsigned short  tca__pad2;
745 };
746 #define TA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
747 #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
748 #define TCA_ACT_TAB 1 /* attr type must be >=1 */       
749 #define TCAA_MAX 1
750
751 /* End of information exported to user level */
752
753 #ifdef __KERNEL__
754
755 #include <linux/config.h>
756
757 extern size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size);
758 static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
759 {
760         int len = strlen(str) + 1;
761         return len > rta->rta_len || memcmp(RTA_DATA(rta), str, len);
762 }
763
764 extern int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len);
765
766 #define rtattr_parse_nested(tb, max, rta) \
767         rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta)))
768
769 extern struct sock *rtnl;
770
771 struct rtnetlink_link
772 {
773         int (*doit)(struct sk_buff *, struct nlmsghdr*, void *attr);
774         int (*dumpit)(struct sk_buff *, struct netlink_callback *cb);
775 };
776
777 extern struct rtnetlink_link * rtnetlink_links[NPROTO];
778 extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo);
779 extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
780
781 extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);
782
783 #define RTA_PUT(skb, attrtype, attrlen, data) \
784 ({      if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
785                  goto rtattr_failure; \
786         __rta_fill(skb, attrtype, attrlen, data); }) 
787
788 #define RTA_PUT_NOHDR(skb, attrlen, data) \
789 ({      if (unlikely(skb_tailroom(skb) < (int)(attrlen))) \
790                 goto rtattr_failure; \
791         memcpy(skb_put(skb, RTA_ALIGN(attrlen)), data, attrlen); })
792                 
793 static inline struct rtattr *
794 __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
795 {
796         struct rtattr *rta;
797         int size = RTA_LENGTH(attrlen);
798
799         rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
800         rta->rta_type = attrtype;
801         rta->rta_len = size;
802         return rta;
803 }
804
805 #define __RTA_PUT(skb, attrtype, attrlen) \
806 ({      if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
807                 goto rtattr_failure; \
808         __rta_reserve(skb, attrtype, attrlen); })
809
810 extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
811
812 extern struct semaphore rtnl_sem;
813
814 #define rtnl_shlock()           down(&rtnl_sem)
815 #define rtnl_shlock_nowait()    down_trylock(&rtnl_sem)
816
817 #define rtnl_shunlock() do { up(&rtnl_sem); \
818                              if (rtnl && rtnl->sk_receive_queue.qlen) \
819                                      rtnl->sk_data_ready(rtnl, 0); \
820                         } while(0)
821
822 extern void rtnl_lock(void);
823 extern int rtnl_lock_interruptible(void);
824 extern void rtnl_unlock(void);
825 extern void rtnetlink_init(void);
826
827 #define ASSERT_RTNL() do { \
828         if (unlikely(down_trylock(&rtnl_sem) == 0)) { \
829                 up(&rtnl_sem); \
830                 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
831                        __FILE__,  __LINE__); \
832                 dump_stack(); \
833         } \
834 } while(0)
835
836 #define BUG_TRAP(x) do { \
837         if (unlikely(!(x))) { \
838                 printk(KERN_ERR "KERNEL: assertion (%s) failed at %s (%d)\n", \
839                         #x,  __FILE__ , __LINE__); \
840         } \
841 } while(0)
842
843 #endif /* __KERNEL__ */
844
845
846 #endif  /* __LINUX_RTNETLINK_H */