Enable ip commands to be compiled seperate from ip, modifed patch from Bastian Blank
This commit is contained in:
@@ -23,21 +23,25 @@ NETWORKING_DIR:=$(TOPDIR)networking/
|
||||
endif
|
||||
|
||||
NETWORKING-y:=
|
||||
NETWORKING-$(CONFIG_HOSTNAME) += hostname.o
|
||||
NETWORKING-$(CONFIG_IFCONFIG) += ifconfig.o
|
||||
NETWORKING-$(CONFIG_IFUPDOWN) += ifupdown.o
|
||||
NETWORKING-$(CONFIG_IP) += ip.o
|
||||
NETWORKING-$(CONFIG_IPCALC) += ipcalc.o
|
||||
NETWORKING-$(CONFIG_HOSTNAME) += hostname.o
|
||||
NETWORKING-$(CONFIG_IFCONFIG) += ifconfig.o
|
||||
NETWORKING-$(CONFIG_IFUPDOWN) += ifupdown.o
|
||||
NETWORKING-$(CONFIG_IP) += ip.o
|
||||
NETWORKING-$(CONFIG_IPCALC) += ipcalc.o
|
||||
NETWORKING-$(CONFIG_IPADDR) += ipaddr.o
|
||||
NETWORKING-$(CONFIG_IPLINK) += iplink.o
|
||||
NETWORKING-$(CONFIG_IPROUTE) += iproute.o
|
||||
NETWORKING-$(CONFIG_IPTUNNEL) += iptunnel.o
|
||||
NETWORKING-$(CONFIG_NC) += nc.o
|
||||
NETWORKING-$(CONFIG_NETSTAT) += netstat.o
|
||||
NETWORKING-$(CONFIG_NSLOOKUP) += nslookup.o
|
||||
NETWORKING-$(CONFIG_NETSTAT) += netstat.o
|
||||
NETWORKING-$(CONFIG_NSLOOKUP) += nslookup.o
|
||||
NETWORKING-$(CONFIG_PING) += ping.o
|
||||
NETWORKING-$(CONFIG_PING6) += ping6.o
|
||||
NETWORKING-$(CONFIG_ROUTE) += route.o
|
||||
NETWORKING-$(CONFIG_TELNET) += telnet.o
|
||||
NETWORKING-$(CONFIG_TELNETD) += telnetd.o
|
||||
NETWORKING-$(CONFIG_TELNETD) += telnetd.o
|
||||
NETWORKING-$(CONFIG_TFTP) += tftp.o
|
||||
NETWORKING-$(CONFIG_TRACEROUTE) += traceroute.o
|
||||
NETWORKING-$(CONFIG_TRACEROUTE) += traceroute.o
|
||||
NETWORKING-$(CONFIG_WGET) += wget.o
|
||||
|
||||
libraries-y+=$(NETWORKING_DIR)$(NETWORKING_AR)
|
||||
|
@@ -33,10 +33,26 @@ bool 'ipcalc' CONFIG_IPCALC
|
||||
if [ "$CONFIG_IPCALC" = "y" ]; then
|
||||
bool ' Fancy IPCALC, more options, adds 300 bytes' CONFIG_FEATURE_IPCALC_FANCY
|
||||
fi
|
||||
bool 'nc' CONFIG_NC
|
||||
bool 'ipaddr' CONFIG_IPADDR
|
||||
if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPADDR" = "y" ]; then
|
||||
define_bool CONFIG_FEATURE_IP_ADDRESS y
|
||||
fi
|
||||
bool 'iplink' CONFIG_IPLINK
|
||||
if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPLINK" = "y" ]; then
|
||||
define_bool CONFIG_FEATURE_IP_LINK y
|
||||
fi
|
||||
bool 'iproute' CONFIG_IPROUTE
|
||||
if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPROUTE" = "y" ]; then
|
||||
define_bool CONFIG_FEATURE_IP_ROUTE y
|
||||
fi
|
||||
bool 'iptunnel' CONFIG_IPTUNNEL
|
||||
if [ "$CONFIG_IP" = "y" ] && [ "$CONFIG_IPTUNNEL" = "y" ]; then
|
||||
define_bool CONFIG_FEATURE_IP_TUNNEL y
|
||||
fi
|
||||
bool 'nc' CONFIG_NC
|
||||
bool 'netstat' CONFIG_NETSTAT
|
||||
bool 'nslookup' CONFIG_NSLOOKUP
|
||||
bool 'ping' CONFIG_PING
|
||||
bool 'ping' CONFIG_PING
|
||||
if [ "$CONFIG_PING" = "y" ]; then
|
||||
bool ' Enable fancy ping output' CONFIG_FEATURE_FANCY_PING
|
||||
fi
|
||||
|
@@ -28,30 +28,30 @@
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#if 0
|
||||
int preferred_family = AF_UNSPEC;
|
||||
int oneline = 0;
|
||||
char * _SL_ = NULL;
|
||||
|
||||
int ip_main(int argc, char **argv)
|
||||
void ip_parse_common_args(int *argcp, char ***argvp)
|
||||
{
|
||||
char *basename;
|
||||
int argc = *argcp;
|
||||
char **argv = *argvp;
|
||||
|
||||
basename = strrchr(argv[0], '/');
|
||||
if (basename == NULL)
|
||||
basename = argv[0];
|
||||
else
|
||||
basename++;
|
||||
|
||||
while (argc > 1) {
|
||||
char *opt = argv[1];
|
||||
|
||||
if (strcmp(opt,"--") == 0) {
|
||||
argc--; argv++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (opt[0] != '-')
|
||||
break;
|
||||
|
||||
if (opt[1] == '-')
|
||||
opt++;
|
||||
|
||||
if (matches(opt, "-family") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
@@ -72,33 +72,44 @@ int ip_main(int argc, char **argv)
|
||||
} else if (matches(opt, "-oneline") == 0) {
|
||||
++oneline;
|
||||
} else {
|
||||
fprintf(stderr, "Option \"%s\" is unknown, try \"ip -help\".\n", opt);
|
||||
exit(-1);
|
||||
show_usage();
|
||||
}
|
||||
argc--; argv++;
|
||||
}
|
||||
|
||||
_SL_ = oneline ? "\\" : "\n" ;
|
||||
}
|
||||
#endif
|
||||
|
||||
int ip_main(int argc, char **argv)
|
||||
{
|
||||
int ret = EXIT_FAILURE;
|
||||
|
||||
ip_parse_common_args(&argc, &argv);
|
||||
|
||||
if (argc > 1) {
|
||||
#ifdef CONFIG_FEATURE_IP_ADDRESS
|
||||
if (matches(argv[1], "address") == 0)
|
||||
return do_ipaddr(argc-2, argv+2);
|
||||
if (matches(argv[1], "address") == 0) {
|
||||
ret = do_ipaddr(argc-2, argv+2);
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_IP_ROUTE
|
||||
if (matches(argv[1], "route") == 0)
|
||||
return do_iproute(argc-2, argv+2);
|
||||
else if (matches(argv[1], "route") == 0) {
|
||||
ret = do_iproute(argc-2, argv+2);
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_IP_LINK
|
||||
if (matches(argv[1], "link") == 0)
|
||||
return do_iplink(argc-2, argv+2);
|
||||
else if (matches(argv[1], "link") == 0) {
|
||||
ret = do_iplink(argc-2, argv+2);
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_IP_TUNNEL
|
||||
if (matches(argv[1], "tunnel") == 0 ||
|
||||
strcmp(argv[1], "tunl") == 0)
|
||||
return do_iptunnel(argc-2, argv+2);
|
||||
else if (matches(argv[1], "tunnel") == 0 || strcmp(argv[1], "tunl") == 0) {
|
||||
ret = do_iptunnel(argc-2, argv+2);
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv[1]);
|
||||
exit(-1);
|
||||
}
|
||||
if (ret) {
|
||||
show_usage();
|
||||
}
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
27
networking/ipaddr.c
Normal file
27
networking/ipaddr.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* ip.c "ip" utility frontend.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
|
||||
*
|
||||
*
|
||||
* Changes:
|
||||
*
|
||||
* Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
|
||||
*/
|
||||
|
||||
#include "./libiproute/utils.h"
|
||||
#include "./libiproute/ip_common.h"
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
int ipaddr_main(int argc, char **argv)
|
||||
{
|
||||
ip_parse_common_args(&argc, &argv);
|
||||
|
||||
return do_ipaddr(argc-1, argv+1);
|
||||
}
|
27
networking/iplink.c
Normal file
27
networking/iplink.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* ip.c "ip" utility frontend.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
|
||||
*
|
||||
*
|
||||
* Changes:
|
||||
*
|
||||
* Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
|
||||
*/
|
||||
|
||||
#include "./libiproute/utils.h"
|
||||
#include "./libiproute/ip_common.h"
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
int iplink_main(int argc, char **argv)
|
||||
{
|
||||
ip_parse_common_args(&argc, &argv);
|
||||
|
||||
return do_iplink(argc-1, argv+1);
|
||||
}
|
27
networking/iproute.c
Normal file
27
networking/iproute.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* ip.c "ip" utility frontend.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
|
||||
*
|
||||
*
|
||||
* Changes:
|
||||
*
|
||||
* Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
|
||||
*/
|
||||
|
||||
#include "./libiproute/utils.h"
|
||||
#include "./libiproute/ip_common.h"
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
int iproute_main(int argc, char **argv)
|
||||
{
|
||||
ip_parse_common_args(&argc, &argv);
|
||||
|
||||
return do_iproute(argc-1, argv+1);
|
||||
}
|
27
networking/iptunnel.c
Normal file
27
networking/iptunnel.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* ip.c "ip" utility frontend.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
|
||||
*
|
||||
*
|
||||
* Changes:
|
||||
*
|
||||
* Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
|
||||
*/
|
||||
|
||||
#include "./libiproute/utils.h"
|
||||
#include "./libiproute/ip_common.h"
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
int iptunnel_main(int argc, char **argv)
|
||||
{
|
||||
ip_parse_common_args(&argc, &argv);
|
||||
|
||||
return do_iptunnel(argc-1, argv+1);
|
||||
}
|
@@ -23,6 +23,7 @@ LIBIPROUTE_DIR:=$(TOPDIR)networking/libiproute/
|
||||
endif
|
||||
|
||||
LIBIPROUTE-$(CONFIG_IP) += \
|
||||
ip_parse_common_args.o \
|
||||
ipaddress.o \
|
||||
iplink.o \
|
||||
iproute.o \
|
||||
|
@@ -1,3 +1,7 @@
|
||||
extern int preferred_family;
|
||||
extern char * _SL_;
|
||||
|
||||
extern void ip_parse_common_args(int *argcp, char ***argvp);
|
||||
extern int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
|
||||
extern int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
|
||||
extern int print_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
|
||||
|
70
networking/libiproute/ip_parse_common_args.c
Normal file
70
networking/libiproute/ip_parse_common_args.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* ip.c "ip" utility frontend.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
|
||||
*
|
||||
*
|
||||
* Changes:
|
||||
*
|
||||
* Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
|
||||
*/
|
||||
|
||||
#include "utils.h"
|
||||
#include "ip_common.h"
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
int preferred_family = AF_UNSPEC;
|
||||
int oneline = 0;
|
||||
char * _SL_ = NULL;
|
||||
|
||||
void ip_parse_common_args(int *argcp, char ***argvp)
|
||||
{
|
||||
int argc = *argcp;
|
||||
char **argv = *argvp;
|
||||
|
||||
while (argc > 1) {
|
||||
char *opt = argv[1];
|
||||
|
||||
if (strcmp(opt,"--") == 0) {
|
||||
argc--; argv++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (opt[0] != '-')
|
||||
break;
|
||||
|
||||
if (opt[1] == '-')
|
||||
opt++;
|
||||
|
||||
if (matches(opt, "-family") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (strcmp(argv[1], "inet") == 0)
|
||||
preferred_family = AF_INET;
|
||||
else if (strcmp(argv[1], "inet6") == 0)
|
||||
preferred_family = AF_INET6;
|
||||
else if (strcmp(argv[1], "link") == 0)
|
||||
preferred_family = AF_PACKET;
|
||||
else
|
||||
invarg(argv[1], "invalid protocol family");
|
||||
} else if (strcmp(opt, "-4") == 0) {
|
||||
preferred_family = AF_INET;
|
||||
} else if (strcmp(opt, "-6") == 0) {
|
||||
preferred_family = AF_INET6;
|
||||
} else if (strcmp(opt, "-0") == 0) {
|
||||
preferred_family = AF_PACKET;
|
||||
} else if (matches(opt, "-oneline") == 0) {
|
||||
++oneline;
|
||||
} else {
|
||||
show_usage();
|
||||
}
|
||||
argc--; argv++;
|
||||
}
|
||||
_SL_ = oneline ? "\\" : "\n" ;
|
||||
}
|
@@ -230,7 +230,6 @@ int print_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
||||
if ((filter.flags^ifa->ifa_flags)&filter.flagmask)
|
||||
return 0;
|
||||
if (filter.label) {
|
||||
SPRINT_BUF(b1);
|
||||
const char *label;
|
||||
if (rta_tb[IFA_LABEL])
|
||||
label = RTA_DATA(rta_tb[IFA_LABEL]);
|
||||
@@ -541,10 +540,10 @@ int ipaddr_list_link(int argc, char **argv)
|
||||
return ipaddr_list(argc, argv);
|
||||
}
|
||||
|
||||
void ipaddr_reset_filter(int oneline)
|
||||
void ipaddr_reset_filter(int _oneline)
|
||||
{
|
||||
memset(&filter, 0, sizeof(filter));
|
||||
filter.oneline = oneline;
|
||||
filter.oneline = _oneline;
|
||||
}
|
||||
|
||||
int default_scope(inet_prefix *lcl)
|
||||
|
Reference in New Issue
Block a user