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