Hi Mohamed,

On Fri, May 20, 2011 at 01:16:22PM -0700, Mohamed Abbas wrote:
> We have problem having VPN work on a networks dont have gateway
> server like some 3G card. To have VPN work we need to add the VPN
> server ip as a host in the active network.
A few comments here:


> ---
>  src/connection.c |   26 ++++++++++++++++++++------
>  1 files changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/src/connection.c b/src/connection.c
> index 8ca1f7a..509a441 100644
> --- a/src/connection.c
> +++ b/src/connection.c
> @@ -42,6 +42,7 @@ struct gateway_data {
>       gboolean vpn;
>       char *vpn_ip;
>       int vpn_phy_index;
> +     char *vpn_phy_ipv4_gateway;
We're trying to be IP version agnostic, so please rename this one vpn_phy_ip.


>  };
>  
>  static GHashTable *gateway_hash = NULL;
> @@ -110,6 +111,7 @@ static struct gateway_data *add_gateway(struct 
> connman_service *service,
>       data->ipv6_gateway = g_strdup(ipv6_gateway);
>       data->active = FALSE;
>       data->vpn_ip = NULL;
> +     data->vpn_phy_ipv4_gateway = NULL;
>       data->vpn = FALSE;
>       data->vpn_phy_index = -1;
>       data->service = service;
> @@ -141,8 +143,14 @@ static void set_default_gateway(struct gateway_data 
> *data)
>       DBG("gateway %s", data->ipv4_gateway);
>  
>       if (data->vpn == TRUE) {
> +
Unnecessary new line.


>               connman_inet_set_gateway_address(data->index,
>                                                       data->vpn_ip);
> +
> +             connman_inet_add_host_route(data->vpn_phy_index,
> +                                             data->vpn_ip,
> +                                             data->vpn_phy_ipv4_gateway);
> +
>               data->active = TRUE;
>  
>               __connman_service_indicate_default(data->service);
> @@ -204,6 +212,7 @@ static void remove_gateway(gpointer user_data)
>       g_free(data->ipv4_gateway);
>       g_free(data->ipv6_gateway);
>       g_free(data->vpn_ip);
> +     g_free(data->vpn_phy_ipv4_gateway);
>       g_free(data);
>  }
>  
> @@ -316,8 +325,17 @@ int __connman_connection_gateway_add(struct 
> connman_service *service,
>               else
>                       new_gateway->vpn_ip = g_strdup(ipv6_gateway);
>  
> -             if (active_gateway)
> +             if (active_gateway) {
> +                     if (active_gateway->ipv4_gateway != NULL &&
> +                                     g_strcmp0(active_gateway->ipv4_gateway,
> +                                                             "0.0.0.0") != 0)
> +                             new_gateway->vpn_phy_ipv4_gateway = g_strdup(
> +                                             active_gateway->ipv4_gateway);
> +                     else
> +                             new_gateway->vpn_phy_ipv4_gateway = NULL;
so vpn_phy_ip should be a copy of active_gateway->ipv4_gateway if ipv4_gateway
and active_gateway->ipv4_gateway are not NULL. If ipv6_gateway and
active_gateway->ipv6_gateway are not NULL, it should be a copy of
active_gateway->ipv6_gateway.



>                       new_gateway->vpn_phy_index = active_gateway->index;
> +             }
>       } else {
>               new_gateway->vpn = FALSE;
>       }
> @@ -327,13 +345,9 @@ int __connman_connection_gateway_add(struct 
> connman_service *service,
>               return 0;
>       }
>  
> -     if (new_gateway->vpn == TRUE) {
> -             connman_inet_add_host_route(active_gateway->index,
> -                                             new_gateway->ipv4_gateway,
> -                                             active_gateway->ipv4_gateway);
Why are we removing this host route ? It's essentially the same that you're
adding above.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to