/ Published in: Objective C

Returns an array with the names of the network interfaces (en0, en1, fw0, etc)
Link to the IOKit framework
Link to the IOKit framework
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#import <IOKit/IOKitLib.h> #import <IOKit/network/IONetworkInterface.h> CFMutableDictionaryRef match; io_iterator_t iter; io_registry_entry_t iface; match = IOServiceMatching(kIONetworkInterfaceClass); IOServiceGetMatchingServices(kIOMasterPortDefault, match, &iter); while (iface = IOIteratorNext(iter)) { CFTypeRef ifNamePrefix, ifUnit; ifNamePrefix = IORegistryEntryCreateCFProperty(iface, CFSTR(kIOInterfaceNamePrefix), kCFAllocatorDefault, 0); ifUnit = IORegistryEntryCreateCFProperty(iface, CFSTR(kIOInterfaceUnit), kCFAllocatorDefault, 0); CFRelease(ifNamePrefix); CFRelease(ifUnit); IOObjectRelease(iface); } IOObjectRelease(iter); return arr; }
Comments
