"Robert P. J. Day" | 63fc1a9 | 2006-07-02 19:47:05 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * ip.c "ip" utility frontend. |
| 4 | * |
Bernhard Reutner-Fischer | ab18782 | 2005-10-26 10:47:26 +0000 | [diff] [blame] | 5 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 6 | * |
| 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 Vlasenko | 5af906e | 2006-11-05 18:05:09 +0000 | [diff] [blame] | 15 | #include "busybox.h" |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 16 | |
Bernhard Reutner-Fischer | ab18782 | 2005-10-26 10:47:26 +0000 | [diff] [blame] | 17 | #include "libiproute/utils.h" |
| 18 | #include "libiproute/ip_common.h" |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 19 | |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 20 | int ip_main(int argc, char **argv) |
| 21 | { |
| 22 | int ret = EXIT_FAILURE; |
| 23 | |
| 24 | ip_parse_common_args(&argc, &argv); |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 25 | |
| 26 | if (argc > 1) { |
Bernhard Reutner-Fischer | 921f5df | 2006-11-21 15:36:08 +0000 | [diff] [blame] | 27 | if (ENABLE_FEATURE_IP_ADDRESS && matches(argv[1], "address") == 0) { |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 28 | ret = do_ipaddr(argc-2, argv+2); |
| 29 | } |
Bernhard Reutner-Fischer | 921f5df | 2006-11-21 15:36:08 +0000 | [diff] [blame] | 30 | if (ENABLE_FEATURE_IP_ROUTE && matches(argv[1], "route") == 0) { |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 31 | ret = do_iproute(argc-2, argv+2); |
| 32 | } |
Bernhard Reutner-Fischer | 921f5df | 2006-11-21 15:36:08 +0000 | [diff] [blame] | 33 | if (ENABLE_FEATURE_IP_LINK && matches(argv[1], "link") == 0) { |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 34 | ret = do_iplink(argc-2, argv+2); |
| 35 | } |
Denis Vlasenko | fd94efa | 2007-01-27 13:13:45 +0000 | [diff] [blame] | 36 | if (ENABLE_FEATURE_IP_TUNNEL |
| 37 | && (matches(argv[1], "tunnel") == 0 || strcmp(argv[1], "tunl") == 0) |
| 38 | ) { |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 39 | ret = do_iptunnel(argc-2, argv+2); |
| 40 | } |
Bernhard Reutner-Fischer | 921f5df | 2006-11-21 15:36:08 +0000 | [diff] [blame] | 41 | if (ENABLE_FEATURE_IP_RULE && matches(argv[1], "rule") == 0) { |
| 42 | ret = do_iprule(argc-2, argv+2); |
| 43 | } |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 44 | } |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 45 | if (ret) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 46 | bb_show_usage(); |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 47 | } |
Denis Vlasenko | 5af906e | 2006-11-05 18:05:09 +0000 | [diff] [blame] | 48 | return EXIT_SUCCESS; |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 49 | } |