I am trying to get a list of active network interfaces with end user understandable names. Like the names listed in System Preferences instead of en0
en5<
This is possible with System Configuration on macOS. In Objective-C like so:
CFArrayRef ref = SCNetworkInterfaceCopyAll();
NSArray* networkInterfaces = (__bridge NSArray *)(ref);
for(int i = 0; i < networkInterfaces.count; i += 1) {
SCNetworkInterfaceRef interface = (__bridge SCNetworkInterfaceRef)(networkInterfaces[i]);
CFStringRef displayName = SCNetworkInterfaceGetLocalizedDisplayName(interface);
CFStringRef bsdName = SCNetworkInterfaceGetBSDName(interface);
NSLog(@"Name:%@ \ninterface: %@\nbsd:%@",displayName, SCNetworkInterfaceGetInterfaceType(interface), bsdName);
}
The localized display name will be something like Display Ethernet
or WiFi
and the BSD name will be something like en5
which will allow matching to the above code.
This approach doesn't work on iOS, but there aren't really any other configurations on iOS anyway.