What exactly means iOS networking interface name? what's pdp_ip ? what's ap?
Asked Answered
F

4

13

I use following code to print all interface and it's mac address

- ( 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;
}

I run the code on iPhone 5 and the output is

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

I wanna know what's the pdp_ip? and what's the ap1,en1?

I find out en0 is wifi hardware mac address

Does ap1 and en1 is virtual interface?

Thank you!

Fictional answered 15/1, 2013 at 8:53 Comment(0)
A
12

ap1, en0, en1 are names of the interfaces on iOS as well as on Mac. If you type in Terminal on Mac ifconfig you would get the same, en0, en1, etc.

pdp_ip interfaces are those that are used for 3G and cellular data, while ap1 is used to represent currently active data connection, Wi-Fi, cellular data or bluetooth.

Alguire answered 17/1, 2013 at 12:42 Comment(1)
en stands for ethernet, what's ap stands for? And I try ifconfig on my mac, there is no ap interface name. Why so many pdp family interfaces? It does means there are more than one cellular data hardware,doesn't it? Thank you !Fictional
B
10

lo = localhost
en = ethernet
ap = Probably for access point (if you are acting as a wifi host)

pdp_ip = maybe PDS data packet? PDS is the Phone Data Service, the data portion of GSM. Since there are four, I might postulate that PDS has the capability to offer four discrete channels.

Belgrade answered 22/5, 2013 at 12:33 Comment(0)
O
2

From my research it appears (i.e. I haven't found any confirming documentation) that if the code above returns more than one "awdl0" entry then Wi-Fi is enabled. Similarly, more than one "pdp_ip0" entry indicates that cellular data is enabled. Other libraries (most notably Reachability) can then be used to indicate that a data connection has been made using either of the above.

Oulman answered 22/4, 2015 at 6:28 Comment(0)
N
0

So the reason for showing 00:00:00:00:00 is because applications cannot see the actual MAC Address of the PDP_ (Cellular Interface) this was introduced as a security measure back in a previous version of iOS.

Negrillo answered 18/11, 2023 at 19:58 Comment(1)
The question was asked nearly 11 years ago (iOS 6 was current). Didn't Apple began hiding the MAC address with iOS 7?Nervous

© 2022 - 2024 — McMap. All rights reserved.