[PATCH] w1: Adds a sysfs entry (w1_master_search) that allows you to disable/enable...
[linux-2.6/verdex.git] / include / linux / rtnetlink.h
blobe68dbf0bf5791f1e0a4e08098fdbf2e9995195e1
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 */
203 /* rtm_scope
205 Really it is not scope, but sort of distance to the destination.
206 NOWHERE are reserved for not existing destinations, HOST is our
207 local addresses, LINK are destinations, located on directly attached
208 link and UNIVERSE is everywhere in the Universe.
210 Intermediate values are also possible f.e. interior routes
211 could be assigned a value between UNIVERSE and LINK.
214 enum rt_scope_t
216 RT_SCOPE_UNIVERSE=0,
217 /* User defined values */
218 RT_SCOPE_SITE=200,
219 RT_SCOPE_LINK=253,
220 RT_SCOPE_HOST=254,
221 RT_SCOPE_NOWHERE=255
224 /* rtm_flags */
226 #define RTM_F_NOTIFY 0x100 /* Notify user of route change */
227 #define RTM_F_CLONED 0x200 /* This route is cloned */
228 #define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */
229 #define RTM_F_PREFIX 0x800 /* Prefix addresses */
231 /* Reserved table identifiers */
233 enum rt_class_t
235 RT_TABLE_UNSPEC=0,
236 /* User defined values */
237 RT_TABLE_DEFAULT=253,
238 RT_TABLE_MAIN=254,
239 RT_TABLE_LOCAL=255,
240 __RT_TABLE_MAX
242 #define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
246 /* Routing message attributes */
248 enum rtattr_type_t
250 RTA_UNSPEC,
251 RTA_DST,
252 RTA_SRC,
253 RTA_IIF,
254 RTA_OIF,
255 RTA_GATEWAY,
256 RTA_PRIORITY,
257 RTA_PREFSRC,
258 RTA_METRICS,
259 RTA_MULTIPATH,
260 RTA_PROTOINFO,
261 RTA_FLOW,
262 RTA_CACHEINFO,
263 RTA_SESSION,
264 RTA_MP_ALGO,
265 __RTA_MAX
268 #define RTA_MAX (__RTA_MAX - 1)
270 #define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
271 #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
273 /* RTM_MULTIPATH --- array of struct rtnexthop.
275 * "struct rtnexthop" describes all necessary nexthop information,
276 * i.e. parameters of path to a destination via this nexthop.
278 * At the moment it is impossible to set different prefsrc, mtu, window
279 * and rtt for different paths from multipath.
282 struct rtnexthop
284 unsigned short rtnh_len;
285 unsigned char rtnh_flags;
286 unsigned char rtnh_hops;
287 int rtnh_ifindex;
290 /* rtnh_flags */
292 #define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
293 #define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
294 #define RTNH_F_ONLINK 4 /* Gateway is forced on link */
296 /* Macros to handle hexthops */
298 #define RTNH_ALIGNTO 4
299 #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
300 #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
301 ((int)(rtnh)->rtnh_len) <= (len))
302 #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
303 #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
304 #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
305 #define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
307 /* RTM_CACHEINFO */
309 struct rta_cacheinfo
311 __u32 rta_clntref;
312 __u32 rta_lastuse;
313 __s32 rta_expires;
314 __u32 rta_error;
315 __u32 rta_used;
317 #define RTNETLINK_HAVE_PEERINFO 1
318 __u32 rta_id;
319 __u32 rta_ts;
320 __u32 rta_tsage;
323 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
325 enum
327 RTAX_UNSPEC,
328 #define RTAX_UNSPEC RTAX_UNSPEC
329 RTAX_LOCK,
330 #define RTAX_LOCK RTAX_LOCK
331 RTAX_MTU,
332 #define RTAX_MTU RTAX_MTU
333 RTAX_WINDOW,
334 #define RTAX_WINDOW RTAX_WINDOW
335 RTAX_RTT,
336 #define RTAX_RTT RTAX_RTT
337 RTAX_RTTVAR,
338 #define RTAX_RTTVAR RTAX_RTTVAR
339 RTAX_SSTHRESH,
340 #define RTAX_SSTHRESH RTAX_SSTHRESH
341 RTAX_CWND,
342 #define RTAX_CWND RTAX_CWND
343 RTAX_ADVMSS,
344 #define RTAX_ADVMSS RTAX_ADVMSS
345 RTAX_REORDERING,
346 #define RTAX_REORDERING RTAX_REORDERING
347 RTAX_HOPLIMIT,
348 #define RTAX_HOPLIMIT RTAX_HOPLIMIT
349 RTAX_INITCWND,
350 #define RTAX_INITCWND RTAX_INITCWND
351 RTAX_FEATURES,
352 #define RTAX_FEATURES RTAX_FEATURES
353 __RTAX_MAX
356 #define RTAX_MAX (__RTAX_MAX - 1)
358 #define RTAX_FEATURE_ECN 0x00000001
359 #define RTAX_FEATURE_SACK 0x00000002
360 #define RTAX_FEATURE_TIMESTAMP 0x00000004
361 #define RTAX_FEATURE_ALLFRAG 0x00000008
363 struct rta_session
365 __u8 proto;
367 union {
368 struct {
369 __u16 sport;
370 __u16 dport;
371 } ports;
373 struct {
374 __u8 type;
375 __u8 code;
376 __u16 ident;
377 } icmpt;
379 __u32 spi;
380 } u;
384 /*********************************************************
385 * Interface address.
386 ****/
388 struct ifaddrmsg
390 unsigned char ifa_family;
391 unsigned char ifa_prefixlen; /* The prefix length */
392 unsigned char ifa_flags; /* Flags */
393 unsigned char ifa_scope; /* See above */
394 int ifa_index; /* Link index */
397 enum
399 IFA_UNSPEC,
400 IFA_ADDRESS,
401 IFA_LOCAL,
402 IFA_LABEL,
403 IFA_BROADCAST,
404 IFA_ANYCAST,
405 IFA_CACHEINFO,
406 IFA_MULTICAST,
407 __IFA_MAX
410 #define IFA_MAX (__IFA_MAX - 1)
412 /* ifa_flags */
414 #define IFA_F_SECONDARY 0x01
415 #define IFA_F_TEMPORARY IFA_F_SECONDARY
417 #define IFA_F_DEPRECATED 0x20
418 #define IFA_F_TENTATIVE 0x40
419 #define IFA_F_PERMANENT 0x80
421 struct ifa_cacheinfo
423 __u32 ifa_prefered;
424 __u32 ifa_valid;
425 __u32 cstamp; /* created timestamp, hundredths of seconds */
426 __u32 tstamp; /* updated timestamp, hundredths of seconds */
430 #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
431 #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
434 Important comment:
435 IFA_ADDRESS is prefix address, rather than local interface address.
436 It makes no difference for normally configured broadcast interfaces,
437 but for point-to-point IFA_ADDRESS is DESTINATION address,
438 local address is supplied in IFA_LOCAL attribute.
441 /**************************************************************
442 * Neighbour discovery.
443 ****/
445 struct ndmsg
447 unsigned char ndm_family;
448 unsigned char ndm_pad1;
449 unsigned short ndm_pad2;
450 int ndm_ifindex; /* Link index */
451 __u16 ndm_state;
452 __u8 ndm_flags;
453 __u8 ndm_type;
456 enum
458 NDA_UNSPEC,
459 NDA_DST,
460 NDA_LLADDR,
461 NDA_CACHEINFO,
462 NDA_PROBES,
463 __NDA_MAX
466 #define NDA_MAX (__NDA_MAX - 1)
468 #define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
469 #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
472 * Neighbor Cache Entry Flags
475 #define NTF_PROXY 0x08 /* == ATF_PUBL */
476 #define NTF_ROUTER 0x80
479 * Neighbor Cache Entry States.
482 #define NUD_INCOMPLETE 0x01
483 #define NUD_REACHABLE 0x02
484 #define NUD_STALE 0x04
485 #define NUD_DELAY 0x08
486 #define NUD_PROBE 0x10
487 #define NUD_FAILED 0x20
489 /* Dummy states */
490 #define NUD_NOARP 0x40
491 #define NUD_PERMANENT 0x80
492 #define NUD_NONE 0x00
495 struct nda_cacheinfo
497 __u32 ndm_confirmed;
498 __u32 ndm_used;
499 __u32 ndm_updated;
500 __u32 ndm_refcnt;
504 /*****************************************************************
505 * Neighbour tables specific messages.
507 * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
508 * NLM_F_DUMP flag set. Every neighbour table configuration is
509 * spread over multiple messages to avoid running into message
510 * size limits on systems with many interfaces. The first message
511 * in the sequence transports all not device specific data such as
512 * statistics, configuration, and the default parameter set.
513 * This message is followed by 0..n messages carrying device
514 * specific parameter sets.
515 * Although the ordering should be sufficient, NDTA_NAME can be
516 * used to identify sequences. The initial message can be identified
517 * by checking for NDTA_CONFIG. The device specific messages do
518 * not contain this TLV but have NDTPA_IFINDEX set to the
519 * corresponding interface index.
521 * To change neighbour table attributes, send RTM_SETNEIGHTBL
522 * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
523 * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
524 * otherwise. Device specific parameter sets can be changed by
525 * setting NDTPA_IFINDEX to the interface index of the corresponding
526 * device.
527 ****/
529 struct ndt_stats
531 __u64 ndts_allocs;
532 __u64 ndts_destroys;
533 __u64 ndts_hash_grows;
534 __u64 ndts_res_failed;
535 __u64 ndts_lookups;
536 __u64 ndts_hits;
537 __u64 ndts_rcv_probes_mcast;
538 __u64 ndts_rcv_probes_ucast;
539 __u64 ndts_periodic_gc_runs;
540 __u64 ndts_forced_gc_runs;
543 enum {
544 NDTPA_UNSPEC,
545 NDTPA_IFINDEX, /* u32, unchangeable */
546 NDTPA_REFCNT, /* u32, read-only */
547 NDTPA_REACHABLE_TIME, /* u64, read-only, msecs */
548 NDTPA_BASE_REACHABLE_TIME, /* u64, msecs */
549 NDTPA_RETRANS_TIME, /* u64, msecs */
550 NDTPA_GC_STALETIME, /* u64, msecs */
551 NDTPA_DELAY_PROBE_TIME, /* u64, msecs */
552 NDTPA_QUEUE_LEN, /* u32 */
553 NDTPA_APP_PROBES, /* u32 */
554 NDTPA_UCAST_PROBES, /* u32 */
555 NDTPA_MCAST_PROBES, /* u32 */
556 NDTPA_ANYCAST_DELAY, /* u64, msecs */
557 NDTPA_PROXY_DELAY, /* u64, msecs */
558 NDTPA_PROXY_QLEN, /* u32 */
559 NDTPA_LOCKTIME, /* u64, msecs */
560 __NDTPA_MAX
562 #define NDTPA_MAX (__NDTPA_MAX - 1)
564 struct ndtmsg
566 __u8 ndtm_family;
567 __u8 ndtm_pad1;
568 __u16 ndtm_pad2;
571 struct ndt_config
573 __u16 ndtc_key_len;
574 __u16 ndtc_entry_size;
575 __u32 ndtc_entries;
576 __u32 ndtc_last_flush; /* delta to now in msecs */
577 __u32 ndtc_last_rand; /* delta to now in msecs */
578 __u32 ndtc_hash_rnd;
579 __u32 ndtc_hash_mask;
580 __u32 ndtc_hash_chain_gc;
581 __u32 ndtc_proxy_qlen;
584 enum {
585 NDTA_UNSPEC,
586 NDTA_NAME, /* char *, unchangeable */
587 NDTA_THRESH1, /* u32 */
588 NDTA_THRESH2, /* u32 */
589 NDTA_THRESH3, /* u32 */
590 NDTA_CONFIG, /* struct ndt_config, read-only */
591 NDTA_PARMS, /* nested TLV NDTPA_* */
592 NDTA_STATS, /* struct ndt_stats, read-only */
593 NDTA_GC_INTERVAL, /* u64, msecs */
594 __NDTA_MAX
596 #define NDTA_MAX (__NDTA_MAX - 1)
598 #define NDTA_RTA(r) ((struct rtattr*)(((char*)(r)) + \
599 NLMSG_ALIGN(sizeof(struct ndtmsg))))
600 #define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))
603 /****
604 * General form of address family dependent message.
605 ****/
607 struct rtgenmsg
609 unsigned char rtgen_family;
612 /*****************************************************************
613 * Link layer specific messages.
614 ****/
616 /* struct ifinfomsg
617 * passes link level specific information, not dependent
618 * on network protocol.
621 struct ifinfomsg
623 unsigned char ifi_family;
624 unsigned char __ifi_pad;
625 unsigned short ifi_type; /* ARPHRD_* */
626 int ifi_index; /* Link index */
627 unsigned ifi_flags; /* IFF_* flags */
628 unsigned ifi_change; /* IFF_* change mask */
631 /********************************************************************
632 * prefix information
633 ****/
635 struct prefixmsg
637 unsigned char prefix_family;
638 int prefix_ifindex;
639 unsigned char prefix_type;
640 unsigned char prefix_len;
641 unsigned char prefix_flags;
644 enum
646 PREFIX_UNSPEC,
647 PREFIX_ADDRESS,
648 PREFIX_CACHEINFO,
649 __PREFIX_MAX
652 #define PREFIX_MAX (__PREFIX_MAX - 1)
654 struct prefix_cacheinfo
656 __u32 preferred_time;
657 __u32 valid_time;
660 /* The struct should be in sync with struct net_device_stats */
661 struct rtnl_link_stats
663 __u32 rx_packets; /* total packets received */
664 __u32 tx_packets; /* total packets transmitted */
665 __u32 rx_bytes; /* total bytes received */
666 __u32 tx_bytes; /* total bytes transmitted */
667 __u32 rx_errors; /* bad packets received */
668 __u32 tx_errors; /* packet transmit problems */
669 __u32 rx_dropped; /* no space in linux buffers */
670 __u32 tx_dropped; /* no space available in linux */
671 __u32 multicast; /* multicast packets received */
672 __u32 collisions;
674 /* detailed rx_errors: */
675 __u32 rx_length_errors;
676 __u32 rx_over_errors; /* receiver ring buff overflow */
677 __u32 rx_crc_errors; /* recved pkt with crc error */
678 __u32 rx_frame_errors; /* recv'd frame alignment error */
679 __u32 rx_fifo_errors; /* recv'r fifo overrun */
680 __u32 rx_missed_errors; /* receiver missed packet */
682 /* detailed tx_errors */
683 __u32 tx_aborted_errors;
684 __u32 tx_carrier_errors;
685 __u32 tx_fifo_errors;
686 __u32 tx_heartbeat_errors;
687 __u32 tx_window_errors;
689 /* for cslip etc */
690 __u32 rx_compressed;
691 __u32 tx_compressed;
694 /* The struct should be in sync with struct ifmap */
695 struct rtnl_link_ifmap
697 __u64 mem_start;
698 __u64 mem_end;
699 __u64 base_addr;
700 __u16 irq;
701 __u8 dma;
702 __u8 port;
705 enum
707 IFLA_UNSPEC,
708 IFLA_ADDRESS,
709 IFLA_BROADCAST,
710 IFLA_IFNAME,
711 IFLA_MTU,
712 IFLA_LINK,
713 IFLA_QDISC,
714 IFLA_STATS,
715 IFLA_COST,
716 #define IFLA_COST IFLA_COST
717 IFLA_PRIORITY,
718 #define IFLA_PRIORITY IFLA_PRIORITY
719 IFLA_MASTER,
720 #define IFLA_MASTER IFLA_MASTER
721 IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */
722 #define IFLA_WIRELESS IFLA_WIRELESS
723 IFLA_PROTINFO, /* Protocol specific information for a link */
724 #define IFLA_PROTINFO IFLA_PROTINFO
725 IFLA_TXQLEN,
726 #define IFLA_TXQLEN IFLA_TXQLEN
727 IFLA_MAP,
728 #define IFLA_MAP IFLA_MAP
729 IFLA_WEIGHT,
730 #define IFLA_WEIGHT IFLA_WEIGHT
731 __IFLA_MAX
735 #define IFLA_MAX (__IFLA_MAX - 1)
737 #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
738 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
740 /* ifi_flags.
742 IFF_* flags.
744 The only change is:
745 IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
746 more not changeable by user. They describe link media
747 characteristics and set by device driver.
749 Comments:
750 - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
751 - If neither of these three flags are set;
752 the interface is NBMA.
754 - IFF_MULTICAST does not mean anything special:
755 multicasts can be used on all not-NBMA links.
756 IFF_MULTICAST means that this media uses special encapsulation
757 for multicast frames. Apparently, all IFF_POINTOPOINT and
758 IFF_BROADCAST devices are able to use multicasts too.
761 /* IFLA_LINK.
762 For usual devices it is equal ifi_index.
763 If it is a "virtual interface" (f.e. tunnel), ifi_link
764 can point to real physical interface (f.e. for bandwidth calculations),
765 or maybe 0, what means, that real media is unknown (usual
766 for IPIP tunnels, when route to endpoint is allowed to change)
769 /* Subtype attributes for IFLA_PROTINFO */
770 enum
772 IFLA_INET6_UNSPEC,
773 IFLA_INET6_FLAGS, /* link flags */
774 IFLA_INET6_CONF, /* sysctl parameters */
775 IFLA_INET6_STATS, /* statistics */
776 IFLA_INET6_MCAST, /* MC things. What of them? */
777 IFLA_INET6_CACHEINFO, /* time values and max reasm size */
778 __IFLA_INET6_MAX
781 #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
783 struct ifla_cacheinfo
785 __u32 max_reasm_len;
786 __u32 tstamp; /* ipv6InterfaceTable updated timestamp */
787 __u32 reachable_time;
788 __u32 retrans_time;
791 /*****************************************************************
792 * Traffic control messages.
793 ****/
795 struct tcmsg
797 unsigned char tcm_family;
798 unsigned char tcm__pad1;
799 unsigned short tcm__pad2;
800 int tcm_ifindex;
801 __u32 tcm_handle;
802 __u32 tcm_parent;
803 __u32 tcm_info;
806 enum
808 TCA_UNSPEC,
809 TCA_KIND,
810 TCA_OPTIONS,
811 TCA_STATS,
812 TCA_XSTATS,
813 TCA_RATE,
814 TCA_FCNT,
815 TCA_STATS2,
816 __TCA_MAX
819 #define TCA_MAX (__TCA_MAX - 1)
821 #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
822 #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
825 /* RTnetlink multicast groups */
827 #define RTMGRP_LINK 1
828 #define RTMGRP_NOTIFY 2
829 #define RTMGRP_NEIGH 4
830 #define RTMGRP_TC 8
832 #define RTMGRP_IPV4_IFADDR 0x10
833 #define RTMGRP_IPV4_MROUTE 0x20
834 #define RTMGRP_IPV4_ROUTE 0x40
836 #define RTMGRP_IPV6_IFADDR 0x100
837 #define RTMGRP_IPV6_MROUTE 0x200
838 #define RTMGRP_IPV6_ROUTE 0x400
839 #define RTMGRP_IPV6_IFINFO 0x800
841 #define RTMGRP_DECnet_IFADDR 0x1000
842 #define RTMGRP_DECnet_ROUTE 0x4000
844 #define RTMGRP_IPV6_PREFIX 0x20000
846 /* TC action piece */
847 struct tcamsg
849 unsigned char tca_family;
850 unsigned char tca__pad1;
851 unsigned short tca__pad2;
853 #define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
854 #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
855 #define TCA_ACT_TAB 1 /* attr type must be >=1 */
856 #define TCAA_MAX 1
858 /* End of information exported to user level */
860 #ifdef __KERNEL__
862 #include <linux/config.h>
864 extern size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size);
865 static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
867 int len = strlen(str) + 1;
868 return len > rta->rta_len || memcmp(RTA_DATA(rta), str, len);
871 extern int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len);
873 #define rtattr_parse_nested(tb, max, rta) \
874 rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta)))
876 extern struct sock *rtnl;
878 struct rtnetlink_link
880 int (*doit)(struct sk_buff *, struct nlmsghdr*, void *attr);
881 int (*dumpit)(struct sk_buff *, struct netlink_callback *cb);
884 extern struct rtnetlink_link * rtnetlink_links[NPROTO];
885 extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo);
886 extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
888 extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);
890 #define RTA_PUT(skb, attrtype, attrlen, data) \
891 ({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
892 goto rtattr_failure; \
893 __rta_fill(skb, attrtype, attrlen, data); })
895 #define RTA_PUT_NOHDR(skb, attrlen, data) \
896 ({ if (unlikely(skb_tailroom(skb) < (int)(attrlen))) \
897 goto rtattr_failure; \
898 memcpy(skb_put(skb, RTA_ALIGN(attrlen)), data, attrlen); })
900 #define RTA_PUT_U8(skb, attrtype, value) \
901 ({ u8 _tmp = (value); \
902 RTA_PUT(skb, attrtype, sizeof(u8), &_tmp); })
904 #define RTA_PUT_U16(skb, attrtype, value) \
905 ({ u16 _tmp = (value); \
906 RTA_PUT(skb, attrtype, sizeof(u16), &_tmp); })
908 #define RTA_PUT_U32(skb, attrtype, value) \
909 ({ u32 _tmp = (value); \
910 RTA_PUT(skb, attrtype, sizeof(u32), &_tmp); })
912 #define RTA_PUT_U64(skb, attrtype, value) \
913 ({ u64 _tmp = (value); \
914 RTA_PUT(skb, attrtype, sizeof(u64), &_tmp); })
916 #define RTA_PUT_SECS(skb, attrtype, value) \
917 RTA_PUT_U64(skb, attrtype, (value) / HZ)
919 #define RTA_PUT_MSECS(skb, attrtype, value) \
920 RTA_PUT_U64(skb, attrtype, jiffies_to_msecs(value))
922 #define RTA_PUT_STRING(skb, attrtype, value) \
923 RTA_PUT(skb, attrtype, strlen(value) + 1, value)
925 #define RTA_PUT_FLAG(skb, attrtype) \
926 RTA_PUT(skb, attrtype, 0, NULL);
928 #define RTA_NEST(skb, type) \
929 ({ struct rtattr *__start = (struct rtattr *) (skb)->tail; \
930 RTA_PUT(skb, type, 0, NULL); \
931 __start; })
933 #define RTA_NEST_END(skb, start) \
934 ({ (start)->rta_len = ((skb)->tail - (unsigned char *) (start)); \
935 (skb)->len; })
937 #define RTA_NEST_CANCEL(skb, start) \
938 ({ if (start) \
939 skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
940 -1; })
942 #define RTA_GET_U8(rta) \
943 ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u8)) \
944 goto rtattr_failure; \
945 *(u8 *) RTA_DATA(rta); })
947 #define RTA_GET_U16(rta) \
948 ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u16)) \
949 goto rtattr_failure; \
950 *(u16 *) RTA_DATA(rta); })
952 #define RTA_GET_U32(rta) \
953 ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u32)) \
954 goto rtattr_failure; \
955 *(u32 *) RTA_DATA(rta); })
957 #define RTA_GET_U64(rta) \
958 ({ u64 _tmp; \
959 if (!rta || RTA_PAYLOAD(rta) < sizeof(u64)) \
960 goto rtattr_failure; \
961 memcpy(&_tmp, RTA_DATA(rta), sizeof(_tmp)); \
962 _tmp; })
964 #define RTA_GET_FLAG(rta) (!!(rta))
966 #define RTA_GET_SECS(rta) ((unsigned long) RTA_GET_U64(rta) * HZ)
967 #define RTA_GET_MSECS(rta) (msecs_to_jiffies((unsigned long) RTA_GET_U64(rta)))
969 static inline struct rtattr *
970 __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
972 struct rtattr *rta;
973 int size = RTA_LENGTH(attrlen);
975 rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
976 rta->rta_type = attrtype;
977 rta->rta_len = size;
978 return rta;
981 #define __RTA_PUT(skb, attrtype, attrlen) \
982 ({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
983 goto rtattr_failure; \
984 __rta_reserve(skb, attrtype, attrlen); })
986 extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
988 extern struct semaphore rtnl_sem;
990 #define rtnl_shlock() down(&rtnl_sem)
991 #define rtnl_shlock_nowait() down_trylock(&rtnl_sem)
993 #define rtnl_shunlock() do { up(&rtnl_sem); \
994 if (rtnl && rtnl->sk_receive_queue.qlen) \
995 rtnl->sk_data_ready(rtnl, 0); \
996 } while(0)
998 extern void rtnl_lock(void);
999 extern int rtnl_lock_interruptible(void);
1000 extern void rtnl_unlock(void);
1001 extern void rtnetlink_init(void);
1003 #define ASSERT_RTNL() do { \
1004 if (unlikely(down_trylock(&rtnl_sem) == 0)) { \
1005 up(&rtnl_sem); \
1006 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
1007 __FILE__, __LINE__); \
1008 dump_stack(); \
1010 } while(0)
1012 #define BUG_TRAP(x) do { \
1013 if (unlikely(!(x))) { \
1014 printk(KERN_ERR "KERNEL: assertion (%s) failed at %s (%d)\n", \
1015 #x, __FILE__ , __LINE__); \
1017 } while(0)
1019 #endif /* __KERNEL__ */
1022 #endif /* __LINUX_RTNETLINK_H */