using arpa/inet.h and sysctl.h to get the ARP routing table.

Hi All,


I am using arpa/inet.h and sysctl.h to get the ARP routing table. I need to fetch MAC addresses of devices connected to wifi.

Can I use the below code in iOS9 or is this not allowed anymore? Please advise.


int mib[] = {CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, RTF_LLINFO};

if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &needed, NULL, 0) < 0)

{

NSLog(@"error in route-sysctl-estimate");

return nil;

}



Thanks for help.

I would strongly recommend that you not go down this path. Honestly, I don’t know if this technique still works but I can say two things:

  • The technique is not supported because the format of the resulting data is not documented (it is document on OS X, but it’s not safe to assume that iOS and OS X are aligned here).

  • iOS is getting increasingly restrictive when it comes to identifiers that can be used to track the user. I would not be surprised if this technique runs into sandbox restrictions in the future (r. 22246722).

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you for your response. We have this requirement to show mac addresses connected so wanted to know if we have any other way of doing this.

Please suggest.

We have this requirement to show mac addresses connected so wanted to know if we have any other way of doing this.

As per the second point in my previous post, the main concern here isn’t a technical one, so alternative technical approaches are unlikely to help.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
using arpa/inet.h and sysctl.h to get the ARP routing table.
 
 
Q