मैं कोड निम्न का उपयोग कर सभी इंटरफेस मुद्रित करने के लिए और यह मैक पतेआईओएस नेटवर्किंग इंटरफेस नाम का क्या अर्थ है? पीडीपी_आईपी क्या है? क्या चल रहा है?
- (void)interfaceInfo{
int mib[6];
size_t len;
char *buf;
unsigned char *ptr;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
char name[128];
memset(name, 0, sizeof(name));
for (int i=1; i<20; i ++) {
if (if_indextoname(i, name)) {
printf("%s ",name);
}else{
continue;
}
if ((mib[5] = if_nametoindex(name)) == 0) {
printf("Error: if_nametoindex error\n");
return NULL;
}
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
printf("Error: sysctl, take 1\n");
return NULL;
}
if ((buf = malloc(len)) == NULL) {
printf("Could not allocate memory. error!\n");
return NULL;
}
if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
printf("Error: sysctl, take 2");
free(buf);
return NULL;
}
ifm = (struct if_msghdr *)buf;
sdl = (struct sockaddr_dl *)(ifm + 1);
ptr = (unsigned char *)LLADDR(sdl);
NSString *macString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
*ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5)];
printf(" %s\n",[macString cStringUsingEncoding:NSUTF8StringEncoding]);
free(buf);
}
return nil;
}
है मैं iPhone 5 पर कोड चलाने के लिए और उत्पादन
lo0 00:00:00:00:00:00
pdp_ip0 00:00:00:00:00:00
pdp_ip1 00:00:00:00:00:00
pdp_ip2 00:00:00:00:00:00
pdp_ip3 00:00:00:00:00:00
ap1 EA:8D:28:44:32:2F
en0 E8:8D:28:44:32:2F
en1 EA:8D:28:44:32:31
awdl0 4A:79:85:44:5B:4D
//I faked parts data
मैं जानता हूँ कि pdp_ip क्या करना चाहते है? और एपी 1, एन 1 क्या है?
मुझे पता en0 है वाईफ़ाई हार्डवेयर मैक पते
AP1 और en1 आभासी इंटरफेस है?
धन्यवाद!
एन ईथरनेट के लिए खड़ा है, एपी क्या है? और मैं अपने मैक पर ifconfig कोशिश करता हूं, कोई एपी इंटरफ़ेस नाम नहीं है। इतने सारे पीडीपी परिवार क्यों इंटरफेस करते हैं? इसका मतलब है कि एक से अधिक सेलुलर डेटा हार्डवेयर हैं, है ना? धन्यवाद ! – Aladdin