diff options
author | Kalle Valo <kalle.valo@canonical.com> | 2010-06-15 01:17:36 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-06-16 00:11:07 +0200 |
commit | 11281de04f7707ebcaf4050ae6ad5d48907b956a (patch) | |
tree | e51a31af617de0640059931c85b8602fd939811f /src/connection.c | |
parent | 460513c7edcbd14e830cb9f0dd9da3a7ee79f3db (diff) | |
download | connman-11281de04f7707ebcaf4050ae6ad5d48907b956a.tar.gz connman-11281de04f7707ebcaf4050ae6ad5d48907b956a.tar.bz2 connman-11281de04f7707ebcaf4050ae6ad5d48907b956a.zip |
Support for ppp default route setting
When gateway is NULL, we need to properly set our connection and element
string to 0.0.0.0 so that the interface is the default route.
Diffstat (limited to 'src/connection.c')
-rw-r--r-- | src/connection.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/connection.c b/src/connection.c index 41c9585a..154076b0 100644 --- a/src/connection.c +++ b/src/connection.c @@ -66,18 +66,19 @@ static struct gateway_data *find_gateway(int index, const char *gateway) static int del_routes(struct gateway_data *data) { - const char *address; - if (data->vpn) { if (data->vpn_phy_index >= 0) connman_inet_del_host_route(data->vpn_phy_index, data->gateway); - address = data->vpn_ip; + return connman_inet_clear_gateway_address(data->index, + data->vpn_ip); + } else if (g_strcmp0(data->gateway, "0.0.0.0") == 0) { + return connman_inet_clear_gateway_interface(data->index); } else { connman_inet_del_host_route(data->index, data->gateway); - address = data->gateway; + return connman_inet_clear_gateway_address(data->index, + data->gateway); } - return connman_inet_clear_gateway_address(data->index, address); } static void find_element(struct connman_element *element, gpointer user_data) @@ -140,7 +141,6 @@ static void set_default_gateway(struct gateway_data *data) { struct connman_element *element = data->element; struct connman_service *service = NULL; - short int ifflags; DBG("gateway %s", data->gateway); @@ -151,13 +151,7 @@ static void set_default_gateway(struct gateway_data *data) return; } - ifflags = connman_inet_ifflags(element->index); - if (ifflags < 0) { - connman_error("Fail to get network interface flags"); - return; - } - - if (ifflags & IFF_POINTOPOINT) { + if (g_strcmp0(data->gateway, "0.0.0.0") == 0) { if (connman_inet_set_gateway_interface(element->index) < 0) return; goto done; @@ -240,6 +234,7 @@ static struct gateway_data *find_active_gateway(void) for (list = gateway_list; list; list = list->next) { struct gateway_data *data = list->data; + if (data->active == TRUE) return data; } @@ -272,15 +267,21 @@ static int connection_probe(struct connman_element *element) DBG("gateway %s", gateway); + /* + * If gateway is NULL, it's a point to point link and the default + * gateway is 0.0.0.0, meaning the interface. + */ + if (gateway == NULL) { + gateway = "0.0.0.0"; + element->ipv4.gateway = g_strdup(gateway); + } + service = __connman_element_get_service(element); __connman_service_indicate_state(service, CONNMAN_SERVICE_STATE_READY); connman_element_set_enabled(element, TRUE); - if (gateway == NULL) - return 0; - active_gateway = find_active_gateway(); new_gateway = add_gateway(element->index, gateway); |