[PATCH] bcm43xx: Fix array overrun in bcm43xx_geo_init
[linux-2.6/kmemtrace.git] / include / linux / rtnetlink.h
blobdf0cdd41085c702f654e86a6c1acc279649f0a42
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_NEWNEIGHTBL = 64,
93 #define RTM_NEWNEIGHTBL RTM_NEWNEIGHTBL
94 RTM_GETNEIGHTBL = 66,
95 #define RTM_GETNEIGHTBL RTM_GETNEIGHTBL
96 RTM_SETNEIGHTBL,
97 #define RTM_SETNEIGHTBL RTM_SETNEIGHTBL
99 __RTM_MAX,
100 #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
103 #define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
104 #define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
105 #define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
108 Generic structure for encapsulation of optional route information.
109 It is reminiscent of sockaddr, but with sa_family replaced
110 with attribute type.
113 struct rtattr
115 unsigned short rta_len;
116 unsigned short rta_type;
119 /* Macros to handle rtattributes */
121 #define RTA_ALIGNTO 4
122 #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
123 #define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \
124 (rta)->rta_len >= sizeof(struct rtattr) && \
125 (rta)->rta_len <= (len))
126 #define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
127 (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
128 #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
129 #define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len))
130 #define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
131 #define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
136 /******************************************************************************
137 * Definitions used in routing table administration.
138 ****/
140 struct rtmsg
142 unsigned char rtm_family;
143 unsigned char rtm_dst_len;
144 unsigned char rtm_src_len;
145 unsigned char rtm_tos;
147 unsigned char rtm_table; /* Routing table id */
148 unsigned char rtm_protocol; /* Routing protocol; see below */
149 unsigned char rtm_scope; /* See below */
150 unsigned char rtm_type; /* See below */
152 unsigned rtm_flags;
155 /* rtm_type */
157 enum
159 RTN_UNSPEC,
160 RTN_UNICAST, /* Gateway or direct route */
161 RTN_LOCAL, /* Accept locally */
162 RTN_BROADCAST, /* Accept locally as broadcast,
163 send as broadcast */
164 RTN_ANYCAST, /* Accept locally as broadcast,
165 but send as unicast */
166 RTN_MULTICAST, /* Multicast route */
167 RTN_BLACKHOLE, /* Drop */
168 RTN_UNREACHABLE, /* Destination is unreachable */
169 RTN_PROHIBIT, /* Administratively prohibited */
170 RTN_THROW, /* Not in this table */
171 RTN_NAT, /* Translate this address */
172 RTN_XRESOLVE, /* Use external resolver */
173 __RTN_MAX
176 #define RTN_MAX (__RTN_MAX - 1)
179 /* rtm_protocol */
181 #define RTPROT_UNSPEC 0
182 #define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects;
183 not used by current IPv4 */
184 #define RTPROT_KERNEL 2 /* Route installed by kernel */
185 #define RTPROT_BOOT 3 /* Route installed during boot */
186 #define RTPROT_STATIC 4 /* Route installed by administrator */
188 /* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
189 they are just passed from user and back as is.
190 It will be used by hypothetical multiple routing daemons.
191 Note that protocol values should be standardized in order to
192 avoid conflicts.
195 #define RTPROT_GATED 8 /* Apparently, GateD */
196 #define RTPROT_RA 9 /* RDISC/ND router advertisements */
197 #define RTPROT_MRT 10 /* Merit MRT */
198 #define RTPROT_ZEBRA 11 /* Zebra */
199 #define RTPROT_BIRD 12 /* BIRD */
200 #define RTPROT_DNROUTED 13 /* DECnet routing daemon */
201 #define RTPROT_XORP 14 /* XORP */
202 #define RTPROT_NTK 15 /* Netsukuku */
204 /* rtm_scope
206 Really it is not scope, but sort of distance to the destination.
207 NOWHERE are reserved for not existing destinations, HOST is our
208 local addresses, LINK are destinations, located on directly attached
209 link and UNIVERSE is everywhere in the Universe.
211 Intermediate values are also possible f.e. interior routes
212 could be assigned a value between UNIVERSE and LINK.
215 enum rt_scope_t
217 RT_SCOPE_UNIVERSE=0,
218 /* User defined values */
219 RT_SCOPE_SITE=200,
220 RT_SCOPE_LINK=253,
221 RT_SCOPE_HOST=254,
222 RT_SCOPE_NOWHERE=255
225 /* rtm_flags */
227 #define RTM_F_NOTIFY 0x100 /* Notify user of route change */
228 #define RTM_F_CLONED 0x200 /* This route is cloned */
229 #define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */
230 #define RTM_F_PREFIX 0x800 /* Prefix addresses */
232 /* Reserved table identifiers */
234 enum rt_class_t
236 RT_TABLE_UNSPEC=0,
237 /* User defined values */
238 RT_TABLE_DEFAULT=253,
239 RT_TABLE_MAIN=254,
240 RT_TABLE_LOCAL=255,
241 __RT_TABLE_MAX
243 #define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
247 /* Routing message attributes */
249 enum rtattr_type_t
251 RTA_UNSPEC,
252 RTA_DST,
253 RTA_SRC,
254 RTA_IIF,
255 RTA_OIF,
256 RTA_GATEWAY,
257 RTA_PRIORITY,
258 RTA_PREFSRC,
259 RTA_METRICS,
260 RTA_MULTIPATH,
261 RTA_PROTOINFO,
262 RTA_FLOW,
263 RTA_CACHEINFO,
264 RTA_SESSION,
265 RTA_MP_ALGO,
266 __RTA_MAX
269 #define RTA_MAX (__RTA_MAX - 1)
271 #define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
272 #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
274 /* RTM_MULTIPATH --- array of struct rtnexthop.
276 * "struct rtnexthop" describes all necessary nexthop information,
277 * i.e. parameters of path to a destination via this nexthop.
279 * At the moment it is impossible to set different prefsrc, mtu, window
280 * and rtt for different paths from multipath.
283 struct rtnexthop
285 unsigned short rtnh_len;
286 unsigned char rtnh_flags;
287 unsigned char rtnh_hops;
288 int rtnh_ifindex;
291 /* rtnh_flags */
293 #define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
294 #define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
295 #define RTNH_F_ONLINK 4 /* Gateway is forced on link */
297 /* Macros to handle hexthops */
299 #define RTNH_ALIGNTO 4
300 #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
301 #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
302 ((int)(rtnh)->rtnh_len) <= (len))
303 #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
304 #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
305 #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
306 #define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
308 /* RTM_CACHEINFO */
310 struct rta_cacheinfo
312 __u32 rta_clntref;
313 __u32 rta_lastuse;
314 __s32 rta_expires;
315 __u32 rta_error;
316 __u32 rta_used;
318 #define RTNETLINK_HAVE_PEERINFO 1
319 __u32 rta_id;
320 __u32 rta_ts;
321 __u32 rta_tsage;
324 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
326 enum
328 RTAX_UNSPEC,
329 #define RTAX_UNSPEC RTAX_UNSPEC
330 RTAX_LOCK,
331 #define RTAX_LOCK RTAX_LOCK
332 RTAX_MTU,
333 #define RTAX_MTU RTAX_MTU
334 RTAX_WINDOW,
335 #define RTAX_WINDOW RTAX_WINDOW
336 RTAX_RTT,
337 #define RTAX_RTT RTAX_RTT
338 RTAX_RTTVAR,
339 #define RTAX_RTTVAR RTAX_RTTVAR
340 RTAX_SSTHRESH,
341 #define RTAX_SSTHRESH RTAX_SSTHRESH
342 RTAX_CWND,
343 #define RTAX_CWND RTAX_CWND
344 RTAX_ADVMSS,
345 #define RTAX_ADVMSS RTAX_ADVMSS
346 RTAX_REORDERING,
347 #define RTAX_REORDERING RTAX_REORDERING
348 RTAX_HOPLIMIT,
349 #define RTAX_HOPLIMIT RTAX_HOPLIMIT
350 RTAX_INITCWND,
351 #define RTAX_INITCWND RTAX_INITCWND
352 RTAX_FEATURES,
353 #define RTAX_FEATURES RTAX_FEATURES
354 __RTAX_MAX
357 #define RTAX_MAX (__RTAX_MAX - 1)
359 #define RTAX_FEATURE_ECN 0x00000001
360 #define RTAX_FEATURE_SACK 0x00000002
361 #define RTAX_FEATURE_TIMESTAMP 0x00000004
362 #define RTAX_FEATURE_ALLFRAG 0x00000008
364 struct rta_session
366 __u8 proto;
367 __u8 pad1;
368 __u16 pad2;
370 union {
371 struct {
372 __u16 sport;
373 __u16 dport;
374 } ports;
376 struct {
377 __u8 type;
378 __u8 code;
379 __u16 ident;
380 } icmpt;
382 __u32 spi;
383 } u;
387 /*********************************************************
388 * Interface address.
389 ****/
391 struct ifaddrmsg
393 unsigned char ifa_family;
394 unsigned char ifa_prefixlen; /* The prefix length */
395 unsigned char ifa_flags; /* Flags */
396 unsigned char ifa_scope; /* See above */
397 int ifa_index; /* Link index */
400 enum
402 IFA_UNSPEC,
403 IFA_ADDRESS,
404 IFA_LOCAL,
405 IFA_LABEL,
406 IFA_BROADCAST,
407 IFA_ANYCAST,
408 IFA_CACHEINFO,
409 IFA_MULTICAST,
410 __IFA_MAX
413 #define IFA_MAX (__IFA_MAX - 1)
415 /* ifa_flags */
417 #define IFA_F_SECONDARY 0x01
418 #define IFA_F_TEMPORARY IFA_F_SECONDARY
420 #define IFA_F_DEPRECATED 0x20
421 #define IFA_F_TENTATIVE 0x40
422 #define IFA_F_PERMANENT 0x80
424 struct ifa_cacheinfo
426 __u32 ifa_prefered;
427 __u32 ifa_valid;
428 __u32 cstamp; /* created timestamp, hundredths of seconds */
429 __u32 tstamp; /* updated timestamp, hundredths of seconds */
433 #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
434 #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
437 Important comment:
438 IFA_ADDRESS is prefix address, rather than local interface address.
439 It makes no difference for normally configured broadcast interfaces,
440 but for point-to-point IFA_ADDRESS is DESTINATION address,
441 local address is supplied in IFA_LOCAL attribute.
444 /**************************************************************
445 * Neighbour discovery.
446 ****/
448 struct ndmsg
450 unsigned char ndm_family;
451 unsigned char ndm_pad1;
452 unsigned short ndm_pad2;
453 int ndm_ifindex; /* Link index */
454 __u16 ndm_state;
455 __u8 ndm_flags;
456 __u8 ndm_type;
459 enum
461 NDA_UNSPEC,
462 NDA_DST,
463 NDA_LLADDR,
464 NDA_CACHEINFO,
465 NDA_PROBES,
466 __NDA_MAX
469 #define NDA_MAX (__NDA_MAX - 1)
471 #define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
472 #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
475 * Neighbor Cache Entry Flags
478 #define NTF_PROXY 0x08 /* == ATF_PUBL */
479 #define NTF_ROUTER 0x80
482 * Neighbor Cache Entry States.
485 #define NUD_INCOMPLETE 0x01
486 #define NUD_REACHABLE 0x02
487 #define NUD_STALE 0x04
488 #define NUD_DELAY 0x08
489 #define NUD_PROBE 0x10
490 #define NUD_FAILED 0x20
492 /* Dummy states */
493 #define NUD_NOARP 0x40
494 #define NUD_PERMANENT 0x80
495 #define NUD_NONE 0x00
498 struct nda_cacheinfo
500 __u32 ndm_confirmed;
501 __u32 ndm_used;
502 __u32 ndm_updated;
503 __u32 ndm_refcnt;
507 /*****************************************************************
508 * Neighbour tables specific messages.
510 * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
511 * NLM_F_DUMP flag set. Every neighbour table configuration is
512 * spread over multiple messages to avoid running into message
513 * size limits on systems with many interfaces. The first message
514 * in the sequence transports all not device specific data such as
515 * statistics, configuration, and the default parameter set.
516 * This message is followed by 0..n messages carrying device
517 * specific parameter sets.
518 * Although the ordering should be sufficient, NDTA_NAME can be
519 * used to identify sequences. The initial message can be identified
520 * by checking for NDTA_CONFIG. The device specific messages do
521 * not contain this TLV but have NDTPA_IFINDEX set to the
522 * corresponding interface index.
524 * To change neighbour table attributes, send RTM_SETNEIGHTBL
525 * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
526 * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
527 * otherwise. Device specific parameter sets can be changed by
528 * setting NDTPA_IFINDEX to the interface index of the corresponding
529 * device.
530 ****/
532 struct ndt_stats
534 __u64 ndts_allocs;
535 __u64 ndts_destroys;
536 __u64 ndts_hash_grows;
537 __u64 ndts_res_failed;
538 __u64 ndts_lookups;
539 __u64 ndts_hits;
540 __u64 ndts_rcv_probes_mcast;
541 __u64 ndts_rcv_probes_ucast;
542 __u64 ndts_periodic_gc_runs;
543 __u64 ndts_forced_gc_runs;
546 enum {
547 NDTPA_UNSPEC,
548 NDTPA_IFINDEX, /* u32, unchangeable */
549 NDTPA_REFCNT, /* u32, read-only */
550 NDTPA_REACHABLE_TIME, /* u64, read-only, msecs */
551 NDTPA_BASE_REACHABLE_TIME, /* u64, msecs */
552 NDTPA_RETRANS_TIME, /* u64, msecs */
553 NDTPA_GC_STALETIME, /* u64, msecs */
554 NDTPA_DELAY_PROBE_TIME, /* u64, msecs */
555 NDTPA_QUEUE_LEN, /* u32 */
556 NDTPA_APP_PROBES, /* u32 */
557 NDTPA_UCAST_PROBES, /* u32 */
558 NDTPA_MCAST_PROBES, /* u32 */
559 NDTPA_ANYCAST_DELAY, /* u64, msecs */
560 NDTPA_PROXY_DELAY, /* u64, msecs */
561 NDTPA_PROXY_QLEN, /* u32 */
562 NDTPA_LOCKTIME, /* u64, msecs */
563 __NDTPA_MAX
565 #define NDTPA_MAX (__NDTPA_MAX - 1)
567 struct ndtmsg
569 __u8 ndtm_family;
570 __u8 ndtm_pad1;
571 __u16 ndtm_pad2;
574 struct ndt_config
576 __u16 ndtc_key_len;
577 __u16 ndtc_entry_size;
578 __u32 ndtc_entries;
579 __u32 ndtc_last_flush; /* delta to now in msecs */
580 __u32 ndtc_last_rand; /* delta to now in msecs */
581 __u32 ndtc_hash_rnd;
582 __u32 ndtc_hash_mask;
583 __u32 ndtc_hash_chain_gc;
584 __u32 ndtc_proxy_qlen;
587 enum {
588 NDTA_UNSPEC,
589 NDTA_NAME, /* char *, unchangeable */
590 NDTA_THRESH1, /* u32 */
591 NDTA_THRESH2, /* u32 */
592 NDTA_THRESH3, /* u32 */
593 NDTA_CONFIG, /* struct ndt_config, read-only */
594 NDTA_PARMS, /* nested TLV NDTPA_* */
595 NDTA_STATS, /* struct ndt_stats, read-only */
596 NDTA_GC_INTERVAL, /* u64, msecs */
597 __NDTA_MAX
599 #define NDTA_MAX (__NDTA_MAX - 1)
601 #define NDTA_RTA(r) ((struct rtattr*)(((char*)(r)) + \
602 NLMSG_ALIGN(sizeof(struct ndtmsg))))
603 #define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))
606 /****
607 * General form of address family dependent message.
608 ****/
610 struct rtgenmsg
612 unsigned char rtgen_family;
615 /*****************************************************************
616 * Link layer specific messages.
617 ****/
619 /* struct ifinfomsg
620 * passes link level specific information, not dependent
621 * on network protocol.
624 struct ifinfomsg
626 unsigned char ifi_family;
627 unsigned char __ifi_pad;
628 unsigned short ifi_type; /* ARPHRD_* */
629 int ifi_index; /* Link index */
630 unsigned ifi_flags; /* IFF_* flags */
631 unsigned ifi_change; /* IFF_* change mask */
634 /********************************************************************
635 * prefix information
636 ****/
638 struct prefixmsg
640 unsigned char prefix_family;
641 unsigned char prefix_pad1;
642 unsigned short prefix_pad2;
643 int prefix_ifindex;
644 unsigned char prefix_type;
645 unsigned char prefix_len;
646 unsigned char prefix_flags;
647 unsigned char prefix_pad3;
650 enum
652 PREFIX_UNSPEC,
653 PREFIX_ADDRESS,
654 PREFIX_CACHEINFO,
655 __PREFIX_MAX
658 #define PREFIX_MAX (__PREFIX_MAX - 1)
660 struct prefix_cacheinfo
662 __u32 preferred_time;
663 __u32 valid_time;
666 /* The struct should be in sync with struct net_device_stats */
667 struct rtnl_link_stats
669 __u32 rx_packets; /* total packets received */
670 __u32 tx_packets; /* total packets transmitted */
671 __u32 rx_bytes; /* total bytes received */
672 __u32 tx_bytes; /* total bytes transmitted */
673 __u32 rx_errors; /* bad packets received */
674 __u32 tx_errors; /* packet transmit problems */
675 __u32 rx_dropped; /* no space in linux buffers */
676 __u32 tx_dropped; /* no space available in linux */
677 __u32 multicast; /* multicast packets received */
678 __u32 collisions;
680 /* detailed rx_errors: */
681 __u32 rx_length_errors;
682 __u32 rx_over_errors; /* receiver ring buff overflow */
683 __u32 rx_crc_errors; /* recved pkt with crc error */
684 __u32 rx_frame_errors; /* recv'd frame alignment error */
685 __u32 rx_fifo_errors; /* recv'r fifo overrun */
686 __u32 rx_missed_errors; /* receiver missed packet */
688 /* detailed tx_errors */
689 __u32 tx_aborted_errors;
690 __u32 tx_carrier_errors;
691 __u32 tx_fifo_errors;
692 __u32 tx_heartbeat_errors;
693 __u32 tx_window_errors;
695 /* for cslip etc */
696 __u32 rx_compressed;
697 __u32 tx_compressed;
700 /* The struct should be in sync with struct ifmap */
701 struct rtnl_link_ifmap
703 __u64 mem_start;
704 __u64 mem_end;
705 __u64 base_addr;
706 __u16 irq;
707 __u8 dma;
708 __u8 port;
711 enum
713 IFLA_UNSPEC,
714 IFLA_ADDRESS,
715 IFLA_BROADCAST,
716 IFLA_IFNAME,
717 IFLA_MTU,
718 IFLA_LINK,
719 IFLA_QDISC,
720 IFLA_STATS,
721 IFLA_COST,
722 #define IFLA_COST IFLA_COST
723 IFLA_PRIORITY,
724 #define IFLA_PRIORITY IFLA_PRIORITY
725 IFLA_MASTER,
726 #define IFLA_MASTER IFLA_MASTER
727 IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */
728 #define IFLA_WIRELESS IFLA_WIRELESS
729 IFLA_PROTINFO, /* Protocol specific information for a link */
730 #define IFLA_PROTINFO IFLA_PROTINFO
731 IFLA_TXQLEN,
732 #define IFLA_TXQLEN IFLA_TXQLEN
733 IFLA_MAP,
734 #define IFLA_MAP IFLA_MAP
735 IFLA_WEIGHT,
736 #define IFLA_WEIGHT IFLA_WEIGHT
737 IFLA_OPERSTATE,
738 IFLA_LINKMODE,
739 __IFLA_MAX
743 #define IFLA_MAX (__IFLA_MAX - 1)
745 #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
746 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
748 /* ifi_flags.
750 IFF_* flags.
752 The only change is:
753 IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
754 more not changeable by user. They describe link media
755 characteristics and set by device driver.
757 Comments:
758 - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
759 - If neither of these three flags are set;
760 the interface is NBMA.
762 - IFF_MULTICAST does not mean anything special:
763 multicasts can be used on all not-NBMA links.
764 IFF_MULTICAST means that this media uses special encapsulation
765 for multicast frames. Apparently, all IFF_POINTOPOINT and
766 IFF_BROADCAST devices are able to use multicasts too.
769 /* IFLA_LINK.
770 For usual devices it is equal ifi_index.
771 If it is a "virtual interface" (f.e. tunnel), ifi_link
772 can point to real physical interface (f.e. for bandwidth calculations),
773 or maybe 0, what means, that real media is unknown (usual
774 for IPIP tunnels, when route to endpoint is allowed to change)
777 /* Subtype attributes for IFLA_PROTINFO */
778 enum
780 IFLA_INET6_UNSPEC,
781 IFLA_INET6_FLAGS, /* link flags */
782 IFLA_INET6_CONF, /* sysctl parameters */
783 IFLA_INET6_STATS, /* statistics */
784 IFLA_INET6_MCAST, /* MC things. What of them? */
785 IFLA_INET6_CACHEINFO, /* time values and max reasm size */
786 __IFLA_INET6_MAX
789 #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
791 struct ifla_cacheinfo
793 __u32 max_reasm_len;
794 __u32 tstamp; /* ipv6InterfaceTable updated timestamp */
795 __u32 reachable_time;
796 __u32 retrans_time;
799 /*****************************************************************
800 * Traffic control messages.
801 ****/
803 struct tcmsg
805 unsigned char tcm_family;
806 unsigned char tcm__pad1;
807 unsigned short tcm__pad2;
808 int tcm_ifindex;
809 __u32 tcm_handle;
810 __u32 tcm_parent;
811 __u32 tcm_info;
814 enum
816 TCA_UNSPEC,
817 TCA_KIND,
818 TCA_OPTIONS,
819 TCA_STATS,
820 TCA_XSTATS,
821 TCA_RATE,
822 TCA_FCNT,
823 TCA_STATS2,
824 __TCA_MAX
827 #define TCA_MAX (__TCA_MAX - 1)
829 #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
830 #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
832 #ifndef __KERNEL__
833 /* RTnetlink multicast groups - backwards compatibility for userspace */
834 #define RTMGRP_LINK 1
835 #define RTMGRP_NOTIFY 2
836 #define RTMGRP_NEIGH 4
837 #define RTMGRP_TC 8
839 #define RTMGRP_IPV4_IFADDR 0x10
840 #define RTMGRP_IPV4_MROUTE 0x20
841 #define RTMGRP_IPV4_ROUTE 0x40
842 #define RTMGRP_IPV4_RULE 0x80
844 #define RTMGRP_IPV6_IFADDR 0x100
845 #define RTMGRP_IPV6_MROUTE 0x200
846 #define RTMGRP_IPV6_ROUTE 0x400
847 #define RTMGRP_IPV6_IFINFO 0x800
849 #define RTMGRP_DECnet_IFADDR 0x1000
850 #define RTMGRP_DECnet_ROUTE 0x4000
852 #define RTMGRP_IPV6_PREFIX 0x20000
853 #endif
855 /* RTnetlink multicast groups */
856 enum rtnetlink_groups {
857 RTNLGRP_NONE,
858 #define RTNLGRP_NONE RTNLGRP_NONE
859 RTNLGRP_LINK,
860 #define RTNLGRP_LINK RTNLGRP_LINK
861 RTNLGRP_NOTIFY,
862 #define RTNLGRP_NOTIFY RTNLGRP_NOTIFY
863 RTNLGRP_NEIGH,
864 #define RTNLGRP_NEIGH RTNLGRP_NEIGH
865 RTNLGRP_TC,
866 #define RTNLGRP_TC RTNLGRP_TC
867 RTNLGRP_IPV4_IFADDR,
868 #define RTNLGRP_IPV4_IFADDR RTNLGRP_IPV4_IFADDR
869 RTNLGRP_IPV4_MROUTE,
870 #define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
871 RTNLGRP_IPV4_ROUTE,
872 #define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
873 RTNLGRP_IPV4_RULE,
874 #define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
875 RTNLGRP_IPV6_IFADDR,
876 #define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
877 RTNLGRP_IPV6_MROUTE,
878 #define RTNLGRP_IPV6_MROUTE RTNLGRP_IPV6_MROUTE
879 RTNLGRP_IPV6_ROUTE,
880 #define RTNLGRP_IPV6_ROUTE RTNLGRP_IPV6_ROUTE
881 RTNLGRP_IPV6_IFINFO,
882 #define RTNLGRP_IPV6_IFINFO RTNLGRP_IPV6_IFINFO
883 RTNLGRP_DECnet_IFADDR,
884 #define RTNLGRP_DECnet_IFADDR RTNLGRP_DECnet_IFADDR
885 RTNLGRP_NOP2,
886 RTNLGRP_DECnet_ROUTE,
887 #define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE
888 RTNLGRP_NOP3,
889 RTNLGRP_NOP4,
890 RTNLGRP_IPV6_PREFIX,
891 #define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX
892 __RTNLGRP_MAX
894 #define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
896 /* TC action piece */
897 struct tcamsg
899 unsigned char tca_family;
900 unsigned char tca__pad1;
901 unsigned short tca__pad2;
903 #define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
904 #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
905 #define TCA_ACT_TAB 1 /* attr type must be >=1 */
906 #define TCAA_MAX 1
908 /* End of information exported to user level */
910 #ifdef __KERNEL__
912 #include <linux/config.h>
913 #include <linux/mutex.h>
915 extern size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size);
916 static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
918 int len = strlen(str) + 1;
919 return len > rta->rta_len || memcmp(RTA_DATA(rta), str, len);
922 extern int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len);
924 #define rtattr_parse_nested(tb, max, rta) \
925 rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta)))
927 extern struct sock *rtnl;
929 struct rtnetlink_link
931 int (*doit)(struct sk_buff *, struct nlmsghdr*, void *attr);
932 int (*dumpit)(struct sk_buff *, struct netlink_callback *cb);
935 extern struct rtnetlink_link * rtnetlink_links[NPROTO];
936 extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo);
937 extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
939 extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);
941 #define RTA_PUT(skb, attrtype, attrlen, data) \
942 ({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
943 goto rtattr_failure; \
944 __rta_fill(skb, attrtype, attrlen, data); })
946 #define RTA_APPEND(skb, attrlen, data) \
947 ({ if (unlikely(skb_tailroom(skb) < (int)(attrlen))) \
948 goto rtattr_failure; \
949 memcpy(skb_put(skb, attrlen), data, attrlen); })
951 #define RTA_PUT_NOHDR(skb, attrlen, data) \
952 ({ RTA_APPEND(skb, RTA_ALIGN(attrlen), data); \
953 memset(skb->tail - (RTA_ALIGN(attrlen) - attrlen), 0, \
954 RTA_ALIGN(attrlen) - attrlen); })
956 #define RTA_PUT_U8(skb, attrtype, value) \
957 ({ u8 _tmp = (value); \
958 RTA_PUT(skb, attrtype, sizeof(u8), &_tmp); })
960 #define RTA_PUT_U16(skb, attrtype, value) \
961 ({ u16 _tmp = (value); \
962 RTA_PUT(skb, attrtype, sizeof(u16), &_tmp); })
964 #define RTA_PUT_U32(skb, attrtype, value) \
965 ({ u32 _tmp = (value); \
966 RTA_PUT(skb, attrtype, sizeof(u32), &_tmp); })
968 #define RTA_PUT_U64(skb, attrtype, value) \
969 ({ u64 _tmp = (value); \
970 RTA_PUT(skb, attrtype, sizeof(u64), &_tmp); })
972 #define RTA_PUT_SECS(skb, attrtype, value) \
973 RTA_PUT_U64(skb, attrtype, (value) / HZ)
975 #define RTA_PUT_MSECS(skb, attrtype, value) \
976 RTA_PUT_U64(skb, attrtype, jiffies_to_msecs(value))
978 #define RTA_PUT_STRING(skb, attrtype, value) \
979 RTA_PUT(skb, attrtype, strlen(value) + 1, value)
981 #define RTA_PUT_FLAG(skb, attrtype) \
982 RTA_PUT(skb, attrtype, 0, NULL);
984 #define RTA_NEST(skb, type) \
985 ({ struct rtattr *__start = (struct rtattr *) (skb)->tail; \
986 RTA_PUT(skb, type, 0, NULL); \
987 __start; })
989 #define RTA_NEST_END(skb, start) \
990 ({ (start)->rta_len = ((skb)->tail - (unsigned char *) (start)); \
991 (skb)->len; })
993 #define RTA_NEST_CANCEL(skb, start) \
994 ({ if (start) \
995 skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
996 -1; })
998 #define RTA_GET_U8(rta) \
999 ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u8)) \
1000 goto rtattr_failure; \
1001 *(u8 *) RTA_DATA(rta); })
1003 #define RTA_GET_U16(rta) \
1004 ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u16)) \
1005 goto rtattr_failure; \
1006 *(u16 *) RTA_DATA(rta); })
1008 #define RTA_GET_U32(rta) \
1009 ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u32)) \
1010 goto rtattr_failure; \
1011 *(u32 *) RTA_DATA(rta); })
1013 #define RTA_GET_U64(rta) \
1014 ({ u64 _tmp; \
1015 if (!rta || RTA_PAYLOAD(rta) < sizeof(u64)) \
1016 goto rtattr_failure; \
1017 memcpy(&_tmp, RTA_DATA(rta), sizeof(_tmp)); \
1018 _tmp; })
1020 #define RTA_GET_FLAG(rta) (!!(rta))
1022 #define RTA_GET_SECS(rta) ((unsigned long) RTA_GET_U64(rta) * HZ)
1023 #define RTA_GET_MSECS(rta) (msecs_to_jiffies((unsigned long) RTA_GET_U64(rta)))
1025 static inline struct rtattr *
1026 __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
1028 struct rtattr *rta;
1029 int size = RTA_LENGTH(attrlen);
1031 rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
1032 rta->rta_type = attrtype;
1033 rta->rta_len = size;
1034 memset(RTA_DATA(rta) + attrlen, 0, RTA_ALIGN(size) - size);
1035 return rta;
1038 #define __RTA_PUT(skb, attrtype, attrlen) \
1039 ({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
1040 goto rtattr_failure; \
1041 __rta_reserve(skb, attrtype, attrlen); })
1043 extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
1045 /* RTNL is used as a global lock for all changes to network configuration */
1046 extern void rtnl_lock(void);
1047 extern void rtnl_unlock(void);
1048 extern int rtnl_trylock(void);
1050 extern void rtnetlink_init(void);
1051 extern void __rtnl_unlock(void);
1053 #define ASSERT_RTNL() do { \
1054 if (unlikely(rtnl_trylock())) { \
1055 rtnl_unlock(); \
1056 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
1057 __FILE__, __LINE__); \
1058 dump_stack(); \
1060 } while(0)
1062 #define BUG_TRAP(x) do { \
1063 if (unlikely(!(x))) { \
1064 printk(KERN_ERR "KERNEL: assertion (%s) failed at %s (%d)\n", \
1065 #x, __FILE__ , __LINE__); \
1067 } while(0)
1069 #endif /* __KERNEL__ */
1072 #endif /* __LINUX_RTNETLINK_H */