int connman_rtnl_register(struct connman_rtnl *rtnl);
void connman_rtnl_unregister(struct connman_rtnl *rtnl);
-int connman_rtnl_send_getroute(void);
-
#ifdef __cplusplus
}
#endif
if (connman_rtnl_register(&connection_rtnl) < 0)
connman_error("Failed to setup RTNL gateway driver");
- connman_rtnl_send_getroute();
-
return connman_driver_register(&connection_driver);
}
int __connman_ipconfig_get_index(struct connman_ipconfig *ipconfig);
unsigned short __connman_ipconfig_get_type(struct connman_ipconfig *ipconfig);
unsigned int __connman_ipconfig_get_flags(struct connman_ipconfig *ipconfig);
+const char *__connman_ipconfig_get_gateway(struct connman_ipconfig *ipconfig);
void __connman_ipconfig_update_link(struct connman_ipconfig *ipconfig,
unsigned flags, unsigned change);
unsigned int flags;
enum connman_ipconfig_method method;
GSList *address_list;
+ char *gateway;
};
static void free_address_list(struct connman_ipconfig *ipconfig)
g_free(ipaddress->address);
g_free(ipaddress);
-
list->data = NULL;
}
connman_info("%s {remove} index %d", ipconfig->interface,
ipconfig->index);
+ g_free(ipconfig->gateway);
+
free_address_list(ipconfig);
g_free(ipconfig->interface);
return ipconfig->flags;
}
+const char *__connman_ipconfig_get_gateway(struct connman_ipconfig *ipconfig)
+{
+ return ipconfig->gateway;
+}
+
void __connman_ipconfig_update_link(struct connman_ipconfig *ipconfig,
unsigned flags, unsigned change)
{
unsigned char scope, const char *destination,
const char *gateway)
{
+ if (scope == 0 && g_strcmp0(destination, "0.0.0.0") == 0) {
+ g_free(ipconfig->gateway);
+ ipconfig->gateway = g_strdup(gateway);
+ }
+
connman_info("%s {add} route %s gw %s scope %u <%s>",
ipconfig->interface, destination,
gateway, scope, scope2str(scope));
unsigned char scope, const char *destination,
const char *gateway)
{
+ if (scope == 0 && g_strcmp0(destination, "0.0.0.0") == 0) {
+ g_free(ipconfig->gateway);
+ ipconfig->gateway = NULL;
+ }
+
connman_info("%s {del} route %s gw %s scope %u <%s>",
ipconfig->interface, destination,
gateway, scope, scope2str(scope));
}
}
-static void trigger_newlink(gpointer key, gpointer value, gpointer user_data)
+static void trigger_rtnl(gpointer key, gpointer value, gpointer user_data)
{
struct connman_rtnl *rtnl = user_data;
struct connman_ipconfig *ipconfig = value;
rtnl->newlink(type, index, flags, 0);
}
+
+ if (rtnl->newgateway) {
+ const char *gateway = __connman_ipconfig_get_gateway(ipconfig);
+
+ if (gateway != NULL)
+ rtnl->newgateway(index, gateway);
+ }
}
static GSList *rtnl_list = NULL;
rtnl_list = g_slist_insert_sorted(rtnl_list, rtnl,
compare_priority);
- g_hash_table_foreach(ipconfig_hash, trigger_newlink, rtnl);
+ g_hash_table_foreach(ipconfig_hash, trigger_rtnl, rtnl);
return 0;
}
return queue_request(req);
}
-int connman_rtnl_send_getroute(void)
+static int send_getroute(void)
{
struct rtnl_request *req;
send_getlink();
send_getaddr();
- connman_rtnl_send_getroute();
+ send_getroute();
}
void __connman_rtnl_cleanup(void)