mirror of
https://github.com/sheumann/hush.git
synced 2024-12-21 23:29:34 +00:00
Enable ip commands to be compiled seperate from ip, modifed patch from Bastian Blank
This commit is contained in:
parent
f3faf41334
commit
f112daa232
@ -255,11 +255,23 @@
|
||||
APPLET(insmod, insmod_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
|
||||
#endif
|
||||
#ifdef CONFIG_IP
|
||||
APPLET(ip, ip_main, _BB_DIR_BIN, _BB_SUID_NEVER)
|
||||
APPLET(ip, ip_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
|
||||
#endif
|
||||
#ifdef CONFIG_IPCALC
|
||||
APPLET(ipcalc, ipcalc_main, _BB_DIR_BIN, _BB_SUID_NEVER)
|
||||
#endif
|
||||
#ifdef CONFIG_IPADDRESS
|
||||
APPLET(ipaddr, ipaddr_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
|
||||
#endif
|
||||
#ifdef CONFIG_IPLINK
|
||||
APPLET(iplink, iplink_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
|
||||
#endif
|
||||
#ifdef CONFIG_IPROUTE
|
||||
APPLET(iproute, iproute_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
|
||||
#endif
|
||||
#ifdef CONFIG_IPTUNNEL
|
||||
APPLET(iptunnel, iptunnel_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
|
||||
#endif
|
||||
#ifdef CONFIG_KILL
|
||||
APPLET(kill, kill_main, _BB_DIR_BIN, _BB_SUID_NEVER)
|
||||
#endif
|
||||
|
@ -989,25 +989,38 @@
|
||||
"\t-x\tdo not export externs"
|
||||
|
||||
#define ip_trivial_usage \
|
||||
"not written yet"
|
||||
"[ OPTIONS ] { address | link | route | tunnel } { COMMAND | help }"
|
||||
#define ip_full_usage \
|
||||
"not written yet"
|
||||
"ip [ OPTIONS ] OBJECT { COMMAND | help }\n" \
|
||||
"where OBJECT := { link | addr | route | tunnel }\n" \
|
||||
"OPTIONS := { -f[amily] { inet | inet6 | link } | -o[neline] }\n"
|
||||
|
||||
#define ipaddr_trivial_usage \
|
||||
"{ {add|del} IFADDR dev STRING | {show|flush} [ dev STRING ] [ to PREFIX ] }"
|
||||
#define ipaddr_full_usage \
|
||||
"ipaddr {add|del} IFADDR dev STRING\n" \
|
||||
"ipaddr {show|flush} [ dev STRING ] [ scope SCOPE-ID ]\n" \
|
||||
" [ to PREFIX ] [ label PATTERN ]\n" \
|
||||
"IFADDR := PREFIX | ADDR peer PREFIX\n" \
|
||||
" [ broadcast ADDR ] [ anycast ADDR ]\n" \
|
||||
" [ label STRING ] [ scope SCOPE-ID ]\n" \
|
||||
"SCOPE-ID := [ host | link | global | NUMBER ]\n"
|
||||
|
||||
#ifndef CONFIG_FEATURE_IPCALC_FANCY
|
||||
#define ipcalc_trivial_usage \
|
||||
# define ipcalc_trivial_usage \
|
||||
"[--broadcast] [--netmask] [--network] ipaddr <netmask>"
|
||||
|
||||
#define ipcalc_full_usage \
|
||||
# define ipcalc_full_usage \
|
||||
"Calculate IP network settings from a IP address\n\n" \
|
||||
"Options:\n" \
|
||||
"\t-b\t--broadcast\tDisplay calculated broadcast address.\n" \
|
||||
"\t-n\t--netmask\tDisplay default netmask for IP.\n" \
|
||||
"\t-w\t--network\tDisplay calculated network address."
|
||||
#else
|
||||
#define ipcalc_trivial_usage \
|
||||
# define ipcalc_trivial_usage \
|
||||
"[OPTION]... ipaddr <netmask>"
|
||||
|
||||
#define ipcalc_full_usage \
|
||||
# define ipcalc_full_usage \
|
||||
"Calculate IP network settings from a IP address\n\n" \
|
||||
"Options:\n" \
|
||||
"\t-b\t--broadcast\tDisplay calculated broadcast address.\n" \
|
||||
@ -1023,6 +1036,32 @@
|
||||
"should display on standard out. Multiple options may be\n" \
|
||||
"specified.\n"
|
||||
|
||||
#define iplink_trivial_usage \
|
||||
"{ set DEVICE { up | down | arp { on | off } | show [ DEVICE ] }"
|
||||
#define iplink_full_usage \
|
||||
"iplink set DEVICE { up | down | arp { on | off } |\n" \
|
||||
" dynamic { on | off } |\n" \
|
||||
" mtu MTU }\n" \
|
||||
"iplink show [ DEVICE ]\n"
|
||||
|
||||
#define iproute_trivial_usage \
|
||||
"{ list | flush | { add | del | change | append | replace | monitor } ROUTE }"
|
||||
#define iproute_full_usage \
|
||||
"iproute { list | flush } SELECTOR\n" \
|
||||
"iproute get ADDRESS [ from ADDRESS iif STRING ]\n" \
|
||||
" [ oif STRING ] [ tos TOS ]\n" \
|
||||
"iproute { add | del | change | append | replace | monitor } ROUTE\n" \
|
||||
"SELECTOR := [ root PREFIX ] [ match PREFIX ] [ proto RTPROTO ]\n" \
|
||||
"ROUTE := [ TYPE ] PREFIX [ tos TOS ] [ proto RTPROTO ]\n"
|
||||
|
||||
#define iptunnel_trivial_usage \
|
||||
"{ add | change | del | show } [ NAME ] [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ] [ ttl TTL ]"
|
||||
#define iptunnel_full_usage \
|
||||
"iptunnel { add | change | del | show } [ NAME ]\n" \
|
||||
" [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\n" \
|
||||
" [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n" \
|
||||
" [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n"
|
||||
|
||||
#define kill_trivial_usage \
|
||||
"[-signal] process-id [process-id ...]"
|
||||
#define kill_full_usage \
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user