blob: 7a7f55c4697645a954e2b99c6c90b396fe2b3f6d [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
Denis Vlasenko5af906e2006-11-05 18:05:09 +000015#include "busybox.h"
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000016
Bernhard Reutner-Fischerab187822005-10-26 10:47:26 +000017#include "libiproute/utils.h"
18#include "libiproute/ip_common.h"
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000019
Glenn L McGrathf112daa2002-12-01 23:04:06 +000020int ip_main(int argc, char **argv)
21{
22 int ret = EXIT_FAILURE;
23
24 ip_parse_common_args(&argc, &argv);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000025
26 if (argc > 1) {
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000027 if (ENABLE_FEATURE_IP_ADDRESS && matches(argv[1], "address") == 0) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000028 ret = do_ipaddr(argc-2, argv+2);
29 }
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000030 if (ENABLE_FEATURE_IP_ROUTE && matches(argv[1], "route") == 0) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000031 ret = do_iproute(argc-2, argv+2);
32 }
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000033 if (ENABLE_FEATURE_IP_LINK && matches(argv[1], "link") == 0) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000034 ret = do_iplink(argc-2, argv+2);
35 }
Denis Vlasenkofd94efa2007-01-27 13:13:45 +000036 if (ENABLE_FEATURE_IP_TUNNEL
37 && (matches(argv[1], "tunnel") == 0 || strcmp(argv[1], "tunl") == 0)
38 ) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000039 ret = do_iptunnel(argc-2, argv+2);
40 }
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000041 if (ENABLE_FEATURE_IP_RULE && matches(argv[1], "rule") == 0) {
42 ret = do_iprule(argc-2, argv+2);
43 }
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000044 }
Glenn L McGrathf112daa2002-12-01 23:04:06 +000045 if (ret) {
Manuel Novoa III cad53642003-03-19 09:13:01 +000046 bb_show_usage();
Glenn L McGrathf112daa2002-12-01 23:04:06 +000047 }
Denis Vlasenko5af906e2006-11-05 18:05:09 +000048 return EXIT_SUCCESS;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000049}