SCNetworkInterfaceGetConfiguration always returns NULL.
SCNetworkInterfaceGetConfiguration always returns NULL.
- Subject: SCNetworkInterfaceGetConfiguration always returns NULL.
- From: Adhamh Findlay <email@hidden>
- Date: Sun, 11 Nov 2007 17:36:19 -0600
Hi,
So I'm attempting to use the system configuration framework to
determine if a network interface is active. If there are no active
network interfaces then I want to disable some options...
I'm using MoreSCF as an example, but I get thinks to work properly
because SCNetworkInterfaceGetConfiguration always returns NULL. The
docs state that this means the passed in interface reference isn't
active, but I'm have an active Airport connection when I run these
tests. Other functions like
SCNetworkInterfaceGetHardwareAddressString and
SCNetworkInterfaceGetBSDName work fine...
Here's the code I'm using. Any thoughts? I'm a total CF noob, so be
easy on me if I haven't done anything correctly. :-)
extern Boolean ActiveNetworkConnection()
{
Boolean isNetworkActive = false;
CFArrayRef interfaces;
CFIndex interfaceCount;
CFIndex interfaceIndex;
CFMutableArrayRef result;
CFArrayRef *portArray;
portArray = NULL;
result = NULL;
interfaces = NULL;
if (SCNetworkInterfaceCopyAll != NULL) {
interfaces = SCNetworkInterfaceCopyAll();
}
interfaceCount = CFArrayGetCount(interfaces);
for (interfaceIndex = 0; interfaceIndex < interfaceCount;
interfaceIndex++) {
Boolean skipIt;
SCNetworkInterfaceRef thisInterface;
CFDictionaryRef interfaceConfig;
skipIt = false;
thisInterface = CFArrayGetValueAtIndex(interfaces, interfaceIndex);
assert(thisInterface != NULL);
interfaceConfig = SCNetworkInterfaceGetConfiguration(thisInterface);
if (interfaceConfig != NULL) {
isNetworkActive = true;
} else {
skipIt = true;
}
}
return isNetworkActive;
}
So I'm attempting to use the system configuration framework to
determine if a network interface is active. If there are no active
network interfaces then I want to disable some options...
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden