+struct get_gateway_params {
+ char *vpn_gateway;
+ int vpn_index;
+};
+
+static void get_gateway_cb(const char *gateway, int index, void *user_data)
+{
+ struct gateway_config *config;
+ struct gateway_data *data;
+ struct get_gateway_params *params = user_data;
+ int family;
+
+ if (index < 0)
+ goto out;
+
+ DBG("phy index %d phy gw %s vpn index %d vpn gw %s", index, gateway,
+ params->vpn_index, params->vpn_gateway);
+
+ data = find_vpn_gateway(params->vpn_index, params->vpn_gateway);
+ if (!data) {
+ DBG("Cannot find VPN link route, index %d addr %s",
+ params->vpn_index, params->vpn_gateway);
+ goto out;
+ }
+
+ family = connman_inet_check_ipaddress(params->vpn_gateway);
+
+ if (family == AF_INET)
+ config = data->ipv4_gateway;
+ else if (family == AF_INET6)
+ config = data->ipv6_gateway;
+ else
+ goto out;
+
+ config->vpn_phy_index = index;
+
+ DBG("vpn %s phy index %d", config->vpn_ip, config->vpn_phy_index);
+
+out:
+ g_free(params->vpn_gateway);
+ g_free(params);
+}
+
+static void set_vpn_routes(struct gateway_data *new_gateway,