diff options
author | Jaehyun Kim <jeik01.kim@samsung.com> | 2021-12-08 01:41:05 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@review> | 2021-12-08 01:41:05 +0000 |
commit | dc6cfda01fbf497a537dccab186d57657a4ea938 (patch) | |
tree | de16abf161bccbc97b17856698b329bb94323b55 | |
parent | 17c2dfb865433db2e64f1e64fcd5fac7cb445c23 (diff) | |
parent | 56680a937cb856c8075032cca9bca107ab4fadb2 (diff) | |
download | connman-dc6cfda01fbf497a537dccab186d57657a4ea938.tar.gz connman-dc6cfda01fbf497a537dccab186d57657a4ea938.tar.bz2 connman-dc6cfda01fbf497a537dccab186d57657a4ea938.zip |
Merge "service: Add a new property 'SecurityList'" into tizensubmit/tizen/20211215.063645accepted/tizen/unified/20211216.155835
-rwxr-xr-x | gsupplicant/gsupplicant.h | 1 | ||||
-rwxr-xr-x | gsupplicant/supplicant.c | 15 | ||||
-rwxr-xr-x | include/network.h | 4 | ||||
-rwxr-xr-x | plugins/wifi.c | 64 | ||||
-rwxr-xr-x | src/network.c | 15 | ||||
-rwxr-xr-x | src/service.c | 21 |
6 files changed, 115 insertions, 5 deletions
diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h index 54802bd9..54283793 100755 --- a/gsupplicant/gsupplicant.h +++ b/gsupplicant/gsupplicant.h @@ -497,6 +497,7 @@ const char *g_supplicant_network_get_eap(GSupplicantNetwork *network); const char *g_supplicant_network_get_identity(GSupplicantNetwork *network); const char *g_supplicant_network_get_phase2(GSupplicantNetwork *network); unsigned int g_supplicant_network_get_keymgmt(GSupplicantNetwork *network); +dbus_bool_t g_supplicant_network_get_privacy(GSupplicantNetwork *network); void *g_supplicant_network_get_wifi_vsie(GSupplicantNetwork *network); const unsigned char *g_supplicant_network_get_countrycode(GSupplicantNetwork *network); diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index 8e055f3a..e439dbe0 100755 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -347,6 +347,7 @@ struct _GSupplicantNetwork { unsigned char country_code[COUNTRY_CODE_LENGTH]; GSupplicantPhy_mode phy_mode; dbus_bool_t owe_transition_mode; + dbus_bool_t privacy; unsigned int transition_mode_ssid_len; unsigned char transition_mode_bssid[6]; unsigned char transition_mode_ssid[32]; @@ -1748,12 +1749,20 @@ const char *g_supplicant_network_get_phase2(GSupplicantNetwork *network) unsigned int g_supplicant_network_get_keymgmt(GSupplicantNetwork *network) { - if (network == NULL) + if (!network) return 0; return network->keymgmt; } +dbus_bool_t g_supplicant_network_get_privacy(GSupplicantNetwork *network) +{ + if (!network) + return FALSE; + + return network->privacy; +} + const unsigned char *g_supplicant_network_get_countrycode(GSupplicantNetwork *network) { @@ -1930,8 +1939,7 @@ bool g_supplicant_network_get_rsn_mode(GSupplicantNetwork *network) if (network == NULL || network->best_bss == NULL) return 0; - if (network->best_bss->security == G_SUPPLICANT_SECURITY_SAE || - network->best_bss->security == G_SUPPLICANT_SECURITY_OWE || + if (network->best_bss->security == G_SUPPLICANT_SECURITY_OWE || network->best_bss->security == G_SUPPLICANT_SECURITY_DPP) return false; @@ -2642,6 +2650,7 @@ static int add_or_replace_bss_to_network(struct g_supplicant_bss *bss) #if defined TIZEN_EXT network->owe_transition_mode = bss->owe_transition_mode; + network->privacy = bss->privacy; memcpy(network->transition_mode_ssid, bss->transition_mode_ssid, bss->transition_mode_ssid_len); memcpy(network->transition_mode_bssid, bss->transition_mode_bssid, WIFI_BSSID_LEN_MAX); diff --git a/include/network.h b/include/network.h index c5b10552..45486996 100755 --- a/include/network.h +++ b/include/network.h @@ -203,6 +203,10 @@ unsigned int connman_network_get_maxrate(struct connman_network *network); int connman_network_get_maxspeed(struct connman_network *network); +int connman_network_set_sec_list(struct connman_network *network, + GSList *sec_list); +void *connman_network_get_sec_list(struct connman_network *network); + int connman_network_set_enc_mode(struct connman_network *network, const char *encryption_mode); const char *connman_network_get_enc_mode(struct connman_network *network); diff --git a/plugins/wifi.c b/plugins/wifi.c index 96c84b13..53bcc8b7 100755 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -4908,6 +4908,59 @@ static void mesh_peer_removed(GSupplicantNetwork *supplicant_network) } #endif + +#if defined TIZEN_EXT +static GSList *get_supported_security_list(unsigned int keymgmt, + bool owe_transition_mode, + GSupplicantNetwork *supplicant_network) +{ + GSList *sec_list = NULL; + dbus_bool_t privacy = g_supplicant_network_get_privacy(supplicant_network); + const char *enc_mode = g_supplicant_network_get_enc_mode(supplicant_network); + + if (keymgmt & + (G_SUPPLICANT_KEYMGMT_WPA_EAP | + G_SUPPLICANT_KEYMGMT_WPA_EAP_256)) + sec_list = g_slist_prepend (sec_list, "ieee8021x"); + else if (keymgmt & G_SUPPLICANT_KEYMGMT_WPA_FT_EAP) + sec_list = g_slist_prepend (sec_list, "ft_ieee8021x"); + + if (sec_list) + return sec_list; + + if (keymgmt & + (G_SUPPLICANT_KEYMGMT_WPA_PSK | + G_SUPPLICANT_KEYMGMT_WPA_PSK_256)) { + if (!g_strcmp0(enc_mode, "aes")) + sec_list = g_slist_prepend (sec_list, "rsn"); + else if (!g_strcmp0(enc_mode, "tkip")) + sec_list = g_slist_prepend (sec_list, "psk"); + else if (!g_strcmp0(enc_mode, "mixed")) { + sec_list = g_slist_prepend (sec_list, "psk"); + sec_list = g_slist_prepend (sec_list, "rsn"); + } + } else if (keymgmt & G_SUPPLICANT_KEYMGMT_WPA_FT_PSK) + sec_list = g_slist_prepend (sec_list, "ft_psk"); + + if (keymgmt & G_SUPPLICANT_KEYMGMT_SAE) + sec_list = g_slist_prepend (sec_list, "sae"); + if (keymgmt & G_SUPPLICANT_KEYMGMT_OWE || owe_transition_mode) + sec_list = g_slist_prepend (sec_list, "owe"); + if (keymgmt & G_SUPPLICANT_KEYMGMT_DPP) + sec_list = g_slist_prepend (sec_list, "dpp"); + + if (sec_list) + return sec_list; + + if (privacy) + sec_list = g_slist_prepend (sec_list, "wep"); + else + sec_list = g_slist_prepend (sec_list, "none"); + + return sec_list; +} +#endif + static void network_added(GSupplicantNetwork *supplicant_network) { struct connman_network *network; @@ -4926,7 +4979,9 @@ static void network_added(GSupplicantNetwork *supplicant_network) const unsigned char *transition_mode_ssid; const unsigned char *transition_mode_bssid; unsigned int transition_mode_ssid_len; + unsigned int keymgmt; GSList *vsie_list = NULL; + GSList *sec_list = NULL; const unsigned char *country_code; ieee80211_modes_e phy_mode; #endif @@ -5030,6 +5085,7 @@ static void network_added(GSupplicantNetwork *supplicant_network) g_supplicant_network_get_frequency(supplicant_network)); #if defined TIZEN_EXT + keymgmt = g_supplicant_network_get_keymgmt(supplicant_network); connman_network_set_bssid(network, g_supplicant_network_get_bssid(supplicant_network)); owe_transition_mode = (bool)g_supplicant_network_get_transition_mode(supplicant_network); @@ -5041,14 +5097,18 @@ static void network_added(GSupplicantNetwork *supplicant_network) transition_mode_bssid = g_supplicant_network_get_transition_mode_bssid(supplicant_network); connman_network_set_transition_mode_bssid(network, transition_mode_bssid); } + + sec_list = get_supported_security_list(keymgmt, + owe_transition_mode, supplicant_network); + + connman_network_set_sec_list(network, sec_list); connman_network_set_maxrate(network, g_supplicant_network_get_maxrate(supplicant_network)); connman_network_set_enc_mode(network, g_supplicant_network_get_enc_mode(supplicant_network)); connman_network_set_rsn_mode(network, g_supplicant_network_get_rsn_mode(supplicant_network)); - connman_network_set_keymgmt(network, - g_supplicant_network_get_keymgmt(supplicant_network)); + connman_network_set_keymgmt(network, keymgmt); connman_network_set_bool(network, "WiFi.HS20AP", g_supplicant_network_is_hs20AP(supplicant_network)); connman_network_set_bssid_list(network, diff --git a/src/network.c b/src/network.c index 845fa008..d72d40a0 100755 --- a/src/network.c +++ b/src/network.c @@ -131,6 +131,7 @@ struct connman_network { char *phase1; unsigned char country_code[WIFI_COUNTRY_CODE_LEN]; GSList *bssid_list; + GSList *sec_list; ieee80211_modes_e phy_mode; connection_mode_e connection_mode; char *connector; @@ -2415,6 +2416,20 @@ int connman_network_get_maxspeed(struct connman_network *network) return 0; } +int connman_network_set_sec_list(struct connman_network *network, + GSList *sec_list) +{ + g_slist_free(network->wifi.sec_list); + network->wifi.sec_list = sec_list; + + return 0; +} + +void *connman_network_get_sec_list(struct connman_network *network) +{ + return network->wifi.sec_list; +} + int connman_network_set_maxrate(struct connman_network *network, unsigned int maxrate) { diff --git a/src/service.c b/src/service.c index 9dfc6754..175f39d9 100755 --- a/src/service.c +++ b/src/service.c @@ -4253,6 +4253,22 @@ int connman_service_iterate_services(connman_service_iterate_cb cb, } #if defined TIZEN_EXT +static void append_security_list(DBusMessageIter *iter, void *user_data) +{ + GSList *sec_list = (GSList *)user_data; + const char *sec_str; + + if (sec_list) { + GSList *list; + for (list = sec_list; list; list = list->next) { + sec_str = (const char *)list->data; + + dbus_message_iter_append_basic(iter, + DBUS_TYPE_STRING, &sec_str); + } + } +} + static void append_wifi_ext_info(DBusMessageIter *dict, struct connman_network *network) { @@ -4272,6 +4288,7 @@ static void append_wifi_ext_info(DBusMessageIter *dict, char *country_code_str = country_code_buff; unsigned char *country_code; uint16_t connection_mode; + GSList *sec_list = NULL; ssid = connman_network_get_blob(network, "WiFi.SSID", &ssid_len); bssid = connman_network_get_bssid(network); @@ -4283,12 +4300,16 @@ static void append_wifi_ext_info(DBusMessageIter *dict, keymgmt = connman_network_get_keymgmt(network); country_code = connman_network_get_countrycode(network); connection_mode = connman_network_get_connection_mode(network); + sec_list = (GSList *)connman_network_get_sec_list(network); snprintf(bssid_str, WIFI_BSSID_STR_LEN, MACSTR, MAC2STR(bssid)); snprintf(country_code_str, (WIFI_COUNTRY_CODE_LEN + 1), "%c%c", country_code[0], country_code[1]); + connman_dbus_dict_append_array(dict, "SecurityList", + DBUS_TYPE_STRING, + append_security_list, sec_list); connman_dbus_dict_append_fixed_array(dict, "SSID", DBUS_TYPE_BYTE, &ssid, ssid_len); |