Add BSSID , signal strength and frequency list of the APs 76/176676/2 accepted/tizen/unified/20180425.062309 submit/tizen/20180424.084858
authorMayank Haarit <mayank.h@samsung.com>
Fri, 20 Apr 2018 15:27:32 +0000 (20:57 +0530)
committerMayank Haarit <mayank.h@samsung.com>
Fri, 20 Apr 2018 15:39:29 +0000 (15:39 +0000)
This patch sends the list of BSSID, signal strength and
frequency of an APs having same SSID and Security type.

Change-Id: I368d37de310687ca173418dfad91fae7082b2357
Signed-off-by: Mayank Haarit <mayank.h@samsung.com>
gsupplicant/gsupplicant.h
gsupplicant/supplicant.c
include/network.h
plugins/wifi.c
src/network.c
src/service.c

index 0a28dbf..3dff2b4 100755 (executable)
@@ -399,6 +399,7 @@ unsigned int g_supplicant_network_get_keymgmt(GSupplicantNetwork *network);
 void *g_supplicant_network_get_wifi_vsie(GSupplicantNetwork *network);
 const unsigned char *g_supplicant_network_get_countrycode(GSupplicantNetwork
                                                          *network);
+void *g_supplicant_network_get_bssid_list(GSupplicantNetwork *network);
 #endif
 
 struct _GSupplicantCallbacks {
index fbfa6c7..c154a0e 100644 (file)
@@ -321,6 +321,14 @@ struct interface_scan_data {
        void *user_data;
 };
 
+#if defined TIZEN_EXT
+struct g_connman_bssids {
+       char bssid[18];
+       uint16_t strength;
+       uint16_t frequency;
+};
+#endif
+
 static int network_remove(struct interface_data *data);
 
 static inline void debug(const char *format, ...)
@@ -1595,6 +1603,46 @@ void *g_supplicant_network_get_wifi_vsie(GSupplicantNetwork *network)
 
        return vsie_list;
 }
+
+static void update_bssid_list(gpointer key, gpointer value, gpointer user_data)
+{
+       struct g_supplicant_bss *bss = value;
+       struct g_connman_bssids *bssids = NULL;
+       char buff[18];
+       GSList **list = (GSList **)user_data;
+
+       bssids = (struct g_connman_bssids *)g_try_malloc0(sizeof(struct g_connman_bssids));
+
+       if (bssids) {
+               g_snprintf(buff, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
+                               bss->bssid[0], bss->bssid[1], bss->bssid[2], bss->bssid[3],
+                               bss->bssid[4], bss->bssid[5]);
+
+               memcpy(bssids->bssid, buff, 18);
+               bssids->bssid[17] = '\0';
+               bssids->strength = bss->signal;
+               bssids->strength += 120;
+
+               if (bssids->strength > 100)
+                       bssids->strength = 100;
+
+               bssids->frequency = bss->frequency;
+               *list = g_slist_append(*list, bssids);
+       } else
+               SUPPLICANT_DBG("Failed to allocate memory");
+}
+
+void *g_supplicant_network_get_bssid_list(GSupplicantNetwork *network)
+{
+       GSList *bssid_list = NULL;
+
+       if (g_hash_table_size(network->bss_table) < 1)
+               return NULL;
+
+       g_hash_table_foreach(network->bss_table, update_bssid_list, &bssid_list);
+
+       return bssid_list;
+}
 #endif
 
 static void merge_network(GSupplicantNetwork *network)
index 63c4e44..98fa7d7 100755 (executable)
@@ -62,6 +62,14 @@ enum connman_network_error {
 
 };
 
+#if defined TIZEN_EXT
+struct connman_bssids {
+       char bssid[18];
+       uint16_t strength;
+       uint16_t frequency;
+};
+#endif
+
 #define CONNMAN_NETWORK_PRIORITY_LOW      -100
 #define CONNMAN_NETWORK_PRIORITY_DEFAULT     0
 #define CONNMAN_NETWORK_PRIORITY_HIGH      100
@@ -160,6 +168,9 @@ int connman_network_set_assoc_status_code(struct connman_network *network,
 int connman_network_set_countrycode(struct connman_network *network, const
                                    unsigned char *country_code);
 unsigned char *connman_network_get_countrycode(struct connman_network *network);
+int connman_network_set_bssid_list(struct connman_network *network,
+                                       GSList *bssids);
+void *connman_network_get_bssid_list(struct connman_network *network);
 #endif
 
 int connman_network_set_name(struct connman_network *network,
index 91732bd..aad3b2c 100755 (executable)
@@ -3509,6 +3509,8 @@ static void network_added(GSupplicantNetwork *supplicant_network)
                        g_supplicant_network_get_keymgmt(supplicant_network));
        connman_network_set_bool(network, "WiFi.HS20AP",
                        g_supplicant_network_is_hs20AP(supplicant_network));
+       connman_network_set_bssid_list(network,
+                       (GSList *)g_supplicant_network_get_bssid_list(supplicant_network));
 #endif
        connman_network_set_available(network, true);
        connman_network_set_string(network, "WiFi.Mode", mode);
@@ -3597,6 +3599,7 @@ static void network_changed(GSupplicantNetwork *network, const char *property)
        uint16_t frequency;
        bool wps;
        const unsigned char *country_code;
+       GSList *bssid_list;
 #endif
 
        interface = g_supplicant_network_get_interface(network);
@@ -3631,6 +3634,8 @@ static void network_changed(GSupplicantNetwork *network, const char *property)
        connman_network_set_bool(connman_network, "WiFi.WPS", wps);
        country_code = g_supplicant_network_get_countrycode(network);
        connman_network_set_countrycode(connman_network, country_code);
+       bssid_list = (GSList *)g_supplicant_network_get_bssid_list(network);
+       connman_network_set_bssid_list(connman_network, bssid_list);
 #endif
 }
 
index eb2d039..c5b5c97 100755 (executable)
@@ -120,6 +120,7 @@ struct connman_network {
                */
                char *phase1;
                unsigned char country_code[WIFI_COUNTRY_CODE_LEN];
+               GSList *bssid_list;
 #endif
        } wifi;
 
@@ -985,6 +986,7 @@ static void network_destruct(struct connman_network *network)
        g_free(network->wifi.pin_wps);
 #if defined TIZEN_EXT
        g_slist_free_full(network->wifi.vsie_list, g_free);
+       g_slist_free_full(network->wifi.bssid_list, g_free);
 #endif
        g_free(network->path);
        g_free(network->group);
@@ -2100,6 +2102,18 @@ unsigned char *connman_network_get_countrycode(struct connman_network *network)
        return (unsigned char *)network->wifi.country_code;
 }
 
+int connman_network_set_bssid_list(struct connman_network *network,
+                                       GSList *bssids)
+{
+       network->wifi.bssid_list = bssids;
+
+       return 0;
+}
+
+void *connman_network_get_bssid_list(struct connman_network *network)
+{
+       return network->wifi.bssid_list;
+}
 #endif
 
 int connman_network_set_nameservers(struct connman_network *network,
index b533dcd..b042461 100755 (executable)
@@ -3303,6 +3303,33 @@ static void append_wifi_ext_info(DBusMessageIter *dict,
                                        DBUS_TYPE_STRING, &str);
        }
 }
+
+static void append_bssid_info(DBusMessageIter *iter, void *user_data)
+{
+        GSList *bssid_list = NULL;
+       struct connman_network *network = user_data;
+        struct connman_bssids *bssids;
+        char bssid_buf[18] = {0,};
+        char *bssid_str = bssid_buf;
+
+        bssid_list = (GSList *)connman_network_get_bssid_list(network);
+        if(bssid_list) {
+                GSList *list;
+                for (list = bssid_list; list; list = list->next) {
+                        bssids = (struct connman_bssids *)list->data;
+                        memcpy(bssid_str, bssids->bssid, 18);
+
+                       connman_dbus_dict_append_basic(iter, "BSSID",
+                                        DBUS_TYPE_STRING, &bssid_str);
+
+                        connman_dbus_dict_append_basic(iter, "Strength",
+                                        DBUS_TYPE_UINT16, &bssids->strength);
+
+                        connman_dbus_dict_append_basic(iter, "Frequency",
+                                        DBUS_TYPE_UINT16, &bssids->frequency);
+                }
+        }
+}
 #endif
 
 static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
@@ -3406,8 +3433,11 @@ static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
                break;
        case CONNMAN_SERVICE_TYPE_WIFI:
 #if defined TIZEN_EXT
-               if (service->network != NULL)
+               if (service->network != NULL) {
                        append_wifi_ext_info(dict, service->network);
+                       connman_dbus_dict_append_dict(dict, "BSSID.List",
+                                       append_bssid_info, service->network);
+               }
 
                connman_dbus_dict_append_dict(dict, "Ethernet",
                                                append_ethernet, service);