From 57253b1e470cdaadeeec20859bed1aba0cadfee5 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Thu, 26 Feb 2009 14:24:21 +0000 Subject: [PATCH] Tweaks --- include/linux/if_tunnel.h | 1 + ip/iptunnel.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h index aeab2cb..ac32b53 100644 --- a/include/linux/if_tunnel.h +++ b/include/linux/if_tunnel.h @@ -31,6 +31,7 @@ struct ip_tunnel_parm __be32 i_key; __be32 o_key; struct iphdr iph; + int proto_type; }; /* SIT-mode i_flags */ diff --git a/ip/iptunnel.c b/ip/iptunnel.c index 0d9a17f..8f51f83 100644 --- a/ip/iptunnel.c +++ b/ip/iptunnel.c @@ -34,12 +34,15 @@ #include "ip_common.h" #include "tunnel.h" +#define ETH_P_ETH 0x6558 /* Ethernet in Ethernet */ + + 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 | isatap } ] [ remote ADDR ] [ local ADDR ]\n"); + fprintf(stderr, " [ mode { ipip | gre [ type { ip | 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"); @@ -84,6 +87,20 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) exit(-1); } p->iph.protocol = IPPROTO_GRE; + NEXT_ARG(); + if (strcmp(*argv,"type") == 0) + { + NEXT_ARG(); + printf("90 route %s\n", *argv); + if (strcmp(*argv,"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) { @@ -323,6 +340,13 @@ static void print_tunnel(struct ip_tunnel_parm *p) /* Do not use format_host() for local addr, * symbolic name will not be useful. */ + if(p->proto_type == ETH_P_ETH) + printf("%s: %s/eth remote %s local %s ", + p->name, + tnl_strproto(p->iph.protocol), + 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"); + else printf("%s: %s/ip remote %s local %s ", p->name, tnl_strproto(p->iph.protocol), -- 2.43.0