Read ARP table on macOS (Swift)?
I am not aware of an API to do this. One could round up all the addresses within a certain range and send an ICMP packet out to each address looking for a response, but this would be a manual technique rather than an API path forward. For an API to do this it would be an Enhancement Request.Is there a supported way to get the ARP table on macOS 10.15/11? Preferably in Swift.
Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
https ://www.xspdf. com/resolution/54077675.html
I'm not sure it is possible to get this address from IP address (seems not to be possible anymore on iOS).
How to get the MAC address of an iOS/iPhone programmatically?, In iOS versions previous to 7.0 getting the MAC address of device was possible. But with new iOS version it has been disabled for the apps to access MAC address In swift we can use. UIDevice.current.identifierForVendor When you request the Device MAC address in iOS 7 and above you will always get the same response: 02:00:00:00:00:00, this has been made by Apple for privacy concerns. In iOS 7 and later, if you ask for the MAC address of an iOS device, the system returns the value 02:00:00:00:00:00.
Can you elaborate on this requirement?We have software that needs to identify clients even if their LAN IP
address changes.
The reason I ask is that identifying a client by its network addresses (IPv4, IPv6, and MAC) is kinda weird because they can all change. A better approach is to give each client a credential and then identity it that way.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Code Block arp
BSD tool is opensourced by Apple.
I encourage you to push back on your accessory vendor here. Using a MAC address as a client identifier is a bad idea for many reasons, not least of which is that there is no way to implement the technique we’re discussing here on iOS-based platforms.The reason we rely on MAC is because the client hardware is not made
by us and does not provide other identification in many cases.
No. You’ll have to use a bridging header to get to this.Is there a module to import if_ether.h structs in Swift?
Keep in mind that these APIs are very old and crufty and they are tricky to call even from C. Unless you’re extremely proficient in Swift’s pointer APIs, it’d be better to do this work in a C-based language. The best option, IMO, is to create an Objective-C wrapper, using it to interface with the ARP table and then publish the results you need over to Swift.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"