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

📄 iproute2.diff

📁 一个可以实现MPLS实验的linux源代码.你不仅可以实现单层标签的转发,还可以实现2个标签的实验,很好的.
💻 DIFF
📖 第 1 页 / 共 5 页
字号:
diff -uNr iproute2/include/linux/genetlink.h iproute2-mpls/include/linux/genetlink.h--- iproute2/include/linux/genetlink.h	1969-12-31 18:00:00.000000000 -0600+++ iproute2-mpls/include/linux/genetlink.h	2005-12-08 22:01:52.000000000 -0600@@ -0,0 +1,82 @@+#ifndef __LINUX_GENERIC_NETLINK_H+#define __LINUX_GENERIC_NETLINK_H++#include <linux/netlink.h>++#define GENL_NAMSIZ	16	/* length of family name */++#define GENL_MIN_ID	NLMSG_MIN_TYPE+#define GENL_MAX_ID	1023++struct genlmsghdr {+	__u8	cmd;+	__u8	version;+	__u16	reserved;+};++#define GENL_HDRLEN	NLMSG_ALIGN(sizeof(struct genlmsghdr))++/*+ * List of reserved static generic netlink identifiers:+ */+#define GENL_ID_GENERATE	0+#define GENL_ID_CTRL		NLMSG_MIN_TYPE++/**************************************************************************+ * Controller+ **************************************************************************/++enum {+	CTRL_CMD_UNSPEC,+	CTRL_CMD_NEWFAMILY,+	CTRL_CMD_DELFAMILY,+	CTRL_CMD_GETFAMILY,+	CTRL_CMD_NEWOPS,+	CTRL_CMD_DELOPS,+	CTRL_CMD_GETOPS,+	__CTRL_CMD_MAX,+};++#define CTRL_CMD_MAX (__CTRL_CMD_MAX - 1)++enum {+	CTRL_ATTR_UNSPEC,+	CTRL_ATTR_FAMILY_ID,+	CTRL_ATTR_FAMILY_NAME,+	__CTRL_ATTR_MAX,+};++#define CTRL_ATTR_MAX (__CTRL_ATTR_MAX - 1)++enum {+	MPLS_CMD_UNSPEC,+	MPLS_CMD_NEWILM,+	MPLS_CMD_DELILM,+	MPLS_CMD_GETILM,+	MPLS_CMD_NEWNHLFE,+	MPLS_CMD_DELNHLFE,+	MPLS_CMD_GETNHLFE,+	MPLS_CMD_NEWXC,+	MPLS_CMD_DELXC,+	MPLS_CMD_GETXC,+	MPLS_CMD_SETLABELSPACE,+	MPLS_CMD_GETLABELSPACE,+	__MPLS_CMD_MAX,+};++#define MPLS_CMD_MAX (__MPLS_CMD_MAX - 1)++enum {+	MPLS_ATTR_UNSPEC,+	MPLS_ATTR_ILM,+	MPLS_ATTR_NHLFE,+	MPLS_ATTR_XC,+	MPLS_ATTR_LABELSPACE,+	MPLS_ATTR_INSTR,+	MPLS_ATTR_STATS,+	__MPLS_ATTR_MAX,+};++#define MPLS_ATTR_MAX (__MPLS_ATTR_MAX - 1)++#endif	/* __LINUX_GENERIC_NETLINK_H */diff -uNr iproute2/include/linux/mpls.h iproute2-mpls/include/linux/mpls.h--- iproute2/include/linux/mpls.h	1969-12-31 18:00:00.000000000 -0600+++ iproute2-mpls/include/linux/mpls.h	2005-12-08 22:01:52.000000000 -0600@@ -0,0 +1,255 @@+/*****************************************************************************+ * MPLS+ *      An implementation of the MPLS (MultiProtocol Label+ *      Switching Architecture) for Linux.+ *+ * Authors:+ *          James Leu        <jleu@mindspring.com>+ *          Ramon Casellas   <casellas@infres.enst.fr>+ *+ *   (c) 1999-2004   James Leu        <jleu@mindspring.com>+ *   (c) 2003-2004   Ramon Casellas   <casellas@infres.enst.fr>+ *+ * include/linux/mpls.h+ *      Data types and structs used by userspace programs to access MPLS+ *      forwarding. Most interface with the MPLS subsystem is IOCTL based+ *+ *      This program is free software; you can redistribute it and/or+ *      modify it under the terms of the GNU General Public License+ *      as published by the Free Software Foundation; either version+ *      2 of the License, or (at your option) any later version.+ ****************************************************************************/++#ifndef _LINUX_MPLS_H_+#define _LINUX_MPLS_H_++#ifdef __KERNEL__+#include <linux/socket.h>+#include <linux/if.h>+#else+#include <sys/socket.h>+#include <net/if.h>+#endif++#define MPLS_NUM_OPS		8++#define MPLS_LINUX_VERSION	0x01090500++#define	MPLS_GRP_ILM	1+#define	MPLS_GRP_NHLFE	2+#define	MPLS_GRP_XC	4+#define	MPLS_GRP_LABELSPACE 8++#define MPLS_IPV4_EXPLICIT_NULL	0       /* only valid as sole label stack entry+					   Pop label and send to IPv4 stack */+#define MPLS_ROUTER_ALERT	1       /* anywhere except bottom, packet it is+					   forwared to a software module+					   determined by the next label,+					   if the packet is forwarded, push this+					   label back on */+#define MPLS_IPV6_EXPLICIT_NULL	2       /* only valid as sole label stack entry+					   Pop label and send to IPv6 stack */+#define MPLS_IMPLICIT_NULL	3       /* a LIB with this, signifies to pop+					   the next label and use that */++#define MPLS_CHANGE_MTU		0x01+#define MPLS_CHANGE_PROP_TTL	0x02+#define MPLS_CHANGE_INSTR	0x04+#define MPLS_CHANGE_PROTO	0x10++enum mpls_dir {+	MPLS_IN = 0x10,+	MPLS_OUT = 0x20+};++enum mpls_opcode_enum {+	MPLS_OP_NOP = 0x00,+	MPLS_OP_POP,+	MPLS_OP_PEEK,+	MPLS_OP_PUSH,+	MPLS_OP_DLV,+	MPLS_OP_FWD,+	MPLS_OP_NF_FWD,+	MPLS_OP_DS_FWD,+	MPLS_OP_EXP_FWD,+	MPLS_OP_SET,+	MPLS_OP_SET_RX,+	MPLS_OP_SET_TC,+	MPLS_OP_SET_DS,+	MPLS_OP_SET_EXP,+	MPLS_OP_EXP2TC,+	MPLS_OP_EXP2DS,+	MPLS_OP_TC2EXP,+	MPLS_OP_DS2EXP,+	MPLS_OP_NF2EXP,+	MPLS_OP_SET_NF,+	MPLS_OP_MAX+};++enum mpls_label_type_enum {+	MPLS_LABEL_GEN = 1,+	MPLS_LABEL_ATM,+	MPLS_LABEL_FR,+	MPLS_LABEL_KEY+};++struct mpls_label_atm {+	u_int16_t  mla_vpi;+	u_int16_t  mla_vci;+};++struct mpls_label {+	enum mpls_label_type_enum ml_type;+	union {+		u_int32_t ml_key;+		u_int32_t ml_gen;+		u_int32_t ml_fr;+		struct mpls_label_atm ml_atm;+	} u;+	int ml_index;+};++struct mpls_in_label_req {+	unsigned int      mil_proto;+	struct mpls_label mil_label;+	unsigned char     mil_change_flag;+};++#define MPLS_LABELSPACE_MAX	255++struct mpls_labelspace_req {+	int mls_ifindex;                  /* Index to the MPLS-enab. interface*/+	int mls_labelspace;               /* Labelspace IN/SET -- OUT/GET     */+};++struct mpls_nexthop_info {+	unsigned int    mni_if;+	struct sockaddr mni_addr;+};++struct mpls_out_label_req {+	struct mpls_label mol_label;+	u_int32_t         mol_mtu;+	int8_t            mol_propagate_ttl;+	unsigned char     mol_change_flag;+};++struct mpls_netfilter_target_info {+        u_int32_t key;++	/* only used by the netfilter kernel modules */+        void *nhlfe;+        void *proto;+};++struct mpls_xconnect_req {+	struct mpls_label mx_in;+	struct mpls_label mx_out;+};++struct mpls_tunnel_req {+	char mt_ifname[IFNAMSIZ];+	unsigned int mt_nhlfe_key;+};++#define MPLS_NFMARK_NUM 64++struct mpls_nfmark_fwd {+	unsigned int nf_key[MPLS_NFMARK_NUM];+	unsigned short nf_mask;+};++#define MPLS_DSMARK_NUM 64++struct mpls_dsmark_fwd {+	unsigned int df_key[MPLS_DSMARK_NUM];+	unsigned char df_mask;+};++#define MPLS_TCINDEX_NUM 64++struct mpls_tcindex_fwd {+	unsigned int tc_key[MPLS_TCINDEX_NUM];+	unsigned short tc_mask;+};++#define MPLS_EXP_NUM 8++struct mpls_exp_fwd {+	unsigned int ef_key[MPLS_EXP_NUM];+};++struct mpls_exp2tcindex {+	unsigned short e2t[MPLS_EXP_NUM];+};++struct mpls_exp2dsmark {+	unsigned char e2d[MPLS_EXP_NUM];+};++struct mpls_tcindex2exp {+	unsigned char t2e_mask;+	unsigned char t2e[MPLS_TCINDEX_NUM];+};++struct mpls_dsmark2exp {+	unsigned char d2e_mask;+	unsigned char d2e[MPLS_DSMARK_NUM];+};++struct mpls_nfmark2exp {+	unsigned char n2e_mask;+	unsigned char n2e[MPLS_NFMARK_NUM];+};++struct mpls_instr_elem {+	unsigned short mir_opcode;+	unsigned char mir_direction;+	union {+		struct mpls_label        push;+		struct mpls_label        fwd;+		struct mpls_nfmark_fwd   nf_fwd;+		struct mpls_dsmark_fwd   ds_fwd;+		struct mpls_exp_fwd      exp_fwd;+		struct mpls_nexthop_info set;+		unsigned int             set_rx;+		unsigned short           set_tc;+		unsigned short           set_ds;+		unsigned char            set_exp;+		struct mpls_exp2tcindex  exp2tc;+		struct mpls_exp2dsmark   exp2ds;+		struct mpls_tcindex2exp  tc2exp;+		struct mpls_dsmark2exp   ds2exp;+		struct mpls_nfmark2exp   nf2exp;+		unsigned long            set_nf;+	} mir_data;+};++/* Standard shortcuts */+#define mir_push       mir_data.push+#define mir_fwd        mir_data.fwd+#define mir_nf_fwd     mir_data.nf_fwd+#define mir_ds_fwd     mir_data.ds_fwd+#define mir_exp_fwd    mir_data.exp_fwd+#define mir_set        mir_data.set+#define mir_set_rx     mir_data.set_rx+#define mir_set_tc     mir_data.set_tc+#define mir_set_tx     mir_data.set_tx+#define mir_set_ds     mir_data.set_ds+#define mir_set_exp    mir_data.set_exp+#define mir_set_nf     mir_data.set_nf+#define mir_exp2tc     mir_data.exp2tc+#define mir_exp2ds     mir_data.exp2ds+#define mir_tc2exp     mir_data.tc2exp+#define mir_ds2exp     mir_data.ds2exp+#define mir_nf2exp     mir_data.nf2exp++struct mpls_instr_req {+	struct mpls_instr_elem       mir_instr[MPLS_NUM_OPS];+	unsigned char                mir_instr_length;+	unsigned char                mir_direction;+	int                          mir_index;+	struct mpls_label            mir_label;+};++#endifdiff -uNr iproute2/include/linux/netlink.h iproute2-mpls/include/linux/netlink.h--- iproute2/include/linux/netlink.h	2005-08-24 00:23:21.000000000 -0500+++ iproute2-mpls/include/linux/netlink.h	2005-12-08 22:01:52.000000000 -0600@@ -5,20 +5,22 @@ #include <linux/types.h>  #define NETLINK_ROUTE		0	/* Routing/device hook				*/-#define NETLINK_SKIP		1	/* Reserved for ENskip  			*/+#define NETLINK_W1		1	/* 1-wire subsystem				*/ #define NETLINK_USERSOCK	2	/* Reserved for user mode socket protocols 	*/ #define NETLINK_FIREWALL	3	/* Firewalling hook				*/-#define NETLINK_TCPDIAG		4	/* TCP socket monitoring			*/+#define NETLINK_INET_DIAG	4	/* INET socket monitoring			*/ #define NETLINK_NFLOG		5	/* netfilter/iptables ULOG */ #define NETLINK_XFRM		6	/* ipsec */ #define NETLINK_SELINUX		7	/* SELinux event notifications */-#define NETLINK_ARPD		8+#define NETLINK_ISCSI		8	/* Open-iSCSI */ #define NETLINK_AUDIT		9	/* auditing */-#define NETLINK_ROUTE6		11	/* af_inet6 route comm channel */+#define NETLINK_FIB_LOOKUP	10	+#define NETLINK_CONNECTOR	11+#define NETLINK_NETFILTER	12	/* netfilter subsystem */ #define NETLINK_IP6_FW		13 #define NETLINK_DNRTMSG		14	/* DECnet routing messages */ #define NETLINK_KOBJECT_UEVENT	15	/* Kernel messages to userspace */-#define NETLINK_TAPBASE		16	/* 16 to 31 are ethertap */+#define NETLINK_GENERIC		16  #define MAX_LINKS 32		 @@ -69,7 +71,8 @@  #define NLMSG_ALIGNTO	4 #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )-#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(sizeof(struct nlmsghdr)))+#define NLMSG_HDRLEN	 ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))+#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN)) #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len)) #define NLMSG_DATA(nlh)  ((void*)(((char*)nlh) + NLMSG_LENGTH(0))) #define NLMSG_NEXT(nlh,len)	 ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \@@ -84,12 +87,23 @@ #define NLMSG_DONE		0x3	/* End of a dump	*/ #define NLMSG_OVERRUN		0x4	/* Data lost		*/ +#define NLMSG_MIN_TYPE		0x10	/* < 0x10: reserved control messages */+ struct nlmsgerr { 	int		error; 	struct nlmsghdr msg; }; +#define NETLINK_ADD_MEMBERSHIP	1+#define NETLINK_DROP_MEMBERSHIP	2+#define NETLINK_PKTINFO		3++struct nl_pktinfo+{+	__u32	group;+};+ #define NET_MAJOR 36		/* Major 36 is reserved for networking 						*/  enum {@@ -97,5 +111,23 @@ 	NETLINK_CONNECTED, }; +/*+ *  <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)-->+ * +---------------------+- - -+- - - - - - - - - -+- - -++ * |        Header       | Pad |     Payload       | Pad |+ * |   (struct nlattr)   | ing |                   | ing |+ * +---------------------+- - -+- - - - - - - - - -+- - -++ *  <-------------- nlattr->nla_len -------------->+ */++struct nlattr+{+	__u16           nla_len;+	__u16           nla_type;+};++#define NLA_ALIGNTO		4+#define NLA_ALIGN(len)		(((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))+#define NLA_HDRLEN		((int) NLA_ALIGN(sizeof(struct nlattr)))  #endif	/* __LINUX_NETLINK_H */diff -uNr iproute2/include/linux/rtnetlink.h iproute2-mpls/include/linux/rtnetlink.h--- iproute2/include/linux/rtnetlink.h	2005-08-30 15:32:42.000000000 -0500+++ iproute2-mpls/include/linux/rtnetlink.h	2005-12-08 22:01:52.000000000 -0600@@ -89,10 +89,21 @@ 	RTM_GETANYCAST	= 62, #define RTM_GETANYCAST	RTM_GETANYCAST -	RTM_MAX,-#define RTM_MAX		RTM_MAX+	RTM_NEWNEIGHTBL	= 64,+#define RTM_NEWNEIGHTBL	RTM_NEWNEIGHTBL+	RTM_GETNEIGHTBL	= 66,+#define RTM_GETNEIGHTBL	RTM_GETNEIGHTBL+	RTM_SETNEIGHTBL,+#define RTM_SETNEIGHTBL	RTM_SETNEIGHTBL++	__RTM_MAX,+#define RTM_MAX		(((__RTM_MAX + 3) & ~3) - 1) }; +#define RTM_NR_MSGTYPES	(RTM_MAX + 1 - RTM_BASE)+#define RTM_NR_FAMILIES	(RTM_NR_MSGTYPES >> 2)+#define RTM_FAM(cmd)	(((cmd) - RTM_BASE) >> 2)+ /*     Generic structure for encapsulation of optional route information.    It is reminiscent of sockaddr, but with sa_family replaced@@ -250,6 +261,8 @@ 	RTA_FLOW, 	RTA_CACHEINFO, 	RTA_SESSION,+	RTA_MP_ALGO,+	RTA_SHIM, 	__RTA_MAX }; @@ -346,10 +359,13 @@ #define RTAX_FEATURE_ECN	0x00000001 #define RTAX_FEATURE_SACK	0x00000002 #define RTAX_FEATURE_TIMESTAMP	0x00000004+#define RTAX_FEATURE_ALLFRAG	0x00000008  struct rta_session { 	__u8	proto;+	__u8	pad1;+	__u16	pad2;

⌨️ 快捷键说明

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