FreeBSD中读取Ethernet Address的一种可行方法
#include <net/if.h>#include <ifaddrs.h>#include <net/if_dl.h>#include <net/ethernet.h> int main(){ struct ifaddrs *list; if(getifaddrs(&list) < 0) { perror("getifaddrs"); return; } struct ifaddrs *cur; for(cur = list; cur != NULL; cur = cur->ifa_next) { if(cur->ifa_addr->sa_family != AF_LINK) continue; char *name = cur->ifa_name; printf(name);printf("\n"); char *addr; struct sockaddr_dl *sdl; …