Return manually set gateway when the ipdevice one is NULL
authorSamuel Ortiz <sameo@linux.intel.com>
Mon, 12 Jul 2010 16:56:58 +0000 (18:56 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 12 Jul 2010 18:44:32 +0000 (20:44 +0200)
With N (> 1) online services, only the connected device will have its
gateway set (as the default route). If the remaining ones have manually set
gateways, then let's return that.

src/ipconfig.c

index 2ef600b..c589223 100644 (file)
@@ -746,7 +746,14 @@ const char *__connman_ipconfig_get_gateway(int index)
        if (ipdevice == NULL)
                return NULL;
 
-       return ipdevice->gateway;
+       if (ipdevice->gateway != NULL)
+               return ipdevice->gateway;
+
+       if (ipdevice->config != NULL &&
+                       ipdevice->config->address != NULL)
+               return ipdevice->config->address->gateway;
+
+       return NULL;
 }
 
 void __connman_ipconfig_set_index(struct connman_ipconfig *ipconfig, int index)