c - Linux getting all network interface names -


i need collect interface names, ones aren't @ moment. ifconfig -a.

getifaddrs() iterating through same interface name multiple times. how can collect interface names once using getifaddrs()?

you check entries getifaddrs belong af_packet family. on system seems list interfaces:

struct ifaddrs *addrs,*tmp;  getifaddrs(&addrs); tmp = addrs;  while (tmp) {     if (tmp->ifa_addr && tmp->ifa_addr->sa_family == af_packet)         printf("%s\n", tmp->ifa_name);      tmp = tmp->ifa_next; }  freeifaddrs(addrs); 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -