summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeonah Moon <seonah1.moon@samsung.com>2017-02-20 19:36:21 +0900
committerSeonah Moon <seonah1.moon@samsung.com>2017-02-23 15:34:42 +0900
commit80b0b7544b4e77b68a4d724e6a3f45e7dd2c8f3f (patch)
treee207897dba68806072e4b8229eae46a490d44634
parent21e92ee0e2531e80b5bda990a99bbe72abf31991 (diff)
downloadconnman-80b0b7544b4e77b68a4d724e6a3f45e7dd2c8f3f.tar.gz
connman-80b0b7544b4e77b68a4d724e6a3f45e7dd2c8f3f.tar.bz2
connman-80b0b7544b4e77b68a4d724e6a3f45e7dd2c8f3f.zip
[connman] Merged IPv6 related code.
1. Added code to set IPv6 gateway addess. 2. Fix IPv6 issue in case of auto-configuration. Change-Id: Ie0e1d53dd269a09600d2f08e66d73cefd6dd3c29 Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
-rwxr-xr-xsrc/connman.h3
-rwxr-xr-xsrc/inet.c31
-rwxr-xr-xsrc/ipconfig.c29
-rwxr-xr-xsrc/network.c29
4 files changed, 89 insertions, 3 deletions
diff --git a/src/connman.h b/src/connman.h
index 2217cc4e..077bc1c7 100755
--- a/src/connman.h
+++ b/src/connman.h
@@ -169,6 +169,9 @@ int __connman_inet_ipv6_send_rs(int index, int timeout,
__connman_inet_rs_cb_t callback, void *user_data);
int __connman_inet_ipv6_send_ra(int index, struct in6_addr *src_addr,
GSList *prefixes, int router_lifetime);
+#if defined TIZEN_EXT
+void __connman_network_set_auto_ipv6_gateway(char *gateway, void *user_data);
+#endif
typedef void (*__connman_inet_ns_cb_t) (struct nd_neighbor_advert *reply,
unsigned int length,
diff --git a/src/inet.c b/src/inet.c
index 972fdff5..fcffab8c 100755
--- a/src/inet.c
+++ b/src/inet.c
@@ -1340,6 +1340,37 @@ static int icmpv6_recv(int fd, gpointer user_data)
return -errno;
}
+#if defined TIZEN_EXT
+ /* Set Received Source Address from router as IPv6 Gateway Address */
+ char src_addr[INET6_ADDRSTRLEN];
+ if(inet_ntop(AF_INET6, &(saddr.sin6_addr), src_addr, INET6_ADDRSTRLEN)
+ == NULL) {
+ xs_cleanup(data);
+ return -errno;
+ }
+ DBG("Received Source Address %s from router", src_addr);
+
+ /* icmpv6_recv() function can be called in two scenarios :
+ * 1. When __connman_inet_ipv6_send_rs() is called from check_dhcpv6()
+ * 2. When __connman_inet_ipv6_send_rs() is called from
+ * __connman_6to4_probe()
+ * In the second case it is not required to set DHCPv6 Gateway Address
+ * as DHCPv6 was not started and network structure was not passed as
+ * user_data. If it is tried to add Source Address as Gateway Address
+ * then it will lead to crash because of user_data being ip_address
+ * instead of network structure. So Adding Gateway Address in case 1st
+ * case only.
+ */
+ char *address = data->user_data;
+ int err = 0;
+ unsigned char buffer[sizeof(struct in6_addr)] = {0, };
+ /* Checking if user_data is an ip_address */
+ err = inet_pton(AF_INET, address, buffer);
+ /* Setting Received Source Address from
+ * router as Gateway Address */
+ if(err <= 0)
+ __connman_network_set_auto_ipv6_gateway(src_addr, data->user_data);
+#endif
hdr = (struct nd_router_advert *)buf;
DBG("code %d len %zd hdr %zd", hdr->nd_ra_code, len,
sizeof(struct nd_router_advert));
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 8987ab1a..27d98b29 100755
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -410,7 +410,20 @@ static void free_ipdevice(gpointer data)
static void __connman_ipconfig_lower_up(struct connman_ipdevice *ipdevice)
{
DBG("ipconfig ipv4 %p ipv6 %p", ipdevice->config_ipv4,
- ipdevice->config_ipv6);
+ ipdevice->config_ipv6);
+#if defined TIZEN_EXT
+ if (ipdevice->config_ipv6 != NULL &&
+ ipdevice->config_ipv6->enabled == TRUE)
+ return;
+
+ char *ifname = connman_inet_ifname(ipdevice->index);
+
+ if (__connman_device_isfiltered(ifname) == FALSE) {
+ ipdevice->ipv6_enabled = get_ipv6_state(ifname);
+ set_ipv6_state(ifname, FALSE);
+ }
+ g_free(ifname);
+#endif
}
static void __connman_ipconfig_lower_down(struct connman_ipdevice *ipdevice)
@@ -1708,6 +1721,11 @@ int __connman_ipconfig_disable(struct connman_ipconfig *ipconfig)
if (ipdevice->config_ipv6 == ipconfig) {
ipconfig_list = g_list_remove(ipconfig_list, ipconfig);
+#if defined TIZEN_EXT
+ if (ipdevice->config_ipv6->method ==
+ CONNMAN_IPCONFIG_METHOD_AUTO)
+ disable_ipv6(ipdevice->config_ipv6);
+#endif
connman_ipaddress_clear(ipdevice->config_ipv6->system);
__connman_ipconfig_unref(ipdevice->config_ipv6);
ipdevice->config_ipv6 = NULL;
@@ -2123,7 +2141,10 @@ int __connman_ipconfig_set_config(struct connman_ipconfig *ipconfig,
case CONNMAN_IPCONFIG_METHOD_OFF:
ipconfig->method = method;
-
+#if defined TIZEN_EXT
+ if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6)
+ disable_ipv6(ipconfig);
+#endif
break;
case CONNMAN_IPCONFIG_METHOD_AUTO:
@@ -2133,7 +2154,9 @@ int __connman_ipconfig_set_config(struct connman_ipconfig *ipconfig,
ipconfig->method = method;
if (privacy_string)
ipconfig->ipv6_privacy_config = privacy;
-
+#if defined TIZEN_EXT
+ enable_ipv6(ipconfig);
+#endif
break;
case CONNMAN_IPCONFIG_METHOD_MANUAL:
diff --git a/src/network.c b/src/network.c
index 86876192..78ce2299 100755
--- a/src/network.c
+++ b/src/network.c
@@ -1729,6 +1729,35 @@ int __connman_network_clear_ipconfig(struct connman_network *network,
return 0;
}
+#if defined TIZEN_EXT
+void __connman_network_set_auto_ipv6_gateway(char *gateway, void *user_data)
+{
+ DBG("");
+
+ struct connman_network *network = user_data;
+ struct connman_service *service;
+ struct connman_ipconfig *ipconfig = NULL;
+ int err;
+
+ service = connman_service_lookup_from_network(network);
+ if (service == NULL)
+ return;
+
+ ipconfig = __connman_service_get_ipconfig(service, AF_INET6);
+ if (ipconfig == NULL)
+ return;
+
+ __connman_ipconfig_set_gateway(ipconfig, gateway);
+ err = __connman_ipconfig_gateway_add(ipconfig, service);
+
+ if(err == 0)
+ __connman_connection_gateway_activate(service,
+ CONNMAN_IPCONFIG_TYPE_IPV6);
+
+ return;
+}
+#endif
+
int __connman_network_enable_ipconfig(struct connman_network *network,
struct connman_ipconfig *ipconfig)
{