From 0bd17929bc6e2df15dc3348f9690f698211c7711 Mon Sep 17 00:00:00 2001 From: "Templin, Fred L" Date: Mon, 26 Nov 2007 09:46:06 -0800 Subject: [PATCH] iproute2-2.6.23: RFC4214 Support (v2.5) This patch includes support for the Intra-Site Automatic Tunnel Addressing Protocol (ISATAP) per RFC4214. The following diffs are specific to the iproute2-2.6.23 software distribution. This message includes the full and patchable diff text; please use this version to apply patches. Signed-off-by: Fred L. Templin Signed-off-by: Stephen Hemminger --- include/linux/if_tunnel.h | 34 ++++++++++++++++++++++++++++++++++ ip/iptunnel.c | 22 +++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 include/linux/if_tunnel.h diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h new file mode 100644 index 000000000..228eb4eb3 --- /dev/null +++ b/include/linux/if_tunnel.h @@ -0,0 +1,34 @@ +#ifndef _IF_TUNNEL_H_ +#define _IF_TUNNEL_H_ + +#include + +#define SIOCGETTUNNEL (SIOCDEVPRIVATE + 0) +#define SIOCADDTUNNEL (SIOCDEVPRIVATE + 1) +#define SIOCDELTUNNEL (SIOCDEVPRIVATE + 2) +#define SIOCCHGTUNNEL (SIOCDEVPRIVATE + 3) + +#define GRE_CSUM __constant_htons(0x8000) +#define GRE_ROUTING __constant_htons(0x4000) +#define GRE_KEY __constant_htons(0x2000) +#define GRE_SEQ __constant_htons(0x1000) +#define GRE_STRICT __constant_htons(0x0800) +#define GRE_REC __constant_htons(0x0700) +#define GRE_FLAGS __constant_htons(0x00F8) +#define GRE_VERSION __constant_htons(0x0007) + +/* i_flags values for SIT mode */ +#define SIT_ISATAP 0x0001 + +struct ip_tunnel_parm +{ + char name[IFNAMSIZ]; + int link; + __be16 i_flags; + __be16 o_flags; + __be32 i_key; + __be32 o_key; + struct iphdr iph; +}; + +#endif /* _IF_TUNNEL_H_ */ diff --git a/ip/iptunnel.c b/ip/iptunnel.c index aee526b33..3b466bfc0 100644 --- a/ip/iptunnel.c +++ b/ip/iptunnel.c @@ -39,7 +39,7 @@ static void usage(void) __attribute__((noreturn)); static void usage(void) { fprintf(stderr, "Usage: ip tunnel { add | change | del | show } [ NAME ]\n"); - fprintf(stderr, " [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\n"); + fprintf(stderr, " [ mode { ipip | gre | sit | isatap } ] [ remote ADDR ] [ local ADDR ]\n"); fprintf(stderr, " [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n"); fprintf(stderr, " [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n"); fprintf(stderr, "\n"); @@ -55,6 +55,7 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) { int count = 0; char medium[IFNAMSIZ]; + int isatap = 0; memset(p, 0, sizeof(*p)); memset(&medium, 0, sizeof(medium)); @@ -90,6 +91,13 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) exit(-1); } p->iph.protocol = IPPROTO_IPV6; + } else if (strcmp(*argv, "isatap") == 0) { + if (p->iph.protocol && p->iph.protocol != IPPROTO_IPV6) { + fprintf(stderr, "You managed to ask for more than one tunnel mode.\n"); + exit(-1); + } + p->iph.protocol = IPPROTO_IPV6; + isatap++; } else { fprintf(stderr,"Cannot guess tunnel mode.\n"); exit(-1); @@ -212,6 +220,10 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) p->iph.protocol = IPPROTO_IPIP; else if (memcmp(p->name, "sit", 3) == 0) p->iph.protocol = IPPROTO_IPV6; + else if (memcmp(p->name, "isatap", 6) == 0) { + p->iph.protocol = IPPROTO_IPV6; + isatap++; + } } if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) { @@ -239,6 +251,14 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) fprintf(stderr, "Broadcast tunnel requires a source address.\n"); return -1; } + if (isatap) { + if (p->iph.daddr) { + fprintf(stderr, "no remote with isatap.\n"); + return -1; + } + p->i_flags |= SIT_ISATAP; + } + return 0; } -- 2.47.2