Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Since nobody has answered my question... here is the answer ;)</p> <pre><code>#include &lt;sys/param.h&gt; #include &lt;sys/file.h&gt; #include &lt;sys/socket.h&gt; #include &lt;sys/sysctl.h&gt; #include &lt;net/if.h&gt; #include &lt;net/if_dl.h&gt; #include "if_types.h" #include "route.h" #include "if_ether.h" #include &lt;netinet/in.h&gt; #include &lt;arpa/inet.h&gt; #include &lt;err.h&gt; #include &lt;errno.h&gt; #include &lt;netdb.h&gt; #include &lt;paths.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;unistd.h&gt; -(NSString*) ip2mac: (char*) ip { int expire_time, flags, export_only, doing_proxy, found_entry; NSString *mAddr = nil; u_long addr = inet_addr(ip); int mib[6]; size_t needed; char *host, *lim, *buf, *next; struct rt_msghdr *rtm; struct sockaddr_inarp *sin; struct sockaddr_dl *sdl; extern int h_errno; struct hostent *hp; mib[0] = CTL_NET; mib[1] = PF_ROUTE; mib[2] = 0; mib[3] = AF_INET; mib[4] = NET_RT_FLAGS; mib[5] = RTF_LLINFO; if (sysctl(mib, 6, NULL, &amp;needed, NULL, 0) &lt; 0) err(1, "route-sysctl-estimate"); if ((buf = malloc(needed)) == NULL) err(1, "malloc"); if (sysctl(mib, 6, buf, &amp;needed, NULL, 0) &lt; 0) err(1, "actual retrieval of routing table"); lim = buf + needed; for (next = buf; next &lt; lim; next += rtm-&gt;rtm_msglen) { rtm = (struct rt_msghdr *)next; sin = (struct sockaddr_inarp *)(rtm + 1); sdl = (struct sockaddr_dl *)(sin + 1); if (addr) { if (addr != sin-&gt;sin_addr.s_addr) continue; found_entry = 1; } if (nflag == 0) hp = gethostbyaddr((caddr_t)&amp;(sin-&gt;sin_addr), sizeof sin-&gt;sin_addr, AF_INET); else hp = 0; if (hp) host = hp-&gt;h_name; else { host = "?"; if (h_errno == TRY_AGAIN) nflag = 1; } if (sdl-&gt;sdl_alen) { u_char *cp = LLADDR(sdl); mAddr = [NSString stringWithFormat:@"%x:%x:%x:%x:%x:%x", cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]]; // ether_print((u_char *)LLADDR(sdl)); } else mAddr = nil; } if (found_entry == 0) { return nil; } else { return mAddr; } } </code></pre> <p>from apples arp.c working on iphone</p> <p>Copy the following:</p> <pre><code>- "if_types.h" - "route.h" - "if_ether.h" </code></pre> <p>headers from mac includes into your project folder and add to classes</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload