⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtnetlink.h

📁 基于组件方式开发操作系统的OSKIT源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef __LINUX_RTNETLINK_H#define __LINUX_RTNETLINK_H#include <linux/config.h>#include <linux/netlink.h>#define RTNL_DEBUG 1/**** *		Routing/neighbour discovery messages. ****//* Types of messages */#define RTM_BASE	0x10#define	RTM_NEWLINK	(RTM_BASE+0)#define	RTM_DELLINK	(RTM_BASE+1)#define	RTM_GETLINK	(RTM_BASE+2)#define	RTM_NEWADDR	(RTM_BASE+4)#define	RTM_DELADDR	(RTM_BASE+5)#define	RTM_GETADDR	(RTM_BASE+6)#define	RTM_NEWROUTE	(RTM_BASE+8)#define	RTM_DELROUTE	(RTM_BASE+9)#define	RTM_GETROUTE	(RTM_BASE+10)#define	RTM_NEWNEIGH	(RTM_BASE+12)#define	RTM_DELNEIGH	(RTM_BASE+13)#define	RTM_GETNEIGH	(RTM_BASE+14)#define	RTM_NEWRULE	(RTM_BASE+16)#define	RTM_DELRULE	(RTM_BASE+17)#define	RTM_GETRULE	(RTM_BASE+18)#define	RTM_NEWQDISC	(RTM_BASE+20)#define	RTM_DELQDISC	(RTM_BASE+21)#define	RTM_GETQDISC	(RTM_BASE+22)#define	RTM_NEWTCLASS	(RTM_BASE+24)#define	RTM_DELTCLASS	(RTM_BASE+25)#define	RTM_GETTCLASS	(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{	unsigned short	rta_len;	unsigned short	rta_type;};/* Macros to handle rtattributes */#define RTA_ALIGNTO	4#define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )#define RTA_OK(rta,len) ((len) > 0 && (rta)->rta_len >= sizeof(struct rtattr) && \			 (rta)->rta_len <= (len))#define RTA_NEXT(rta,attrlen)	((attrlen) -= RTA_ALIGN((rta)->rta_len), \				 (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))#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) ((int)((rta)->rta_len) - RTA_LENGTH(0))/****************************************************************************** *		Definitions used in routing table administation. ****/struct rtmsg{	unsigned char		rtm_family;	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	*/	unsigned char		rtm_scope;	/* See below */		unsigned char		rtm_type;	/* See below	*/	unsigned		rtm_flags;};/* rtm_type */enum{	RTN_UNSPEC,	RTN_UNICAST,		/* Gateway or direct route	*/	RTN_LOCAL,		/* Accept locally		*/	RTN_BROADCAST,		/* Accept locally as broadcast,				   send as broadcast */	RTN_ANYCAST,		/* Accept locally as broadcast,				   but send as unicast */	RTN_MULTICAST,		/* Multicast route		*/	RTN_BLACKHOLE,		/* Drop				*/	RTN_UNREACHABLE,	/* Destination is unreachable   */	RTN_PROHIBIT,		/* Administratively prohibited	*/	RTN_THROW,		/* Not in this table		*/	RTN_NAT,		/* Translate this address	*/	RTN_XRESOLVE,		/* Use external resolver	*/};#define RTN_MAX RTN_XRESOLVE/* rtm_protocol */#define RTPROT_UNSPEC	0#define RTPROT_REDIRECT	1	/* Route installed by ICMP redirects;				   not used by current IPv4 */#define RTPROT_KERNEL	2	/* Route installed by kernel		*/#define RTPROT_BOOT	3	/* Route installed during boot		*/#define RTPROT_STATIC	4	/* Route installed by administrator	*//* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;   they just passed from user and back as is.   It will be used by hypothetical multiple routing daemons.   Note that protocol values should be standardized in order to   avoid conflicts. */#define RTPROT_GATED	8	/* Apparently, GateD */#define RTPROT_RA	9	/* RDISC/ND router advertisments */#define RTPROT_MRT	10	/* Merit MRT */#define RTPROT_ZEBRA	11	/* Zebra */#define RTPROT_BIRD	12	/* BIRD *//* rtm_scope   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, 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.*/enum rt_scope_t{	RT_SCOPE_UNIVERSE=0,/* User defined values  */	RT_SCOPE_SITE=200,	RT_SCOPE_LINK=253,	RT_SCOPE_HOST=254,	RT_SCOPE_NOWHERE=255};/* rtm_flags */#define RTM_F_NOTIFY		0x100	/* Notify user of route change	*/#define RTM_F_CLONED		0x200	/* This route is cloned		*/#define RTM_F_EQUALIZE		0x400	/* Multipath equalizer: NI	*//* Reserved table identifiers */enum rt_class_t{	RT_TABLE_UNSPEC=0,/* User defined values */	RT_TABLE_DEFAULT=253,	RT_TABLE_MAIN=254,	RT_TABLE_LOCAL=255};#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,	RTA_METRICS,	RTA_MULTIPATH,	RTA_PROTOINFO,	RTA_FLOW,	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) && \			   ((int)(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)))/* 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. ****/struct ifaddrmsg{	unsigned char	ifa_family;	unsigned char	ifa_prefixlen;	/* The prefix length		*/	unsigned char	ifa_flags;	/* Flags			*/	unsigned char	ifa_scope;	/* See above			*/	int		ifa_index;	/* Link index			*/};enum{	IFA_UNSPEC,	IFA_ADDRESS,	IFA_LOCAL,	IFA_LABEL,	IFA_BROADCAST,	IFA_ANYCAST,	IFA_CACHEINFO};#define IFA_MAX IFA_CACHEINFO/* ifa_flags */#define IFA_F_SECONDARY		0x01#define IFA_F_DEPRECATED	0x20#define IFA_F_TENTATIVE		0x40#define IFA_F_PERMANENT		0x80struct ifa_cacheinfo{	__s32	ifa_prefered;	__s32	ifa_valid;};#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:   IFA_ADDRESS is prefix address, rather than local interface address.   It makes no difference for normally configured broadcast interfaces,   but for point-to-point IFA_ADDRESS is DESTINATION address,   local address is supplied in IFA_LOCAL attribute. *//************************************************************** *		Neighbour discovery. ****/struct ndmsg{	unsigned char	ndm_family;	unsigned char	ndm_pad1;	unsigned short	ndm_pad2;	int		ndm_ifindex;	/* Link index			*/	__u16		ndm_state;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -