]>
Commit | Line | Data |
---|---|---|
9447a0d3 MN |
1 | /* |
2 | * Copyright (C)2006 USAGI/WIDE Project | |
ae665a52 | 3 | * |
9447a0d3 MN |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
ae665a52 | 8 | * |
9447a0d3 MN |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
ae665a52 | 13 | * |
9447a0d3 | 14 | * You should have received a copy of the GNU General Public License |
4d98ab00 | 15 | * along with this program; if not, see <http://www.gnu.org/licenses>. |
9447a0d3 | 16 | */ |
9447a0d3 MN |
17 | /* |
18 | * Author: | |
19 | * Masahide NAKAMURA @USAGI | |
20 | */ | |
ae665a52 | 21 | |
9447a0d3 MN |
22 | #include <stdio.h> |
23 | #include <string.h> | |
24 | #include <stdlib.h> | |
9447a0d3 | 25 | #include <unistd.h> |
288384f2 MN |
26 | #include <sys/types.h> |
27 | #include <sys/socket.h> | |
9447a0d3 | 28 | #include <arpa/inet.h> |
288384f2 | 29 | #include <sys/ioctl.h> |
9447a0d3 | 30 | #include <linux/ip.h> |
288384f2 MN |
31 | #include <linux/if.h> |
32 | #include <linux/if_arp.h> | |
9447a0d3 | 33 | #include <linux/if_tunnel.h> |
288384f2 | 34 | #include <linux/ip6_tunnel.h> |
9447a0d3 | 35 | |
288384f2 MN |
36 | #include "utils.h" |
37 | #include "tunnel.h" | |
ea71beac | 38 | #include "ip_common.h" |
9447a0d3 | 39 | |
288384f2 MN |
40 | #define IP6_FLOWINFO_TCLASS htonl(0x0FF00000) |
41 | #define IP6_FLOWINFO_FLOWLABEL htonl(0x000FFFFF) | |
9447a0d3 | 42 | |
288384f2 MN |
43 | #define DEFAULT_TNL_HOP_LIMIT (64) |
44 | ||
45 | static void usage(void) __attribute__((noreturn)); | |
9447a0d3 MN |
46 | |
47 | static void usage(void) | |
48 | { | |
8589eb4e MC |
49 | fprintf(stderr, |
50 | "Usage: ip -f inet6 tunnel { add | change | del | show } [ NAME ]\n" | |
51 | " [ mode { ip6ip6 | ipip6 | ip6gre | vti6 | any } ]\n" | |
52 | " [ remote ADDR local ADDR ] [ dev PHYS_DEV ]\n" | |
53 | " [ encaplimit ELIM ]\n" | |
54 | " [ hoplimit TTL ] [ tclass TCLASS ] [ flowlabel FLOWLABEL ]\n" | |
55 | " [ dscp inherit ]\n" | |
56 | " [ [no]allow-localremote ]\n" | |
57 | " [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n" | |
58 | "\n" | |
59 | "Where: NAME := STRING\n" | |
60 | " ADDR := IPV6_ADDRESS\n" | |
61 | " ELIM := { none | 0..255 }(default=%d)\n" | |
62 | " TTL := 0..255 (default=%d)\n" | |
63 | " TCLASS := { 0x0..0xff | inherit }\n" | |
64 | " FLOWLABEL := { 0x0..0xfffff | inherit }\n" | |
65 | " KEY := { DOTTED_QUAD | NUMBER }\n", | |
66 | IPV6_DEFAULT_TNL_ENCAP_LIMIT, | |
288384f2 | 67 | DEFAULT_TNL_HOP_LIMIT); |
9447a0d3 MN |
68 | exit(-1); |
69 | } | |
70 | ||
3e953938 | 71 | static void print_tunnel(const void *t) |
9447a0d3 | 72 | { |
3e953938 | 73 | const struct ip6_tnl_parm2 *p = t; |
9af72f81 PS |
74 | char s1[1024]; |
75 | char s2[1024]; | |
9447a0d3 | 76 | |
9af72f81 PS |
77 | /* Do not use format_host() for local addr, |
78 | * symbolic name will not be useful. | |
79 | */ | |
288384f2 | 80 | printf("%s: %s/ipv6 remote %s local %s", |
9af72f81 PS |
81 | p->name, |
82 | tnl_strproto(p->proto), | |
a418e451 | 83 | format_host_r(AF_INET6, 16, &p->raddr, s1, sizeof(s1)), |
2e96d2cc | 84 | rt_addr_n2a_r(AF_INET6, 16, &p->laddr, s2, sizeof(s2))); |
9447a0d3 | 85 | if (p->link) { |
ea71beac | 86 | const char *n = ll_index_to_name(p->link); |
56f5daac | 87 | |
9447a0d3 MN |
88 | if (n) |
89 | printf(" dev %s", n); | |
90 | } | |
9447a0d3 | 91 | |
288384f2 MN |
92 | if (p->flags & IP6_TNL_F_IGN_ENCAP_LIMIT) |
93 | printf(" encaplimit none"); | |
94 | else | |
95 | printf(" encaplimit %u", p->encap_limit); | |
9447a0d3 | 96 | |
375560c4 SP |
97 | if (p->hop_limit) |
98 | printf(" hoplimit %u", p->hop_limit); | |
99 | else | |
100 | printf(" hoplimit inherit"); | |
9447a0d3 | 101 | |
288384f2 | 102 | if (p->flags & IP6_TNL_F_USE_ORIG_TCLASS) |
eddde110 | 103 | printf(" tclass inherit"); |
288384f2 MN |
104 | else { |
105 | __u32 val = ntohl(p->flowinfo & IP6_FLOWINFO_TCLASS); | |
56f5daac | 106 | |
eddde110 | 107 | printf(" tclass 0x%02x", (__u8)(val >> 20)); |
9447a0d3 | 108 | } |
9447a0d3 | 109 | |
288384f2 | 110 | if (p->flags & IP6_TNL_F_USE_ORIG_FLOWLABEL) |
eddde110 | 111 | printf(" flowlabel inherit"); |
288384f2 | 112 | else |
eddde110 | 113 | printf(" flowlabel 0x%05x", ntohl(p->flowinfo & IP6_FLOWINFO_FLOWLABEL)); |
9447a0d3 | 114 | |
288384f2 | 115 | printf(" (flowinfo 0x%08x)", ntohl(p->flowinfo)); |
9447a0d3 | 116 | |
288384f2 MN |
117 | if (p->flags & IP6_TNL_F_RCV_DSCP_COPY) |
118 | printf(" dscp inherit"); | |
af89576d | 119 | |
21440d19 SL |
120 | if (p->flags & IP6_TNL_F_ALLOW_LOCAL_REMOTE) |
121 | printf(" allow-localremote"); | |
122 | ||
40f9070d DF |
123 | if ((p->i_flags & GRE_KEY) && (p->o_flags & GRE_KEY) && |
124 | p->o_key == p->i_key) | |
125 | printf(" key %u", ntohl(p->i_key)); | |
126 | else { | |
127 | if (p->i_flags & GRE_KEY) | |
128 | printf(" ikey %u", ntohl(p->i_key)); | |
129 | if (p->o_flags & GRE_KEY) | |
130 | printf(" okey %u", ntohl(p->o_key)); | |
131 | } | |
af89576d | 132 | |
40f9070d | 133 | if (p->proto == IPPROTO_GRE) { |
04ce8d3e | 134 | if (p->i_flags & GRE_SEQ) |
4cb8d030 | 135 | printf("%s Drop packets out of sequence.", _SL_); |
04ce8d3e | 136 | if (p->i_flags & GRE_CSUM) |
af89576d | 137 | printf("%s Checksum in received packet is required.", _SL_); |
04ce8d3e | 138 | if (p->o_flags & GRE_SEQ) |
af89576d | 139 | printf("%s Sequence packets on output.", _SL_); |
04ce8d3e | 140 | if (p->o_flags & GRE_CSUM) |
af89576d | 141 | printf("%s Checksum output packets.", _SL_); |
142 | } | |
9447a0d3 MN |
143 | } |
144 | ||
af89576d | 145 | static int parse_args(int argc, char **argv, int cmd, struct ip6_tnl_parm2 *p) |
9447a0d3 | 146 | { |
21a5a6b3 | 147 | int count = 0; |
26111ab1 | 148 | const char *medium = NULL; |
9447a0d3 MN |
149 | |
150 | while (argc > 0) { | |
0b959b0f YH |
151 | if (strcmp(*argv, "mode") == 0) { |
152 | NEXT_ARG(); | |
153 | if (strcmp(*argv, "ipv6/ipv6") == 0 || | |
154 | strcmp(*argv, "ip6ip6") == 0) | |
155 | p->proto = IPPROTO_IPV6; | |
f36d1140 SK |
156 | else if (strcmp(*argv, "vti6") == 0) { |
157 | p->proto = IPPROTO_IPV6; | |
158 | p->i_flags |= VTI_ISVTI; | |
159 | } else if (strcmp(*argv, "ip/ipv6") == 0 || | |
0b959b0f YH |
160 | strcmp(*argv, "ipv4/ipv6") == 0 || |
161 | strcmp(*argv, "ipip6") == 0 || | |
162 | strcmp(*argv, "ip4ip6") == 0) | |
163 | p->proto = IPPROTO_IPIP; | |
af89576d | 164 | else if (strcmp(*argv, "ip6gre") == 0 || |
165 | strcmp(*argv, "gre/ipv6") == 0) | |
166 | p->proto = IPPROTO_GRE; | |
0b959b0f YH |
167 | else if (strcmp(*argv, "any/ipv6") == 0 || |
168 | strcmp(*argv, "any") == 0) | |
169 | p->proto = 0; | |
170 | else { | |
56f5daac | 171 | fprintf(stderr, "Unknown tunnel mode \"%s\"\n", *argv); |
4b726cb1 SH |
172 | exit(-1); |
173 | } | |
174 | } else if (strcmp(*argv, "remote") == 0) { | |
288384f2 | 175 | inet_prefix raddr; |
56f5daac | 176 | |
288384f2 | 177 | NEXT_ARG(); |
9aceaad7 | 178 | get_addr(&raddr, *argv, AF_INET6); |
288384f2 MN |
179 | memcpy(&p->raddr, &raddr.data, sizeof(p->raddr)); |
180 | } else if (strcmp(*argv, "local") == 0) { | |
181 | inet_prefix laddr; | |
56f5daac | 182 | |
288384f2 | 183 | NEXT_ARG(); |
9aceaad7 | 184 | get_addr(&laddr, *argv, AF_INET6); |
288384f2 MN |
185 | memcpy(&p->laddr, &laddr.data, sizeof(p->laddr)); |
186 | } else if (strcmp(*argv, "dev") == 0) { | |
187 | NEXT_ARG(); | |
26111ab1 | 188 | medium = *argv; |
288384f2 MN |
189 | } else if (strcmp(*argv, "encaplimit") == 0) { |
190 | NEXT_ARG(); | |
191 | if (strcmp(*argv, "none") == 0) { | |
192 | p->flags |= IP6_TNL_F_IGN_ENCAP_LIMIT; | |
9447a0d3 MN |
193 | } else { |
194 | __u8 uval; | |
56f5daac | 195 | |
288384f2 MN |
196 | if (get_u8(&uval, *argv, 0) < -1) |
197 | invarg("invalid ELIM", *argv); | |
9447a0d3 | 198 | p->encap_limit = uval; |
3f83dce5 | 199 | p->flags &= ~IP6_TNL_F_IGN_ENCAP_LIMIT; |
9447a0d3 | 200 | } |
eddde110 YH |
201 | } else if (strcmp(*argv, "hoplimit") == 0 || |
202 | strcmp(*argv, "ttl") == 0 || | |
203 | strcmp(*argv, "hlim") == 0) { | |
288384f2 | 204 | __u8 uval; |
56f5daac | 205 | |
288384f2 MN |
206 | NEXT_ARG(); |
207 | if (get_u8(&uval, *argv, 0)) | |
eddde110 | 208 | invarg("invalid TTL", *argv); |
288384f2 | 209 | p->hop_limit = uval; |
eddde110 YH |
210 | } else if (strcmp(*argv, "tclass") == 0 || |
211 | strcmp(*argv, "tc") == 0 || | |
212 | strcmp(*argv, "tos") == 0 || | |
213 | matches(*argv, "dsfield") == 0) { | |
288384f2 | 214 | __u8 uval; |
56f5daac | 215 | |
288384f2 | 216 | NEXT_ARG(); |
df5574d0 | 217 | p->flowinfo &= ~IP6_FLOWINFO_TCLASS; |
288384f2 MN |
218 | if (strcmp(*argv, "inherit") == 0) |
219 | p->flags |= IP6_TNL_F_USE_ORIG_TCLASS; | |
220 | else { | |
221 | if (get_u8(&uval, *argv, 16)) | |
eddde110 | 222 | invarg("invalid TClass", *argv); |
288384f2 MN |
223 | p->flowinfo |= htonl((__u32)uval << 20) & IP6_FLOWINFO_TCLASS; |
224 | p->flags &= ~IP6_TNL_F_USE_ORIG_TCLASS; | |
225 | } | |
eddde110 YH |
226 | } else if (strcmp(*argv, "flowlabel") == 0 || |
227 | strcmp(*argv, "fl") == 0) { | |
288384f2 | 228 | __u32 uval; |
56f5daac | 229 | |
288384f2 | 230 | NEXT_ARG(); |
df5574d0 | 231 | p->flowinfo &= ~IP6_FLOWINFO_FLOWLABEL; |
288384f2 MN |
232 | if (strcmp(*argv, "inherit") == 0) |
233 | p->flags |= IP6_TNL_F_USE_ORIG_FLOWLABEL; | |
234 | else { | |
235 | if (get_u32(&uval, *argv, 16)) | |
eddde110 | 236 | invarg("invalid Flowlabel", *argv); |
288384f2 | 237 | if (uval > 0xFFFFF) |
eddde110 | 238 | invarg("invalid Flowlabel", *argv); |
288384f2 MN |
239 | p->flowinfo |= htonl(uval) & IP6_FLOWINFO_FLOWLABEL; |
240 | p->flags &= ~IP6_TNL_F_USE_ORIG_FLOWLABEL; | |
241 | } | |
242 | } else if (strcmp(*argv, "dscp") == 0) { | |
243 | NEXT_ARG(); | |
244 | if (strcmp(*argv, "inherit") != 0) | |
245 | invarg("not inherit", *argv); | |
246 | p->flags |= IP6_TNL_F_RCV_DSCP_COPY; | |
21440d19 SL |
247 | } else if (strcmp(*argv, "allow-localremote") == 0) { |
248 | p->flags |= IP6_TNL_F_ALLOW_LOCAL_REMOTE; | |
249 | } else if (strcmp(*argv, "noallow-localremote") == 0) { | |
250 | p->flags &= ~IP6_TNL_F_ALLOW_LOCAL_REMOTE; | |
af89576d | 251 | } else if (strcmp(*argv, "key") == 0) { |
af89576d | 252 | NEXT_ARG(); |
253 | p->i_flags |= GRE_KEY; | |
254 | p->o_flags |= GRE_KEY; | |
a7ed1520 | 255 | p->i_key = p->o_key = tnl_parse_key("key", *argv); |
af89576d | 256 | } else if (strcmp(*argv, "ikey") == 0) { |
af89576d | 257 | NEXT_ARG(); |
258 | p->i_flags |= GRE_KEY; | |
a7ed1520 | 259 | p->i_key = tnl_parse_key("ikey", *argv); |
af89576d | 260 | } else if (strcmp(*argv, "okey") == 0) { |
af89576d | 261 | NEXT_ARG(); |
262 | p->o_flags |= GRE_KEY; | |
a7ed1520 | 263 | p->o_key = tnl_parse_key("okey", *argv); |
af89576d | 264 | } else if (strcmp(*argv, "seq") == 0) { |
265 | p->i_flags |= GRE_SEQ; | |
266 | p->o_flags |= GRE_SEQ; | |
267 | } else if (strcmp(*argv, "iseq") == 0) { | |
268 | p->i_flags |= GRE_SEQ; | |
269 | } else if (strcmp(*argv, "oseq") == 0) { | |
270 | p->o_flags |= GRE_SEQ; | |
271 | } else if (strcmp(*argv, "csum") == 0) { | |
272 | p->i_flags |= GRE_CSUM; | |
273 | p->o_flags |= GRE_CSUM; | |
274 | } else if (strcmp(*argv, "icsum") == 0) { | |
275 | p->i_flags |= GRE_CSUM; | |
276 | } else if (strcmp(*argv, "ocsum") == 0) { | |
277 | p->o_flags |= GRE_CSUM; | |
9447a0d3 | 278 | } else { |
288384f2 MN |
279 | if (strcmp(*argv, "name") == 0) { |
280 | NEXT_ARG(); | |
7894ce77 | 281 | } else if (matches(*argv, "help") == 0) |
9447a0d3 | 282 | usage(); |
288384f2 MN |
283 | if (p->name[0]) |
284 | duparg2("name", *argv); | |
625df645 PS |
285 | if (get_ifname(p->name, *argv)) |
286 | invarg("\"name\" not a valid ifname", *argv); | |
21a5a6b3 | 287 | if (cmd == SIOCCHGTUNNEL && count == 0) { |
d17b136f | 288 | struct ip6_tnl_parm2 old_p = {}; |
56f5daac | 289 | |
21a5a6b3 JB |
290 | if (tnl_get_ioctl(*argv, &old_p)) |
291 | return -1; | |
292 | *p = old_p; | |
293 | } | |
9447a0d3 | 294 | } |
21a5a6b3 | 295 | count++; |
9447a0d3 MN |
296 | argc--; argv++; |
297 | } | |
26111ab1 | 298 | if (medium) { |
ea71beac | 299 | p->link = ll_name_to_index(medium); |
fe99adbc SP |
300 | if (!p->link) |
301 | return nodev(medium); | |
9447a0d3 MN |
302 | } |
303 | return 0; | |
304 | } | |
305 | ||
af89576d | 306 | static void ip6_tnl_parm_init(struct ip6_tnl_parm2 *p, int apply_default) |
288384f2 MN |
307 | { |
308 | memset(p, 0, sizeof(*p)); | |
309 | p->proto = IPPROTO_IPV6; | |
310 | if (apply_default) { | |
311 | p->hop_limit = DEFAULT_TNL_HOP_LIMIT; | |
312 | p->encap_limit = IPV6_DEFAULT_TNL_ENCAP_LIMIT; | |
313 | } | |
314 | } | |
315 | ||
3e953938 SP |
316 | static void ip6_tnl_parm_initialize(const struct tnl_print_nlmsg_info *info) |
317 | { | |
318 | const struct ifinfomsg *ifi = info->ifi; | |
319 | const struct ip6_tnl_parm2 *p1 = info->p1; | |
320 | struct ip6_tnl_parm2 *p2 = info->p2; | |
321 | ||
322 | ip6_tnl_parm_init(p2, 0); | |
323 | if (ifi->ifi_type == ARPHRD_IP6GRE) | |
324 | p2->proto = IPPROTO_GRE; | |
325 | p2->link = ifi->ifi_index; | |
326 | strcpy(p2->name, p1->name); | |
327 | } | |
328 | ||
329 | static bool ip6_tnl_parm_match(const struct tnl_print_nlmsg_info *info) | |
288384f2 | 330 | { |
3e953938 SP |
331 | const struct ip6_tnl_parm2 *p1 = info->p1; |
332 | const struct ip6_tnl_parm2 *p2 = info->p2; | |
333 | ||
288384f2 MN |
334 | return ((!p1->link || p1->link == p2->link) && |
335 | (!p1->name[0] || strcmp(p1->name, p2->name) == 0) && | |
1f4c51c0 JB |
336 | (IN6_IS_ADDR_UNSPECIFIED(&p1->laddr) || |
337 | IN6_ARE_ADDR_EQUAL(&p1->laddr, &p2->laddr)) && | |
338 | (IN6_IS_ADDR_UNSPECIFIED(&p1->raddr) || | |
339 | IN6_ARE_ADDR_EQUAL(&p1->raddr, &p2->raddr)) && | |
288384f2 MN |
340 | (!p1->proto || !p2->proto || p1->proto == p2->proto) && |
341 | (!p1->encap_limit || p1->encap_limit == p2->encap_limit) && | |
342 | (!p1->hop_limit || p1->hop_limit == p2->hop_limit) && | |
343 | (!(p1->flowinfo & IP6_FLOWINFO_TCLASS) || | |
344 | !((p1->flowinfo ^ p2->flowinfo) & IP6_FLOWINFO_TCLASS)) && | |
345 | (!(p1->flowinfo & IP6_FLOWINFO_FLOWLABEL) || | |
346 | !((p1->flowinfo ^ p2->flowinfo) & IP6_FLOWINFO_FLOWLABEL)) && | |
347 | (!p1->flags || (p1->flags & p2->flags))); | |
348 | } | |
349 | ||
9447a0d3 MN |
350 | static int do_show(int argc, char **argv) |
351 | { | |
3e953938 | 352 | struct ip6_tnl_parm2 p, p1; |
288384f2 MN |
353 | |
354 | ip6_tnl_parm_init(&p, 0); | |
c3651bf4 | 355 | p.proto = 0; /* default to any */ |
9447a0d3 | 356 | |
56f5daac SH |
357 | if (parse_args(argc, argv, SIOCGETTUNNEL, &p) < 0) |
358 | return -1; | |
9447a0d3 | 359 | |
3e953938 SP |
360 | if (!p.name[0] || show_stats) { |
361 | struct tnl_print_nlmsg_info info = { | |
362 | .p1 = &p, | |
363 | .p2 = &p1, | |
364 | .init = ip6_tnl_parm_initialize, | |
365 | .match = ip6_tnl_parm_match, | |
366 | .print = print_tunnel, | |
367 | }; | |
368 | ||
369 | return do_tunnels_list(&info); | |
370 | } | |
ec895940 SP |
371 | |
372 | if (tnl_get_ioctl(p.name, &p)) | |
373 | return -1; | |
9447a0d3 | 374 | |
ec895940 SP |
375 | print_tunnel(&p); |
376 | fputc('\n', stdout); | |
56f5daac | 377 | return 0; |
9447a0d3 MN |
378 | } |
379 | ||
9447a0d3 MN |
380 | static int do_add(int cmd, int argc, char **argv) |
381 | { | |
af89576d | 382 | struct ip6_tnl_parm2 p; |
a0638e18 | 383 | const char *basedev = "ip6tnl0"; |
288384f2 MN |
384 | |
385 | ip6_tnl_parm_init(&p, 1); | |
9447a0d3 | 386 | |
21a5a6b3 | 387 | if (parse_args(argc, argv, cmd, &p) < 0) |
9447a0d3 | 388 | return -1; |
288384f2 | 389 | |
a0638e18 AA |
390 | if (p.proto == IPPROTO_GRE) |
391 | basedev = "ip6gre0"; | |
392 | else if (p.i_flags & VTI_ISVTI) | |
393 | basedev = "ip6_vti0"; | |
394 | ||
395 | return tnl_add_ioctl(cmd, basedev, p.name, &p); | |
9447a0d3 MN |
396 | } |
397 | ||
288384f2 | 398 | static int do_del(int argc, char **argv) |
9447a0d3 | 399 | { |
af89576d | 400 | struct ip6_tnl_parm2 p; |
a0638e18 | 401 | const char *basedev = "ip6tnl0"; |
288384f2 MN |
402 | |
403 | ip6_tnl_parm_init(&p, 1); | |
9447a0d3 | 404 | |
21a5a6b3 | 405 | if (parse_args(argc, argv, SIOCDELTUNNEL, &p) < 0) |
9447a0d3 MN |
406 | return -1; |
407 | ||
a0638e18 AA |
408 | if (p.proto == IPPROTO_GRE) |
409 | basedev = "ip6gre0"; | |
410 | else if (p.i_flags & VTI_ISVTI) | |
411 | basedev = "ip6_vti0"; | |
412 | ||
413 | return tnl_del_ioctl(basedev, p.name, &p); | |
9447a0d3 MN |
414 | } |
415 | ||
ae665a52 SH |
416 | int do_ip6tunnel(int argc, char **argv) |
417 | { | |
288384f2 MN |
418 | switch (preferred_family) { |
419 | case AF_UNSPEC: | |
420 | preferred_family = AF_INET6; | |
421 | break; | |
422 | case AF_INET6: | |
423 | break; | |
424 | default: | |
14645ec2 | 425 | fprintf(stderr, "Unsupported protocol family: %d\n", preferred_family); |
288384f2 MN |
426 | exit(-1); |
427 | } | |
428 | ||
9447a0d3 | 429 | if (argc > 0) { |
288384f2 | 430 | if (matches(*argv, "add") == 0) |
9447a0d3 | 431 | return do_add(SIOCADDTUNNEL, argc - 1, argv + 1); |
288384f2 | 432 | if (matches(*argv, "change") == 0) |
9447a0d3 | 433 | return do_add(SIOCCHGTUNNEL, argc - 1, argv + 1); |
6e30461e | 434 | if (matches(*argv, "delete") == 0) |
9447a0d3 | 435 | return do_del(argc - 1, argv + 1); |
288384f2 MN |
436 | if (matches(*argv, "show") == 0 || |
437 | matches(*argv, "lst") == 0 || | |
438 | matches(*argv, "list") == 0) | |
9447a0d3 | 439 | return do_show(argc - 1, argv + 1); |
288384f2 | 440 | if (matches(*argv, "help") == 0) |
9447a0d3 | 441 | usage(); |
9447a0d3 MN |
442 | } else |
443 | return do_show(0, NULL); | |
444 | ||
288384f2 MN |
445 | fprintf(stderr, "Command \"%s\" is unknown, try \"ip -f inet6 tunnel help\".\n", *argv); |
446 | exit(-1); | |
9447a0d3 | 447 | } |