From 105da95218c9d30375efc43f9edd8ef32998fedb Mon Sep 17 00:00:00 2001 From: Andy Bavier Date: Wed, 12 Mar 2008 19:41:51 +0000 Subject: [PATCH] Changes for creating EGRE tunnels --- ip/iptunnel.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ip/iptunnel.c b/ip/iptunnel.c index 2da3df1..35b0895 100644 --- a/ip/iptunnel.c +++ b/ip/iptunnel.c @@ -44,7 +44,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 | gre/ip | gre/eth | sit } ] [ 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"); @@ -189,12 +189,17 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) } p->iph.protocol = IPPROTO_IPIP; } else if (strcmp(*argv, "gre") == 0 || - strcmp(*argv, "gre/ip") == 0) { + strcmp(*argv, "gre/ip") == 0 || + strcmp(*argv, "gre/eth") == 0) { if (p->iph.protocol && p->iph.protocol != IPPROTO_GRE) { fprintf(stderr,"You managed to ask for more than one tunnel mode.\n"); exit(-1); } p->iph.protocol = IPPROTO_GRE; + if (strcmp(*argv,"gre/eth") == 0) + p->proto_type = ETH_P_ETH; + else + p->proto_type = ETH_P_IP; } else if (strcmp(*argv, "sit") == 0 || strcmp(*argv, "ipv6/ip") == 0) { if (p->iph.protocol && p->iph.protocol != IPPROTO_IPV6) { @@ -366,7 +371,7 @@ static int do_add(int cmd, int argc, char **argv) fprintf(stderr, "ttl != 0 and noptmudisc are incompatible\n"); return -1; } - + switch (p.iph.protocol) { case IPPROTO_IPIP: return do_add_ioctl(cmd, "tunl0", &p); @@ -414,11 +419,12 @@ void print_tunnel(struct ip_tunnel_parm *p) /* Do not use format_host() for local addr, * symbolic name will not be useful. */ - printf("%s: %s/ip remote %s local %s ", + printf("%s: %s/%s remote %s local %s ", p->name, p->iph.protocol == IPPROTO_IPIP ? "ip" : (p->iph.protocol == IPPROTO_GRE ? "gre" : (p->iph.protocol == IPPROTO_IPV6 ? "ipv6" : "unknown")), + (p->proto_type == ETH_P_ETH ? "eth" : "ip"), p->iph.daddr ? format_host(AF_INET, 4, &p->iph.daddr, s1, sizeof(s1)) : "any", p->iph.saddr ? rt_addr_n2a(AF_INET, 4, &p->iph.saddr, s2, sizeof(s2)) : "any"); @@ -540,6 +546,7 @@ static int do_show(int argc, char **argv) if (parse_args(argc, argv, SIOCGETTUNNEL, &p) < 0) return -1; + printf("NOTE: EGRE tunnels will not show up here, use ifconfig\n"); switch (p.iph.protocol) { case IPPROTO_IPIP: err = do_get_ioctl(p.name[0] ? p.name : "tunl0", &p); -- 2.47.0