1 #ifndef __LINUX_RTNETLINK_H
2 #define __LINUX_RTNETLINK_H
6 * @name Specialized Message Types for Routing Netlink
13 #define RTM_BASE RTM_BASE
16 #define RTM_NEWLINK RTM_NEWLINK
18 #define RTM_DELLINK RTM_DELLINK
20 #define RTM_GETLINK RTM_GETLINK
22 #define RTM_SETLINK RTM_SETLINK
25 #define RTM_NEWADDR RTM_NEWADDR
27 #define RTM_DELADDR RTM_DELADDR
29 #define RTM_GETADDR RTM_GETADDR
32 #define RTM_NEWROUTE RTM_NEWROUTE
34 #define RTM_DELROUTE RTM_DELROUTE
36 #define RTM_GETROUTE RTM_GETROUTE
39 #define RTM_NEWNEIGH RTM_NEWNEIGH
41 #define RTM_DELNEIGH RTM_DELNEIGH
43 #define RTM_GETNEIGH RTM_GETNEIGH
46 #define RTM_NEWRULE RTM_NEWRULE
48 #define RTM_DELRULE RTM_DELRULE
50 #define RTM_GETRULE RTM_GETRULE
53 #define RTM_NEWQDISC RTM_NEWQDISC
55 #define RTM_DELQDISC RTM_DELQDISC
57 #define RTM_GETQDISC RTM_GETQDISC
60 #define RTM_NEWTCLASS RTM_NEWTCLASS
62 #define RTM_DELTCLASS RTM_DELTCLASS
64 #define RTM_GETTCLASS RTM_GETTCLASS
67 #define RTM_NEWTFILTER RTM_NEWTFILTER
69 #define RTM_DELTFILTER RTM_DELTFILTER
71 #define RTM_GETTFILTER RTM_GETTFILTER
74 #define RTM_NEWACTION RTM_NEWACTION
76 #define RTM_DELACTION RTM_DELACTION
78 #define RTM_GETACTION RTM_GETACTION
81 #define RTM_NEWPREFIX RTM_NEWPREFIX
83 #define RTM_GETPREFIX RTM_GETPREFIX
85 RTM_GETMULTICAST = 58,
86 #define RTM_GETMULTICAST RTM_GETMULTICAST
89 #define RTM_GETANYCAST RTM_GETANYCAST
92 #define RTM_NEWNEIGHTBL RTM_NEWNEIGHTBL
94 #define RTM_GETNEIGHTBL RTM_GETNEIGHTBL
96 #define RTM_SETNEIGHTBL RTM_SETNEIGHTBL
101 #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
105 #define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
106 #define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
107 #define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
112 unsigned char rtm_family;
113 unsigned char rtm_dst_len;
114 unsigned char rtm_src_len;
115 unsigned char rtm_tos;
117 unsigned char rtm_table; /* Routing table id */
118 unsigned char rtm_protocol; /* Routing protocol; see below */
119 unsigned char rtm_scope; /* See below */
120 unsigned char rtm_type; /* See below */
130 RTN_UNICAST, /* Gateway or direct route */
131 RTN_LOCAL, /* Accept locally */
132 RTN_BROADCAST, /* Accept locally as broadcast,
134 RTN_ANYCAST, /* Accept locally as broadcast,
135 but send as unicast */
136 RTN_MULTICAST, /* Multicast route */
137 RTN_BLACKHOLE, /* Drop */
138 RTN_UNREACHABLE, /* Destination is unreachable */
139 RTN_PROHIBIT, /* Administratively prohibited */
140 RTN_THROW, /* Not in this table */
141 RTN_NAT, /* Translate this address */
142 RTN_XRESOLVE, /* Use external resolver */
146 #define RTN_MAX (__RTN_MAX - 1)
151 #define RTPROT_UNSPEC 0
152 #define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects;
153 not used by current IPv4 */
154 #define RTPROT_KERNEL 2 /* Route installed by kernel */
155 #define RTPROT_BOOT 3 /* Route installed during boot */
156 #define RTPROT_STATIC 4 /* Route installed by administrator */
158 /* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
159 they are just passed from user and back as is.
160 It will be used by hypothetical multiple routing daemons.
161 Note that protocol values should be standardized in order to
165 #define RTPROT_GATED 8 /* Apparently, GateD */
166 #define RTPROT_RA 9 /* RDISC/ND router advertisements */
167 #define RTPROT_MRT 10 /* Merit MRT */
168 #define RTPROT_ZEBRA 11 /* Zebra */
169 #define RTPROT_BIRD 12 /* BIRD */
170 #define RTPROT_DNROUTED 13 /* DECnet routing daemon */
171 #define RTPROT_XORP 14 /* XORP */
175 Really it is not scope, but sort of distance to the destination.
176 NOWHERE are reserved for not existing destinations, HOST is our
177 local addresses, LINK are destinations, located on directly attached
178 link and UNIVERSE is everywhere in the Universe.
180 Intermediate values are also possible f.e. interior routes
181 could be assigned a value between UNIVERSE and LINK.
187 /* User defined values */
196 #define RTM_F_NOTIFY 0x100 /* Notify user of route change */
197 #define RTM_F_CLONED 0x200 /* This route is cloned */
198 #define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */
199 #define RTM_F_PREFIX 0x800 /* Prefix addresses */
201 /* Reserved table identifiers */
206 /* User defined values */
207 RT_TABLE_DEFAULT=253,
212 #define RT_TABLE_MAX (__RT_TABLE_MAX - 1)
216 /* Routing message attributes */
238 #define RTA_MAX (__RTA_MAX - 1)
240 #define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
241 #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
243 /* RTM_MULTIPATH --- array of struct rtnexthop.
245 * "struct rtnexthop" describes all necessary nexthop information,
246 * i.e. parameters of path to a destination via this nexthop.
248 * At the moment it is impossible to set different prefsrc, mtu, window
249 * and rtt for different paths from multipath.
254 unsigned short rtnh_len;
255 unsigned char rtnh_flags;
256 unsigned char rtnh_hops;
262 #define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
263 #define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
264 #define RTNH_F_ONLINK 4 /* Gateway is forced on link */
266 /* Macros to handle hexthops */
268 #define RTNH_ALIGNTO 4
269 #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
270 #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
271 ((int)(rtnh)->rtnh_len) <= (len))
272 #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
273 #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
274 #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
275 #define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
287 #define RTNETLINK_HAVE_PEERINFO 1
293 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
298 #define RTAX_UNSPEC RTAX_UNSPEC
300 #define RTAX_LOCK RTAX_LOCK
302 #define RTAX_MTU RTAX_MTU
304 #define RTAX_WINDOW RTAX_WINDOW
306 #define RTAX_RTT RTAX_RTT
308 #define RTAX_RTTVAR RTAX_RTTVAR
310 #define RTAX_SSTHRESH RTAX_SSTHRESH
312 #define RTAX_CWND RTAX_CWND
314 #define RTAX_ADVMSS RTAX_ADVMSS
316 #define RTAX_REORDERING RTAX_REORDERING
318 #define RTAX_HOPLIMIT RTAX_HOPLIMIT
320 #define RTAX_INITCWND RTAX_INITCWND
322 #define RTAX_FEATURES RTAX_FEATURES
326 #define RTAX_MAX (__RTAX_MAX - 1)
329 * @name Features Metric Flags
333 #define RTAX_FEATURE_ECN 0x00000001
334 #define RTAX_FEATURE_SACK 0x00000002
335 #define RTAX_FEATURE_TIMESTAMP 0x00000004
336 #define RTAX_FEATURE_ALLFRAG 0x00000008
361 /*********************************************************
367 unsigned char ifa_family;
368 unsigned char ifa_prefixlen; /* The prefix length */
369 unsigned char ifa_flags; /* Flags */
370 unsigned char ifa_scope; /* See above */
371 int ifa_index; /* Link index */
387 #define IFA_MAX (__IFA_MAX - 1)
390 * @name Address Flags
394 #define IFA_F_SECONDARY 0x01
395 #define IFA_F_TEMPORARY IFA_F_SECONDARY
397 #define IFA_F_DEPRECATED 0x20
398 #define IFA_F_TENTATIVE 0x40
399 #define IFA_F_PERMANENT 0x80
405 __u32 cstamp; /* created timestamp, hundredths of seconds */
406 __u32 tstamp; /* updated timestamp, hundredths of seconds */
410 #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
411 #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
415 IFA_ADDRESS is prefix address, rather than local interface address.
416 It makes no difference for normally configured broadcast interfaces,
417 but for point-to-point IFA_ADDRESS is DESTINATION address,
418 local address is supplied in IFA_LOCAL attribute.
421 /**************************************************************
422 * Neighbour discovery.
427 unsigned char ndm_family;
428 unsigned char ndm_pad1;
429 unsigned short ndm_pad2;
430 int ndm_ifindex; /* Link index */
446 #define NDA_MAX (__NDA_MAX - 1)
448 #define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
449 #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
452 * Neighbor Cache Entry Flags
455 #define NTF_PROXY 0x08 /* == ATF_PUBL */
456 #define NTF_ROUTER 0x80
459 * Neighbor Cache Entry States.
462 #define NUD_INCOMPLETE 0x01
463 #define NUD_REACHABLE 0x02
464 #define NUD_STALE 0x04
465 #define NUD_DELAY 0x08
466 #define NUD_PROBE 0x10
467 #define NUD_FAILED 0x20
470 #define NUD_NOARP 0x40
471 #define NUD_PERMANENT 0x80
472 #define NUD_NONE 0x00
483 /*****************************************************************
484 * Neighbour tables specific messages.
487 * Phase 1: foreach neighbour table
488 * neighbour table base configuration and statistics
489 * NDTA_NAME, NDTA_CONFIG, NDTA_THRESH[1-3], NDTA_STATS
492 * Phase 2: foreach neighbour table device parameter set
493 * NDTA_NAME, NDTA_PARMS
500 __u64 ndts_hash_grows;
501 __u64 ndts_res_failed;
504 __u64 ndts_rcv_probes_mcast;
505 __u64 ndts_rcv_probes_ucast;
506 __u64 ndts_periodic_gc_runs;
507 __u64 ndts_forced_gc_runs;
512 NDTPA_IFINDEX, /* u32, read-only */
513 NDTPA_REFCNT, /* u32, read-only */
514 NDTPA_REACHABLE_TIME, /* u64, msecs, read-only */
515 NDTPA_BASE_REACHABLE_TIME, /* u64, msecs */
516 NDTPA_RETRANS_TIME, /* u64, msecs */
517 NDTPA_GC_STALETIME, /* u64, msecs */
518 NDTPA_DELAY_PROBE_TIME, /* u64, msecs */
519 NDTPA_QUEUE_LEN, /* u32 */
520 NDTPA_APP_PROBES, /* u32 */
521 NDTPA_UCAST_PROBES, /* u32 */
522 NDTPA_MCAST_PROBES, /* u32 */
523 NDTPA_ANYCAST_DELAY, /* u64, msecs */
524 NDTPA_PROXY_DELAY, /* u64, msecs */
525 NDTPA_PROXY_QLEN, /* u32 */
526 NDTPA_LOCKTIME, /* u64, msecs */
529 #define NDTPA_MAX (__NDTPA_MAX - 1)
541 __u16 ndtc_entry_size;
543 __u32 ndtc_last_flush; /* delta to now in msecs */
544 __u32 ndtc_last_rand; /* delta to now in msecs */
546 __u32 ndtc_hash_mask;
547 __u32 ndtc_hash_chain_gc;
548 __u32 ndtc_proxy_qlen;
553 NDTA_NAME, /* char * */
554 NDTA_THRESH1, /* u32 */
555 NDTA_THRESH2, /* u32 */
556 NDTA_THRESH3, /* u32 */
557 NDTA_CONFIG, /* struct ndt_config */
558 NDTA_PARMS, /* NDTPA_* */
559 NDTA_STATS, /* struct ndt_stats */
560 NDTA_GC_INTERVAL, /* u64, msecs */
563 #define NDTA_MAX (__NDTA_MAX - 1)
565 #define NDTA_RTA(r) ((struct rtattr*)(((char*)(r)) + \
566 NLMSG_ALIGN(sizeof(struct ndtmsg))))
567 #define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))
570 * General form of address family dependent message.
575 unsigned char rtgen_family;
578 /*****************************************************************
579 * Link layer specific messages.
583 * passes link level specific information, not dependent
584 * on network protocol.
589 unsigned char ifi_family;
590 unsigned char __ifi_pad;
591 unsigned short ifi_type; /* ARPHRD_* */
592 int ifi_index; /* Link index */
593 unsigned ifi_flags; /* IFF_* flags */
594 unsigned ifi_change; /* IFF_* change mask */
597 /********************************************************************
603 unsigned char prefix_family;
605 unsigned char prefix_type;
606 unsigned char prefix_len;
607 unsigned char prefix_flags;
618 #define PREFIX_MAX (__PREFIX_MAX - 1)
620 struct prefix_cacheinfo
622 __u32 preferred_time;
626 /* The struct should be in sync with struct net_device_stats */
627 struct rtnl_link_stats
629 __u32 rx_packets; /* total packets received */
630 __u32 tx_packets; /* total packets transmitted */
631 __u32 rx_bytes; /* total bytes received */
632 __u32 tx_bytes; /* total bytes transmitted */
633 __u32 rx_errors; /* bad packets received */
634 __u32 tx_errors; /* packet transmit problems */
635 __u32 rx_dropped; /* no space in linux buffers */
636 __u32 tx_dropped; /* no space available in linux */
637 __u32 multicast; /* multicast packets received */
640 /* detailed rx_errors: */
641 __u32 rx_length_errors;
642 __u32 rx_over_errors; /* receiver ring buff overflow */
643 __u32 rx_crc_errors; /* recved pkt with crc error */
644 __u32 rx_frame_errors; /* recv'd frame alignment error */
645 __u32 rx_fifo_errors; /* recv'r fifo overrun */
646 __u32 rx_missed_errors; /* receiver missed packet */
648 /* detailed tx_errors */
649 __u32 tx_aborted_errors;
650 __u32 tx_carrier_errors;
651 __u32 tx_fifo_errors;
652 __u32 tx_heartbeat_errors;
653 __u32 tx_window_errors;
660 /* The struct should be in sync with struct ifmap */
661 struct rtnl_link_ifmap
682 #define IFLA_COST IFLA_COST
684 #define IFLA_PRIORITY IFLA_PRIORITY
686 #define IFLA_MASTER IFLA_MASTER
687 IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */
688 #define IFLA_WIRELESS IFLA_WIRELESS
689 IFLA_PROTINFO, /* Protocol specific information for a link */
690 #define IFLA_PROTINFO IFLA_PROTINFO
692 #define IFLA_TXQLEN IFLA_TXQLEN
694 #define IFLA_MAP IFLA_MAP
696 #define IFLA_WEIGHT IFLA_WEIGHT
701 #define IFLA_MAX (__IFLA_MAX - 1)
703 #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
704 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
711 IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are
712 more not changeable by user. They describe link media
713 characteristics and set by device driver.
716 - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid
717 - If neither of these three flags are set;
718 the interface is NBMA.
720 - IFF_MULTICAST does not mean anything special:
721 multicasts can be used on all not-NBMA links.
722 IFF_MULTICAST means that this media uses special encapsulation
723 for multicast frames. Apparently, all IFF_POINTOPOINT and
724 IFF_BROADCAST devices are able to use multicasts too.
728 For usual devices it is equal ifi_index.
729 If it is a "virtual interface" (f.e. tunnel), ifi_link
730 can point to real physical interface (f.e. for bandwidth calculations),
731 or maybe 0, what means, that real media is unknown (usual
732 for IPIP tunnels, when route to endpoint is allowed to change)
735 /* Subtype attributes for IFLA_PROTINFO */
739 IFLA_INET6_FLAGS, /* link flags */
740 IFLA_INET6_CONF, /* sysctl parameters */
741 IFLA_INET6_STATS, /* statistics */
742 IFLA_INET6_MCAST, /* MC things. What of them? */
743 IFLA_INET6_CACHEINFO, /* time values and max reasm size */
747 #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
749 struct ifla_cacheinfo
752 __u32 tstamp; /* ipv6InterfaceTable updated timestamp */
753 __u32 reachable_time;
757 /*****************************************************************
758 * Traffic control messages.
763 unsigned char tcm_family;
764 unsigned char tcm__pad1;
765 unsigned short tcm__pad2;
785 #define TCA_MAX (__TCA_MAX - 1)
787 #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
788 #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
791 /* RTnetlink multicast groups */
793 #define RTMGRP_LINK 1
794 #define RTMGRP_NOTIFY 2
795 #define RTMGRP_NEIGH 4
798 #define RTMGRP_IPV4_IFADDR 0x10
799 #define RTMGRP_IPV4_MROUTE 0x20
800 #define RTMGRP_IPV4_ROUTE 0x40
802 #define RTMGRP_IPV6_IFADDR 0x100
803 #define RTMGRP_IPV6_MROUTE 0x200
804 #define RTMGRP_IPV6_ROUTE 0x400
805 #define RTMGRP_IPV6_IFINFO 0x800
807 #define RTMGRP_DECnet_IFADDR 0x1000
808 #define RTMGRP_DECnet_ROUTE 0x4000
810 #define RTMGRP_IPV6_PREFIX 0x20000
812 /* RTnetlink multicast groups */
813 enum rtnetlink_groups {
827 RTNLGRP_DECnet_IFADDR,
829 RTNLGRP_DECnet_ROUTE,
836 #define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
839 /* TC action piece */
842 unsigned char tca_family;
843 unsigned char tca__pad1;
844 unsigned short tca__pad2;
846 #define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
847 #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
848 #define TCA_ACT_TAB 1 /* attr type must be >=1 */
851 /* End of information exported to user level */
853 #endif /* __LINUX_RTNETLINK_H */