2 * ip.c "ip" utility frontend.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
14 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
22 #include <sys/socket.h>
23 #include <netinet/in.h>
26 #include "./libiproute/utils.h"
27 #include "./libiproute/ip_common.h"
31 int preferred_family = AF_UNSPEC;
35 int ip_main(int argc, char **argv)
39 basename = strrchr(argv[0], '/');
47 if (strcmp(opt,"--") == 0) {
55 if (matches(opt, "-family") == 0) {
58 if (strcmp(argv[1], "inet") == 0)
59 preferred_family = AF_INET;
60 else if (strcmp(argv[1], "inet6") == 0)
61 preferred_family = AF_INET6;
62 else if (strcmp(argv[1], "link") == 0)
63 preferred_family = AF_PACKET;
65 invarg(argv[1], "invalid protocol family");
66 } else if (strcmp(opt, "-4") == 0) {
67 preferred_family = AF_INET;
68 } else if (strcmp(opt, "-6") == 0) {
69 preferred_family = AF_INET6;
70 } else if (strcmp(opt, "-0") == 0) {
71 preferred_family = AF_PACKET;
72 } else if (matches(opt, "-oneline") == 0) {
75 fprintf(stderr, "Option \"%s\" is unknown, try \"ip -help\".\n", opt);
81 _SL_ = oneline ? "\\" : "\n" ;
84 #ifdef CONFIG_FEATURE_IP_ADDRESS
85 if (matches(argv[1], "address") == 0)
86 return do_ipaddr(argc-2, argv+2);
88 #ifdef CONFIG_FEATURE_IP_ROUTE
89 if (matches(argv[1], "route") == 0)
90 return do_iproute(argc-2, argv+2);
92 #ifdef CONFIG_FEATURE_IP_LINK
93 if (matches(argv[1], "link") == 0)
94 return do_iplink(argc-2, argv+2);
96 #ifdef CONFIG_FEATURE_IP_TUNNEL
97 if (matches(argv[1], "tunnel") == 0 ||
98 strcmp(argv[1], "tunl") == 0)
99 return do_iptunnel(argc-2, argv+2);
101 fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv[1]);