Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/networking/arp.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/networking/arp.c
r3232 r3621 23 23 //usage: "Manipulate ARP cache\n" 24 24 //usage: "\n -a Display (all) hosts" 25 //usage: "\n - s Set newARP entry"26 //usage: "\n - d Delete a specifiedentry"25 //usage: "\n -d Delete ARP entry" 26 //usage: "\n -s Set new entry" 27 27 //usage: "\n -v Verbose" 28 28 //usage: "\n -n Don't resolve names" 29 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 31 //usage: "\n -A,-p AF Protocol family" 32 32 //usage: "\n -H HWTYPE Hardware address type" 33 33 34 34 #include "libbb.h" 35 #include "common_bufsiz.h" 35 36 #include "inet_common.h" 36 37 … … 69 70 const char *device; /* current device */ 70 71 smallint hw_set; /* flag if hw-type was set (-H) */ 71 72 72 } FIX_ALIASING; 73 #define G (*(struct globals*) &bb_common_bufsiz1)73 #define G (*(struct globals*)bb_common_bufsiz1) 74 74 #define ap (G.ap ) 75 75 #define hw (G.hw ) … … 77 77 #define hw_set (G.hw_set ) 78 78 #define INIT_G() do { \ 79 setup_common_bufsiz(); \ 79 80 device = ""; \ 80 81 } while (0) … … 214 215 215 216 /* Get the hardware address to a specified interface name */ 216 static void arp_getdevhw(char *ifname, struct sockaddr *sa, 217 const struct hwtype *hwt) 217 static void arp_getdevhw(char *ifname, struct sockaddr *sa) 218 218 { 219 219 struct ifreq ifr; … … 222 222 strcpy(ifr.ifr_name, ifname); 223 223 ioctl_or_perror_and_die(sockfd, SIOCGIFHWADDR, &ifr, 224 "can t get HW-Address for '%s'", ifname);225 if (hw t && (ifr.ifr_hwaddr.sa_family != hw->type)) {224 "can't get HW-Address for '%s'", ifname); 225 if (hw_set && (ifr.ifr_hwaddr.sa_family != hw->type)) { 226 226 bb_error_msg_and_die("protocol type mismatch"); 227 227 } … … 234 234 } 235 235 bb_error_msg("device '%s' has HW address %s '%s'", 236 237 236 ifname, xhw->name, 237 xhw->print((unsigned char *) &ifr.ifr_hwaddr.sa_data)); 238 238 } 239 239 } … … 262 262 } 263 263 if (option_mask32 & ARP_OPT_D) { 264 arp_getdevhw(*args++, &req.arp_ha , hw_set ? hw : NULL);264 arp_getdevhw(*args++, &req.arp_ha); 265 265 } else { 266 266 if (hw->input(*args++, &req.arp_ha) < 0) { … … 461 461 } 462 462 if (option_mask32 & ARP_OPT_v) 463 printf("Entries: % d\tSkipped: %d\tFound: %d\n",463 printf("Entries: %u\tSkipped: %u\tFound: %u\n", 464 464 entries, entries - shown, shown); 465 465 466 466 if (!shown) { 467 467 if (hw_set || host || device[0]) 468 printf("No match found in % dentries\n", entries);468 printf("No match found in %u entries\n", entries); 469 469 } 470 470 if (ENABLE_FEATURE_CLEAN_UP) { … … 478 478 int arp_main(int argc UNUSED_PARAM, char **argv) 479 479 { 480 const char *hw_type = "ether";480 const char *hw_type; 481 481 const char *protocol; 482 482 unsigned opts; … … 485 485 486 486 xmove_fd(xsocket(AF_INET, SOCK_DGRAM, 0), sockfd); 487 487 488 ap = get_aftype(DFLT_AF); 488 if (!ap) 489 bb_error_msg_and_die("%s: %s not supported", DFLT_AF, "address family"); 489 /* Defaults are always supported */ 490 //if (!ap) 491 // bb_error_msg_and_die("%s: %s not supported", DFLT_AF, "address family"); 492 hw = get_hwtype(DFLT_HW); 493 //if (!hw) 494 // bb_error_msg_and_die("%s: %s not supported", DFLT_HW, "hardware type"); 490 495 491 496 opts = getopt32(argv, "A:p:H:t:i:adnDsv", &protocol, &protocol, … … 494 499 if (opts & (ARP_OPT_A | ARP_OPT_p)) { 495 500 ap = get_aftype(protocol); 496 if ( ap == NULL)501 if (!ap) 497 502 bb_error_msg_and_die("%s: unknown %s", protocol, "address family"); 498 503 } 499 if (opts & (ARP_OPT_ A | ARP_OPT_p)) {504 if (opts & (ARP_OPT_H | ARP_OPT_t)) { 500 505 hw = get_hwtype(hw_type); 501 if ( hw == NULL)506 if (!hw) 502 507 bb_error_msg_and_die("%s: unknown %s", hw_type, "hardware type"); 503 508 hw_set = 1; … … 508 513 bb_error_msg_and_die("%s: kernel only supports 'inet'", ap->name); 509 514 } 510 511 /* If no hw type specified get default */512 if (!hw) {513 hw = get_hwtype(DFLT_HW);514 if (!hw)515 bb_error_msg_and_die("%s: %s not supported", DFLT_HW, "hardware type");516 }517 518 515 if (hw->alen <= 0) { 519 516 bb_error_msg_and_die("%s: %s without ARP support", … … 529 526 return arp_del(argv); 530 527 } 528 531 529 //if (opts & ARP_OPT_a) - default 532 530 return arp_show(argv[0]);
Note:
See TracChangeset
for help on using the changeset viewer.