Merge "[tizen 4.0]: Add support of Disconnect Reason Event Handler" into tizen accepted/tizen/common/20170303.090745 accepted/tizen/ivi/20170303.065637 accepted/tizen/mobile/20170303.065550 accepted/tizen/tv/20170303.065605 accepted/tizen/unified/20170309.035138 accepted/tizen/wearable/20170303.065623 submit/tizen/20170303.005553 submit/tizen_unified/20170308.100411
authortaesub kim <taesub.kim@samsung.com>
Fri, 3 Mar 2017 00:45:31 +0000 (16:45 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 3 Mar 2017 00:45:31 +0000 (16:45 -0800)
src/connman.h
src/dhcp.c
src/dnsproxy.c
src/inet.c
src/ipconfig.c
src/network.c

index 2217cc4..077bc1c 100755 (executable)
@@ -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,
index 644aac6..7ca19d0 100755 (executable)
@@ -480,24 +480,11 @@ done:
 static void ipv4ll_available_cb(GDHCPClient *ipv4ll_client, gpointer user_data)
 {
        struct connman_dhcp *dhcp = user_data;
-#if !defined TIZEN_EXT
                char *address, *netmask;
                unsigned char prefixlen;
-#endif
 
        DBG("IPV4LL available");
 
-#if defined TIZEN_EXT
-               /*
-                * Description: When DHCP is failed,
-                *               most of normal users cannot understand auto-generated IP
-                *              (IPV4 link local) and serious troubles to make Internet connection.
-                */
-               dhcp_invalidate(dhcp, true);
-
-               connman_network_set_error(dhcp->network,
-                                       CONNMAN_NETWORK_ERROR_DHCP_FAIL);
-#else
        address = g_dhcp_client_get_address(ipv4ll_client);
        netmask = g_dhcp_client_get_netmask(ipv4ll_client);
 
@@ -513,7 +500,6 @@ static void ipv4ll_available_cb(GDHCPClient *ipv4ll_client, gpointer user_data)
 
        g_free(address);
        g_free(netmask);
-#endif
 }
 
 static int dhcp_initialize(struct connman_dhcp *dhcp)
index d44de64..5fd4b26 100755 (executable)
@@ -3126,21 +3126,6 @@ static int parse_request(unsigned char *buf, int len,
                remain -= label_len + 1;
        }
 
-#if defined TIZEN_EXT
-       /* parse DNS query type either A or AAAA
-        * enforce to drop AAAA temporarily (IPv6 not supported)
-        */
-       if (last_label != NULL) {
-               uint16_t *type_p = (uint16_t *)last_label;
-               uint16_t type = ntohs(*type_p);
-
-               if (type == 0x1c) {
-                       DBG("query %s is type AAAA(0x%x)", name, type);
-                       return -ENOENT;
-               }
-       }
-#endif
-
        if (last_label && arcount && remain >= 9 && last_label[4] == 0 &&
                                !memcmp(last_label + 5, opt_edns0_type, 2)) {
                uint16_t edns0_bufsize;
@@ -3665,41 +3650,6 @@ static gboolean tcp6_listener_event(GIOChannel *channel, GIOCondition condition,
                                &ifdata->tcp6_listener_watch);
 }
 
-#if defined TIZEN_EXT
-/* Temporarily disable AAAA type to enhance performance (IPv6 not supported) */
-static void __send_response_not_implemented(int sk, unsigned char *buf, int len,
-                               const struct sockaddr *to, socklen_t tolen,
-                               int protocol)
-{
-       struct domain_hdr *hdr;
-       int err, offset = protocol_offset(protocol);
-
-       DBG("sk %d", sk);
-
-       if (offset < 0)
-               return;
-
-       if (len < 12)
-               return;
-
-       hdr = (void *) (buf + offset);
-
-       DBG("id 0x%04x qr %d opcode %d", hdr->id, hdr->qr, hdr->opcode);
-
-       hdr->qr = 1;
-       hdr->rcode = 4;
-
-       hdr->ancount = 0;
-       hdr->nscount = 0;
-       hdr->arcount = 0;
-
-       err = sendto(sk, buf, len, MSG_NOSIGNAL, to, tolen);
-       if (err < 0)
-               connman_error("Failed to send DNS response to %d: %s",
-                               sk, strerror(errno));
-}
-#endif
-
 static bool udp_listener_event(GIOChannel *channel, GIOCondition condition,
                                struct listener_data *ifdata, int family,
                                guint *listener_watch)
@@ -3746,16 +3696,6 @@ static bool udp_listener_event(GIOChannel *channel, GIOCondition condition,
 
        err = parse_request(buf, len, query, sizeof(query));
        if (err < 0 || (g_slist_length(server_list) == 0)) {
-#if defined TIZEN_EXT
-               if (err == -ENOENT) {
-                       /* Temporarily disable AAAA type to enhance performance
-                        * (IPv6 not supported)
-                        */
-                       __send_response_not_implemented(sk, buf, len, client_addr,
-                                                                       *client_addr_len, IPPROTO_UDP);
-                       return TRUE;
-               }
-#endif
                send_response(sk, buf, len, client_addr,
                                *client_addr_len, IPPROTO_UDP);
                return true;
index 972fdff..fcffab8 100755 (executable)
@@ -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));
index 8987ab1..27d98b2 100755 (executable)
@@ -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:
index 8687619..78ce229 100755 (executable)
@@ -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)
 {