Ok, a slightly modified (hopefully more read-able) example.
I figured out a workaround, but I'm not sure I understand why.
#include <CoreFoundation/CoreFoundation.h>
#include <SystemConfiguration/SCNetworkConfiguration.h>
int main (int argc, const char * argv[]) {
CFArrayRef networkInterfaceArrayRef = NULL;
SCNetworkInterfaceRef networkInterfaceRef = NULL;
CFStringRef bsdInterfaceName = NULL;
const char *intName = NULL;
int interfaceIndex = 0;
int vlanCapableInts = 0;
networkInterfaceArrayRef = SCVLANInterfaceCopyAvailablePhysicalInterfaces();
vlanCapableInts = CFArrayGetCount(networkInterfaceArrayRef);
printf("There are %d physical interfaces capable of supporting VLANs.\n", vlanCapableInts);
for(interfaceIndex = 0; interfaceIndex < vlanCapableInts; interfaceIndex++) {
networkInterfaceRef = CFArrayGetValueAtIndex(networkInterfaceArrayRef, interfaceIndex);
bsdInterfaceName = SCNetworkInterfaceGetBSDName(networkInterfaceRef);
intName = CFStringGetCStringPtr(bsdInterfaceName, kCFStringEncodingUTF8);
printf("%s supports VLANs.\n", intName);
}
CFRelease(networkInterfaceArrayRef);
return 0;
}
I still get the following when running the above code:
There are 2 physical interfaces capable of supporting VLANs.
(null) supports VLANs.
(null) supports VLANs.
If I step through the code, bsdInterfaceName contains "en0" and "en1" respectively, but attempting to call CFStringGetCStringRef on it always returns NULL, but it works fine if I use kCFStringEncodingMacRoman. Why can't I use kCFStringEncodingUTF8 (Or ASCII) in this example?
- Terry
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden