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"
32 int preferred_family = AF_UNSPEC;
36 void ip_parse_common_args(int *argcp, char ***argvp)
44 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) {
79 _SL_ = oneline ? "\\" : "\n" ;
83 int ip_main(int argc, char **argv)
85 int ret = EXIT_FAILURE;
87 ip_parse_common_args(&argc, &argv);
90 #ifdef CONFIG_FEATURE_IP_ADDRESS
91 if (matches(argv[1], "address") == 0) {
92 ret = do_ipaddr(argc-2, argv+2);
95 #ifdef CONFIG_FEATURE_IP_ROUTE
96 else if (matches(argv[1], "route") == 0) {
97 ret = do_iproute(argc-2, argv+2);
100 #ifdef CONFIG_FEATURE_IP_LINK
101 else if (matches(argv[1], "link") == 0) {
102 ret = do_iplink(argc-2, argv+2);
105 #ifdef CONFIG_FEATURE_IP_TUNNEL
106 else if (matches(argv[1], "tunnel") == 0 || strcmp(argv[1], "tunl") == 0) {
107 ret = do_iptunnel(argc-2, argv+2);
114 return(EXIT_SUCCESS);