An ugly way to get MAC Address in FreeBSD

char ethaddr[6];    struct ifaddrs *list;    if(getifaddrs(&list) < 0)    {        perror("getifaddrs");    }            struct ifaddrs *cur;            for(cur = list; cur != NULL; cur = cur->ifa_next)    {        if(cur->ifa_addr->sa_family != AF_LINK)            continue;        if(cur->ifa_name!=if_name)            continue;        int i;        for (i=9;i<15;i++)        ethaddr[i-9]=cur->ifa_addr->sa_data[i];    }            freeifaddrs(list); I’ll refer to some books …

Continue reading ‘An ugly way to get MAC Address in FreeBSD’ »