Overview
Comment: | +[OFSystemInfo networkInterfaces]: Add MAC address |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
76861c3f78602efbdb876502293a200f |
User & Date: | js on 2023-04-22 19:44:36 |
Other Links: | manifest | tags |
Context
2023-04-22
| ||
19:52 | Add OF_SYSTEM_INFO_HAS_NETWORK_INTERFACES define check-in: 74fea18d17 user: js tags: trunk | |
19:44 | +[OFSystemInfo networkInterfaces]: Add MAC address check-in: 76861c3f78 user: js tags: trunk | |
17:47 | Make sure the ABI of OFSocketAddress stays stable check-in: 19ace65ba8 user: js tags: trunk | |
Changes
Modified configure.ac from [9411580ad1] to [4855fb9648].
︙ | ︙ | |||
1419 1420 1421 1422 1423 1424 1425 | ;; esac AC_CHECK_HEADER(sys/socket.h, [ AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1, [Whether we have sys/socket.h]) ]) | | | 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 | ;; esac AC_CHECK_HEADER(sys/socket.h, [ AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1, [Whether we have sys/socket.h]) ]) AC_CHECK_TYPE([struct sockaddr_storage], [ AC_DEFINE(OF_HAVE_SOCKADDR_STORAGE, 1, [Whether we have struct sockaddr_storage]) ], [], [ #ifdef OF_HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef OF_HAVE_SYS_SOCKET_H |
︙ | ︙ | |||
1698 1699 1700 1701 1702 1703 1704 | egrep_cpp_yes #endif ], [ AC_DEFINE(OF_HAVE_APPLETALK, 1, [Whether we have AppleTalk]) AC_SUBST(USE_SRCS_APPLETALK, '${SRCS_APPLETALK}') | | | 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 | egrep_cpp_yes #endif ], [ AC_DEFINE(OF_HAVE_APPLETALK, 1, [Whether we have AppleTalk]) AC_SUBST(USE_SRCS_APPLETALK, '${SRCS_APPLETALK}') AC_CHECK_TYPE([struct ifreq], [ AC_DEFINE(OF_HAVE_APPLETALK_IFCONFIG, 1, m4_normalize([ Whether AppleTalk interfaces can be configured ])) AC_SUBST(OFATALKCFG, ofatalkcfg) ], [], [ |
︙ | ︙ | |||
1759 1760 1761 1762 1763 1764 1765 | [Whether we have select() or similar]) AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M, "OFSelectKernelEventObserver.m") ]) ;; esac | | > > > > > | 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 | [Whether we have select() or similar]) AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M, "OFSelectKernelEventObserver.m") ]) ;; esac AC_CHECK_HEADERS(ifaddrs.h netpacket/packet.h) AC_CHECK_FUNC(getifaddrs, [ AC_DEFINE(OF_HAVE_GETIFADDRS, 1, [Whether we have getifaddrs()]) ]) AC_CHECK_TYPES([struct sockaddr_ll], [], [], [ #ifdef HAVE_NETPACKET_PACKET_H # include <netpacket/packet.h> #endif ]) AC_ARG_WITH(tls, AS_HELP_STRING([--with-tls], [ enable TLS support using the specified library (yes, openssl, gnutls, securetransport or no)])) AS_IF([test x"$with_tls" = x""], [with_tls="yes"]) |
︙ | ︙ |
Modified src/OFSystemInfo.h from [5d11d16867] to [4d9e8807d3].
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /** * @brief A key in the per-interface dictionary returned by * @ref networkInterfaces. * * Possible keys are: * * * @ref OFNetworkInterfaceAddresses */ typedef OFConstantString *OFNetworkInterfaceInfoKey; /** * @brief The addresses of a network interface. * * This maps to an @ref OFData of @ref OFSocketAddress. */ extern OFConstantString *const OFNetworkInterfaceAddresses; #endif /** * @class OFSystemInfo OFSystemInfo.h ObjFW/OFSystemInfo.h * * @brief A class for querying information about the system. */ | > > > > > > > > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | /** * @brief A key in the per-interface dictionary returned by * @ref networkInterfaces. * * Possible keys are: * * * @ref OFNetworkInterfaceAddresses * * @ref OFNetworkInterfaceEthernetAddress */ typedef OFConstantString *OFNetworkInterfaceInfoKey; /** * @brief The addresses of a network interface. * * This maps to an @ref OFData of @ref OFSocketAddress. */ extern OFConstantString *const OFNetworkInterfaceAddresses; /** * @brief The Ethernet address of a network interface. * * This maps to an @ref OFData. */ extern OFConstantString *const OFNetworkInterfaceEthernetAddress; #endif /** * @class OFSystemInfo OFSystemInfo.h ObjFW/OFSystemInfo.h * * @brief A class for querying information about the system. */ |
︙ | ︙ |
Modified src/OFSystemInfo.m from [74da2775f2] to [5cf06ea45f].
︙ | ︙ | |||
84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #if !defined(PATH_MAX) && defined(MAX_PATH) # define PATH_MAX MAX_PATH #endif #ifdef HAVE_IFADDRS_H # include <ifaddrs.h> #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 * paths when using a new SDK while targeting iOS 9 or earlier. To work around * this, we define those manually, only to be used when the replacements are | > > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | #if !defined(PATH_MAX) && defined(MAX_PATH) # define PATH_MAX MAX_PATH #endif #ifdef HAVE_IFADDRS_H # include <ifaddrs.h> #endif #ifdef HAVE_NETPACKET_PACKET_H # include <netpacket/packet.h> #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 * paths when using a new SDK while targeting iOS 9 or earlier. To work around * this, we define those manually, only to be used when the replacements are |
︙ | ︙ | |||
120 121 122 123 124 125 126 127 128 129 130 131 132 133 | uint32_t eax, ebx, ecx, edx; }; #endif #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_GETIFADDRS) OFConstantString *const OFNetworkInterfaceAddresses = @"OFNetworkInterfaceAddresses"; #endif static size_t pageSize = 4096; static size_t numberOfCPUs = 1; static OFString *operatingSystemName = nil; static OFString *operatingSystemVersion = nil; | > > | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | uint32_t eax, ebx, ecx, edx; }; #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; static OFString *operatingSystemVersion = nil; |
︙ | ︙ | |||
901 902 903 904 905 906 907 908 909 910 911 912 913 914 | interface = [OFMutableDictionary dictionary]; [interfaces setObject: interface forKey: interfaceName]; } if (iter->ifa_addr == NULL) continue; addresses = [interface objectForKey: OFNetworkInterfaceAddresses]; if (addresses == nil) { addresses = [OFMutableData dataWithItemSize: sizeof(OFSocketAddress)]; [interface | > > > > > > > > > > > > > > > > > > > | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 | interface = [OFMutableDictionary dictionary]; [interfaces setObject: interface 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 dataWithItemSize: sizeof(OFSocketAddress)]; [interface |
︙ | ︙ |