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