summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuleshov Aleksey2013-02-04 15:14:20 +0100
committerDenys Vlasenko2013-02-04 15:14:20 +0100
commita8816dafc4b274b17c58df88cabdbf9e2b47f528 (patch)
treecfe93a4e1e5a874370e741c524575a73c9953189
parent6e29d07417c84e69ed0fb375205ae4e62fa236f7 (diff)
downloadbusybox-a8816dafc4b274b17c58df88cabdbf9e2b47f528.zip
busybox-a8816dafc4b274b17c58df88cabdbf9e2b47f528.tar.gz
arp: fix -H/-t handling.
While at it, shrank code. function old new delta arp_main 1558 1487 -71 Signed-off-by: Kuleshov Aleksey <rndfax@yandex.ru> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/arp.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/networking/arp.c b/networking/arp.c
index 1c99987..201bb2a 100644
--- a/networking/arp.c
+++ b/networking/arp.c
@@ -477,28 +477,33 @@ static int arp_show(char *name)
int arp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int arp_main(int argc UNUSED_PARAM, char **argv)
{
- const char *hw_type = "ether";
+ const char *hw_type;
const char *protocol;
unsigned opts;
INIT_G();
xmove_fd(xsocket(AF_INET, SOCK_DGRAM, 0), sockfd);
+
ap = get_aftype(DFLT_AF);
- if (!ap)
- bb_error_msg_and_die("%s: %s not supported", DFLT_AF, "address family");
+ /* Defaults are always supported */
+ //if (!ap)
+ // bb_error_msg_and_die("%s: %s not supported", DFLT_AF, "address family");
+ hw = get_hwtype(DFLT_HW);
+ //if (!hw)
+ // bb_error_msg_and_die("%s: %s not supported", DFLT_HW, "hardware type");
opts = getopt32(argv, "A:p:H:t:i:adnDsv", &protocol, &protocol,
&hw_type, &hw_type, &device);
argv += optind;
if (opts & (ARP_OPT_A | ARP_OPT_p)) {
ap = get_aftype(protocol);
- if (ap == NULL)
+ if (!ap)
bb_error_msg_and_die("%s: unknown %s", protocol, "address family");
}
- if (opts & (ARP_OPT_A | ARP_OPT_p)) {
+ if (opts & (ARP_OPT_H | ARP_OPT_t)) {
hw = get_hwtype(hw_type);
- if (hw == NULL)
+ if (!hw)
bb_error_msg_and_die("%s: unknown %s", hw_type, "hardware type");
hw_set = 1;
}
@@ -507,14 +512,6 @@ int arp_main(int argc UNUSED_PARAM, char **argv)
if (ap->af != AF_INET) {
bb_error_msg_and_die("%s: kernel only supports 'inet'", ap->name);
}
-
- /* If no hw type specified get default */
- if (!hw) {
- hw = get_hwtype(DFLT_HW);
- if (!hw)
- bb_error_msg_and_die("%s: %s not supported", DFLT_HW, "hardware type");
- }
-
if (hw->alen <= 0) {
bb_error_msg_and_die("%s: %s without ARP support",
hw->name, "hardware type");
@@ -528,6 +525,7 @@ int arp_main(int argc UNUSED_PARAM, char **argv)
return arp_set(argv);
return arp_del(argv);
}
+
//if (opts & ARP_OPT_a) - default
return arp_show(argv[0]);
}