Thank you for your reply. I tried blow method to get interface type.
extern uint32_t functionalTypeForInterfaceNamed(const char * name) {
int fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) { return IFRTYPE_FUNCTIONAL_UNKNOWN; }
struct ifreq ifr = {};
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
bool success = ioctl(fd, SIOCGIFFUNCTIONALTYPE, &ifr) >= 0;
int junk = close(fd);
assert(junk == 0);
if (!success) {
return IFRTYPE_FUNCTIONAL_UNKNOWN;
}
return ifr.ifr_ifru.ifru_functional_type;
}
There are three default enX interfaces, the en0 is IFRTYPE_FUNCTIONAL_WIFI_INFRA, the en1,en2 are IFRTYPE_FUNCTIONAL_WIRED, but I haven't inserted any ethernet adapter on my iPad yet. When I insert an ethernet adapter, an additional network interface which is also IFRTYPE_FUNCTIONAL_WIRED appear. It definitely affect my judgement. How to distinguish between those default enX which are IFRTYPE_FUNCTIONAL_WIRED type and the real ethernet adapter which insert on my iPad?
Topic:
App & System Services
SubTopic:
Networking