diff options
Diffstat (limited to 'networking/arping.c')
-rw-r--r-- | networking/arping.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/networking/arping.c b/networking/arping.c index bf0a77cf4..2e1adf0a2 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -302,9 +302,9 @@ int arping_main(int argc, char **argv) | |||
302 | break; | 302 | break; |
303 | case 'I': | 303 | case 'I': |
304 | if (optarg == NULL) | 304 | if (optarg == NULL) |
305 | show_usage(); | 305 | bb_show_usage(); |
306 | if (xstrlen(optarg) > IF_NAMESIZE) { | 306 | if (bb_strlen(optarg) > IF_NAMESIZE) { |
307 | error_msg("Interface name `%s' must be less than %d", optarg, | 307 | bb_error_msg("Interface name `%s' must be less than %d", optarg, |
308 | IF_NAMESIZE); | 308 | IF_NAMESIZE); |
309 | exit(2); | 309 | exit(2); |
310 | } | 310 | } |
@@ -319,20 +319,20 @@ int arping_main(int argc, char **argv) | |||
319 | case 'h': | 319 | case 'h': |
320 | case '?': | 320 | case '?': |
321 | default: | 321 | default: |
322 | show_usage(); | 322 | bb_show_usage(); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | argc -= optind; | 325 | argc -= optind; |
326 | argv += optind; | 326 | argv += optind; |
327 | 327 | ||
328 | if (argc != 1) | 328 | if (argc != 1) |
329 | show_usage(); | 329 | bb_show_usage(); |
330 | 330 | ||
331 | target = *argv; | 331 | target = *argv; |
332 | 332 | ||
333 | 333 | ||
334 | if (s < 0) { | 334 | if (s < 0) { |
335 | error_msg("socket"); | 335 | bb_error_msg("socket"); |
336 | exit(socket_errno); | 336 | exit(socket_errno); |
337 | } | 337 | } |
338 | 338 | ||
@@ -342,21 +342,21 @@ int arping_main(int argc, char **argv) | |||
342 | memset(&ifr, 0, sizeof(ifr)); | 342 | memset(&ifr, 0, sizeof(ifr)); |
343 | strncpy(ifr.ifr_name, device, IFNAMSIZ - 1); | 343 | strncpy(ifr.ifr_name, device, IFNAMSIZ - 1); |
344 | if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) { | 344 | if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) { |
345 | error_msg("Interface %s not found", device); | 345 | bb_error_msg("Interface %s not found", device); |
346 | exit(2); | 346 | exit(2); |
347 | } | 347 | } |
348 | ifindex = ifr.ifr_ifindex; | 348 | ifindex = ifr.ifr_ifindex; |
349 | 349 | ||
350 | if (ioctl(s, SIOCGIFFLAGS, (char *) &ifr)) { | 350 | if (ioctl(s, SIOCGIFFLAGS, (char *) &ifr)) { |
351 | error_msg("SIOCGIFFLAGS"); | 351 | bb_error_msg("SIOCGIFFLAGS"); |
352 | exit(2); | 352 | exit(2); |
353 | } | 353 | } |
354 | if (!(ifr.ifr_flags & IFF_UP)) { | 354 | if (!(ifr.ifr_flags & IFF_UP)) { |
355 | error_msg("Interface %s is down", device); | 355 | bb_error_msg("Interface %s is down", device); |
356 | exit(2); | 356 | exit(2); |
357 | } | 357 | } |
358 | if (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)) { | 358 | if (ifr.ifr_flags & (IFF_NOARP | IFF_LOOPBACK)) { |
359 | error_msg("Interface %s is not ARPable", device); | 359 | bb_error_msg("Interface %s is not ARPable", device); |
360 | exit(dad ? 0 : 2); | 360 | exit(dad ? 0 : 2); |
361 | } | 361 | } |
362 | } | 362 | } |
@@ -366,14 +366,14 @@ int arping_main(int argc, char **argv) | |||
366 | 366 | ||
367 | hp = gethostbyname2(target, AF_INET); | 367 | hp = gethostbyname2(target, AF_INET); |
368 | if (!hp) { | 368 | if (!hp) { |
369 | error_msg("invalid or unknown target %s", target); | 369 | bb_error_msg("invalid or unknown target %s", target); |
370 | exit(2); | 370 | exit(2); |
371 | } | 371 | } |
372 | memcpy(&dst, hp->h_addr, 4); | 372 | memcpy(&dst, hp->h_addr, 4); |
373 | } | 373 | } |
374 | 374 | ||
375 | if (source && !inet_aton(source, &src)) { | 375 | if (source && !inet_aton(source, &src)) { |
376 | error_msg("invalid source address %s", source); | 376 | bb_error_msg("invalid source address %s", source); |
377 | exit(2); | 377 | exit(2); |
378 | } | 378 | } |
379 | 379 | ||
@@ -385,21 +385,21 @@ int arping_main(int argc, char **argv) | |||
385 | int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); | 385 | int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); |
386 | 386 | ||
387 | if (probe_fd < 0) { | 387 | if (probe_fd < 0) { |
388 | error_msg("socket"); | 388 | bb_error_msg("socket"); |
389 | exit(2); | 389 | exit(2); |
390 | } | 390 | } |
391 | if (device) { | 391 | if (device) { |
392 | if (setsockopt | 392 | if (setsockopt |
393 | (probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, | 393 | (probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, |
394 | strlen(device) + 1) == -1) | 394 | strlen(device) + 1) == -1) |
395 | error_msg("WARNING: interface %s is ignored", device); | 395 | bb_error_msg("WARNING: interface %s is ignored", device); |
396 | } | 396 | } |
397 | memset(&saddr, 0, sizeof(saddr)); | 397 | memset(&saddr, 0, sizeof(saddr)); |
398 | saddr.sin_family = AF_INET; | 398 | saddr.sin_family = AF_INET; |
399 | if (src.s_addr) { | 399 | if (src.s_addr) { |
400 | saddr.sin_addr = src; | 400 | saddr.sin_addr = src; |
401 | if (bind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) == -1) { | 401 | if (bind(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) == -1) { |
402 | error_msg("bind"); | 402 | bb_error_msg("bind"); |
403 | exit(2); | 403 | exit(2); |
404 | } | 404 | } |
405 | } else if (!dad) { | 405 | } else if (!dad) { |
@@ -415,12 +415,12 @@ int arping_main(int argc, char **argv) | |||
415 | perror("WARNING: setsockopt(SO_DONTROUTE)"); | 415 | perror("WARNING: setsockopt(SO_DONTROUTE)"); |
416 | if (connect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) | 416 | if (connect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr)) |
417 | == -1) { | 417 | == -1) { |
418 | error_msg("connect"); | 418 | bb_error_msg("connect"); |
419 | exit(2); | 419 | exit(2); |
420 | } | 420 | } |
421 | if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == | 421 | if (getsockname(probe_fd, (struct sockaddr *) &saddr, &alen) == |
422 | -1) { | 422 | -1) { |
423 | error_msg("getsockname"); | 423 | bb_error_msg("getsockname"); |
424 | exit(2); | 424 | exit(2); |
425 | } | 425 | } |
426 | src = saddr.sin_addr; | 426 | src = saddr.sin_addr; |
@@ -432,7 +432,7 @@ int arping_main(int argc, char **argv) | |||
432 | me.sll_ifindex = ifindex; | 432 | me.sll_ifindex = ifindex; |
433 | me.sll_protocol = htons(ETH_P_ARP); | 433 | me.sll_protocol = htons(ETH_P_ARP); |
434 | if (bind(s, (struct sockaddr *) &me, sizeof(me)) == -1) { | 434 | if (bind(s, (struct sockaddr *) &me, sizeof(me)) == -1) { |
435 | error_msg("bind"); | 435 | bb_error_msg("bind"); |
436 | exit(2); | 436 | exit(2); |
437 | } | 437 | } |
438 | 438 | ||
@@ -440,12 +440,12 @@ int arping_main(int argc, char **argv) | |||
440 | int alen = sizeof(me); | 440 | int alen = sizeof(me); |
441 | 441 | ||
442 | if (getsockname(s, (struct sockaddr *) &me, &alen) == -1) { | 442 | if (getsockname(s, (struct sockaddr *) &me, &alen) == -1) { |
443 | error_msg("getsockname"); | 443 | bb_error_msg("getsockname"); |
444 | exit(2); | 444 | exit(2); |
445 | } | 445 | } |
446 | } | 446 | } |
447 | if (me.sll_halen == 0) { | 447 | if (me.sll_halen == 0) { |
448 | error_msg("Interface \"%s\" is not ARPable (no ll address)", device); | 448 | bb_error_msg("Interface \"%s\" is not ARPable (no ll address)", device); |
449 | exit(dad ? 0 : 2); | 449 | exit(dad ? 0 : 2); |
450 | } | 450 | } |
451 | he = me; | 451 | he = me; |
@@ -458,7 +458,7 @@ int arping_main(int argc, char **argv) | |||
458 | } | 458 | } |
459 | 459 | ||
460 | if (!src.s_addr && !dad) { | 460 | if (!src.s_addr && !dad) { |
461 | error_msg("no src address in the non-DAD mode"); | 461 | bb_error_msg("no src address in the non-DAD mode"); |
462 | exit(2); | 462 | exit(2); |
463 | } | 463 | } |
464 | 464 | ||