mirror of
https://code.videolan.org/videolan/vlc
synced 2024-10-03 01:31:53 +02:00
upnp: implement IPv4 host IP lookup for AppleOS
This adds an additional info line to match the IPv6 implementation.
This commit is contained in:
parent
2c27f5e09e
commit
643fee9b6a
@ -408,12 +408,60 @@ inline char *getPreferedAdapter()
|
||||
#endif
|
||||
#else
|
||||
|
||||
inline char *getIpv4ForMulticast()
|
||||
#ifdef __APPLE__
|
||||
|
||||
inline bool necessaryFlagsSetOnInterface(struct ifaddrs *anInterface)
|
||||
{
|
||||
unsigned int flags = anInterface->ifa_flags;
|
||||
if( (flags & IFF_UP) && (flags & IFF_RUNNING) && !(flags & IFF_LOOPBACK) && !(flags & IFF_POINTOPOINT) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static char *getIpv4ForMulticast()
|
||||
{
|
||||
struct ifaddrs *listOfInterfaces;
|
||||
struct ifaddrs *anInterface;
|
||||
int ret = getifaddrs(&listOfInterfaces);
|
||||
char *bestIP = NULL;
|
||||
|
||||
if (ret != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
anInterface = listOfInterfaces;
|
||||
while (anInterface != NULL) {
|
||||
if (anInterface->ifa_addr->sa_family == AF_INET) {
|
||||
bool ret = necessaryFlagsSetOnInterface(anInterface);
|
||||
if (ret) {
|
||||
/* ignore sockets connecting to the touchbar on MacBooks */
|
||||
if (strncmp(anInterface->ifa_name, "bridge", 6) != 0) {
|
||||
if (bestIP) {
|
||||
FREENULL(bestIP);
|
||||
}
|
||||
bestIP = strdup(inet_ntoa(((struct sockaddr_in *)anInterface->ifa_addr)->sin_addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
anInterface = anInterface->ifa_next;
|
||||
}
|
||||
freeifaddrs(listOfInterfaces);
|
||||
|
||||
return bestIP;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static char *getIpv4ForMulticast()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _WIN32 */
|
||||
#endif /* UPNP_WRAPPER_H */
|
||||
|
Loading…
Reference in New Issue
Block a user