Overview
Comment: | +[OFSystemInfo networkInterfaces]: MAC on Linux |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ccf154b51a0e97d1418a70392aa0ee60 |
User & Date: | js on 2023-06-11 19:58:25 |
Other Links: | manifest | tags |
Context
2023-06-17
| ||
21:55 | OFSPX*SocketTests: Connect to specific net + node check-in: 652dc3c52b user: js tags: trunk | |
2023-06-11
| ||
19:58 | +[OFSystemInfo networkInterfaces]: MAC on Linux check-in: ccf154b51a user: js tags: trunk | |
16:45 | Add support for IPv4s embedded into IPv6s check-in: af9084b456 user: js tags: trunk | |
Changes
Modified configure.ac from [04b3936c93] to [f817109140].
︙ | ︙ | |||
1765 1766 1767 1768 1769 1770 1771 | [Whether we have select() or similar]) AC_SUBST(OF_SELECT_KERNEL_EVENT_OBSERVER_M, "OFSelectKernelEventObserver.m") ]) ;; esac | | < < < < < < < < < < < < < < | 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(net/if.h) AC_CHECK_FUNCS(if_nameindex) 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"]) tls_support="no" |
︙ | ︙ |
Modified src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m from [d0edd5bf34] to [1453e7f2e0].
︙ | ︙ | |||
20 21 22 23 24 25 26 | #endif #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif #ifdef HAVE_NET_IF_H # include <net/if.h> #endif | < < < < < < < < < | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #endif #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif #ifdef HAVE_NET_IF_H # include <net/if.h> #endif #import "OFSystemInfo.h" #import "OFSystemInfo+NetworkInterfaces.h" #import "OFArray.h" #import "OFData.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES |
︙ | ︙ | |||
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | OFSocketAddressFamilyAppleTalk, AF_APPLETALK, sizeof(struct sockaddr_at)); # else return false; # endif } #endif + (OFDictionary OF_GENERIC(OFString *, OFNetworkInterface) *)networkInterfaces { void *pool = objc_autoreleasePoolPush(); OFMutableDictionary *ret = [OFMutableDictionary dictionary]; bool success = false; OFEnumerator *enumerator; OFMutableDictionary *interface; success |= queryNetworkInterfaceIndices(ret); success |= queryNetworkInterfaceIPv4Addresses(ret); #ifdef OF_HAVE_IPV6 success |= queryNetworkInterfaceIPv6Addresses(ret); #endif #ifdef OF_HAVE_IPX success |= queryNetworkInterfaceIPXAddresses(ret); #endif #ifdef OF_HAVE_APPLETALK success |= queryNetworkInterfaceAppleTalkAddresses(ret); #endif if (!success) { objc_autoreleasePoolPop(pool); return nil; } enumerator = [ret objectEnumerator]; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | OFSocketAddressFamilyAppleTalk, AF_APPLETALK, sizeof(struct sockaddr_at)); # 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]; bool success = false; OFEnumerator *enumerator; OFMutableDictionary *interface; success |= queryNetworkInterfaceIndices(ret); success |= queryNetworkInterfaceIPv4Addresses(ret); #ifdef OF_HAVE_IPV6 success |= queryNetworkInterfaceIPv6Addresses(ret); #endif #ifdef OF_HAVE_IPX success |= queryNetworkInterfaceIPXAddresses(ret); #endif #ifdef OF_HAVE_APPLETALK success |= queryNetworkInterfaceAppleTalkAddresses(ret); #endif success |= queryNetworkInterfaceHardwareAddress(ret); if (!success) { objc_autoreleasePoolPop(pool); return nil; } enumerator = [ret objectEnumerator]; |
︙ | ︙ |
Modified src/platform/Windows/OFSystemInfo+NetworkInterfaces.m from [3ab22d3ec6] to [0c6d28d689].
︙ | ︙ | |||
181 182 183 184 185 186 187 | return nil; adapterInfo = newAdapterInfo; error = GetAdaptersInfo(adapterInfo, &adapterInfoSize); } if (error != ERROR_SUCCESS) | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | return nil; adapterInfo = newAdapterInfo; error = GetAdaptersInfo(adapterInfo, &adapterInfoSize); } if (error != ERROR_SUCCESS) return nil; for (PIP_ADAPTER_INFO iter = adapterInfo; iter != NULL; iter = iter->Next) { OFMutableDictionary *interface; OFString *name, *IPString; OFNumber *index; OFSocketAddress IPv4Address; |
︙ | ︙ |