mirror of
https://github.com/sheumann/hush.git
synced 2025-01-12 14:30:54 +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)
|
APPLET(insmod, insmod_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_IP
|
#ifdef CONFIG_IP
|
||||||
APPLET(ip, ip_main, _BB_DIR_BIN, _BB_SUID_NEVER)
|
APPLET(ip, ip_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_IPCALC
|
#ifdef CONFIG_IPCALC
|
||||||
APPLET(ipcalc, ipcalc_main, _BB_DIR_BIN, _BB_SUID_NEVER)
|
APPLET(ipcalc, ipcalc_main, _BB_DIR_BIN, _BB_SUID_NEVER)
|
||||||
#endif
|
#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
|
#ifdef CONFIG_KILL
|
||||||
APPLET(kill, kill_main, _BB_DIR_BIN, _BB_SUID_NEVER)
|
APPLET(kill, kill_main, _BB_DIR_BIN, _BB_SUID_NEVER)
|
||||||
#endif
|
#endif
|
||||||
|
@ -989,25 +989,38 @@
|
|||||||
"\t-x\tdo not export externs"
|
"\t-x\tdo not export externs"
|
||||||
|
|
||||||
#define ip_trivial_usage \
|
#define ip_trivial_usage \
|
||||||
"not written yet"
|
"[ OPTIONS ] { address | link | route | tunnel } { COMMAND | help }"
|
||||||
#define ip_full_usage \
|
#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
|
#ifndef CONFIG_FEATURE_IPCALC_FANCY
|
||||||
#define ipcalc_trivial_usage \
|
# define ipcalc_trivial_usage \
|
||||||
"[--broadcast] [--netmask] [--network] ipaddr <netmask>"
|
"[--broadcast] [--netmask] [--network] ipaddr <netmask>"
|
||||||
|
|
||||||
#define ipcalc_full_usage \
|
# define ipcalc_full_usage \
|
||||||
"Calculate IP network settings from a IP address\n\n" \
|
"Calculate IP network settings from a IP address\n\n" \
|
||||||
"Options:\n" \
|
"Options:\n" \
|
||||||
"\t-b\t--broadcast\tDisplay calculated broadcast address.\n" \
|
"\t-b\t--broadcast\tDisplay calculated broadcast address.\n" \
|
||||||
"\t-n\t--netmask\tDisplay default netmask for IP.\n" \
|
"\t-n\t--netmask\tDisplay default netmask for IP.\n" \
|
||||||
"\t-w\t--network\tDisplay calculated network address."
|
"\t-w\t--network\tDisplay calculated network address."
|
||||||
#else
|
#else
|
||||||
#define ipcalc_trivial_usage \
|
# define ipcalc_trivial_usage \
|
||||||
"[OPTION]... ipaddr <netmask>"
|
"[OPTION]... ipaddr <netmask>"
|
||||||
|
|
||||||
#define ipcalc_full_usage \
|
# define ipcalc_full_usage \
|
||||||
"Calculate IP network settings from a IP address\n\n" \
|
"Calculate IP network settings from a IP address\n\n" \
|
||||||
"Options:\n" \
|
"Options:\n" \
|
||||||
"\t-b\t--broadcast\tDisplay calculated broadcast address.\n" \
|
"\t-b\t--broadcast\tDisplay calculated broadcast address.\n" \
|
||||||
@ -1023,6 +1036,32 @@
|
|||||||
"should display on standard out. Multiple options may be\n" \
|
"should display on standard out. Multiple options may be\n" \
|
||||||
"specified.\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 \
|
#define kill_trivial_usage \
|
||||||
"[-signal] process-id [process-id ...]"
|
"[-signal] process-id [process-id ...]"
|
||||||
#define kill_full_usage \
|
#define kill_full_usage \
|
||||||
|
@ -28,6 +28,10 @@ NETWORKING-$(CONFIG_IFCONFIG) += ifconfig.o
|
|||||||
NETWORKING-$(CONFIG_IFUPDOWN) += ifupdown.o
|
NETWORKING-$(CONFIG_IFUPDOWN) += ifupdown.o
|
||||||
NETWORKING-$(CONFIG_IP) += ip.o
|
NETWORKING-$(CONFIG_IP) += ip.o
|
||||||
NETWORKING-$(CONFIG_IPCALC) += ipcalc.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_NC) += nc.o
|
||||||
NETWORKING-$(CONFIG_NETSTAT) += netstat.o
|
NETWORKING-$(CONFIG_NETSTAT) += netstat.o
|
||||||
NETWORKING-$(CONFIG_NSLOOKUP) += nslookup.o
|
NETWORKING-$(CONFIG_NSLOOKUP) += nslookup.o
|
||||||
|
@ -33,6 +33,22 @@ bool 'ipcalc' CONFIG_IPCALC
|
|||||||
if [ "$CONFIG_IPCALC" = "y" ]; then
|
if [ "$CONFIG_IPCALC" = "y" ]; then
|
||||||
bool ' Fancy IPCALC, more options, adds 300 bytes' CONFIG_FEATURE_IPCALC_FANCY
|
bool ' Fancy IPCALC, more options, adds 300 bytes' CONFIG_FEATURE_IPCALC_FANCY
|
||||||
fi
|
fi
|
||||||
|
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 'nc' CONFIG_NC
|
||||||
bool 'netstat' CONFIG_NETSTAT
|
bool 'netstat' CONFIG_NETSTAT
|
||||||
bool 'nslookup' CONFIG_NSLOOKUP
|
bool 'nslookup' CONFIG_NSLOOKUP
|
||||||
|
@ -28,30 +28,30 @@
|
|||||||
|
|
||||||
#include "busybox.h"
|
#include "busybox.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
int preferred_family = AF_UNSPEC;
|
int preferred_family = AF_UNSPEC;
|
||||||
int oneline = 0;
|
int oneline = 0;
|
||||||
char * _SL_ = NULL;
|
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) {
|
while (argc > 1) {
|
||||||
char *opt = argv[1];
|
char *opt = argv[1];
|
||||||
|
|
||||||
if (strcmp(opt,"--") == 0) {
|
if (strcmp(opt,"--") == 0) {
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt[0] != '-')
|
if (opt[0] != '-')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (opt[1] == '-')
|
if (opt[1] == '-')
|
||||||
opt++;
|
opt++;
|
||||||
|
|
||||||
if (matches(opt, "-family") == 0) {
|
if (matches(opt, "-family") == 0) {
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
@ -72,33 +72,44 @@ int ip_main(int argc, char **argv)
|
|||||||
} else if (matches(opt, "-oneline") == 0) {
|
} else if (matches(opt, "-oneline") == 0) {
|
||||||
++oneline;
|
++oneline;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Option \"%s\" is unknown, try \"ip -help\".\n", opt);
|
show_usage();
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
}
|
}
|
||||||
|
|
||||||
_SL_ = oneline ? "\\" : "\n" ;
|
_SL_ = oneline ? "\\" : "\n" ;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int ip_main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ret = EXIT_FAILURE;
|
||||||
|
|
||||||
|
ip_parse_common_args(&argc, &argv);
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
#ifdef CONFIG_FEATURE_IP_ADDRESS
|
#ifdef CONFIG_FEATURE_IP_ADDRESS
|
||||||
if (matches(argv[1], "address") == 0)
|
if (matches(argv[1], "address") == 0) {
|
||||||
return do_ipaddr(argc-2, argv+2);
|
ret = do_ipaddr(argc-2, argv+2);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_FEATURE_IP_ROUTE
|
#ifdef CONFIG_FEATURE_IP_ROUTE
|
||||||
if (matches(argv[1], "route") == 0)
|
else if (matches(argv[1], "route") == 0) {
|
||||||
return do_iproute(argc-2, argv+2);
|
ret = do_iproute(argc-2, argv+2);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_FEATURE_IP_LINK
|
#ifdef CONFIG_FEATURE_IP_LINK
|
||||||
if (matches(argv[1], "link") == 0)
|
else if (matches(argv[1], "link") == 0) {
|
||||||
return do_iplink(argc-2, argv+2);
|
ret = do_iplink(argc-2, argv+2);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_FEATURE_IP_TUNNEL
|
#ifdef CONFIG_FEATURE_IP_TUNNEL
|
||||||
if (matches(argv[1], "tunnel") == 0 ||
|
else if (matches(argv[1], "tunnel") == 0 || strcmp(argv[1], "tunl") == 0) {
|
||||||
strcmp(argv[1], "tunl") == 0)
|
ret = do_iptunnel(argc-2, argv+2);
|
||||||
return do_iptunnel(argc-2, argv+2);
|
|
||||||
#endif
|
|
||||||
fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv[1]);
|
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
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
|
endif
|
||||||
|
|
||||||
LIBIPROUTE-$(CONFIG_IP) += \
|
LIBIPROUTE-$(CONFIG_IP) += \
|
||||||
|
ip_parse_common_args.o \
|
||||||
ipaddress.o \
|
ipaddress.o \
|
||||||
iplink.o \
|
iplink.o \
|
||||||
iproute.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_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_addrinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg);
|
||||||
extern int print_neigh(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)
|
if ((filter.flags^ifa->ifa_flags)&filter.flagmask)
|
||||||
return 0;
|
return 0;
|
||||||
if (filter.label) {
|
if (filter.label) {
|
||||||
SPRINT_BUF(b1);
|
|
||||||
const char *label;
|
const char *label;
|
||||||
if (rta_tb[IFA_LABEL])
|
if (rta_tb[IFA_LABEL])
|
||||||
label = RTA_DATA(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);
|
return ipaddr_list(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ipaddr_reset_filter(int oneline)
|
void ipaddr_reset_filter(int _oneline)
|
||||||
{
|
{
|
||||||
memset(&filter, 0, sizeof(filter));
|
memset(&filter, 0, sizeof(filter));
|
||||||
filter.oneline = oneline;
|
filter.oneline = _oneline;
|
||||||
}
|
}
|
||||||
|
|
||||||
int default_scope(inet_prefix *lcl)
|
int default_scope(inet_prefix *lcl)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user