static BOOL _HasCellularInterface()

in Source/TNLCommunicationAgent.m [1175:1196]


static BOOL _HasCellularInterface()
{
    struct ifaddrs * addrs;
    if (getifaddrs(&addrs) != 0) {
        return NO;
    }

    tnl_defer(^{
        freeifaddrs(addrs);
    });

    for (const struct ifaddrs * cursor = addrs; cursor != NULL; cursor = cursor->ifa_next) {
        NSString *name = @(cursor->ifa_name);
        if ([name isEqualToString:@"pdp_ip0"]) {
            // All cellular interfaces are `pdp_ip`.
            // There can be multiple, but the first one will always be number `0`.
            return YES;
        }
    }

    return NO;
}