If I run the following code, it only prints interfaces that are in the RUNNING state. Is there a way to get a list of interfaces that are not RUNNING and could be either UP or DOWN?
int main()
{
struct ifreq *pIfr;
struct ifconf ifc;
char buf[1024];
int s, i, j;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s==-1)
return -1;
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
ioctl(s, SIOCGIFCONF, &ifc);
pIfr = ifc.ifc_req;
for (i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; pIfr++) {
printf("name=%s\n", pIfr->ifr_name);
}
close(s);
return 0;
}
~
Looks like an ioctl loop with SIOCGIFNAME returns all interfaces. The input is an index, and the call returns the interface name.