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>
__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,
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));
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)
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;
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:
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:
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)
{