static void if_print(char *ifname) { char buff[1024]; struct interface ife; struct ifconf ifc; struct ifreq *ifr; int i; if (ifname == (char *)NULL) { ifc.ifc_len = sizeof(buff); ifc.ifc_buf = buff; if (ioctl(skfd, SIOCGIFCONF, &ifc) < 0) { fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno)); return; } ifr = ifc.ifc_req; for (i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++) { if (if_fetch(ifr->ifr_name, &ife) < 0) { fprintf(stderr, NLS_CATGETS(catfd, ifconfigSet, ifconfig_unkn, "%s: unknown interface.\n"), ifr->ifr_name); continue; } if (((ife.flags & IFF_UP) == 0) && !opt_a) continue; ife_print(&ife); } } else { if (if_fetch(ifname, &ife) < 0) fprintf(stderr, NLS_CATGETS(catfd, ifconfigSet, ifconfig_unkn, "%s: unknown interface.\n"), ifname); else ife_print(&ife); } }
static int if_print(char *ifname) { int res; if (!ifname) { res = for_all_interfaces(do_if_print, &opt_a); } else { struct interface *ife; ife = lookup_interface(ifname); res = do_if_fetch(ife); if (res >= 0) ife_print(ife); } return res; }
static int if_print(char *ifname) { int res; if (ife_short) printf(_("Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg\n")); if (!ifname) { res = for_all_interfaces(do_if_print, &opt_a); } else { struct interface *ife; ife = lookup_interface(ifname); if (!ife) { return -1; } res = do_if_fetch(ife); if (res >= 0) ife_print(ife); } return res; }