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
Post a Comment