Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting ARP table on iPhone/iPad
    primarykey
    data
    text
    <p>I am trying to get the ARP entries on my iPad like <a href="https://stackoverflow.com/questions/2189200/get-router-mac-without-system-call-for-arp-in-objective-c" title="https://stackoverflow.com/questions/2189200/get-router-mac-without-system-call-for-arp-in-objective-c">here</a>.</p> <p>When compiling the code to run on my iPad (so not the simulator) I am getting missing header error messages. You can resolve them by copying the header files into you project locally as mentioned in this <a href="https://stackoverflow.com/questions/2258172/how-do-i-query-the-arp-table-on-iphone" title="https://stackoverflow.com/questions/2258172/how-do-i-query-the-arp-table-on-iphone">post</a>. </p> <p>The problem lies in the line</p> <blockquote> <p>sdl = (struct sockaddr_dl *)(sin + 1);</p> </blockquote> <p>in this piece of code:</p> <pre><code>-(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>It gives the following error message:</p> <p><strong>Arithmetic on pointer to incomplete type 'struct sockaddr_inarp*'</strong> </p> <p>When you compile the code for the iPad simulator everything runs fine.</p> <p>Does anyone have an idea how to solve this? A similar question (but not solved) is asked <a href="http://www.iphonedevsdk.com/forum/iphone-sdk-development/76712-help-implementing-arp-iphone.html#post428871" rel="nofollow noreferrer" title="http://www.iphonedevsdk.com/forum/iphone-sdk-development/76712-help-implementing-arp-iphone.html#post428871">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

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