| 464 | } |
| 465 | |
| 466 | int |
| 467 | main(int argc, char *argv[]) |
| 468 | { |
| 469 | int c, all, namesonly, downonly, uponly; |
| 470 | const struct afswtch *afp = NULL; |
| 471 | int ifindex; |
| 472 | struct ifaddrs *ifap, *sifap, *ifa; |
| 473 | struct ifreq paifr; |
| 474 | const struct sockaddr_dl *sdl; |
| 475 | char options[1024], *cp, *envformat, *namecp = NULL; |
| 476 | struct ifa_queue q = TAILQ_HEAD_INITIALIZER(q); |
| 477 | struct ifa_order_elt *cur, *tmp; |
| 478 | const char *ifname, *matchgroup, *nogroup; |
| 479 | struct option *p; |
| 480 | size_t iflen; |
| 481 | int flags; |
| 482 | |
| 483 | #ifdef FSTACK |
| 484 | ff_ipc_init(); |
| 485 | #endif |
| 486 | |
| 487 | all = downonly = uponly = namesonly = noload = verbose = 0; |
| 488 | f_inet = f_inet6 = f_ether = f_addr = NULL; |
| 489 | matchgroup = nogroup = NULL; |
| 490 | |
| 491 | envformat = getenv("IFCONFIG_FORMAT"); |
| 492 | if (envformat != NULL) |
| 493 | setformat(envformat); |
| 494 | |
| 495 | /* |
| 496 | * Ensure we print interface name when expected to, |
| 497 | * even if we terminate early due to error. |
| 498 | */ |
| 499 | atexit(printifnamemaybe); |
| 500 | |
| 501 | /* Parse leading line options */ |
| 502 | #ifndef FSTACK |
| 503 | strlcpy(options, "G:adf:klmnuv", sizeof(options)); |
| 504 | #else |
| 505 | strlcpy(options, "p:G:adf:klmnuv", sizeof(options)); |
| 506 | #endif |
| 507 | for (p = opts; p != NULL; p = p->next) |
| 508 | strlcat(options, p->opt, sizeof(options)); |
| 509 | while ((c = getopt(argc, argv, options)) != -1) { |
| 510 | switch (c) { |
| 511 | #ifdef FSTACK |
| 512 | case 'p': |
| 513 | ff_set_proc_id(atoi(optarg)); |
| 514 | break; |
| 515 | #endif |
| 516 | case 'a': /* scan all interfaces */ |
| 517 | all++; |
| 518 | break; |
| 519 | case 'd': /* restrict scan to "down" interfaces */ |
| 520 | downonly++; |
| 521 | break; |
| 522 | case 'f': |
| 523 | if (optarg == NULL) |
nothing calls this directly
no test coverage detected