blob: fe5714f166bbaba3c84a74244c7049315f448954 [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00002/*
3 * ip.c "ip" utility frontend.
4 *
Bernhard Reutner-Fischerab187822005-10-26 10:47:26 +00005 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00006 *
7 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
8 *
9 *
10 * Changes:
11 *
12 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
13 */
14
15#include <stdio.h>
16#include <stdlib.h>
17#include <unistd.h>
18#include <syslog.h>
19#include <fcntl.h>
20#include <sys/socket.h>
21#include <netinet/in.h>
22#include <string.h>
23
Bernhard Reutner-Fischerab187822005-10-26 10:47:26 +000024#include "libiproute/utils.h"
25#include "libiproute/ip_common.h"
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000026
27#include "busybox.h"
28
Glenn L McGrathf112daa2002-12-01 23:04:06 +000029int ip_main(int argc, char **argv)
30{
31 int ret = EXIT_FAILURE;
32
33 ip_parse_common_args(&argc, &argv);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000034
35 if (argc > 1) {
36#ifdef CONFIG_FEATURE_IP_ADDRESS
Glenn L McGrathf112daa2002-12-01 23:04:06 +000037 if (matches(argv[1], "address") == 0) {
38 ret = do_ipaddr(argc-2, argv+2);
39 }
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000040#endif
41#ifdef CONFIG_FEATURE_IP_ROUTE
Glenn L McGrath19efb3d2004-04-12 02:35:44 +000042 if (matches(argv[1], "route") == 0) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000043 ret = do_iproute(argc-2, argv+2);
44 }
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000045#endif
46#ifdef CONFIG_FEATURE_IP_LINK
Glenn L McGrath19efb3d2004-04-12 02:35:44 +000047 if (matches(argv[1], "link") == 0) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000048 ret = do_iplink(argc-2, argv+2);
49 }
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000050#endif
51#ifdef CONFIG_FEATURE_IP_TUNNEL
Glenn L McGrath19efb3d2004-04-12 02:35:44 +000052 if (matches(argv[1], "tunnel") == 0 || strcmp(argv[1], "tunl") == 0) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000053 ret = do_iptunnel(argc-2, argv+2);
54 }
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000055#endif
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000056 }
Glenn L McGrathf112daa2002-12-01 23:04:06 +000057 if (ret) {
Manuel Novoa III cad53642003-03-19 09:13:01 +000058 bb_show_usage();
Glenn L McGrathf112daa2002-12-01 23:04:06 +000059 }
60 return(EXIT_SUCCESS);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000061}