88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
interface = [OFMutableDictionary dictionary];
[ret setObject: interface forKey: name];
}
index = [OFNumber numberWithUnsignedInt: iter->IfIndex];
[interface setObject: index
forKey: OFNetworkInterfaceIndex];
for (PIP_ADAPTER_UNICAST_ADDRESS_LH addrIter =
iter->FirstUnicastAddress; addrIter != NULL;
addrIter = addrIter->Next) {
OFSocketAddress address;
int length;
OFNetworkInterfaceKey key;
|
>
>
>
>
>
>
>
>
>
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
interface = [OFMutableDictionary dictionary];
[ret setObject: interface forKey: name];
}
index = [OFNumber numberWithUnsignedInt: iter->IfIndex];
[interface setObject: index
forKey: OFNetworkInterfaceIndex];
if (iter->PhysicalAddressLength > 0) {
const OFNetworkInterfaceKey key =
OFNetworkInterfaceHardwareAddress;
OFData *address = [OFData
dataWithItems: iter->PhysicalAddress
count: iter->PhysicalAddressLength];
[interface setObject: address forKey: key];
}
for (PIP_ADAPTER_UNICAST_ADDRESS_LH addrIter =
iter->FirstUnicastAddress; addrIter != NULL;
addrIter = addrIter->Next) {
OFSocketAddress address;
int length;
OFNetworkInterfaceKey key;
|
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
return nil;
for (PIP_ADAPTER_INFO iter = adapterInfo; iter != NULL;
iter = iter->Next) {
OFMutableDictionary *interface;
OFString *name, *IPString;
OFNumber *index;
OFSocketAddress address;
OFData *addresses;
name = [OFString stringWithCString: iter->AdapterName
encoding: encoding];
if ((interface = [ret objectForKey: name]) == nil) {
interface = [OFMutableDictionary dictionary];
[ret setObject: interface forKey: name];
}
index = [OFNumber numberWithUnsignedInt: iter->Index];
[interface setObject: index
forKey: OFNetworkInterfaceIndex];
IPString = [OFString
stringWithCString: iter->IpAddressList.IpAddress
.String
encoding: encoding];
if ([IPString isEqual: @"0.0.0.0"])
continue;
address = OFSocketAddressParseIPv4(IPString, 0);
addresses = [OFData dataWithItems: &address
count: 1
itemSize: sizeof(address)];
[interface setObject: addresses
forKey: OFNetworkInterfaceIPv4Addresses];
}
} @finally {
free(adapterInfo);
}
|
|
>
>
>
>
>
>
>
>
>
|
|
|
|
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
return nil;
for (PIP_ADAPTER_INFO iter = adapterInfo; iter != NULL;
iter = iter->Next) {
OFMutableDictionary *interface;
OFString *name, *IPString;
OFNumber *index;
OFSocketAddress IPv4Address;
OFData *addresses;
name = [OFString stringWithCString: iter->AdapterName
encoding: encoding];
if ((interface = [ret objectForKey: name]) == nil) {
interface = [OFMutableDictionary dictionary];
[ret setObject: interface forKey: name];
}
index = [OFNumber numberWithUnsignedInt: iter->Index];
[interface setObject: index
forKey: OFNetworkInterfaceIndex];
if (iter->AddressLength > 0) {
const OFNetworkInterfaceKey key =
OFNetworkInterfaceHardwareAddress;
OFData *address = [OFData
dataWithItems: iter->Address
count: iter->AddressLength];
[interface setObject: address forKey: key];
}
IPString = [OFString
stringWithCString: iter->IpAddressList.IpAddress
.String
encoding: encoding];
if ([IPString isEqual: @"0.0.0.0"])
continue;
IPv4Address = OFSocketAddressParseIPv4(IPString, 0);
addresses = [OFData dataWithItems: &IPv4Address
count: 1
itemSize: sizeof(IPv4Address)];
[interface setObject: addresses
forKey: OFNetworkInterfaceIPv4Addresses];
}
} @finally {
free(adapterInfo);
}
|