summaryrefslogtreecommitdiff
path: root/src/inet.c
diff options
context:
space:
mode:
authorSeonah Moon <seonah1.moon@samsung.com>2017-02-20 10:36:21 (GMT)
committerSeonah Moon <seonah1.moon@samsung.com>2017-02-23 06:34:42 (GMT)
commit80b0b7544b4e77b68a4d724e6a3f45e7dd2c8f3f (patch)
treee207897dba68806072e4b8229eae46a490d44634 /src/inet.c
parent21e92ee0e2531e80b5bda990a99bbe72abf31991 (diff)
downloadconnman-80b0b7544b4e77b68a4d724e6a3f45e7dd2c8f3f.zip
connman-80b0b7544b4e77b68a4d724e6a3f45e7dd2c8f3f.tar.gz
connman-80b0b7544b4e77b68a4d724e6a3f45e7dd2c8f3f.tar.bz2
[connman] Merged IPv6 related code.refs/changes/70/115570/6
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>
Diffstat (limited to 'src/inet.c')
-rwxr-xr-xsrc/inet.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/inet.c b/src/inet.c
index 972fdff..fcffab8 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));