From a8816dafc4b274b17c58df88cabdbf9e2b47f528 Mon Sep 17 00:00:00 2001 From: Kuleshov Aleksey Date: Mon, 4 Feb 2013 15:14:20 +0100 Subject: arp: fix -H/-t handling. While at it, shrank code. function old new delta arp_main 1558 1487 -71 Signed-off-by: Kuleshov Aleksey Signed-off-by: Denys Vlasenko --- networking/arp.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'networking/arp.c') diff --git a/networking/arp.c b/networking/arp.c index 1c99987ae..201bb2aff 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]); } -- cgit v1.2.3