Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -1767,26 +1767,12 @@ "OFSelectKernelEventObserver.m") ]) ;; esac - AC_CHECK_HEADERS(net/if.h net/if_types.h net/if_dl.h) - AC_CHECK_HEADERS(netpacket/packet.h) + AC_CHECK_HEADERS(net/if.h) AC_CHECK_FUNCS(if_nameindex) - AC_CHECK_TYPES([struct sockaddr_dl], [], [], [ - #ifdef HAVE_SYS_TYPES_H - # include - #endif - #ifdef HAVE_NET_IF_DL_H - # include - #endif - ]) - AC_CHECK_TYPES([struct sockaddr_ll], [], [], [ - #ifdef HAVE_NETPACKET_PACKET_H - # include - #endif - ]) AC_ARG_WITH(tls, AS_HELP_STRING([--with-tls], [ enable TLS support using the specified library (yes, openssl, gnutls, securetransport or no)])) Index: src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m ================================================================== --- src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m +++ src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m @@ -22,19 +22,10 @@ # include #endif #ifdef HAVE_NET_IF_H # include #endif -#ifdef HAVE_NET_IF_TYPES_H -# include -#endif -#ifdef HAVE_NET_IF_DL_H -# include -#endif -#ifdef HAVE_NETPACKET_PACKET_H -# include -#endif #import "OFSystemInfo.h" #import "OFSystemInfo+NetworkInterfaces.h" #import "OFArray.h" #import "OFData.h" @@ -299,10 +290,51 @@ # else return false; # endif } #endif + +static bool +queryNetworkInterfaceHardwareAddress(OFMutableDictionary *ret) +{ +#if defined(HAVE_IOCTL) && defined(HAVE_NET_IF_H) && defined(SIOCGIFHWADDR) + OFStringEncoding encoding = [OFLocale encoding]; + int sock = socket(AF_INET, SOCK_DGRAM, 0); + + if (sock < 0) + return false; + + for (OFString *name in ret) { + size_t nameLength = [name cStringLengthWithEncoding: encoding]; + struct ifreq ifr; + OFData *hardwareAddress; + + if (nameLength > IFNAMSIZ) + continue; + + memset(&ifr, 0, sizeof(ifr)); + memcpy(&ifr.ifr_name, [name cStringWithEncoding: encoding], + nameLength); + + if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) + continue; + + if (ifr.ifr_hwaddr.sa_family != 1) + continue; + + hardwareAddress = [OFData dataWithItems: ifr.ifr_hwaddr.sa_data + count: 6]; + [[ret objectForKey: name] + setObject: hardwareAddress + forKey: OFNetworkInterfaceHardwareAddress]; + } + + return true; +#else + return false; +#endif +} + (OFDictionary OF_GENERIC(OFString *, OFNetworkInterface) *)networkInterfaces { void *pool = objc_autoreleasePoolPush(); OFMutableDictionary *ret = [OFMutableDictionary dictionary]; @@ -319,10 +351,11 @@ success |= queryNetworkInterfaceIPXAddresses(ret); #endif #ifdef OF_HAVE_APPLETALK success |= queryNetworkInterfaceAppleTalkAddresses(ret); #endif + success |= queryNetworkInterfaceHardwareAddress(ret); if (!success) { objc_autoreleasePoolPop(pool); return nil; } Index: src/platform/Windows/OFSystemInfo+NetworkInterfaces.m ================================================================== --- src/platform/Windows/OFSystemInfo+NetworkInterfaces.m +++ src/platform/Windows/OFSystemInfo+NetworkInterfaces.m @@ -183,11 +183,11 @@ adapterInfo = newAdapterInfo; error = GetAdaptersInfo(adapterInfo, &adapterInfoSize); } if (error != ERROR_SUCCESS) - return nil; + return nil; for (PIP_ADAPTER_INFO iter = adapterInfo; iter != NULL; iter = iter->Next) { OFMutableDictionary *interface; OFString *name, *IPString;