Maintain connection status when wifi roaming
[platform/upstream/connman.git] / src / network.c
index d71b419..8eb8c1e 100755 (executable)
@@ -122,6 +122,7 @@ struct connman_network {
                unsigned int keymgmt;
                char *keymgmt_type;
                bool rsn_mode;
+               bool pmf_required;
                int disconnect_reason;
                int assoc_status_code;
                GSList *vsie_list;
@@ -146,9 +147,11 @@ struct connman_network {
                int transition_mode_ssid_len;
                unsigned char transition_mode_bssid[WIFI_BSSID_LEN_MAX];
                bool roaming_progress;
+               bool roaming_dhcp;
                char *roaming_cur_bssid;
                char *roaming_dst_bssid;
                __time_t roam_scan_time;
+               unsigned int max_bssid_count;
                int snr;
 #endif
        } wifi;
@@ -560,6 +563,10 @@ static int set_connected_manual(struct connman_network *network)
        ipconfig = __connman_service_get_ip4config(service);
        __connman_ipconfig_enable(ipconfig);
 
+#if defined TIZEN_EXT
+       if (!service || !ipconfig)
+               return -EINVAL;
+#endif
        if (!__connman_ipconfig_get_local(ipconfig))
                __connman_service_read_ip4config(service);
 
@@ -595,7 +602,11 @@ static void remove_dhcp_timeout(struct connman_network *network)
        }
 }
 
+#if defined TIZEN_EXT
+int set_connected_dhcp(struct connman_network *network)
+#else
 static int set_connected_dhcp(struct connman_network *network)
+#endif
 {
        struct connman_service *service;
        struct connman_ipconfig *ipconfig_ipv4;
@@ -1345,6 +1356,7 @@ static void network_destruct(struct connman_network *network)
 #if defined TIZEN_EXT
        g_slist_free_full(network->wifi.vsie_list, g_free);
        g_slist_free_full(network->wifi.bssid_list, g_free);
+       g_hash_table_destroy(network->wifi.assoc_reject_table);
 #endif
        g_free(network->path);
        g_free(network->group);
@@ -1409,6 +1421,9 @@ struct connman_network *
 connman_network_ref_debug(struct connman_network *network,
                        const char *file, int line, const char *caller)
 {
+#if defined TIZEN_EXT
+       if (!simplified_log)
+#endif
        DBG("%p name %s ref %d by %s:%d:%s()", network, network->name,
                network->refcount + 1, file, line, caller);
 
@@ -1426,6 +1441,9 @@ connman_network_ref_debug(struct connman_network *network,
 void connman_network_unref_debug(struct connman_network *network,
                                const char *file, int line, const char *caller)
 {
+#if defined TIZEN_EXT
+       if (!simplified_log)
+#endif
        DBG("%p name %s ref %d by %s:%d:%s()", network, network->name,
                network->refcount - 1, file, line, caller);
 
@@ -2374,9 +2392,6 @@ int connman_network_set_bssid(struct connman_network *network,
        if (bssid == NULL)
                return -EINVAL;
 
-       if (network->connected)
-               return -EPERM;
-
        if (!simplified_log)
                DBG("network %p bssid %02x:%02x:%02x:%02x:%02x:%02x", network,
                                bssid[0], bssid[1], bssid[2],
@@ -2595,9 +2610,15 @@ unsigned char *connman_network_get_countrycode(struct connman_network *network)
 int connman_network_set_bssid_list(struct connman_network *network,
                                        GSList *bssids)
 {
+       unsigned int max_bssid_count;
+
        g_slist_free_full(network->wifi.bssid_list, g_free);
        network->wifi.bssid_list = bssids;
 
+       max_bssid_count = g_slist_length(bssids);
+       if (network->wifi.max_bssid_count < max_bssid_count)
+               network->wifi.max_bssid_count = max_bssid_count;
+
        return 0;
 }
 
@@ -2635,6 +2656,11 @@ void *connman_network_get_bssid_list(struct connman_network *network)
        return network->wifi.bssid_list;
 }
 
+unsigned int connman_network_get_max_bssid_count(struct connman_network *network)
+{
+       return network->wifi.max_bssid_count;
+}
+
 int connman_network_set_last_connected_bssid(struct connman_network *network,
                                const unsigned char *bssid)
 {
@@ -2663,6 +2689,8 @@ void connman_network_set_assoc_reject_table(struct connman_network *network,
        if (!assoc_reject_table)
                return;
 
+       g_hash_table_destroy(network->wifi.assoc_reject_table);
+
        network->wifi.assoc_reject_table = assoc_reject_table;
 }
 
@@ -2814,6 +2842,21 @@ int connman_network_set_wifi_channel(struct connman_network *network,
        return 0;
 }
 
+int connman_network_set_autoconnect(struct connman_network *network,
+                               bool autoconnect)
+{
+       if (!network->driver || !network->driver->set_autoconnect)
+               return 0;
+       return network->driver->set_autoconnect(network, autoconnect);
+}
+
+bool __connman_network_native_autoconnect(struct connman_network *network)
+{
+       if (!network->driver || !network->driver->set_autoconnect)
+               return false;
+       return true;
+}
+
 uint16_t connman_network_get_wifi_channel(struct connman_network *network)
 {
        return network->wifi.channel;
@@ -3009,9 +3052,12 @@ int connman_network_set_bool(struct connman_network *network,
                network->wifi.isHS20AP = value;
        else if (g_strcmp0(key, "WiFi.TRANSITION_MODE") == 0)
                network->wifi.owe_transition_mode = value;
-       else if (g_strcmp0(key, "WiFi.Roaming") == 0) {
+       else if (g_strcmp0(key, "WiFi.Roaming") == 0)
                network->wifi.roaming_progress = value;
-       }
+       else if (g_strcmp0(key, "WiFi.RoamingDHCP") == 0)
+               network->wifi.roaming_dhcp = value;
+       else if (g_strcmp0(key, "WiFi.PMFRequired") == 0)
+               network->wifi.pmf_required = value;
 #endif
 
        return -EINVAL;
@@ -3044,6 +3090,10 @@ bool connman_network_get_bool(struct connman_network *network,
                return network->wifi.owe_transition_mode;
        else if (g_str_equal(key, "WiFi.Roaming"))
                return network->wifi.roaming_progress;
+       else if (g_str_equal(key, "WiFi.RoamingDHCP"))
+               return network->wifi.roaming_dhcp;
+       else if (g_str_equal(key, "WiFi.PMFRequired"))
+               return network->wifi.pmf_required;
 #endif
 
        return false;
@@ -3134,6 +3184,7 @@ const void *connman_network_get_blob(struct connman_network *network,
                return network->wifi.transition_mode_ssid;
 #endif
        }
+
        return NULL;
 }