patch-2.1.89 linux/include/linux/rtnetlink.h

Next file: linux/include/linux/sdla_x25.h
Previous file: linux/include/linux/route.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.88/linux/include/linux/rtnetlink.h linux/include/linux/rtnetlink.h
@@ -5,6 +5,7 @@
 #include <linux/netlink.h>
 
 #define RTNL_DEBUG 1
+#define CONFIG_RTNL_OLD_IFINFO 1
 
 
 /****
@@ -35,19 +36,24 @@
 #define	RTM_DELRULE	(RTM_BASE+17)
 #define	RTM_GETRULE	(RTM_BASE+18)
 
-#define	RTM_MAX		(RTM_BASE+19)
-
-
-/* Generic structure for encapsulation optional route
-   information. It is reminiscent of sockaddr, but with sa_family
-   replaced with attribute type.
-   It would be good, if constructions of sort:
-   struct something {
-     struct rtattr rta;
-     struct a_content a;
-   }
-   had correct alignment. It is true for x86, but I have no idea
-   how to make it on 64bit architectures. Please, teach me. --ANK
+#define	RTM_NEWQDISC	(RTM_BASE+20)
+#define	RTM_DELQDSIC	(RTM_BASE+21)
+#define	RTM_GETQDISC	(RTM_BASE+22)
+
+#define	RTM_NEWTFLOW	(RTM_BASE+24)
+#define	RTM_DELTFLOW	(RTM_BASE+25)
+#define	RTM_GETTFLOW	(RTM_BASE+26)
+
+#define	RTM_NEWTFILTER	(RTM_BASE+28)
+#define	RTM_DELTFILTER	(RTM_BASE+29)
+#define	RTM_GETTFILTER	(RTM_BASE+30)
+
+#define	RTM_MAX		(RTM_BASE+31)
+
+/* 
+   Generic structure for encapsulation optional route information.
+   It is reminiscent of sockaddr, but with sa_family replaced
+   with attribute type.
  */
 
 struct rtattr
@@ -56,25 +62,6 @@
 	unsigned short	rta_type;
 };
 
-enum rtattr_type_t
-{
-	RTA_UNSPEC,
-	RTA_DST,
-	RTA_SRC,
-	RTA_IIF,
-	RTA_OIF,
-	RTA_GATEWAY,
-	RTA_PRIORITY,
-	RTA_PREFSRC,
-	RTA_WINDOW,
-	RTA_RTT,
-	RTA_MTU,
-	RTA_IFNAME,
-	RTA_CACHEINFO
-};
-
-#define RTA_MAX RTA_CACHEINFO
-
 /* Macros to handle rtattributes */
 
 #define RTA_ALIGNTO	4
@@ -86,49 +73,14 @@
 #define RTA_LENGTH(len)	(RTA_ALIGN(sizeof(struct rtattr)) + (len))
 #define RTA_SPACE(len)	RTA_ALIGN(RTA_LENGTH(len))
 #define RTA_DATA(rta)   ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
+#define RTA_PAYLOAD(rta) ((rta)->rta_len - RTA_LENGTH(0))
 
-struct rta_cacheinfo
-{
-	__u32	rta_clntref;
-	__u32	rta_lastuse;
-	__s32	rta_expires;
-	__u32	rta_error;
-	__u32	rta_used;
-};
-
-/*
- * "struct rtnexthop" describres all necessary nexthop information,
- * i.e. parameters of path to a destination via this nextop.
- *
- * At the moment it is impossible to set different prefsrc, mtu, window
- * and rtt for different paths from multipath.
- */
-
-struct rtnexthop
-{
-	unsigned short		rtnh_len;
-	unsigned char		rtnh_flags;
-	unsigned char		rtnh_hops;
-	int			rtnh_ifindex;
-};
-
-/* rtnh_flags */
-
-#define RTNH_F_DEAD		1	/* Nexthop is dead (used by multipath)	*/
-#define RTNH_F_PERVASIVE	2	/* Do recursive gateway lookup	*/
-#define RTNH_F_ONLINK		4	/* Gateway is forced on link	*/
 
-/* Macros to handle hexthops */
 
-#define RTNH_ALIGNTO	4
-#define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
-#define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
-			   (rtnh)->rtnh_len <= (len))
-#define RTNH_NEXT(rtnh)	((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
-#define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
-#define RTNH_SPACE(len)	RTNH_ALIGN(RTNH_LENGTH(len))
-#define RTNH_DATA(rtnh)   ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
 
+/******************************************************************************
+ *		Definitions used in routing table administation.
+ ****/
 
 struct rtmsg
 {
@@ -136,21 +88,24 @@
 	unsigned char		rtm_dst_len;
 	unsigned char		rtm_src_len;
 	unsigned char		rtm_tos;
+
 	unsigned char		rtm_table;	/* Routing table id */
 	unsigned char		rtm_protocol;	/* Routing protocol; see below	*/
+#ifdef CONFIG_RTNL_OLD_IFINFO
 	unsigned char		rtm_nhs;	/* Number of nexthops */
+#else
+	unsigned char		rtm_scope;	/* See below */	
+#endif
 	unsigned char		rtm_type;	/* See below	*/
+
+#ifdef CONFIG_RTNL_OLD_IFINFO
 	unsigned short		rtm_optlen;	/* Byte length of rtm_opt */
 	unsigned char		rtm_scope;	/* See below */	
 	unsigned char		rtm_whatsit;	/* Unused byte */
+#endif
 	unsigned		rtm_flags;
 };
 
-#define RTM_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
-#define RTM_RTNH(r) ((struct rtnexthop*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg)) \
-					   + NLMSG_ALIGN((r)->rtm_optlen)))
-#define RTM_NHLEN(nlh,r) ((nlh)->nlmsg_len - NLMSG_SPACE(sizeof(struct rtmsg)) - NLMSG_ALIGN((r)->rtm_optlen))
-
 /* rtm_type */
 
 enum
@@ -173,6 +128,7 @@
 
 #define RTN_MAX RTN_XRESOLVE
 
+
 /* rtm_protocol */
 
 #define RTPROT_UNSPEC	0
@@ -198,8 +154,8 @@
 
    Really it is not scope, but sort of distance to the destination.
    NOWHERE are reserved for not existing destinations, HOST is our
-   local addresses, LINK are destinations, locate on directly attached
-   link and UNIVERSE is everywhere in the Universe :-)
+   local addresses, LINK are destinations, located on directly attached
+   link and UNIVERSE is everywhere in the Universe.
 
    Intermediate values are also possible f.e. interior routes
    could be assigned a value between UNIVERSE and LINK.
@@ -208,7 +164,7 @@
 enum rt_scope_t
 {
 	RT_SCOPE_UNIVERSE=0,
-/* User defined values f.e. "site" */
+/* User defined values  */
 	RT_SCOPE_SITE=200,
 	RT_SCOPE_LINK=253,
 	RT_SCOPE_HOST=254,
@@ -219,8 +175,10 @@
 
 #define RTM_F_NOTIFY		0x100	/* Notify user of route change	*/
 #define RTM_F_CLONED		0x200	/* This route is cloned		*/
-#define RTM_F_NOPMTUDISC	0x400	/* Do not make PMTU discovery	*/
-#define RTM_F_EQUALIZE		0x800	/* Multipath equalizer: NI	*/
+#define RTM_F_EQUALIZE		0x400	/* Multipath equalizer: NI	*/
+#ifdef CONFIG_RTNL_OLD_IFINFO
+#define RTM_F_NOPMTUDISC	0x800	/* Do not make PMTU discovery	*/
+#endif
 
 /* Reserved table identifiers */
 
@@ -235,6 +193,107 @@
 #define RT_TABLE_MAX RT_TABLE_LOCAL
 
 
+
+/* Routing message attributes */
+
+enum rtattr_type_t
+{
+	RTA_UNSPEC,
+	RTA_DST,
+	RTA_SRC,
+	RTA_IIF,
+	RTA_OIF,
+	RTA_GATEWAY,
+	RTA_PRIORITY,
+	RTA_PREFSRC,
+#ifndef CONFIG_RTNL_OLD_IFINFO
+	RTA_METRICS,
+	RTA_MULTIPATH,
+	RTA_PROTOINFO,
+	RTA_FLOW,
+#else
+	RTA_WINDOW,
+	RTA_RTT,
+	RTA_MTU,
+	RTA_IFNAME,
+#endif
+	RTA_CACHEINFO
+};
+
+#define RTA_MAX RTA_CACHEINFO
+
+#define RTM_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
+#define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
+
+/* RTM_MULTIPATH --- array of struct rtnexthop.
+ *
+ * "struct rtnexthop" describres all necessary nexthop information,
+ * i.e. parameters of path to a destination via this nextop.
+ *
+ * At the moment it is impossible to set different prefsrc, mtu, window
+ * and rtt for different paths from multipath.
+ */
+
+struct rtnexthop
+{
+	unsigned short		rtnh_len;
+	unsigned char		rtnh_flags;
+	unsigned char		rtnh_hops;
+	int			rtnh_ifindex;
+};
+
+/* rtnh_flags */
+
+#define RTNH_F_DEAD		1	/* Nexthop is dead (used by multipath)	*/
+#define RTNH_F_PERVASIVE	2	/* Do recursive gateway lookup	*/
+#define RTNH_F_ONLINK		4	/* Gateway is forced on link	*/
+
+/* Macros to handle hexthops */
+
+#define RTNH_ALIGNTO	4
+#define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
+#define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
+			   (rtnh)->rtnh_len <= (len))
+#define RTNH_NEXT(rtnh)	((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
+#define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
+#define RTNH_SPACE(len)	RTNH_ALIGN(RTNH_LENGTH(len))
+#define RTNH_DATA(rtnh)   ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
+
+#ifdef CONFIG_RTNL_OLD_IFINFO
+#define RTM_RTNH(r) ((struct rtnexthop*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg)) \
+					   + NLMSG_ALIGN((r)->rtm_optlen)))
+#define RTM_NHLEN(nlh,r) ((nlh)->nlmsg_len - NLMSG_SPACE(sizeof(struct rtmsg)) - NLMSG_ALIGN((r)->rtm_optlen))
+#endif
+
+/* RTM_CACHEINFO */
+
+struct rta_cacheinfo
+{
+	__u32	rta_clntref;
+	__u32	rta_lastuse;
+	__s32	rta_expires;
+	__u32	rta_error;
+	__u32	rta_used;
+};
+
+/* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
+
+enum
+{
+	RTAX_UNSPEC,
+	RTAX_LOCK,
+	RTAX_MTU,
+	RTAX_WINDOW,
+	RTAX_RTT,
+	RTAX_HOPS,
+	RTAX_SSTHRESH,
+	RTAX_CWND,
+};
+
+#define RTAX_MAX RTAX_CWND
+
+
+
 /*********************************************************
  *		Interface address.
  ****/
@@ -277,6 +336,7 @@
 
 
 #define IFA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
+#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
 
 /*
    Important comment:
@@ -293,6 +353,8 @@
 struct ndmsg
 {
 	unsigned char	ndm_family;
+	unsigned char	ndm_pad1;
+	unsigned short	ndm_pad2;
 	int		ndm_ifindex;	/* Link index			*/
 	__u16		ndm_state;
 	__u8		ndm_flags;
@@ -310,6 +372,31 @@
 #define NDA_MAX NDA_CACHEINFO
 
 #define NDA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
+#define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
+
+/*
+ *	Neighbor Cache Entry Flags
+ */
+
+#define NTF_PROXY	0x08	/* == ATF_PUBL */
+#define NTF_ROUTER	0x80
+
+/*
+ *	Neighbor Cache Entry States.
+ */
+
+#define NUD_INCOMPLETE	0x01
+#define NUD_REACHABLE	0x02
+#define NUD_STALE	0x04
+#define NUD_DELAY	0x08
+#define NUD_PROBE	0x10
+#define NUD_FAILED	0x20
+
+/* Dummy states */
+#define NUD_NOARP	0x40
+#define NUD_PERMANENT	0x80
+#define NUD_NONE	0x00
+
 
 struct nda_cacheinfo
 {
@@ -337,6 +424,7 @@
  * on network protocol.
  */
 
+#ifdef CONFIG_RTNL_OLD_IFINFO
 struct ifinfomsg
 {
 	unsigned char	ifi_family;		/* Dummy	*/
@@ -363,9 +451,37 @@
 	IFLA_STATS
 };
 
+#else
+
+struct ifinfomsg
+{
+	unsigned char	ifi_family;
+	unsigned char	__ifi_pad;
+	unsigned short	ifi_type;		/* ARPHRD_* */
+	int		ifi_index;		/* Link index	*/
+	unsigned	ifi_flags;		/* IFF_* flags	*/
+	unsigned	ifi_change;		/* IFF_* change mask */
+};
+
+enum
+{
+	IFLA_UNSPEC,
+	IFLA_ADDRESS,
+	IFLA_BROADCAST,
+	IFLA_IFNAME,
+	IFLA_MTU,
+	IFLA_LINK,
+	IFLA_QDISC,
+	IFLA_STATS
+};
+
+#endif
+
+
 #define IFLA_MAX IFLA_STATS
 
 #define IFLA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
+#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
 
 /* ifi_flags.
 
@@ -396,6 +512,42 @@
    for IPIP tunnels, when route to endpoint is allowed to change)
  */
 
+/*****************************************************************
+ *		Traffic control messages.
+ ****/
+
+struct tcmsg
+{
+	unsigned char	tcm_family;
+	unsigned char	tcm__pad1;
+	unsigned short	tcm__pad2;
+	int		tcm_ifindex;
+	__u32		tcm_handle;
+	__u32		tcm_parent;
+	__u32		tcm_info;
+};
+
+enum
+{
+	TCA_UNSPEC,
+	TCA_KIND,
+	TCA_OPTIONS,
+	TCA_STATS,
+	TCA_XSTATS
+};
+
+#define TCA_MAX TCA_XSTATS
+
+#define TCA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
+#define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
+
+
+/* SUMMARY: maximal rtattr understood by kernel */
+
+#define RTATTR_MAX		RTA_MAX
+
+/* RTnetlink multicast groups */
+
 #define RTMGRP_LINK		1
 #define RTMGRP_NOTIFY		2
 #define RTMGRP_NEIGH		4
@@ -408,34 +560,9 @@
 #define RTMGRP_IPV6_MROUTE	0x200
 #define RTMGRP_IPV6_ROUTE	0x400
 
+/* End of information exported to user level */
 
 #ifdef __KERNEL__
-
-struct kern_rta
-{
-	void		*rta_dst;
-	void		*rta_src;
-	int		*rta_iif;
-	int		*rta_oif;
-	void		*rta_gw;
-	u32		*rta_priority;
-	void		*rta_prefsrc;
-	unsigned	*rta_window;
-	unsigned	*rta_rtt;
-	unsigned	*rta_mtu;
-	unsigned char	*rta_ifname;
-	struct rta_cacheinfo *rta_ci;
-};
-
-struct kern_ifa
-{
-	void		*ifa_address;
-	void		*ifa_local;
-	unsigned char	*ifa_label;
-	void		*ifa_broadcast;
-	void		*ifa_anycast;
-};
-
 
 extern atomic_t rtnl_rlockct;
 extern struct wait_queue *rtnl_wait;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov