Commit f3bdd42e authored by Felix Paul Kühne's avatar Felix Paul Kühne

WiFi Sharing / Remote Playback: automatically select a good interface to listen on

parent e2255cb5
...@@ -79,12 +79,6 @@ ...@@ -79,12 +79,6 @@
#define kVLCDarwinNotificationNowPlayingInfoUpdate @"org.videolan.ios-app.nowPlayingInfoUpdate" #define kVLCDarwinNotificationNowPlayingInfoUpdate @"org.videolan.ios-app.nowPlayingInfoUpdate"
#if TARGET_IPHONE_SIMULATOR
#define WifiInterfaceName @"en1"
#else
#define WifiInterfaceName @"en0"
#endif
#define kVLCMigratedToUbiquitousStoredServerList @"kVLCMigratedToUbiquitousStoredServerList" #define kVLCMigratedToUbiquitousStoredServerList @"kVLCMigratedToUbiquitousStoredServerList"
#define kVLCStoredServerList @"kVLCStoredServerList" #define kVLCStoredServerList @"kVLCStoredServerList"
#define kVLCStoreDropboxCredentials @"kVLCStoreDropboxCredentials" #define kVLCStoreDropboxCredentials @"kVLCStoreDropboxCredentials"
......
...@@ -138,7 +138,45 @@ ...@@ -138,7 +138,45 @@
// Initialize our http server // Initialize our http server
_httpServer = [[HTTPServer alloc] init]; _httpServer = [[HTTPServer alloc] init];
[_httpServer setInterface:WifiInterfaceName];
// find an interface to listen on
struct ifaddrs *listOfInterfaces = NULL;
struct ifaddrs *anInterface = NULL;
NSString *interfaceToUse = nil;
int ret = getifaddrs(&listOfInterfaces);
if (ret == 0) {
anInterface = listOfInterfaces;
while (anInterface != NULL) {
if (anInterface->ifa_addr->sa_family == AF_INET) {
APLog(@"Found interface %s", anInterface->ifa_name);
/* check for primary interface first */
if (strncmp (anInterface->ifa_name,"en0",strlen("en0")) == 0) {
unsigned int flags = anInterface->ifa_flags;
if( (flags & 0x1) && (flags & 0x40) && !(flags & 0x8) ) {
interfaceToUse = [NSString stringWithUTF8String:anInterface->ifa_name];
break;
}
}
/* oh well, let's move on to the secondary interface */
if (strncmp (anInterface->ifa_name,"en1",strlen("en1")) == 0) {
unsigned int flags = anInterface->ifa_flags;
if( (flags & 0x1) && (flags & 0x40) && !(flags & 0x8) ) {
interfaceToUse = [NSString stringWithUTF8String:anInterface->ifa_name];
break;
}
}
}
anInterface = anInterface->ifa_next;
}
freeifaddrs(listOfInterfaces);
}
if (interfaceToUse == nil)
return false;
[_httpServer setInterface:interfaceToUse];
[_httpServer setIPv4Enabled:YES]; [_httpServer setIPv4Enabled:YES];
[_httpServer setIPv6Enabled:[[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingWiFiSharingIPv6] boolValue]]; [_httpServer setIPv6Enabled:[[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingWiFiSharingIPv6] boolValue]];
......
...@@ -62,10 +62,4 @@ ...@@ -62,10 +62,4 @@
#define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6"
#define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) #define kVLCSettingWiFiSharingIPv6DefaultValue @(NO)
#if TARGET_IPHONE_SIMULATOR
#define WifiInterfaceName @"en1"
#else
#define WifiInterfaceName @"en1"
#endif
#define kVLCfortvOSMovieDBKey @"" #define kVLCfortvOSMovieDBKey @""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment