MCPcopy Index your code
hub / github.com/F-Stack/f-stack / main

Function main

tools/ifconfig/ifconfig.c:466–782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464}
465
466int
467main(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)

Callers

nothing calls this directly

Calls 15

ff_ipc_initFunction · 0.85
setformatFunction · 0.85
ff_set_proc_idFunction · 0.85
af_getbynameFunction · 0.85
ifmaybeloadFunction · 0.85
if_nametoindexFunction · 0.85
strcmpFunction · 0.85
ifconfigFunction · 0.85
ff_ipc_exitFunction · 0.85
getifflagsFunction · 0.85
getifaddrsFunction · 0.85
calcordersFunction · 0.85

Tested by

no test coverage detected