मैं अपने आईपैड पर here जैसे एआरपी प्रविष्टियां प्राप्त करने की कोशिश कर रहा हूं।आईफोन/आईपैड पर एआरपी टेबल प्राप्त करना
मेरे आईपैड पर चलाने के लिए कोड को संकलित करते समय (इसलिए सिम्युलेटर नहीं) मुझे अनुपलब्ध हेडर त्रुटि संदेश मिल रहा है। आप इस post में वर्णित अनुसार स्थानीय रूप से प्रोजेक्ट में हेडर फ़ाइलों की प्रतिलिपि बनाकर उन्हें हल कर सकते हैं।
समस्या लाइन में निहित है
कोड के इस टुकड़े मेंएसडीएल = (struct sockaddr_dl *) (पाप +1);
:
अंकगणित अधूरा प्रकार के 'struct sockaddr_inarp *'
जब आप संकलन सूचक पर:
-(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, &needed, NULL, 0) < 0)
err(1, "route-sysctl-estimate");
if ((buf = malloc(needed)) == NULL)
err(1, "malloc");
if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
err(1, "actual retrieval of routing table");
lim = buf + needed;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
sin = (struct sockaddr_inarp *)(rtm + 1);
sdl = (struct sockaddr_dl *)(sin + 1);
if (addr) {
if (addr != sin->sin_addr.s_addr)
continue;
found_entry = 1;
}
if (nflag == 0)
hp = gethostbyaddr((caddr_t)&(sin->sin_addr),
sizeof sin->sin_addr, AF_INET);
else
hp = 0;
if (hp)
host = hp->h_name;
else {
host = "?";
if (h_errno == TRY_AGAIN)
nflag = 1;
}
if (sdl->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;
}
}
यह निम्न त्रुटि संदेश देता है आईपैड सिम्युलेटर के लिए कोड सब कुछ ठीक चलाता है।
क्या किसी को यह पता है कि इसे कैसे हल किया जाए? एक समान प्रश्न (लेकिन हल नहीं किया गया) here से पूछा जाता है।
हाय @ रिचर्ड: - Iam को अव्यवस्थित पहचानकर्ता के रूप में nflag मिल रहा है, मुझे – Bonnie
@ रिचर्ड के लिए किस फ़ाइल को शामिल/आयात करने की आवश्यकता है: मैं 'उद्देश्य-सी' के लिए नया हूं, मैं चाहता हूं क्लाइंट का 'आईपी पता' जो 'हॉटस्पॉट' से जुड़ा हुआ है। और मुझे 'ARP.c' और' ARP.h' मिला। लेकिन 'एआरपी तालिका' में 'आईपी पता' प्राप्त करने के लिए इसका उपयोग कैसे करें? – Martin
क्षमा करें, आप कोड को .m फ़ाइल में डालते हैं और सीधे संकलित करते हैं? – Wun