Skip to content
Snippets Groups Projects
Commit a8e6a381 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

upnp: add basic network interface discovery for iOS and tvOS

parent 5a7e1f74
No related branches found
No related tags found
No related merge requests found
......@@ -1602,9 +1602,39 @@ inline char *getPreferedAdapter()
}
#else
static char *getPreferedAdapter()
inline bool necessaryFlagsSetOnInterface(struct ifaddrs *anInterface)
{
return NULL;
unsigned int flags = anInterface->ifa_flags;
if( (flags & IFF_UP) && (flags & IFF_RUNNING) && !(flags & IFF_LOOPBACK) && !(flags & IFF_POINTOPOINT) ) {
return true;
}
return false;
}
inline char *getPreferedAdapter()
{
struct ifaddrs *listOfInterfaces;
struct ifaddrs *anInterface;
int ret = getifaddrs(&listOfInterfaces);
char *adapterName = NULL;
if (ret != 0) {
return NULL;
}
anInterface = listOfInterfaces;
while (anInterface != NULL) {
bool ret = necessaryFlagsSetOnInterface(anInterface);
if (ret) {
adapterName = strdup(anInterface->ifa_name);
break;
}
anInterface = anInterface->ifa_next;
}
freeifaddrs(listOfInterfaces);
return adapterName;
}
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment