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