"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 | |
| 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-Fischer | ab18782 | 2005-10-26 10:47:26 +0000 | [diff] [blame] | 24 | #include "libiproute/utils.h" |
| 25 | #include "libiproute/ip_common.h" |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 26 | |
| 27 | #include "busybox.h" |
| 28 | |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 29 | int ip_main(int argc, char **argv) |
| 30 | { |
| 31 | int ret = EXIT_FAILURE; |
| 32 | |
| 33 | ip_parse_common_args(&argc, &argv); |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 34 | |
| 35 | if (argc > 1) { |
| 36 | #ifdef CONFIG_FEATURE_IP_ADDRESS |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 37 | if (matches(argv[1], "address") == 0) { |
| 38 | ret = do_ipaddr(argc-2, argv+2); |
| 39 | } |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 40 | #endif |
| 41 | #ifdef CONFIG_FEATURE_IP_ROUTE |
Glenn L McGrath | 19efb3d | 2004-04-12 02:35:44 +0000 | [diff] [blame] | 42 | if (matches(argv[1], "route") == 0) { |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 43 | ret = do_iproute(argc-2, argv+2); |
| 44 | } |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 45 | #endif |
| 46 | #ifdef CONFIG_FEATURE_IP_LINK |
Glenn L McGrath | 19efb3d | 2004-04-12 02:35:44 +0000 | [diff] [blame] | 47 | if (matches(argv[1], "link") == 0) { |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 48 | ret = do_iplink(argc-2, argv+2); |
| 49 | } |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 50 | #endif |
| 51 | #ifdef CONFIG_FEATURE_IP_TUNNEL |
Glenn L McGrath | 19efb3d | 2004-04-12 02:35:44 +0000 | [diff] [blame] | 52 | if (matches(argv[1], "tunnel") == 0 || strcmp(argv[1], "tunl") == 0) { |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 53 | ret = do_iptunnel(argc-2, argv+2); |
| 54 | } |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 55 | #endif |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 56 | } |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 57 | if (ret) { |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 58 | bb_show_usage(); |
Glenn L McGrath | f112daa | 2002-12-01 23:04:06 +0000 | [diff] [blame] | 59 | } |
| 60 | return(EXIT_SUCCESS); |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 61 | } |