aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-02-04 16:18:58 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-02-04 16:18:58 +0100
commit06af569f447664526a76e527ea14ae059f5c19a9 (patch)
tree4aa31f79d817209daf0a798d327ecee07d3bc3de
parenta8816dafc4b274b17c58df88cabdbf9e2b47f528 (diff)
downloadbusybox-w32-06af569f447664526a76e527ea14ae059f5c19a9.tar.gz
busybox-w32-06af569f447664526a76e527ea14ae059f5c19a9.tar.bz2
busybox-w32-06af569f447664526a76e527ea14ae059f5c19a9.zip
arp: code shrink
function old new delta packed_usage 29257 29252 -5 arp_main 1487 1471 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/arp.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/networking/arp.c b/networking/arp.c
index 201bb2aff..40d244116 100644
--- a/networking/arp.c
+++ b/networking/arp.c
@@ -22,12 +22,12 @@
22//usage:#define arp_full_usage "\n\n" 22//usage:#define arp_full_usage "\n\n"
23//usage: "Manipulate ARP cache\n" 23//usage: "Manipulate ARP cache\n"
24//usage: "\n -a Display (all) hosts" 24//usage: "\n -a Display (all) hosts"
25//usage: "\n -s Set new ARP entry" 25//usage: "\n -d Delete ARP entry"
26//usage: "\n -d Delete a specified entry" 26//usage: "\n -s Set new entry"
27//usage: "\n -v Verbose" 27//usage: "\n -v Verbose"
28//usage: "\n -n Don't resolve names" 28//usage: "\n -n Don't resolve names"
29//usage: "\n -i IF Network interface" 29//usage: "\n -i IF Network interface"
30//usage: "\n -D Read <hwaddr> from given device" 30//usage: "\n -D Read HWADDR from IFACE"
31//usage: "\n -A,-p AF Protocol family" 31//usage: "\n -A,-p AF Protocol family"
32//usage: "\n -H HWTYPE Hardware address type" 32//usage: "\n -H HWTYPE Hardware address type"
33 33
@@ -213,16 +213,15 @@ static int arp_del(char **args)
213} 213}
214 214
215/* Get the hardware address to a specified interface name */ 215/* Get the hardware address to a specified interface name */
216static void arp_getdevhw(char *ifname, struct sockaddr *sa, 216static void arp_getdevhw(char *ifname, struct sockaddr *sa)
217 const struct hwtype *hwt)
218{ 217{
219 struct ifreq ifr; 218 struct ifreq ifr;
220 const struct hwtype *xhw; 219 const struct hwtype *xhw;
221 220
222 strcpy(ifr.ifr_name, ifname); 221 strcpy(ifr.ifr_name, ifname);
223 ioctl_or_perror_and_die(sockfd, SIOCGIFHWADDR, &ifr, 222 ioctl_or_perror_and_die(sockfd, SIOCGIFHWADDR, &ifr,
224 "cant get HW-Address for '%s'", ifname); 223 "can't get HW-Address for '%s'", ifname);
225 if (hwt && (ifr.ifr_hwaddr.sa_family != hw->type)) { 224 if (hw_set && (ifr.ifr_hwaddr.sa_family != hw->type)) {
226 bb_error_msg_and_die("protocol type mismatch"); 225 bb_error_msg_and_die("protocol type mismatch");
227 } 226 }
228 memcpy(sa, &(ifr.ifr_hwaddr), sizeof(struct sockaddr)); 227 memcpy(sa, &(ifr.ifr_hwaddr), sizeof(struct sockaddr));
@@ -233,8 +232,8 @@ static void arp_getdevhw(char *ifname, struct sockaddr *sa,
233 xhw = get_hwntype(-1); 232 xhw = get_hwntype(-1);
234 } 233 }
235 bb_error_msg("device '%s' has HW address %s '%s'", 234 bb_error_msg("device '%s' has HW address %s '%s'",
236 ifname, xhw->name, 235 ifname, xhw->name,
237 xhw->print((unsigned char *) &ifr.ifr_hwaddr.sa_data)); 236 xhw->print((unsigned char *) &ifr.ifr_hwaddr.sa_data));
238 } 237 }
239} 238}
240 239
@@ -261,7 +260,7 @@ static int arp_set(char **args)
261 bb_error_msg_and_die("need hardware address"); 260 bb_error_msg_and_die("need hardware address");
262 } 261 }
263 if (option_mask32 & ARP_OPT_D) { 262 if (option_mask32 & ARP_OPT_D) {
264 arp_getdevhw(*args++, &req.arp_ha, hw_set ? hw : NULL); 263 arp_getdevhw(*args++, &req.arp_ha);
265 } else { 264 } else {
266 if (hw->input(*args++, &req.arp_ha) < 0) { 265 if (hw->input(*args++, &req.arp_ha) < 0) {
267 bb_error_msg_and_die("invalid hardware address"); 266 bb_error_msg_and_die("invalid hardware address");