Re: [PATCH 1/1] fix a crash when using vpn.

2010-10-19 Thread Samuel Ortiz
Hi Mohamed,

On Fri, Oct 15, 2010 at 04:11:20AM -0700, Mohamed Abbas wrote:
> VPN services dont have network, so we need to make sure not
> to use service->network while in vpn services.
The fix makes sense, but could you instead improve
__connman_service_get_index() to handle the VPN case, and then call this
routine from the below functions ?

Cheers,
Samuel.


> ---
>  src/service.c |   16 +---
>  1 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/src/service.c b/src/service.c
> index 1cb292f..4ad46ec 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -407,7 +407,10 @@ void __connman_service_nameserver_add_routes(struct 
> connman_service *service,
>   if (service == NULL)
>   return;
>  
> - index = connman_network_get_index(service->network);
> + if (service->type == CONNMAN_SERVICE_TYPE_VPN)
> + index = connman_ipconfig_get_index(service->ipconfig);
> + else
> + index = connman_network_get_index(service->network);
>  
>   if (service->nameservers != NULL) {
>   int i;
> @@ -442,7 +445,10 @@ void __connman_service_nameserver_del_routes(struct 
> connman_service *service)
>   if (service == NULL)
>   return;
>  
> - index = connman_network_get_index(service->network);
> + if (service->type == CONNMAN_SERVICE_TYPE_VPN)
> + index = connman_ipconfig_get_index(service->ipconfig);
> + else
> + index = connman_network_get_index(service->network);
>  
>   if (service->nameservers != NULL) {
>   int i;
> @@ -1893,7 +1899,11 @@ static DBusMessage *set_property(DBusConnection *conn,
>   if (str == NULL)
>   return __connman_error_invalid_arguments(msg);
>  
> - index = connman_network_get_index(service->network);
> + if (service->type == CONNMAN_SERVICE_TYPE_VPN)
> + index = connman_ipconfig_get_index(service->ipconfig);
> + else
> + index = connman_network_get_index(service->network);
> +
>   gw = __connman_ipconfig_get_gateway(index);
>  
>   if (gw && strlen(gw))
> -- 
> 1.7.2.3
> 
> ___
> connman mailing list
> connman@connman.net
> http://lists.connman.net/listinfo/connman

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 1/1] fix a crash when using vpn.

2010-10-15 Thread Mohamed Abbas
VPN services dont have network, so we need to make sure not
to use service->network while in vpn services.
---
 src/service.c |   16 +---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/service.c b/src/service.c
index 1cb292f..4ad46ec 100644
--- a/src/service.c
+++ b/src/service.c
@@ -407,7 +407,10 @@ void __connman_service_nameserver_add_routes(struct 
connman_service *service,
if (service == NULL)
return;
 
-   index = connman_network_get_index(service->network);
+   if (service->type == CONNMAN_SERVICE_TYPE_VPN)
+   index = connman_ipconfig_get_index(service->ipconfig);
+   else
+   index = connman_network_get_index(service->network);
 
if (service->nameservers != NULL) {
int i;
@@ -442,7 +445,10 @@ void __connman_service_nameserver_del_routes(struct 
connman_service *service)
if (service == NULL)
return;
 
-   index = connman_network_get_index(service->network);
+   if (service->type == CONNMAN_SERVICE_TYPE_VPN)
+   index = connman_ipconfig_get_index(service->ipconfig);
+   else
+   index = connman_network_get_index(service->network);
 
if (service->nameservers != NULL) {
int i;
@@ -1893,7 +1899,11 @@ static DBusMessage *set_property(DBusConnection *conn,
if (str == NULL)
return __connman_error_invalid_arguments(msg);
 
-   index = connman_network_get_index(service->network);
+   if (service->type == CONNMAN_SERVICE_TYPE_VPN)
+   index = connman_ipconfig_get_index(service->ipconfig);
+   else
+   index = connman_network_get_index(service->network);
+
gw = __connman_ipconfig_get_gateway(index);
 
if (gw && strlen(gw))
-- 
1.7.2.3

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman