From: Elena Tebesoi <elena.tebe...@gmail.com>

A GPRS service can also have IPV6 configuration.
This patch sets the network index for IPV6.
---
This patch is built ontop of current connman_network_set_index
implementation. However, the entire method of setting network
index needs some rethinking. As discussed on IRC with Patrik Flykt,
connman_network_set_index could be used only to set network->index
and configuration of index for IPv4 and IPv6 could be done in another
place in the code.
---
 include/network.h |    1 +
 plugins/ofono.c   |    2 ++
 src/network.c     |   43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/include/network.h b/include/network.h
index 12b0621..f368033 100644
--- a/include/network.h
+++ b/include/network.h
@@ -81,6 +81,7 @@ enum connman_network_type connman_network_get_type(struct 
connman_network *netwo
 const char *connman_network_get_identifier(struct connman_network *network);
 
 void connman_network_set_index(struct connman_network *network, int index);
+void connman_network_set_ipv6_index(struct connman_network *network, int 
index);
 int connman_network_get_index(struct connman_network *network);
 
 void connman_network_set_group(struct connman_network *network,
diff --git a/plugins/ofono.c b/plugins/ofono.c
index ae419be..2fe1609 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -295,6 +295,8 @@ static void set_connected(struct modem_data *modem)
                break;
 
        case CONNMAN_IPCONFIG_METHOD_FIXED:
+               connman_network_set_ipv6_index(modem->network,
+                                                       modem->context->index);
                connman_network_set_ipv6_method(modem->network,
                                                        
modem->context->ipv6_method);
                connman_network_set_ipaddress(modem->network,
diff --git a/src/network.c b/src/network.c
index 5bd1502..8da6929 100644
--- a/src/network.c
+++ b/src/network.c
@@ -497,6 +497,49 @@ done:
 }
 
 /**
+ * connman_network_set_ipv6_index:
+ * @network: network structure
+ * @index: index number
+ *
+ * Set index number of network's IPv6 configuration
+ */
+void connman_network_set_ipv6_index(struct connman_network *network, int index)
+{
+       struct connman_service *service;
+       struct connman_ipconfig *ipconfig;
+
+       service = __connman_service_lookup_from_network(network);
+       if (service == NULL)
+               goto done;
+
+       ipconfig = __connman_service_get_ip6config(service);
+
+       DBG("index %d service %p ip6config %p", network->index,
+               service, ipconfig);
+
+       if (network->index < 0 && ipconfig == NULL) {
+               if (ipconfig == NULL)
+                       /*
+                        * This is needed for plugins that havent set their
+                        * ipconfig layer yet, due to not being able to get
+                        * a network index prior to creating a service.
+                        */
+                       __connman_service_create_ip6config(service, index);
+               else
+                       __connman_ipconfig_set_index(ipconfig, index);
+
+       } else {
+               /* If index changed, the index of ipconfig must be reset. */
+               if (ipconfig == NULL)
+                       goto done;
+
+               __connman_ipconfig_set_index(ipconfig, index);
+       }
+
+done:
+       network->index = index;
+}
+/**
  * connman_network_get_index:
  * @network: network structure
  *
-- 
1.7.5.4

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

Reply via email to