From 645ff10be169a02870c8a0a2615c6a48b2d031d3 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 12 Jul 2010 18:56:58 +0200 Subject: [PATCH] Return manually set gateway when the ipdevice one is NULL 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ipconfig.c b/src/ipconfig.c index 2ef600b..c589223 100644 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -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) -- 2.7.4