Merge "vpn: Export vpn_ipconfig_foreach as linker symbol" into tizen
authorJaehyun Kim <jeik01.kim@samsung.com>
Wed, 8 Sep 2021 06:44:05 +0000 (06:44 +0000)
committerGerrit Code Review <gerrit@review>
Wed, 8 Sep 2021 06:44:05 +0000 (06:44 +0000)
gsupplicant/supplicant.c
plugins/wifi.c
src/clock.c
src/connman.h
src/ntp.c
src/service.c

index f4abb07..906f0ea 100755 (executable)
@@ -304,6 +304,8 @@ struct g_supplicant_bss {
        dbus_bool_t hs20;
        unsigned char country_code[COUNTRY_CODE_LENGTH];
        GSupplicantPhy_mode phy_mode;
+       dbus_int16_t snr;
+       dbus_uint32_t est_throughput;
 #endif
        unsigned int wps_capabilities;
 #if defined TIZEN_EXT
@@ -443,6 +445,8 @@ struct g_connman_bssids {
        int score_assoc_reject;
        int score_frequency;
        int score_strength;
+       int score_snr;
+       int score_est_throughput;
 #endif
        int ins_score;
 };
@@ -2110,8 +2114,22 @@ static int calculate_score_strength(dbus_int16_t strength)
        return score;
 }
 
+static int calculate_score_est_throughput(dbus_uint32_t est_throughput)
+{
+       int score = 0;
+
+       if (est_throughput >= 10000)
+               score = est_throughput / 10000;
+
+       if (score > 40)
+               score = 40;
+
+       return score;
+}
+
 static int calculate_score(bool is_last_connected, uint16_t assoc_reject_cnt,
-               dbus_int16_t strength, dbus_uint16_t frequency)
+               dbus_uint16_t frequency, dbus_int16_t strength,
+               dbus_int16_t snr, dbus_uint32_t est_throughput)
 {
        int score = 0;
 
@@ -2119,6 +2137,8 @@ static int calculate_score(bool is_last_connected, uint16_t assoc_reject_cnt,
        score += calculate_score_assoc_reject(assoc_reject_cnt);
        score += calculate_score_frequency(strength, frequency);
        score += calculate_score_strength(strength);
+       score += (int)snr;
+       score += calculate_score_est_throughput(est_throughput);
 
        return score;
 }
@@ -2151,10 +2171,13 @@ static void update_bssid_list(gpointer key, gpointer value, gpointer user_data)
                bssids->score_assoc_reject = calculate_score_assoc_reject(bssids->assoc_reject_cnt);
                bssids->score_frequency = calculate_score_frequency(bss->signal, bssids->frequency);
                bssids->score_strength = calculate_score_strength(bssids->strength);
+               bssids->score_snr = (int)bss->snr;
+               bssids->score_est_throughput = calculate_score_est_throughput(bss->est_throughput);
 #endif
 
                bssids->ins_score = calculate_score(bssids->is_last_connected,
-                       bssids->assoc_reject_cnt, bssids->frequency, bss->signal);
+                       bssids->assoc_reject_cnt, bssids->frequency, bss->signal,
+                       bss->snr, bss->est_throughput);
 
                bssid_data->bssid_list = g_slist_append(bssid_data->bssid_list, bssids);
        } else
@@ -2541,12 +2564,13 @@ static bool update_best_bss(GSupplicantNetwork *network,
        score_new = calculate_score(
                compare_bssid(bss->bssid, network->last_connected_bssid),
                get_assoc_reject_cnt(network->assoc_reject_table, bss->bssid),
-               bss->frequency, bss->signal);
+               bss->frequency, bss->signal, bss->snr, bss->est_throughput);
 
        score_best = calculate_score(
                compare_bssid(network->best_bss->bssid, network->last_connected_bssid),
                get_assoc_reject_cnt(network->assoc_reject_table, network->best_bss->bssid),
-               network->best_bss->frequency, network->best_bss->signal);
+               network->best_bss->frequency, network->best_bss->signal,
+               network->best_bss->snr, network->best_bss->est_throughput);
 
        if (score_new > score_best) {
                SUPPLICANT_DBG("new[" MACSTR "][%u] : best[" MACSTR "][%u]",
@@ -3240,6 +3264,17 @@ static void bss_property(const char *key, DBusMessageIter *iter,
                dbus_bool_t hs20 = FALSE;
                dbus_message_iter_get_basic(iter, &hs20);
                bss->hs20 = hs20;
+       } else if (g_strcmp0(key, "SNR") == 0) {
+               dbus_int16_t snr = 0;
+
+               dbus_message_iter_get_basic(iter, &snr);
+               bss->snr = snr;
+       } else if (g_strcmp0(key, "EstThroughput") == 0) {
+               dbus_uint32_t est_throughput = 0;
+
+               dbus_message_iter_get_basic(iter, &est_throughput);
+               if (est_throughput != 0)
+                       bss->est_throughput = est_throughput;
 #endif
        } else if (g_strcmp0(key, "IEs") == 0)
                bss_process_ies(iter, bss);
@@ -7800,7 +7835,7 @@ int g_supplicant_interface_connect(GSupplicantInterface *interface,
                                        interface_add_network_result, data,
                                        interface);
                }
-        }
+       }
 
        if (ret < 0) {
                g_free(data->path);
index 4257a5d..8216816 100755 (executable)
@@ -4459,9 +4459,9 @@ static void interface_state(GSupplicantInterface *interface)
 
 #if defined TIZEN_EXT
                if (handle_assoc_status_code(interface, wifi)) {
-                       GSList *bssid_list = (GSList *)connman_network_get_bssid_list(network);
                        const char *group = connman_network_get_group(network);
                        GSupplicantNetwork *supplicant_network;
+                       GSList *bssid_list = NULL;
                        guint bssid_length = 0;
 
                        if (group) {
@@ -4473,6 +4473,7 @@ static void interface_state(GSupplicantInterface *interface)
                                g_supplicant_network_update_assoc_reject(interface, supplicant_network);
                        }
 
+                       bssid_list = (GSList *)connman_network_get_bssid_list(network);
                        if (bssid_list)
                                bssid_length = g_slist_length(bssid_list);
 
index f04cf17..40729b2 100755 (executable)
@@ -39,6 +39,9 @@ static enum time_updates time_updates_config = TIME_UPDATES_AUTO;
 static enum timezone_updates timezone_updates_config = TIMEZONE_UPDATES_AUTO;
 
 static char *timezone_config = NULL;
+#if defined TIZEN_EXT
+static bool time_updated = false;
+#endif
 
 static const char *time_updates2string(enum time_updates value)
 {
@@ -175,6 +178,9 @@ static DBusMessage *get_properties(DBusConnection *conn,
        DBusMessageIter array, dict;
        struct timeval tv;
        const char *str;
+#if defined TIZEN_EXT
+       dbus_bool_t val = time_updated;
+#endif
 
        DBG("conn %p", conn);
 
@@ -186,6 +192,12 @@ static DBusMessage *get_properties(DBusConnection *conn,
 
        connman_dbus_dict_open(&array, &dict);
 
+#if defined TIZEN_EXT
+       connman_dbus_dict_append_basic(&dict, "TimeUpdated",
+                                               DBUS_TYPE_BOOLEAN,
+                                               &val);
+#endif
+
        if (gettimeofday(&tv, NULL) == 0) {
                dbus_uint64_t val = tv.tv_sec;
 
@@ -392,6 +404,13 @@ static const GDBusSignalTable clock_signals[] = {
 
 static DBusConnection *connection = NULL;
 
+#if defined TIZEN_EXT
+void __connman_clock_set_time_updated(bool updated)
+{
+       time_updated = updated;
+}
+#endif
+
 void __connman_clock_update_timezone(void)
 {
        DBG("");
index 97bb80a..e92f2b1 100755 (executable)
@@ -79,6 +79,9 @@ int __connman_clock_init(void);
 void __connman_clock_cleanup(void);
 
 void __connman_clock_update_timezone(void);
+#if defined TIZEN_EXT
+void __connman_clock_set_time_updated(bool updated);
+#endif
 
 int __connman_timezone_init(void);
 void __connman_timezone_cleanup(void);
index ccea3ea..0de4df7 100755 (executable)
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -407,6 +407,8 @@ static void decode_msg(struct ntp_data *nd, void *base, size_t len,
                DBG("%lu cur seconds, %lu cur nsecs, %lu req seconds, %lu req nsecs",
                        cur.tv_sec, cur.tv_nsec, req.tv_sec, req.tv_nsec);
                DBG("setting time");
+
+               __connman_clock_set_time_updated(true);
        }
 #else
        if (offset < STEPTIME_MIN_OFFSET && offset > -STEPTIME_MIN_OFFSET) {
index 2b69a0b..a409162 100755 (executable)
@@ -813,7 +813,8 @@ static void count_assoc_reject(gpointer key, gpointer value, gpointer user_data)
        struct assoc_reject_data *assoc_data = value;
        int *assoc_reject_count = user_data;
 
-       *assoc_reject_count += g_slist_length(assoc_data->reject_time_list);
+       if (assoc_data)
+               *assoc_reject_count += g_slist_length(assoc_data->reject_time_list);
 }
 
 static bool update_assoc_reject(struct connman_service *service)