diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-04-12 11:34:39 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-04-12 11:34:39 +0000 |
commit | b290889f0265e1278e8a868aa82a65bcc9099b0f (patch) | |
tree | 2fc8dcc3b7f525f61817417e32c2827b57e17b8a /networking/libiproute/ipaddress.c | |
parent | 51742f4bb0c57a4d5063ece9437a2f34a42e52c8 (diff) | |
download | busybox-w32-b290889f0265e1278e8a868aa82a65bcc9099b0f.tar.gz busybox-w32-b290889f0265e1278e8a868aa82a65bcc9099b0f.tar.bz2 busybox-w32-b290889f0265e1278e8a868aa82a65bcc9099b0f.zip |
- add xsendto and use where appropriate; shrink iplink; sanitize libiproute a bit.
-916 byte
Diffstat (limited to 'networking/libiproute/ipaddress.c')
-rw-r--r-- | networking/libiproute/ipaddress.c | 42 |
1 files changed, 10 insertions, 32 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index ab9706492..4f83924ae 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c | |||
@@ -486,22 +486,13 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush) | |||
486 | argc--; | 486 | argc--; |
487 | } | 487 | } |
488 | 488 | ||
489 | if (rtnl_open(&rth, 0) < 0) | 489 | xrtnl_open(&rth); |
490 | exit(1); | ||
491 | 490 | ||
492 | if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK) < 0) { | 491 | xrtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK); |
493 | bb_perror_msg_and_die("cannot send dump request"); | 492 | xrtnl_dump_filter(&rth, store_nlmsg, &linfo); |
494 | } | ||
495 | |||
496 | if (rtnl_dump_filter(&rth, store_nlmsg, &linfo, NULL, NULL) < 0) { | ||
497 | bb_error_msg_and_die("dump terminated"); | ||
498 | } | ||
499 | 493 | ||
500 | if (filter_dev) { | 494 | if (filter_dev) { |
501 | filter.ifindex = ll_name_to_index(filter_dev); | 495 | filter.ifindex = xll_name_to_index(filter_dev); |
502 | if (filter.ifindex <= 0) { | ||
503 | bb_error_msg_and_die("device \"%s\" does not exist", filter_dev); | ||
504 | } | ||
505 | } | 496 | } |
506 | 497 | ||
507 | if (flush) { | 498 | if (flush) { |
@@ -513,13 +504,9 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush) | |||
513 | filter.rth = &rth; | 504 | filter.rth = &rth; |
514 | 505 | ||
515 | for (;;) { | 506 | for (;;) { |
516 | if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { | 507 | xrtnl_wilddump_request(&rth, filter.family, RTM_GETADDR); |
517 | bb_perror_msg_and_die("cannot send dump request"); | ||
518 | } | ||
519 | filter.flushed = 0; | 508 | filter.flushed = 0; |
520 | if (rtnl_dump_filter(&rth, print_addrinfo, stdout, NULL, NULL) < 0) { | 509 | xrtnl_dump_filter(&rth, print_addrinfo, stdout); |
521 | bb_error_msg_and_die("flush terminated"); | ||
522 | } | ||
523 | if (filter.flushed == 0) { | 510 | if (filter.flushed == 0) { |
524 | return 0; | 511 | return 0; |
525 | } | 512 | } |
@@ -529,13 +516,8 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush) | |||
529 | } | 516 | } |
530 | 517 | ||
531 | if (filter.family != AF_PACKET) { | 518 | if (filter.family != AF_PACKET) { |
532 | if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { | 519 | xrtnl_wilddump_request(&rth, filter.family, RTM_GETADDR); |
533 | bb_perror_msg_and_die("cannot send dump request"); | 520 | xrtnl_dump_filter(&rth, store_nlmsg, &ainfo); |
534 | } | ||
535 | |||
536 | if (rtnl_dump_filter(&rth, store_nlmsg, &ainfo, NULL, NULL) < 0) { | ||
537 | bb_error_msg_and_die("dump terminated"); | ||
538 | } | ||
539 | } | 521 | } |
540 | 522 | ||
541 | 523 | ||
@@ -779,15 +761,11 @@ static int ipaddr_modify(int cmd, int argc, char **argv) | |||
779 | if (!scoped && cmd != RTM_DELADDR) | 761 | if (!scoped && cmd != RTM_DELADDR) |
780 | req.ifa.ifa_scope = default_scope(&lcl); | 762 | req.ifa.ifa_scope = default_scope(&lcl); |
781 | 763 | ||
782 | if (rtnl_open(&rth, 0) < 0) | 764 | xrtnl_open(&rth); |
783 | exit(1); | ||
784 | 765 | ||
785 | ll_init_map(&rth); | 766 | ll_init_map(&rth); |
786 | 767 | ||
787 | req.ifa.ifa_index = ll_name_to_index(d); | 768 | req.ifa.ifa_index = xll_name_to_index(d); |
788 | if (req.ifa.ifa_index == 0) { | ||
789 | bb_error_msg_and_die("cannot find device \"%s\"", d); | ||
790 | } | ||
791 | 769 | ||
792 | if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) | 770 | if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) |
793 | return 2; | 771 | return 2; |