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
|