blob: fdd848049fc84584603e84f1f43b6f3cb785dd5e [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
Denis Vlasenko06af2162007-02-03 17:28:39 +000020int ip_main(int argc, char **argv);
Glenn L McGrathf112daa2002-12-01 23:04:06 +000021int ip_main(int argc, char **argv)
22{
23 int ret = EXIT_FAILURE;
24
25 ip_parse_common_args(&argc, &argv);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000026
27 if (argc > 1) {
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000028 if (ENABLE_FEATURE_IP_ADDRESS && matches(argv[1], "address") == 0) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000029 ret = do_ipaddr(argc-2, argv+2);
30 }
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000031 if (ENABLE_FEATURE_IP_ROUTE && matches(argv[1], "route") == 0) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000032 ret = do_iproute(argc-2, argv+2);
33 }
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000034 if (ENABLE_FEATURE_IP_LINK && matches(argv[1], "link") == 0) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000035 ret = do_iplink(argc-2, argv+2);
36 }
Denis Vlasenkofd94efa2007-01-27 13:13:45 +000037 if (ENABLE_FEATURE_IP_TUNNEL
38 && (matches(argv[1], "tunnel") == 0 || strcmp(argv[1], "tunl") == 0)
39 ) {
Glenn L McGrathf112daa2002-12-01 23:04:06 +000040 ret = do_iptunnel(argc-2, argv+2);
41 }
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000042 if (ENABLE_FEATURE_IP_RULE && matches(argv[1], "rule") == 0) {
43 ret = do_iprule(argc-2, argv+2);
44 }
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000045 }
Glenn L McGrathf112daa2002-12-01 23:04:06 +000046 if (ret) {
Manuel Novoa III cad53642003-03-19 09:13:01 +000047 bb_show_usage();
Glenn L McGrathf112daa2002-12-01 23:04:06 +000048 }
Denis Vlasenko5af906e2006-11-05 18:05:09 +000049 return EXIT_SUCCESS;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000050}