@@ -86,10 +86,13 @@ #endif #ifdef HAVE_IFADDRS_H # include #endif +#ifdef HAVE_NETPACKET_PACKET_H +# include +#endif #if defined(OF_MACOS) || defined(OF_IOS) /* * These have been dropped from newer iOS SDKs, however, their replacements are * not available on iOS < 10. This means it's impossible to search for the @@ -122,10 +125,12 @@ #endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_GETIFADDRS) OFConstantString *const OFNetworkInterfaceAddresses = @"OFNetworkInterfaceAddresses"; +OFConstantString *const OFNetworkInterfaceEthernetAddress = + @"OFNetworkInterfaceEthernetAddress"; #endif static size_t pageSize = 4096; static size_t numberOfCPUs = 1; static OFString *operatingSystemName = nil; @@ -903,10 +908,29 @@ forKey: interfaceName]; } if (iter->ifa_addr == NULL) continue; + +# if defined(HAVE_STRUCT_SOCKADDR_LL) && defined(AF_PACKET) + if (iter->ifa_addr->sa_family == AF_PACKET) { + const OFNetworkInterfaceInfoKey key = + OFNetworkInterfaceEthernetAddress; + struct sockaddr_ll *sll = (struct sockaddr_ll *) + (void *)iter->ifa_addr; + OFData *addr; + + /* ARP hardware address type 1 is Ethernet. */ + if (sll->sll_hatype != 1) + continue; + + addr = [OFData dataWithItems: sll->sll_addr + count: sll->sll_halen]; + [interface setObject: addr forKey: key]; + continue; + } +# endif addresses = [interface objectForKey: OFNetworkInterfaceAddresses]; if (addresses == nil) { addresses = [OFMutableData