1 #ifndef __LINUX_RTNETLINK_H
2 #define __LINUX_RTNETLINK_H
8 * Routing/neighbour discovery messages.
11 /* Types of messages */
15 #define RTM_BASE RTM_BASE
18 #define RTM_NEWLINK RTM_NEWLINK
20 #define RTM_DELLINK RTM_DELLINK
22 #define RTM_GETLINK RTM_GETLINK
24 #define RTM_SETLINK RTM_SETLINK
27 #define RTM_NEWADDR RTM_NEWADDR
29 #define RTM_DELADDR RTM_DELADDR
31 #define RTM_GETADDR RTM_GETADDR
34 #define RTM_NEWROUTE RTM_NEWROUTE
36 #define RTM_DELROUTE RTM_DELROUTE
38 #define RTM_GETROUTE RTM_GETROUTE
41 #define RTM_NEWNEIGH RTM_NEWNEIGH
43 #define RTM_DELNEIGH RTM_DELNEIGH
45 #define RTM_GETNEIGH RTM_GETNEIGH
48 #define RTM_NEWRULE RTM_NEWRULE
50 #define RTM_DELRULE RTM_DELRULE
52 #define RTM_GETRULE RTM_GETRULE
55 #define RTM_NEWQDISC RTM_NEWQDISC
57 #define RTM_DELQDISC RTM_DELQDISC
59 #define RTM_GETQDISC RTM_GETQDISC
62 #define RTM_NEWTCLASS RTM_NEWTCLASS
64 #define RTM_DELTCLASS RTM_DELTCLASS
66 #define RTM_GETTCLASS RTM_GETTCLASS
69 #define RTM_NEWTFILTER RTM_NEWTFILTER
71 #define RTM_DELTFILTER RTM_DELTFILTER
73 #define RTM_GETTFILTER RTM_GETTFILTER
76 #define RTM_NEWACTION RTM_NEWACTION
78 #define RTM_DELACTION RTM_DELACTION
80 #define RTM_GETACTION RTM_GETACTION
83 #define RTM_NEWPREFIX RTM_NEWPREFIX
85 #define RTM_GETPREFIX RTM_GETPREFIX
87 RTM_GETMULTICAST
= 58,
88 #define RTM_GETMULTICAST RTM_GETMULTICAST
91 #define RTM_GETANYCAST RTM_GETANYCAST
94 #define RTM_NEWNEIGHTBL RTM_NEWNEIGHTBL
96 #define RTM_GETNEIGHTBL RTM_GETNEIGHTBL
98 #define RTM_SETNEIGHTBL RTM_SETNEIGHTBL
101 #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
104 #define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
105 #define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
106 #define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
109 Generic structure for encapsulation of optional route information.
110 It is reminiscent of sockaddr, but with sa_family replaced
116 unsigned short rta_len
;
117 unsigned short rta_type
;
120 /* Macros to handle rtattributes */
122 #define RTA_ALIGNTO 4
123 #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
124 #define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \
125 (rta)->rta_len >= sizeof(struct rtattr) && \
126 (rta)->rta_len <= (len))
127 #define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
128 (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
129 #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
130 #define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len))
131 #define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
132 #define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
137 /******************************************************************************
138 * Definitions used in routing table administration.
143 unsigned char rtm_family
;
144 unsigned char rtm_dst_len
;
145 unsigned char rtm_src_len
;
146 unsigned char rtm_tos
;
148 unsigned char rtm_table
; /* Routing table id */
149 unsigned char rtm_protocol
; /* Routing protocol; see below */
150 unsigned char rtm_scope
; /* See below */
151 unsigned char rtm_type
; /* See below */
161 RTN_UNICAST
, /* Gateway or direct route */
162 RTN_LOCAL
, /* Accept locally */
163 RTN_BROADCAST
, /* Accept locally as broadcast,
165 RTN_ANYCAST
, /* Accept locally as broadcast,
166 but send as unicast */
167 RTN_MULTICAST
, /* Multicast route */
168 RTN_BLACKHOLE
, /* Drop */
169 RTN_UNREACHABLE
, /* Destination is unreachable */
170 RTN_PROHIBIT
, /* Administratively prohibited */
171 RTN_THROW
, /* Not in this table */
172 RTN_NAT
, /* Translate this address */
173 RTN_XRESOLVE
, /* Use external resolver */
177 #define RTN_MAX (__RTN_MAX - 1)
182 #define RTPROT_UNSPEC 0
183 #define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects;
184 not used by current IPv4 */
185 #define RTPROT_KERNEL 2 /* Route installed by kernel */
186 #define RTPROT_BOOT 3 /* Route installed during boot */
187 #define RTPROT_STATIC 4 /* Route installed by administrator */
189 /* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
190 they are just passed from user and back as is.
191 It will be used by hypothetical multiple routing daemons.
192 Note that protocol values should be standardized in order to
196 #define RTPROT_GATED 8 /* Apparently, GateD */
197 #define RTPROT_RA 9 /* RDISC/ND router advertisements */
198 #define RTPROT_MRT 10 /* Merit MRT */
199 #define RTPROT_ZEBRA 11 /* Zebra */
200 #define RTPROT_BIRD 12 /* BIRD */
201 #define RTPROT_DNROUTED 13 /* DECnet routing daemon */
202 #define RTPROT_XORP 14 /* XORP */
203 #define RTPROT_NTK 15 /* Netsukuku */
207 Really it is not scope, but sort of distance to the destination.
208 NOWHERE are reserved for not existing destinations, HOST is our
209 local addresses, LINK are destinations, located on directly attached
210 link and UNIVERSE is everywhere in the Universe.
212 Intermediate values are also possible f.e. interior routes
213 could be assigned a value between UNIVERSE and LINK.
219 /* User defined values */
228 #define RTM_F_NOTIFY 0x100 /* Notify user of route change */
229 #define RTM_F_CLONED 0x200 /* This route is cloned */
230 #define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */
231 #define RTM_F_PREFIX 0x800 /* Prefix addresses */
233 /* Reserved table identifiers */
238 /* User defined values */
239 RT_TABLE_DEFAULT
=253,
244 #define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
248 /* Routing message attributes */
270 #define RTA_MAX (__RTA_MAX - 1)
272 #define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
273 #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
275 /* RTM_MULTIPATH --- array of struct rtnexthop.
277 * "struct rtnexthop" describes all necessary nexthop information,
278 * i.e. parameters of path to a destination via this nexthop.
280 * At the moment it is impossible to set different prefsrc, mtu, window
281 * and rtt for different paths from multipath.
286 unsigned short rtnh_len
;
287 unsigned char rtnh_flags
;
288 unsigned char rtnh_hops
;
294 #define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
295 #define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
296 #define RTNH_F_ONLINK 4 /* Gateway is forced on link */
298 /* Macros to handle hexthops */
300 #define RTNH_ALIGNTO 4
301 #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
302 #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
303 ((int)(rtnh)->rtnh_len) <= (len))
304 #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
305 #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
306 #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
307 #define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
313 uint32_t rta_clntref
;
314 uint32_t rta_lastuse
;
319 #define RTNETLINK_HAVE_PEERINFO 1
325 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
330 #define RTAX_UNSPEC RTAX_UNSPEC
332 #define RTAX_LOCK RTAX_LOCK
334 #define RTAX_MTU RTAX_MTU
336 #define RTAX_WINDOW RTAX_WINDOW
338 #define RTAX_RTT RTAX_RTT
340 #define RTAX_RTTVAR RTAX_RTTVAR
342 #define RTAX_SSTHRESH RTAX_SSTHRESH
344 #define RTAX_CWND RTAX_CWND
346 #define RTAX_ADVMSS RTAX_ADVMSS
348 #define RTAX_REORDERING RTAX_REORDERING
350 #define RTAX_HOPLIMIT RTAX_HOPLIMIT
352 #define RTAX_INITCWND RTAX_INITCWND
354 #define RTAX_FEATURES RTAX_FEATURES
358 #define RTAX_MAX (__RTAX_MAX - 1)
360 #define RTAX_FEATURE_ECN 0x00000001
361 #define RTAX_FEATURE_SACK 0x00000002
362 #define RTAX_FEATURE_TIMESTAMP 0x00000004
363 #define RTAX_FEATURE_ALLFRAG 0x00000008
388 /*********************************************************
394 unsigned char ifa_family
;
395 unsigned char ifa_prefixlen
; /* The prefix length */
396 unsigned char ifa_flags
; /* Flags */
397 unsigned char ifa_scope
; /* See above */
398 int ifa_index
; /* Link index */
414 #define IFA_MAX (__IFA_MAX - 1)
418 #define IFA_F_SECONDARY 0x01
419 #define IFA_F_TEMPORARY IFA_F_SECONDARY
421 #define IFA_F_DEPRECATED 0x20
422 #define IFA_F_TENTATIVE 0x40
423 #define IFA_F_PERMANENT 0x80
427 uint32_t ifa_prefered
;
429 uint32_t cstamp
; /* created timestamp, hundredths of seconds */
430 uint32_t tstamp
; /* updated timestamp, hundredths of seconds */
434 #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
435 #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
439 IFA_ADDRESS is prefix address, rather than local interface address.
440 It makes no difference for normally configured broadcast interfaces,
441 but for point-to-point IFA_ADDRESS is DESTINATION address,
442 local address is supplied in IFA_LOCAL attribute.
445 /**************************************************************
446 * Neighbour discovery.
451 unsigned char ndm_family
;
452 unsigned char ndm_pad1
;
453 unsigned short ndm_pad2
;
454 int ndm_ifindex
; /* Link index */
470 #define NDA_MAX (__NDA_MAX - 1)
472 #define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
473 #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
476 * Neighbor Cache Entry Flags
479 #define NTF_PROXY 0x08 /* == ATF_PUBL */
480 #define NTF_ROUTER 0x80
483 * Neighbor Cache Entry States.
486 #define NUD_INCOMPLETE 0x01
487 #define NUD_REACHABLE 0x02
488 #define NUD_STALE 0x04
489 #define NUD_DELAY 0x08
490 #define NUD_PROBE 0x10
491 #define NUD_FAILED 0x20
494 #define NUD_NOARP 0x40
495 #define NUD_PERMANENT 0x80
496 #define NUD_NONE 0x00
501 uint32_t ndm_confirmed
;
503 uint32_t ndm_updated
;
508 /*****************************************************************
509 * Neighbour tables specific messages.
511 * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
512 * NLM_F_DUMP flag set. Every neighbour table configuration is
513 * spread over multiple messages to avoid running into message
514 * size limits on systems with many interfaces. The first message
515 * in the sequence transports all not device specific data such as
516 * statistics, configuration, and the default parameter set.
517 * This message is followed by 0..n messages carrying device
518 * specific parameter sets.
519 * Although the ordering should be sufficient, NDTA_NAME can be
520 * used to identify sequences. The initial message can be identified
521 * by checking for NDTA_CONFIG. The device specific messages do
522 * not contain this TLV but have NDTPA_IFINDEX set to the
523 * corresponding interface index.
525 * To change neighbour table attributes, send RTM_SETNEIGHTBL
526 * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
527 * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
528 * otherwise. Device specific parameter sets can be changed by
529 * setting NDTPA_IFINDEX to the interface index of the corresponding
535 uint64_t ndts_allocs
;
536 uint64_t ndts_destroys
;
537 uint64_t ndts_hash_grows
;
538 uint64_t ndts_res_failed
;
539 uint64_t ndts_lookups
;
541 uint64_t ndts_rcv_probes_mcast
;
542 uint64_t ndts_rcv_probes_ucast
;
543 uint64_t ndts_periodic_gc_runs
;
544 uint64_t ndts_forced_gc_runs
;
549 NDTPA_IFINDEX
, /* uint32_t, unchangeable */
550 NDTPA_REFCNT
, /* uint32_t, read-only */
551 NDTPA_REACHABLE_TIME
, /* uint64_t, read-only, msecs */
552 NDTPA_BASE_REACHABLE_TIME
, /* uint64_t, msecs */
553 NDTPA_RETRANS_TIME
, /* uint64_t, msecs */
554 NDTPA_GC_STALETIME
, /* uint64_t, msecs */
555 NDTPA_DELAY_PROBE_TIME
, /* uint64_t, msecs */
556 NDTPA_QUEUE_LEN
, /* uint32_t */
557 NDTPA_APP_PROBES
, /* uint32_t */
558 NDTPA_UCAST_PROBES
, /* uint32_t */
559 NDTPA_MCAST_PROBES
, /* uint32_t */
560 NDTPA_ANYCAST_DELAY
, /* uint64_t, msecs */
561 NDTPA_PROXY_DELAY
, /* uint64_t, msecs */
562 NDTPA_PROXY_QLEN
, /* uint32_t */
563 NDTPA_LOCKTIME
, /* uint64_t, msecs */
566 #define NDTPA_MAX (__NDTPA_MAX - 1)
577 uint16_t ndtc_key_len
;
578 uint16_t ndtc_entry_size
;
579 uint32_t ndtc_entries
;
580 uint32_t ndtc_last_flush
; /* delta to now in msecs */
581 uint32_t ndtc_last_rand
; /* delta to now in msecs */
582 uint32_t ndtc_hash_rnd
;
583 uint32_t ndtc_hash_mask
;
584 uint32_t ndtc_hash_chain_gc
;
585 uint32_t ndtc_proxy_qlen
;
590 NDTA_NAME
, /* char *, unchangeable */
591 NDTA_THRESH1
, /* uint32_t */
592 NDTA_THRESH2
, /* uint32_t */
593 NDTA_THRESH3
, /* uint32_t */
594 NDTA_CONFIG
, /* struct ndt_config, read-only */
595 NDTA_PARMS
, /* nested TLV NDTPA_* */
596 NDTA_STATS
, /* struct ndt_stats, read-only */
597 NDTA_GC_INTERVAL
, /* uint64_t, msecs */
600 #define NDTA_MAX (__NDTA_MAX - 1)
602 #define NDTA_RTA(r) ((struct rtattr*)(((char*)(r)) + \
603 NLMSG_ALIGN(sizeof(struct ndtmsg))))
604 #define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))
608 * General form of address family dependent message.
613 unsigned char rtgen_family
;
616 /*****************************************************************
617 * Link layer specific messages.
621 * passes link level specific information, not dependent
622 * on network protocol.
627 unsigned char ifi_family
;
628 unsigned char __ifi_pad
;
629 unsigned short ifi_type
; /* ARPHRD_* */
630 int ifi_index
; /* Link index */
631 unsigned ifi_flags
; /* IFF_* flags */
632 unsigned ifi_change
; /* IFF_* change mask */
635 /********************************************************************
641 unsigned char prefix_family
;
642 unsigned char prefix_pad1
;
643 unsigned short prefix_pad2
;
645 unsigned char prefix_type
;
646 unsigned char prefix_len
;
647 unsigned char prefix_flags
;
648 unsigned char prefix_pad3
;
659 #define PREFIX_MAX (__PREFIX_MAX - 1)
661 struct prefix_cacheinfo
663 uint32_t preferred_time
;
667 /* The struct should be in sync with struct net_device_stats */
668 struct rtnl_link_stats
670 uint32_t rx_packets
; /* total packets received */
671 uint32_t tx_packets
; /* total packets transmitted */
672 uint32_t rx_bytes
; /* total bytes received */
673 uint32_t tx_bytes
; /* total bytes transmitted */
674 uint32_t rx_errors
; /* bad packets received */
675 uint32_t tx_errors
; /* packet transmit problems */
676 uint32_t rx_dropped
; /* no space in linux buffers */
677 uint32_t tx_dropped
; /* no space available in linux */
678 uint32_t multicast
; /* multicast packets received */
681 /* detailed rx_errors: */
682 uint32_t rx_length_errors
;
683 uint32_t rx_over_errors
; /* receiver ring buff overflow */
684 uint32_t rx_crc_errors
; /* recved pkt with crc error */
685 uint32_t rx_frame_errors
; /* recv'd frame alignment error */
686 uint32_t rx_fifo_errors
; /* recv'r fifo overrun */
687 uint32_t rx_missed_errors
; /* receiver missed packet */
689 /* detailed tx_errors */
690 uint32_t tx_aborted_errors
;
691 uint32_t tx_carrier_errors
;
692 uint32_t tx_fifo_errors
;
693 uint32_t tx_heartbeat_errors
;
694 uint32_t tx_window_errors
;
697 uint32_t rx_compressed
;
698 uint32_t tx_compressed
;
701 /* The struct should be in sync with struct ifmap */
702 struct rtnl_link_ifmap
723 #define IFLA_COST IFLA_COST
725 #define IFLA_PRIORITY IFLA_PRIORITY
727 #define IFLA_MASTER IFLA_MASTER
728 IFLA_WIRELESS
, /* Wireless Extension event - see wireless.h */
729 #define IFLA_WIRELESS IFLA_WIRELESS
730 IFLA_PROTINFO
, /* Protocol specific information for a link */
731 #define IFLA_PROTINFO IFLA_PROTINFO
733 #define IFLA_TXQLEN IFLA_TXQLEN
735 #define IFLA_MAP IFLA_MAP
737 #define IFLA_WEIGHT IFLA_WEIGHT
744 #define IFLA_MAX (__IFLA_MAX - 1)
746 #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
747 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
754 IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
755 more not changeable by user. They describe link media
756 characteristics and set by device driver.
759 - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
760 - If neither of these three flags are set;
761 the interface is NBMA.
763 - IFF_MULTICAST does not mean anything special:
764 multicasts can be used on all not-NBMA links.
765 IFF_MULTICAST means that this media uses special encapsulation
766 for multicast frames. Apparently, all IFF_POINTOPOINT and
767 IFF_BROADCAST devices are able to use multicasts too.
771 For usual devices it is equal ifi_index.
772 If it is a "virtual interface" (f.e. tunnel), ifi_link
773 can point to real physical interface (f.e. for bandwidth calculations),
774 or maybe 0, what means, that real media is unknown (usual
775 for IPIP tunnels, when route to endpoint is allowed to change)
778 /* Subtype attributes for IFLA_PROTINFO */
782 IFLA_INET6_FLAGS
, /* link flags */
783 IFLA_INET6_CONF
, /* sysctl parameters */
784 IFLA_INET6_STATS
, /* statistics */
785 IFLA_INET6_MCAST
, /* MC things. What of them? */
786 IFLA_INET6_CACHEINFO
, /* time values and max reasm size */
790 #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
792 struct ifla_cacheinfo
794 uint32_t max_reasm_len
;
795 uint32_t tstamp
; /* ipv6InterfaceTable updated timestamp */
796 uint32_t reachable_time
;
797 uint32_t retrans_time
;
800 /*****************************************************************
801 * Traffic control messages.
806 unsigned char tcm_family
;
807 unsigned char tcm__pad1
;
808 unsigned short tcm__pad2
;
828 #define TCA_MAX (__TCA_MAX - 1)
830 #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
831 #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
834 /* RTnetlink multicast groups - backwards compatibility for userspace */
835 #define RTMGRP_LINK 1
836 #define RTMGRP_NOTIFY 2
837 #define RTMGRP_NEIGH 4
840 #define RTMGRP_IPV4_IFADDR 0x10
841 #define RTMGRP_IPV4_MROUTE 0x20
842 #define RTMGRP_IPV4_ROUTE 0x40
843 #define RTMGRP_IPV4_RULE 0x80
845 #define RTMGRP_IPV6_IFADDR 0x100
846 #define RTMGRP_IPV6_MROUTE 0x200
847 #define RTMGRP_IPV6_ROUTE 0x400
848 #define RTMGRP_IPV6_IFINFO 0x800
850 #define RTMGRP_DECnet_IFADDR 0x1000
851 #define RTMGRP_DECnet_ROUTE 0x4000
853 #define RTMGRP_IPV6_PREFIX 0x20000
856 /* RTnetlink multicast groups */
857 enum rtnetlink_groups
{
859 #define RTNLGRP_NONE RTNLGRP_NONE
861 #define RTNLGRP_LINK RTNLGRP_LINK
863 #define RTNLGRP_NOTIFY RTNLGRP_NOTIFY
865 #define RTNLGRP_NEIGH RTNLGRP_NEIGH
867 #define RTNLGRP_TC RTNLGRP_TC
869 #define RTNLGRP_IPV4_IFADDR RTNLGRP_IPV4_IFADDR
871 #define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
873 #define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
875 #define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
877 #define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
879 #define RTNLGRP_IPV6_MROUTE RTNLGRP_IPV6_MROUTE
881 #define RTNLGRP_IPV6_ROUTE RTNLGRP_IPV6_ROUTE
883 #define RTNLGRP_IPV6_IFINFO RTNLGRP_IPV6_IFINFO
884 RTNLGRP_DECnet_IFADDR
,
885 #define RTNLGRP_DECnet_IFADDR RTNLGRP_DECnet_IFADDR
887 RTNLGRP_DECnet_ROUTE
,
888 #define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE
892 #define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX
895 #define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
897 /* TC action piece */
900 unsigned char tca_family
;
901 unsigned char tca__pad1
;
902 unsigned short tca__pad2
;
904 #define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
905 #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
906 #define TCA_ACT_TAB 1 /* attr type must be >=1 */
909 /* End of information exported to user level */
913 #include <linux/config.h>
914 #include <linux/mutex.h>
916 extern size_t rtattr_strlcpy(char *dest
, const struct rtattr
*rta
, size_t size
);
917 static __inline__
int rtattr_strcmp(const struct rtattr
*rta
, const char *str
)
919 int len
= strlen(str
) + 1;
920 return len
> rta
->rta_len
|| memcmp(RTA_DATA(rta
), str
, len
);
923 extern int rtattr_parse(struct rtattr
*tb
[], int maxattr
, struct rtattr
*rta
, int len
);
925 #define rtattr_parse_nested(tb, max, rta) \
926 rtattr_parse((tb), (max), RTA_DATA((rta)), RTA_PAYLOAD((rta)))
928 extern struct sock
*rtnl
;
930 struct rtnetlink_link
932 int (*doit
)(struct sk_buff
*, struct nlmsghdr
*, void *attr
);
933 int (*dumpit
)(struct sk_buff
*, struct netlink_callback
*cb
);
936 extern struct rtnetlink_link
* rtnetlink_links
[NPROTO
];
937 extern int rtnetlink_send(struct sk_buff
*skb
, uint32_t pid
, uint32_t group
, int echo
);
938 extern int rtnetlink_put_metrics(struct sk_buff
*skb
, uint32_t *metrics
);
940 extern void __rta_fill(struct sk_buff
*skb
, int attrtype
, int attrlen
, const void *data
);
942 #define RTA_PUT(skb, attrtype, attrlen, data) \
943 ({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
944 goto rtattr_failure; \
945 __rta_fill(skb, attrtype, attrlen, data); })
947 #define RTA_APPEND(skb, attrlen, data) \
948 ({ if (unlikely(skb_tailroom(skb) < (int)(attrlen))) \
949 goto rtattr_failure; \
950 memcpy(skb_put(skb, attrlen), data, attrlen); })
952 #define RTA_PUT_NOHDR(skb, attrlen, data) \
953 ({ RTA_APPEND(skb, RTA_ALIGN(attrlen), data); \
954 memset(skb->tail - (RTA_ALIGN(attrlen) - attrlen), 0, \
955 RTA_ALIGN(attrlen) - attrlen); })
957 #define RTA_PUT_U8(skb, attrtype, value) \
958 ({ uint8_t _tmp = (value); \
959 RTA_PUT(skb, attrtype, sizeof(uint8_t), &_tmp); })
961 #define RTA_PUT_U16(skb, attrtype, value) \
962 ({ uint16_t _tmp = (value); \
963 RTA_PUT(skb, attrtype, sizeof(uint16_t), &_tmp); })
965 #define RTA_PUT_U32(skb, attrtype, value) \
966 ({ uint32_t _tmp = (value); \
967 RTA_PUT(skb, attrtype, sizeof(uint32_t), &_tmp); })
969 #define RTA_PUT_U64(skb, attrtype, value) \
970 ({ uint64_t _tmp = (value); \
971 RTA_PUT(skb, attrtype, sizeof(uint64_t), &_tmp); })
973 #define RTA_PUT_SECS(skb, attrtype, value) \
974 RTA_PUT_U64(skb, attrtype, (value) / HZ)
976 #define RTA_PUT_MSECS(skb, attrtype, value) \
977 RTA_PUT_U64(skb, attrtype, jiffies_to_msecs(value))
979 #define RTA_PUT_STRING(skb, attrtype, value) \
980 RTA_PUT(skb, attrtype, strlen(value) + 1, value)
982 #define RTA_PUT_FLAG(skb, attrtype) \
983 RTA_PUT(skb, attrtype, 0, NULL);
985 #define RTA_NEST(skb, type) \
986 ({ struct rtattr *__start = (struct rtattr *) (skb)->tail; \
987 RTA_PUT(skb, type, 0, NULL); \
990 #define RTA_NEST_END(skb, start) \
991 ({ (start)->rta_len = ((skb)->tail - (unsigned char *) (start)); \
994 #define RTA_NEST_CANCEL(skb, start) \
996 skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
999 #define RTA_GET_U8(rta) \
1000 ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(uint8_t)) \
1001 goto rtattr_failure; \
1002 *(uint8_t *) RTA_DATA(rta); })
1004 #define RTA_GET_U16(rta) \
1005 ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(uint16_t)) \
1006 goto rtattr_failure; \
1007 *(uint16_t *) RTA_DATA(rta); })
1009 #define RTA_GET_U32(rta) \
1010 ({ if (!rta || RTA_PAYLOAD(rta) < sizeof(uint32_t)) \
1011 goto rtattr_failure; \
1012 *(uint32_t *) RTA_DATA(rta); })
1014 #define RTA_GET_U64(rta) \
1016 if (!rta || RTA_PAYLOAD(rta) < sizeof(uint64_t)) \
1017 goto rtattr_failure; \
1018 memcpy(&_tmp, RTA_DATA(rta), sizeof(_tmp)); \
1021 #define RTA_GET_FLAG(rta) (!!(rta))
1023 #define RTA_GET_SECS(rta) ((unsigned long) RTA_GET_U64(rta) * HZ)
1024 #define RTA_GET_MSECS(rta) (msecs_to_jiffies((unsigned long) RTA_GET_U64(rta)))
1026 static __inline__
struct rtattr
*
1027 __rta_reserve(struct sk_buff
*skb
, int attrtype
, int attrlen
)
1030 int size
= RTA_LENGTH(attrlen
);
1032 rta
= (struct rtattr
*)skb_put(skb
, RTA_ALIGN(size
));
1033 rta
->rta_type
= attrtype
;
1034 rta
->rta_len
= size
;
1035 memset(RTA_DATA(rta
) + attrlen
, 0, RTA_ALIGN(size
) - size
);
1039 #define __RTA_PUT(skb, attrtype, attrlen) \
1040 ({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
1041 goto rtattr_failure; \
1042 __rta_reserve(skb, attrtype, attrlen); })
1044 extern void rtmsg_ifinfo(int type
, struct net_device
*dev
, unsigned change
);
1046 /* RTNL is used as a global lock for all changes to network configuration */
1047 extern void rtnl_lock(void);
1048 extern void rtnl_unlock(void);
1049 extern int rtnl_trylock(void);
1051 extern void rtnetlink_init(void);
1052 extern void __rtnl_unlock(void);
1054 #define ASSERT_RTNL() do { \
1055 if (unlikely(rtnl_trylock())) { \
1057 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
1058 __FILE__, __LINE__); \
1063 #define BUG_TRAP(x) do { \
1064 if (unlikely(!(x))) { \
1065 printk(KERN_ERR "KERNEL: assertion (%s) failed at %s (%d)\n", \
1066 #x, __FILE__ , __LINE__); \
1070 #endif /* __KERNEL__ */
1073 #endif /* __LINUX_RTNETLINK_H */