You could check which entries from getifaddrs belong to the AF_PACKET family. On my system that seems to list all interfaces:
struct ifaddrs *addrs,*tmp;
getifaddrs(&addrs);
tmp = addrs;
while (tmp)
{
if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET)
printf("%s
", tmp->ifa_name);
tmp = tmp->ifa_next;
}
freeifaddrs(addrs);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…