[TG3]: Add tagged status support.
[linux-2.6/verdex.git] / include / linux / rtnetlink.h
blob91ac97c207771c49530d579f16ca7abb3028914f
1 #ifndef __LINUX_RTNETLINK_H
2 #define __LINUX_RTNETLINK_H
4 #include <linux/netlink.h>
6 /****
7 * Routing/neighbour discovery messages.
8 ****/
10 /* Types of messages */
12 enum {
13 RTM_BASE = 16,
14 #define RTM_BASE RTM_BASE
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
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
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
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
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
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
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
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
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
81 RTM_NEWPREFIX = 52,
82 #define RTM_NEWPREFIX RTM_NEWPREFIX
83 RTM_GETPREFIX = 54,
84 #define RTM_GETPREFIX RTM_GETPREFIX
86 RTM_GETMULTICAST = 58,
87 #define RTM_GETMULTICAST RTM_GETMULTICAST
89 RTM_GETANYCAST = 62,
90 #define RTM_GETANYCAST RTM_GETANYCAST
92 __RTM_MAX,
93 #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
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)
101 Generic structure for encapsulation of optional route information.
102 It is reminiscent of sockaddr, but with sa_family replaced
103 with attribute type.
106 struct rtattr
108 unsigned short rta_len;
109 unsigned short rta_type;
112 /* Macros to handle rtattributes */
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))
129 /******************************************************************************
130 * Definitions used in routing table administration.
131 ****/
133 struct rtmsg
135 unsigned char rtm_family;
136 unsigned char rtm_dst_len;
137 unsigned char rtm_src_len;
138 unsigned char rtm_tos;
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 */
145 unsigned rtm_flags;
148 /* rtm_type */
150 enum
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
169 #define RTN_MAX (__RTN_MAX - 1)
172 /* rtm_protocol */
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 */
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.
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 */
196 /* rtm_scope
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.
203 Intermediate values are also possible f.e. interior routes
204 could be assigned a value between UNIVERSE and LINK.
207 enum rt_scope_t
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
217 /* rtm_flags */
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 */
224 /* Reserved table identifiers */
226 enum rt_class_t
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
235 #define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
239 /* Routing message attributes */
241 enum rtattr_type_t
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
261 #define RTA_MAX (__RTA_MAX - 1)
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))
266 /* RTM_MULTIPATH --- array of struct rtnexthop.
268 * "struct rtnexthop" describes all necessary nexthop information,
269 * i.e. parameters of path to a destination via this nexthop.
271 * At the moment it is impossible to set different prefsrc, mtu, window
272 * and rtt for different paths from multipath.
275 struct rtnexthop
277 unsigned short rtnh_len;
278 unsigned char rtnh_flags;
279 unsigned char rtnh_hops;
280 int rtnh_ifindex;
283 /* rtnh_flags */
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 */
289 /* Macros to handle hexthops */
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)))
300 /* RTM_CACHEINFO */
302 struct rta_cacheinfo
304 __u32 rta_clntref;
305 __u32 rta_lastuse;
306 __s32 rta_expires;
307 __u32 rta_error;
308 __u32 rta_used;
310 #define RTNETLINK_HAVE_PEERINFO 1
311 __u32 rta_id;
312 __u32 rta_ts;
313 __u32 rta_tsage;
316 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
318 enum
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
349 #define RTAX_MAX (__RTAX_MAX - 1)
351 #define RTAX_FEATURE_ECN 0x00000001
352 #define RTAX_FEATURE_SACK 0x00000002
353 #define RTAX_FEATURE_TIMESTAMP 0x00000004
354 #define RTAX_FEATURE_ALLFRAG 0x00000008
356 struct rta_session
358 __u8 proto;
360 union {
361 struct {
362 __u16 sport;
363 __u16 dport;
364 } ports;
366 struct {
367 __u8 type;
368 __u8 code;
369 __u16 ident;
370 } icmpt;
372 __u32 spi;
373 } u;
377 /*********************************************************
378 * Interface address.
379 ****/
381 struct ifaddrmsg
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 */
390 enum
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
403 #define IFA_MAX (__IFA_MAX - 1)
405 /* ifa_flags */
407 #define IFA_F_SECONDARY 0x01
408 #define IFA_F_TEMPORARY IFA_F_SECONDARY
410 #define IFA_F_DEPRECATED 0x20
411 #define IFA_F_TENTATIVE 0x40
412 #define IFA_F_PERMANENT 0x80
414 struct ifa_cacheinfo
416 __u32 ifa_prefered;
417 __u32 ifa_valid;
418 __u32 cstamp; /* created timestamp, hundredths of seconds */
419 __u32 tstamp; /* updated timestamp, hundredths of seconds */
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))
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.
434 /**************************************************************
435 * Neighbour discovery.
436 ****/
438 struct ndmsg
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;
449 enum
451 NDA_UNSPEC,
452 NDA_DST,
453 NDA_LLADDR,
454 NDA_CACHEINFO,
455 NDA_PROBES,
456 __NDA_MAX
459 #define NDA_MAX (__NDA_MAX - 1)
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))
465 * Neighbor Cache Entry Flags
468 #define NTF_PROXY 0x08 /* == ATF_PUBL */
469 #define NTF_ROUTER 0x80
472 * Neighbor Cache Entry States.
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
482 /* Dummy states */
483 #define NUD_NOARP 0x40
484 #define NUD_PERMANENT 0x80
485 #define NUD_NONE 0x00
488 struct nda_cacheinfo
490 __u32 ndm_confirmed;
491 __u32 ndm_used;
492 __u32 ndm_updated;
493 __u32 ndm_refcnt;
496 /****
497 * General form of address family dependent message.
498 ****/
500 struct rtgenmsg
502 unsigned char rtgen_family;
505 /*****************************************************************
506 * Link layer specific messages.
507 ****/
509 /* struct ifinfomsg
510 * passes link level specific information, not dependent
511 * on network protocol.
514 struct ifinfomsg
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 */
524 /********************************************************************
525 * prefix information
526 ****/
528 struct prefixmsg
530 unsigned char prefix_family;
531 int prefix_ifindex;
532 unsigned char prefix_type;
533 unsigned char prefix_len;
534 unsigned char prefix_flags;
537 enum
539 PREFIX_UNSPEC,
540 PREFIX_ADDRESS,
541 PREFIX_CACHEINFO,
542 __PREFIX_MAX
545 #define PREFIX_MAX (__PREFIX_MAX - 1)
547 struct prefix_cacheinfo
549 __u32 preferred_time;
550 __u32 valid_time;
553 /* The struct should be in sync with struct net_device_stats */
554 struct rtnl_link_stats
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;
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 */
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;
582 /* for cslip etc */
583 __u32 rx_compressed;
584 __u32 tx_compressed;
587 /* The struct should be in sync with struct ifmap */
588 struct rtnl_link_ifmap
590 __u64 mem_start;
591 __u64 mem_end;
592 __u64 base_addr;
593 __u16 irq;
594 __u8 dma;
595 __u8 port;
598 enum
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
628 #define IFLA_MAX (__IFLA_MAX - 1)
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))
633 /* ifi_flags.
635 IFF_* flags.
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.
642 Comments:
643 - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
644 - If neither of these three flags are set;
645 the interface is NBMA.
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.
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)
662 /* Subtype attributes for IFLA_PROTINFO */
663 enum
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
674 #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
676 struct ifla_cacheinfo
678 __u32 max_reasm_len;
679 __u32 tstamp; /* ipv6InterfaceTable updated timestamp */
680 __u32 reachable_time;
681 __u32 retrans_time;
684 /*****************************************************************
685 * Traffic control messages.
686 ****/
688 struct tcmsg
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;
699 enum
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
712 #define TCA_MAX (__TCA_MAX - 1)
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))
718 /* RTnetlink multicast groups */
720 #define RTMGRP_LINK 1
721 #define RTMGRP_NOTIFY 2
722 #define RTMGRP_NEIGH 4
723 #define RTMGRP_TC 8
725 #define RTMGRP_IPV4_IFADDR 0x10
726 #define RTMGRP_IPV4_MROUTE 0x20
727 #define RTMGRP_IPV4_ROUTE 0x40
729 #define RTMGRP_IPV6_IFADDR 0x100
730 #define RTMGRP_IPV6_MROUTE 0x200
731 #define RTMGRP_IPV6_ROUTE 0x400
732 #define RTMGRP_IPV6_IFINFO 0x800
734 #define RTMGRP_DECnet_IFADDR 0x1000
735 #define RTMGRP_DECnet_ROUTE 0x4000
737 #define RTMGRP_IPV6_PREFIX 0x20000
739 /* TC action piece */
740 struct tcamsg
742 unsigned char tca_family;
743 unsigned char tca__pad1;
744 unsigned short tca__pad2;
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
751 /* End of information exported to user level */
753 #ifdef __KERNEL__
755 #include <linux/config.h>
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)
760 int len = strlen(str) + 1;
761 return len > rta->rta_len || memcmp(RTA_DATA(rta), str, len);
764 extern int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len);
766 #define rtattr_parse_nested(tb, max, rta) \
767 rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta)))
769 extern struct sock *rtnl;
771 struct rtnetlink_link
773 int (*doit)(struct sk_buff *, struct nlmsghdr*, void *attr);
774 int (*dumpit)(struct sk_buff *, struct netlink_callback *cb);
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);
781 extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);
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); })
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); })
793 static inline struct rtattr *
794 __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
796 struct rtattr *rta;
797 int size = RTA_LENGTH(attrlen);
799 rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
800 rta->rta_type = attrtype;
801 rta->rta_len = size;
802 return rta;
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); })
810 extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
812 extern struct semaphore rtnl_sem;
814 #define rtnl_shlock() down(&rtnl_sem)
815 #define rtnl_shlock_nowait() down_trylock(&rtnl_sem)
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)
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);
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(); \
834 } while(0)
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__); \
841 } while(0)
843 #endif /* __KERNEL__ */
846 #endif /* __LINUX_RTNETLINK_H */