* Obtain stats for interface(s). */
| 516 | * Obtain stats for interface(s). |
| 517 | */ |
| 518 | static void |
| 519 | fill_iftot(struct iftot *st) |
| 520 | { |
| 521 | struct ifaddrs *ifap, *ifa; |
| 522 | bool found = false; |
| 523 | |
| 524 | if (getifaddrs(&ifap) != 0) |
| 525 | xo_err(EX_OSERR, "getifaddrs"); |
| 526 | |
| 527 | bzero(st, sizeof(*st)); |
| 528 | |
| 529 | for (ifa = ifap; ifa; ifa = ifa->ifa_next) { |
| 530 | if (ifa->ifa_addr->sa_family != AF_LINK) |
| 531 | continue; |
| 532 | if (interface) { |
| 533 | if (strcmp(ifa->ifa_name, interface) == 0) |
| 534 | found = true; |
| 535 | else |
| 536 | continue; |
| 537 | } |
| 538 | |
| 539 | st->ift_ip += IFA_STAT(ipackets); |
| 540 | st->ift_ie += IFA_STAT(ierrors); |
| 541 | st->ift_id += IFA_STAT(iqdrops); |
| 542 | st->ift_ib += IFA_STAT(ibytes); |
| 543 | st->ift_op += IFA_STAT(opackets); |
| 544 | st->ift_oe += IFA_STAT(oerrors); |
| 545 | st->ift_od += IFA_STAT(oqdrops); |
| 546 | st->ift_ob += IFA_STAT(obytes); |
| 547 | st->ift_co += IFA_STAT(collisions); |
| 548 | } |
| 549 | |
| 550 | if (interface && found == false) |
| 551 | xo_err(EX_DATAERR, "interface %s not found", interface); |
| 552 | |
| 553 | freeifaddrs(ifap); |
| 554 | } |
| 555 | |
| 556 | /* |
| 557 | * Set a flag to indicate that a signal from the periodic itimer has been |
no test coverage detected