The current JUCE code only finds the active network interface MAC address.
The following code finds every network interface and gives its MAC:
#include <stdio.h> //printf #include <string.h> //strncpy #include <sys/socket.h> #include <sys/ioctl.h> #include <net/if.h> //ifreq #include <ifaddrs.h> //ifreq #include <unistd.h> //close void findAllAddresses (Array<MACAddress>& result) { struct ifreq ifr; struct ifaddrs * addrs = 0; if (getifaddrs(&addrs) == -1) return; const int s = socket (AF_INET, SOCK_DGRAM, 0); if (s == -1) { freeifaddrs(addrs); return; } struct ifaddrs * thisaddr = addrs; while (thisaddr) { ifr.ifr_addr.sa_family = AF_INET; strcpy(ifr.ifr_name, thisaddr->ifa_name); if (0 == ioctl(s, SIOCGIFHWADDR, &ifr)) { MACAddress ma ((const uint8*) ifr.ifr_hwaddr.sa_data); if (! ma.isNull()) result.addIfNotAlreadyThere (ma); } thisaddr = thisaddr->ifa_next; } freeifaddrs(addrs); close(s); }