#include #include #include #include #include #include #include #include #include #include #include #include int main() { int s, rc, i, count; struct ifconf ifc; char out[100]; s = socket(AF_INET, SOCK_DGRAM, 0); if (s == -1) err(1, "socket"); ifc.ifc_len = 0; ifc.ifc_req = NULL; rc = ioctl(s, SIOCGIFCONF, &ifc); if (rc == -1) err(1, "SIOCGIFCONF"); ifc.ifc_buf = malloc(ifc.ifc_len); if (ifc.ifc_buf == NULL) err(1, "malloc"); rc = ioctl(s, SIOCGIFCONF, &ifc); if (rc == -1) err(1, "SIOCGIFCONF"); count = ifc.ifc_len / sizeof(struct ifreq); for (i=0; i