From bfe522304da217296e2a61040f58e35ec5d6f3f2 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Mon, 16 Aug 2021 09:51:46 +0200 Subject: New upstream version 1.30.6 --- src/core/supplicant/nm-supplicant-config.c | 5 ++++ src/core/supplicant/nm-supplicant-interface.c | 28 ++++++++++++++++++++--- src/core/supplicant/nm-supplicant-manager.c | 33 ++++++++------------------- src/core/supplicant/nm-supplicant-types.h | 15 ++++++++++++ 4 files changed, 55 insertions(+), 26 deletions(-) (limited to 'src/core/supplicant') diff --git a/src/core/supplicant/nm-supplicant-config.c b/src/core/supplicant/nm-supplicant-config.c index eab494b0..bc2a692e 100644 --- a/src/core/supplicant/nm-supplicant-config.c +++ b/src/core/supplicant/nm-supplicant-config.c @@ -841,6 +841,11 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * g_string_append(key_mgmt_conf, " wpa-psk-sha256"); if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) g_string_append(key_mgmt_conf, " ft-psk"); + if (_get_capability(priv, NM_SUPPL_CAP_TYPE_SAE)) { + g_string_append(key_mgmt_conf, " sae"); + if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) + g_string_append(key_mgmt_conf, " ft-sae"); + } } else if (nm_streq(key_mgmt, "wpa-eap")) { if (_get_capability(priv, NM_SUPPL_CAP_TYPE_PMF)) { g_string_append(key_mgmt_conf, " wpa-eap-sha256"); diff --git a/src/core/supplicant/nm-supplicant-interface.c b/src/core/supplicant/nm-supplicant-interface.c index 6d9c604f..a38ebf18 100644 --- a/src/core/supplicant/nm-supplicant-interface.c +++ b/src/core/supplicant/nm-supplicant-interface.c @@ -586,7 +586,7 @@ _bss_info_properties_changed(NMSupplicantInterface *self, if (v_v) { if (g_variant_lookup(v_v, "Type", "&s", &v_s)) { f = NM_802_11_AP_FLAGS_WPS; - if (nm_streq(v_s, "pcb")) + if (nm_streq(v_s, "pbc")) f |= NM_802_11_AP_FLAGS_WPS_PBC; else if (nm_streq(v_s, "pin")) f |= NM_802_11_AP_FLAGS_WPS_PIN; @@ -1171,19 +1171,24 @@ parse_capabilities(NMSupplicantInterface *self, GVariant *capabilities) const gboolean old_prop_scan_ssid = priv->prop_scan_ssid; const guint32 old_max_scan_ssids = priv->max_scan_ssids; gboolean have_ft = FALSE; + gboolean have_sae = FALSE; gint32 max_scan_ssids; const char ** array; nm_assert(capabilities && g_variant_is_of_type(capabilities, G_VARIANT_TYPE_VARDICT)); if (g_variant_lookup(capabilities, "KeyMgmt", "^a&s", &array)) { - have_ft = g_strv_contains(array, "wpa-ft-psk"); + have_ft = g_strv_contains(array, "wpa-ft-psk"); + have_sae = g_strv_contains(array, "sae"); g_free(array); } priv->iface_capabilities = NM_SUPPL_CAP_MASK_SET(priv->iface_capabilities, NM_SUPPL_CAP_TYPE_FT, have_ft ? NM_TERNARY_TRUE : NM_TERNARY_FALSE); + priv->iface_capabilities = NM_SUPPL_CAP_MASK_SET(priv->iface_capabilities, + NM_SUPPL_CAP_TYPE_SAE, + have_sae ? NM_TERNARY_TRUE : NM_TERNARY_FALSE); if (g_variant_lookup(capabilities, "Modes", "^a&s", &array)) { /* Setting p2p_capable might toggle _prop_p2p_available_get(). However, @@ -1255,6 +1260,15 @@ _starting_check_ready(NMSupplicantInterface *self) return; } + _LOGD("interface supported features:" + " AP%c" + " FT%c" + " SAE%c" + "", + NM_SUPPL_CAP_TO_CHAR(priv->iface_capabilities, NM_SUPPL_CAP_TYPE_AP), + NM_SUPPL_CAP_TO_CHAR(priv->iface_capabilities, NM_SUPPL_CAP_TYPE_FT), + NM_SUPPL_CAP_TO_CHAR(priv->iface_capabilities, NM_SUPPL_CAP_TYPE_SAE)); + set_state(self, priv->supp_state); } @@ -1278,6 +1292,10 @@ _get_capability(NMSupplicantInterfacePrivate *priv, NMSupplCapType type) value = iface_value; } break; + case NM_SUPPL_CAP_TYPE_SAE: + nm_assert(NM_SUPPL_CAP_MASK_GET(priv->global_capabilities, type) == NM_TERNARY_DEFAULT); + value = NM_SUPPL_CAP_MASK_GET(priv->iface_capabilities, type); + break; default: nm_assert(NM_SUPPL_CAP_MASK_GET(priv->iface_capabilities, type) == NM_TERNARY_DEFAULT); value = NM_SUPPL_CAP_MASK_GET(priv->global_capabilities, type); @@ -1305,9 +1323,13 @@ nm_supplicant_interface_get_capabilities(NMSupplicantInterface *self) caps = NM_SUPPL_CAP_MASK_SET(caps, NM_SUPPL_CAP_TYPE_FT, _get_capability(priv, NM_SUPPL_CAP_TYPE_FT)); + caps = NM_SUPPL_CAP_MASK_SET(caps, + NM_SUPPL_CAP_TYPE_SAE, + _get_capability(priv, NM_SUPPL_CAP_TYPE_SAE)); nm_assert(!NM_FLAGS_ANY(priv->iface_capabilities, - ~(NM_SUPPL_CAP_MASK_T_AP_MASK | NM_SUPPL_CAP_MASK_T_FT_MASK))); + ~(NM_SUPPL_CAP_MASK_T_AP_MASK | NM_SUPPL_CAP_MASK_T_FT_MASK + | NM_SUPPL_CAP_MASK_T_SAE_MASK))); #if NM_MORE_ASSERTS > 10 { diff --git a/src/core/supplicant/nm-supplicant-manager.c b/src/core/supplicant/nm-supplicant-manager.c index 32554187..7cf1a2bb 100644 --- a/src/core/supplicant/nm-supplicant-manager.c +++ b/src/core/supplicant/nm-supplicant-manager.c @@ -168,19 +168,6 @@ _caps_set(NMSupplicantManagerPrivate *priv, NMSupplCapType type, NMTernary value priv->capabilities = NM_SUPPL_CAP_MASK_SET(priv->capabilities, type, value); } -static char -_caps_to_char(NMSupplicantManagerPrivate *priv, NMSupplCapType type) -{ - NMTernary val; - - val = NM_SUPPL_CAP_MASK_GET(priv->capabilities, type); - if (val == NM_TERNARY_TRUE) - return '+'; - if (val == NM_TERNARY_FALSE) - return '-'; - return '?'; -} - /*****************************************************************************/ static void @@ -395,7 +382,7 @@ _create_iface_complete(NMSupplMgrCreateIfaceHandle *handle, nm_clear_g_cancellable(&handle->cancellable); nm_ref_string_unref(handle->name_owner); - nm_g_slice_free_fcn(handle); + nm_g_slice_free(handle); } static void @@ -1008,15 +995,15 @@ _dbus_get_capabilities_cb(GVariant *res, GError *error, gpointer user_data) " FAST%c" " WFD%c" "", - _caps_to_char(priv, NM_SUPPL_CAP_TYPE_AP), - _caps_to_char(priv, NM_SUPPL_CAP_TYPE_PMF), - _caps_to_char(priv, NM_SUPPL_CAP_TYPE_FILS), - _caps_to_char(priv, NM_SUPPL_CAP_TYPE_P2P), - _caps_to_char(priv, NM_SUPPL_CAP_TYPE_FT), - _caps_to_char(priv, NM_SUPPL_CAP_TYPE_SHA384), - _caps_to_char(priv, NM_SUPPL_CAP_TYPE_MESH), - _caps_to_char(priv, NM_SUPPL_CAP_TYPE_FAST), - _caps_to_char(priv, NM_SUPPL_CAP_TYPE_WFD)); + NM_SUPPL_CAP_TO_CHAR(priv->capabilities, NM_SUPPL_CAP_TYPE_AP), + NM_SUPPL_CAP_TO_CHAR(priv->capabilities, NM_SUPPL_CAP_TYPE_PMF), + NM_SUPPL_CAP_TO_CHAR(priv->capabilities, NM_SUPPL_CAP_TYPE_FILS), + NM_SUPPL_CAP_TO_CHAR(priv->capabilities, NM_SUPPL_CAP_TYPE_P2P), + NM_SUPPL_CAP_TO_CHAR(priv->capabilities, NM_SUPPL_CAP_TYPE_FT), + NM_SUPPL_CAP_TO_CHAR(priv->capabilities, NM_SUPPL_CAP_TYPE_SHA384), + NM_SUPPL_CAP_TO_CHAR(priv->capabilities, NM_SUPPL_CAP_TYPE_MESH), + NM_SUPPL_CAP_TO_CHAR(priv->capabilities, NM_SUPPL_CAP_TYPE_FAST), + NM_SUPPL_CAP_TO_CHAR(priv->capabilities, NM_SUPPL_CAP_TYPE_WFD)); nm_assert(g_hash_table_size(priv->supp_ifaces) == 0); nm_assert(c_list_is_empty(&priv->supp_lst_head)); diff --git a/src/core/supplicant/nm-supplicant-types.h b/src/core/supplicant/nm-supplicant-types.h index adcf02db..ae2db3f6 100644 --- a/src/core/supplicant/nm-supplicant-types.h +++ b/src/core/supplicant/nm-supplicant-types.h @@ -41,6 +41,7 @@ typedef enum { NM_SUPPL_CAP_TYPE_FILS, NM_SUPPL_CAP_TYPE_P2P, NM_SUPPL_CAP_TYPE_FT, + NM_SUPPL_CAP_TYPE_SAE, NM_SUPPL_CAP_TYPE_SHA384, NM_SUPPL_CAP_TYPE_MESH, NM_SUPPL_CAP_TYPE_FAST, @@ -71,6 +72,7 @@ typedef enum { _NM_SUPPL_CAP_MASK_DEFINE(MESH), _NM_SUPPL_CAP_MASK_DEFINE(WFD), _NM_SUPPL_CAP_MASK_DEFINE(FT), + _NM_SUPPL_CAP_MASK_DEFINE(SAE), _NM_SUPPL_CAP_MASK_DEFINE(SHA384), #undef _NM_SUPPL_CAP_MASK_DEFINE } NMSupplCapMask; @@ -114,6 +116,19 @@ NM_SUPPL_CAP_MASK_GET(NMSupplCapMask features, NMSupplCapType type) return (NMTernary)(f - 1); } +static inline char +NM_SUPPL_CAP_TO_CHAR(NMSupplCapMask features, NMSupplCapType type) +{ + NMTernary val; + + val = NM_SUPPL_CAP_MASK_GET(features, type); + if (val == NM_TERNARY_TRUE) + return '+'; + if (val == NM_TERNARY_FALSE) + return '-'; + return '?'; +} + /*****************************************************************************/ /** -- cgit 1.3.0-6-gf8a5 From e74c568b07b50b97873fb4ee1d776dedefbd54d6 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Fri, 1 Oct 2021 23:05:04 +0200 Subject: New upstream version 1.32.12 --- src/core/supplicant/nm-supplicant-config.c | 173 +++++++++++++-------- src/core/supplicant/nm-supplicant-interface.c | 172 ++++++++++++-------- src/core/supplicant/nm-supplicant-manager.c | 8 +- .../supplicant/nm-supplicant-settings-verify.c | 1 + src/core/supplicant/nm-supplicant-types.h | 11 +- src/core/supplicant/tests/test-supplicant-config.c | 39 ++++- 6 files changed, 257 insertions(+), 147 deletions(-) (limited to 'src/core/supplicant') diff --git a/src/core/supplicant/nm-supplicant-config.c b/src/core/supplicant/nm-supplicant-config.c index bc2a692e..1959a161 100644 --- a/src/core/supplicant/nm-supplicant-config.c +++ b/src/core/supplicant/nm-supplicant-config.c @@ -10,11 +10,11 @@ #include -#include "nm-glib-aux/nm-str-buf.h" -#include "nm-core-internal.h" +#include "libnm-glib-aux/nm-str-buf.h" +#include "libnm-core-intern/nm-core-internal.h" #include "nm-supplicant-settings-verify.h" #include "nm-setting.h" -#include "nm-libnm-core-intern/nm-auth-subject.h" +#include "libnm-core-aux-intern/nm-auth-subject.h" #include "NetworkManagerUtils.h" #include "nm-utils.h" #include "nm-setting-ip4-config.h" @@ -334,11 +334,10 @@ nm_supplicant_config_to_variant(NMSupplicantConfig *self) break; case NM_SUPPL_OPT_TYPE_BYTES: case NM_SUPPL_OPT_TYPE_UTF8: - g_variant_builder_add( - &builder, - "{sv}", - key, - g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, option->value, option->len, 1)); + g_variant_builder_add(&builder, + "{sv}", + key, + nm_g_variant_new_ay((const guint8 *) option->value, option->len)); break; case NM_SUPPL_OPT_TYPE_KEYWORD: case NM_SUPPL_OPT_TYPE_STRING: @@ -667,8 +666,8 @@ add_string_val(NMSupplicantConfig *self, display_value, \ error) \ ({ \ - typeof(*(setting)) *_setting = (setting); \ - gboolean _success = TRUE; \ + typeof(setting) _setting = (setting); \ + gboolean _success = TRUE; \ \ if (nm_setting_##setting_name##_get_num_##field_plural(_setting)) { \ const char _separator = (separator); \ @@ -815,7 +814,7 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * nm_auto_free_gstring GString *key_mgmt_conf = NULL; const char * key_mgmt, *auth_alg; const char * psk; - gboolean set_pmf; + gboolean set_pmf, wps_disabled; g_return_val_if_fail(NM_IS_SUPPLICANT_CONFIG(self), FALSE); g_return_val_if_fail(setting != NULL, FALSE); @@ -835,58 +834,82 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * } key_mgmt = nm_setting_wireless_security_get_key_mgmt(setting); - key_mgmt_conf = g_string_new(key_mgmt); - if (nm_streq(key_mgmt, "wpa-psk")) { + key_mgmt_conf = g_string_new(""); + + if (nm_streq(key_mgmt, "none")) { + g_string_append(key_mgmt_conf, "NONE"); + + } else if (nm_streq(key_mgmt, "ieee8021x")) { + g_string_append(key_mgmt_conf, "IEEE8021X"); + + } else if (nm_streq(key_mgmt, "owe")) { + pmf = NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED; + + g_string_append(key_mgmt_conf, "OWE"); + + } else if (nm_streq(key_mgmt, "wpa-psk")) { + if (pmf != NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED) + g_string_append(key_mgmt_conf, "WPA-PSK"); if (_get_capability(priv, NM_SUPPL_CAP_TYPE_PMF)) - g_string_append(key_mgmt_conf, " wpa-psk-sha256"); + g_string_append(key_mgmt_conf, " WPA-PSK-SHA256"); if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) - g_string_append(key_mgmt_conf, " ft-psk"); + g_string_append(key_mgmt_conf, " FT-PSK"); if (_get_capability(priv, NM_SUPPL_CAP_TYPE_SAE)) { - g_string_append(key_mgmt_conf, " sae"); + g_string_append(key_mgmt_conf, " SAE"); if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) - g_string_append(key_mgmt_conf, " ft-sae"); + g_string_append(key_mgmt_conf, " FT-SAE"); } + + } else if (nm_streq(key_mgmt, "sae")) { + pmf = NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED; + + g_string_append(key_mgmt_conf, "SAE"); + if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) + g_string_append(key_mgmt_conf, " FT-SAE"); + } else if (nm_streq(key_mgmt, "wpa-eap")) { + if (pmf != NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED) + g_string_append(key_mgmt_conf, "WPA-EAP"); + if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) { + g_string_append(key_mgmt_conf, " FT-EAP"); + if (_get_capability(priv, NM_SUPPL_CAP_TYPE_SHA384)) + g_string_append(key_mgmt_conf, " FT-EAP-SHA384"); + } if (_get_capability(priv, NM_SUPPL_CAP_TYPE_PMF)) { - g_string_append(key_mgmt_conf, " wpa-eap-sha256"); - + g_string_append(key_mgmt_conf, " WPA-EAP-SHA256"); if (_get_capability(priv, NM_SUPPL_CAP_TYPE_SUITEB192) && pmf == NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED) - g_string_append(key_mgmt_conf, " wpa-eap-suite-b-192"); + g_string_append(key_mgmt_conf, " WPA-EAP-SUITE-B-192"); } - if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) - g_string_append(key_mgmt_conf, " ft-eap"); - if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT) - && _get_capability(priv, NM_SUPPL_CAP_TYPE_SHA384)) - g_string_append(key_mgmt_conf, " ft-eap-sha384"); + switch (fils) { case NM_SETTING_WIRELESS_SECURITY_FILS_REQUIRED: g_string_truncate(key_mgmt_conf, 0); if (!_get_capability(priv, NM_SUPPL_CAP_TYPE_PMF)) - g_string_assign(key_mgmt_conf, "fils-sha256 fils-sha384"); + g_string_assign(key_mgmt_conf, "FILS-SHA256 FILS-SHA384"); /* fall-through */ case NM_SETTING_WIRELESS_SECURITY_FILS_OPTIONAL: - if (_get_capability(priv, NM_SUPPL_CAP_TYPE_PMF)) - g_string_append(key_mgmt_conf, " fils-sha256 fils-sha384"); - if (_get_capability(priv, NM_SUPPL_CAP_TYPE_PMF) - && _get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) - g_string_append(key_mgmt_conf, " ft-fils-sha256"); - if (_get_capability(priv, NM_SUPPL_CAP_TYPE_PMF) - && _get_capability(priv, NM_SUPPL_CAP_TYPE_FT) - && _get_capability(priv, NM_SUPPL_CAP_TYPE_SHA384)) - g_string_append(key_mgmt_conf, " ft-fils-sha384"); + if (_get_capability(priv, NM_SUPPL_CAP_TYPE_PMF)) { + g_string_append(key_mgmt_conf, " FILS-SHA256 FILS-SHA384"); + if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) { + g_string_append(key_mgmt_conf, " FT-FILS-SHA256"); + if (_get_capability(priv, NM_SUPPL_CAP_TYPE_SHA384)) + g_string_append(key_mgmt_conf, " FT-FILS-SHA384"); + } + } break; + default: break; } - } else if (nm_streq(key_mgmt, "sae")) { - if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) - g_string_append(key_mgmt_conf, " ft-sae"); + } else if (nm_streq(key_mgmt, "wpa-eap-suite-b-192")) { pmf = NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED; - if (!nm_supplicant_config_add_option(self, "pairwise", "GCMP-256", -1, NULL, error) - || !nm_supplicant_config_add_option(self, "group", "GCMP-256", -1, NULL, error)) - return FALSE; + + g_string_append(key_mgmt_conf, "WPA-EAP-SUITE-B-192"); + if (_get_capability(priv, NM_SUPPL_CAP_TYPE_FT) + && _get_capability(priv, NM_SUPPL_CAP_TYPE_SHA384)) + g_string_append(key_mgmt_conf, " FT-EAP-SHA384"); } if (!add_string_val(self, key_mgmt_conf->str, "key_mgmt", TRUE, NULL, error)) @@ -955,10 +978,6 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * } } - /* Don't try to enable PMF on non-WPA/SAE/OWE networks */ - if (!NM_IN_STRSET(key_mgmt, "wpa-eap", "wpa-eap-suite-b-192", "wpa-psk", "sae", "owe")) - pmf = NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE; - /* Check if we actually support PMF */ set_pmf = TRUE; if (!_get_capability(priv, NM_SUPPL_CAP_TYPE_PMF)) { @@ -973,7 +992,7 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * } /* Only WPA-specific things when using WPA */ - if (NM_IN_STRSET(key_mgmt, "wpa-psk", "wpa-eap", "sae", "owe")) { + if (NM_IN_STRSET(key_mgmt, "owe", "wpa-psk", "sae", "wpa-eap", "wpa-eap-suite-b-192")) { if (!ADD_STRING_LIST_VAL(self, setting, wireless_security, @@ -985,29 +1004,40 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * NULL, error)) return FALSE; - if (!ADD_STRING_LIST_VAL(self, - setting, - wireless_security, - pairwise, - pairwise, - "pairwise", - ' ', - TRUE, - NULL, - error)) - return FALSE; - if (!ADD_STRING_LIST_VAL(self, - setting, - wireless_security, - group, - groups, - "group", - ' ', - TRUE, - NULL, - error)) - return FALSE; + if (nm_streq(key_mgmt, "wpa-eap-suite-b-192")) { + if (!nm_supplicant_config_add_option(self, "pairwise", "GCMP-256", -1, NULL, error)) + return FALSE; + if (!nm_supplicant_config_add_option(self, "group", "GCMP-256", -1, NULL, error)) + return FALSE; + } else { + if (!ADD_STRING_LIST_VAL(self, + setting, + wireless_security, + pairwise, + pairwise, + "pairwise", + ' ', + TRUE, + NULL, + error)) + return FALSE; + if (!ADD_STRING_LIST_VAL(self, + setting, + wireless_security, + group, + groups, + "group", + ' ', + TRUE, + NULL, + error)) + return FALSE; + } + + /* We set the supplicants global "pmf" config value to "1" (optional), + * so no need to set it network-specific again if PMF_OPTIONAL is set. + */ if (set_pmf && NM_IN_SET(pmf, NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE, @@ -1107,6 +1137,13 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig * } } + wps_disabled = (nm_setting_wireless_security_get_wps_method(setting) + == NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DISABLED); + if (wps_disabled) { + if (!nm_supplicant_config_add_option(self, "wps_disabled", "1", 1, NULL, error)) + return FALSE; + } + return TRUE; } diff --git a/src/core/supplicant/nm-supplicant-interface.c b/src/core/supplicant/nm-supplicant-interface.c index a38ebf18..1556e290 100644 --- a/src/core/supplicant/nm-supplicant-interface.c +++ b/src/core/supplicant/nm-supplicant-interface.c @@ -12,13 +12,13 @@ #include #include "NetworkManagerUtils.h" -#include "nm-core-internal.h" -#include "nm-glib-aux/nm-c-list.h" -#include "nm-glib-aux/nm-ref-string.h" -#include "nm-std-aux/nm-dbus-compat.h" +#include "libnm-core-intern/nm-core-internal.h" +#include "libnm-glib-aux/nm-c-list.h" +#include "libnm-glib-aux/nm-ref-string.h" +#include "libnm-glib-aux/nm-dbus-aux.h" +#include "libnm-std-aux/nm-dbus-compat.h" #include "nm-supplicant-config.h" #include "nm-supplicant-manager.h" -#include "shared/nm-glib-aux/nm-dbus-aux.h" #define DBUS_TIMEOUT_MSEC 20000 @@ -267,30 +267,41 @@ security_from_vardict(GVariant *security) NM80211ApSecurityFlags flags = NM_802_11_AP_SEC_NONE; const char ** array; const char * tmp; + gsize i; + const char * v; nm_assert(g_variant_is_of_type(security, G_VARIANT_TYPE_VARDICT)); if (g_variant_lookup(security, "KeyMgmt", "^a&s", &array)) { - if (g_strv_contains(array, "wpa-psk") || g_strv_contains(array, "wpa-ft-psk")) - flags |= NM_802_11_AP_SEC_KEY_MGMT_PSK; - if (g_strv_contains(array, "wpa-eap") || g_strv_contains(array, "wpa-ft-eap") - || g_strv_contains(array, "wpa-fils-sha256") - || g_strv_contains(array, "wpa-fils-sha384")) - flags |= NM_802_11_AP_SEC_KEY_MGMT_802_1X; - if (g_strv_contains(array, "sae")) - flags |= NM_802_11_AP_SEC_KEY_MGMT_SAE; - if (g_strv_contains(array, "owe")) - flags |= NM_802_11_AP_SEC_KEY_MGMT_OWE; - if (g_strv_contains(array, "wpa-eap-suite-b-192")) - flags |= NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192; + for (i = 0; (v = array[i]); i++) { + if (NM_IN_STRSET(v, "wpa-psk", "wpa-psk-sha256", "wpa-ft-psk")) + flags |= NM_802_11_AP_SEC_KEY_MGMT_PSK; + else if (NM_IN_STRSET(v, + "wpa-eap", + "wpa-eap-sha256", + "wpa-ft-eap", + "wpa-fils-sha256", + "wpa-fils-sha384", + "wpa-fils-ft-sha256", + "wpa-fils-ft-sha384")) + flags |= NM_802_11_AP_SEC_KEY_MGMT_802_1X; + else if (NM_IN_STRSET(v, "sae", "ft-sae")) + flags |= NM_802_11_AP_SEC_KEY_MGMT_SAE; + else if (NM_IN_STRSET(v, "owe")) + flags |= NM_802_11_AP_SEC_KEY_MGMT_OWE; + else if (NM_IN_STRSET(v, "wpa-eap-suite-b-192", "wpa-ft-eap-sha384")) + flags |= NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192; + } g_free(array); } if (g_variant_lookup(security, "Pairwise", "^a&s", &array)) { - if (g_strv_contains(array, "tkip")) - flags |= NM_802_11_AP_SEC_PAIR_TKIP; - if (g_strv_contains(array, "ccmp")) - flags |= NM_802_11_AP_SEC_PAIR_CCMP; + for (i = 0; (v = array[i]); i++) { + if (NM_IN_STRSET(v, "tkip")) + flags |= NM_802_11_AP_SEC_PAIR_TKIP; + else if (NM_IN_STRSET(v, "ccmp")) + flags |= NM_802_11_AP_SEC_PAIR_CCMP; + } g_free(array); } @@ -359,8 +370,12 @@ _dbus_connection_call_simple_cb(GObject *source, GAsyncResult *result, gpointer gs_free_error GError *error = NULL; const char * log_reason; gs_free char * remote_error = NULL; + gpointer p_suppress_warning; + gboolean suppress_warning; + + nm_utils_user_data_unpack(user_data, &self, &log_reason, &p_suppress_warning); - nm_utils_user_data_unpack(user_data, &self, &log_reason); + suppress_warning = GPOINTER_TO_INT(p_suppress_warning); res = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), result, &error); if (nm_utils_error_is_cancelled(error)) @@ -371,37 +386,70 @@ _dbus_connection_call_simple_cb(GObject *source, GAsyncResult *result, gpointer return; } - remote_error = g_dbus_error_get_remote_error(error); - if (!nm_streq0(remote_error, "fi.w1.wpa_supplicant1.NotConnected")) { - g_dbus_error_strip_remote_error(error); - _LOGW("call-%s: failed with %s", log_reason, error->message); - return; + if (!suppress_warning) { + remote_error = g_dbus_error_get_remote_error(error); + if (!nm_streq0(remote_error, "fi.w1.wpa_supplicant1.NotConnected")) { + g_dbus_error_strip_remote_error(error); + _LOGW("call-%s: failed with %s", log_reason, error->message); + return; + } } _LOGT("call-%s: failed with %s", log_reason, error->message); } static void -_dbus_connection_call_simple(NMSupplicantInterface *self, - const char * interface_name, - const char * method_name, - GVariant * parameters, - const GVariantType * reply_type, - const char * log_reason) +_dbus_connection_call_simple_full_impl(NMSupplicantInterface *self, + const char * interface_name, + const char * method_name, + GVariant * parameters, + const GVariantType * reply_type, + const char * log_reason, + gboolean suppress_warning) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); - _dbus_connection_call(self, - interface_name, - method_name, - parameters, - reply_type, - G_DBUS_CALL_FLAGS_NONE, - DBUS_TIMEOUT_MSEC, - priv->main_cancellable, - _dbus_connection_call_simple_cb, - nm_utils_user_data_pack(self, log_reason)); -} + _dbus_connection_call( + self, + interface_name, + method_name, + parameters, + reply_type, + G_DBUS_CALL_FLAGS_NONE, + DBUS_TIMEOUT_MSEC, + priv->main_cancellable, + _dbus_connection_call_simple_cb, + nm_utils_user_data_pack(self, log_reason, GINT_TO_POINTER(suppress_warning))); +} + +#define _dbus_connection_call_simple_full(self, \ + interface_name, \ + method_name, \ + parameters, \ + reply_type, \ + log_reason, \ + suppress_warning) \ + _dbus_connection_call_simple_full_impl((self), \ + (interface_name), \ + (method_name), \ + (parameters), \ + (reply_type), \ + "" log_reason "", \ + (suppress_warning)) + +#define _dbus_connection_call_simple(self, \ + interface_name, \ + method_name, \ + parameters, \ + reply_type, \ + log_reason) \ + _dbus_connection_call_simple_full_impl((self), \ + (interface_name), \ + (method_name), \ + (parameters), \ + (reply_type), \ + "" log_reason "", \ + FALSE) /*****************************************************************************/ @@ -557,7 +605,7 @@ _bss_info_properties_changed(NMSupplicantInterface *self, guint16 v_u16; guint32 v_u32; NM80211ApFlags p_ap_flags; - NM80211Mode p_mode; + _NM80211Mode p_mode; guint8 p_signal_percent; const guint8 * arr_data; gsize arr_len; @@ -605,15 +653,15 @@ _bss_info_properties_changed(NMSupplicantInterface *self, if (nm_g_variant_lookup(properties, "Mode", "&s", &v_s)) { if (nm_streq(v_s, "infrastructure")) - p_mode = NM_802_11_MODE_INFRA; + p_mode = _NM_802_11_MODE_INFRA; else if (nm_streq(v_s, "ad-hoc")) - p_mode = NM_802_11_MODE_ADHOC; + p_mode = _NM_802_11_MODE_ADHOC; else if (nm_streq(v_s, "mesh")) - p_mode = NM_802_11_MODE_MESH; + p_mode = _NM_802_11_MODE_MESH; else - p_mode = NM_802_11_MODE_UNKNOWN; + p_mode = _NM_802_11_MODE_UNKNOWN; } else if (initial) - p_mode = NM_802_11_MODE_UNKNOWN; + p_mode = _NM_802_11_MODE_UNKNOWN; else p_mode = bss_info->mode; if (bss_info->mode != p_mode) { @@ -1619,11 +1667,10 @@ _wps_handle_set_pc_cb(GVariant *res, GError *error, gpointer user_data) * enroll with any BSS in range. */ if (!nm_utils_hwaddr_aton(wps_data->bssid, bssid_buf, sizeof(bssid_buf))) nm_assert_not_reached(); - g_variant_builder_add( - &start_args, - "{sv}", - "Bssid", - g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, bssid_buf, ETH_ALEN, sizeof(guint8))); + g_variant_builder_add(&start_args, + "{sv}", + "Bssid", + nm_g_variant_new_ay(bssid_buf, ETH_ALEN)); } wps_data->needs_cancelling = TRUE; @@ -1901,7 +1948,7 @@ _properties_changed_main(NMSupplicantInterface *self, GVariant *properties) if (nm_g_variant_lookup(properties, "CurrentBSS", "&o", &v_s)) { v_s = nm_dbus_path_not_empty(v_s); - if (!nm_ref_string_equals_str(priv->current_bss, v_s)) { + if (!nm_ref_string_equal_str(priv->current_bss, v_s)) { nm_ref_string_unref(priv->current_bss); priv->current_bss = nm_ref_string_new(v_s); do_notify_current_bss = TRUE; @@ -2721,12 +2768,13 @@ nm_supplicant_interface_p2p_cancel_connect(NMSupplicantInterface *self) { g_return_if_fail(NM_IS_SUPPLICANT_INTERFACE(self)); - _dbus_connection_call_simple(self, - NM_WPAS_DBUS_IFACE_INTERFACE_P2P_DEVICE, - "Cancel", - NULL, - G_VARIANT_TYPE("()"), - "p2p-cancel"); + _dbus_connection_call_simple_full(self, + NM_WPAS_DBUS_IFACE_INTERFACE_P2P_DEVICE, + "Cancel", + NULL, + G_VARIANT_TYPE("()"), + "p2p-cancel", + TRUE); } void diff --git a/src/core/supplicant/nm-supplicant-manager.c b/src/core/supplicant/nm-supplicant-manager.c index 7cf1a2bb..e432889b 100644 --- a/src/core/supplicant/nm-supplicant-manager.c +++ b/src/core/supplicant/nm-supplicant-manager.c @@ -8,13 +8,13 @@ #include "nm-supplicant-manager.h" -#include "nm-core-internal.h" +#include "libnm-core-intern/nm-core-internal.h" #include "nm-dbus-manager.h" -#include "nm-glib-aux/nm-dbus-aux.h" -#include "nm-glib-aux/nm-ref-string.h" +#include "libnm-glib-aux/nm-dbus-aux.h" +#include "libnm-glib-aux/nm-ref-string.h" #include "nm-supplicant-interface.h" #include "nm-supplicant-types.h" -#include "platform/nm-platform.h" +#include "libnm-platform/nm-platform.h" /*****************************************************************************/ diff --git a/src/core/supplicant/nm-supplicant-settings-verify.c b/src/core/supplicant/nm-supplicant-settings-verify.c index 3f0a33e0..5e77b207 100644 --- a/src/core/supplicant/nm-supplicant-settings-verify.c +++ b/src/core/supplicant/nm-supplicant-settings-verify.c @@ -144,6 +144,7 @@ static const struct Opt opt_table[] = { OPT_BYTES("wep_key2", 0), OPT_BYTES("wep_key3", 0), OPT_INT("wep_tx_keyidx", 0, 3), + OPT_INT("wps_disabled", 0, 1), }; static gboolean diff --git a/src/core/supplicant/nm-supplicant-types.h b/src/core/supplicant/nm-supplicant-types.h index ae2db3f6..c9b72de1 100644 --- a/src/core/supplicant/nm-supplicant-types.h +++ b/src/core/supplicant/nm-supplicant-types.h @@ -7,6 +7,7 @@ #define __NETWORKMANAGER_SUPPLICANT_TYPES_H__ #include "c-list/src/c-list.h" +#include "libnm-base/nm-base.h" #define NM_WPAS_DBUS_SERVICE "fi.w1.wpa_supplicant1" #define NM_WPAS_DBUS_PATH "/fi/w1/wpa_supplicant1" @@ -50,9 +51,9 @@ typedef enum { _NM_SUPPL_CAP_TYPE_NUM, } NMSupplCapType; -#define NM_SUPPL_CAP_MASK_NO(type) ((NMSupplCapMask)(1llu << ((type) *2u))) -#define NM_SUPPL_CAP_MASK_YES(type) ((NMSupplCapMask)(2llu << ((type) *2u))) -#define NM_SUPPL_CAP_MASK_MASK(type) ((NMSupplCapMask)(3llu << ((type) *2u))) +#define NM_SUPPL_CAP_MASK_NO(type) ((NMSupplCapMask) (1llu << ((type) *2u))) +#define NM_SUPPL_CAP_MASK_YES(type) ((NMSupplCapMask) (2llu << ((type) *2u))) +#define NM_SUPPL_CAP_MASK_MASK(type) ((NMSupplCapMask) (3llu << ((type) *2u))) typedef enum { NM_SUPPL_CAP_MASK_NONE = 0, @@ -113,7 +114,7 @@ NM_SUPPL_CAP_MASK_GET(NMSupplCapMask features, NMSupplCapType type) nm_assert(NM_IN_SET(f, 0, 1, 2)); - return (NMTernary)(f - 1); + return (NMTernary) (f - 1); } static inline char @@ -178,7 +179,7 @@ typedef struct _NMSupplicantBssInfo { NM80211ApFlags ap_flags : 5; - NM80211Mode mode : 4; + _NM80211Mode mode : 4; bool bssid_valid : 1; diff --git a/src/core/supplicant/tests/test-supplicant-config.c b/src/core/supplicant/tests/test-supplicant-config.c index 99729c18..0cf35d0e 100644 --- a/src/core/supplicant/tests/test-supplicant-config.c +++ b/src/core/supplicant/tests/test-supplicant-config.c @@ -14,7 +14,7 @@ #include #include -#include "nm-core-internal.h" +#include "libnm-core-intern/nm-core-internal.h" #include "supplicant/nm-supplicant-config.h" #include "supplicant/nm-supplicant-settings-verify.h" @@ -394,7 +394,17 @@ test_wifi_wpa_psk(const char * detail, NMTST_EXPECT_NM_INFO("Config: added 'scan_ssid' value '1'*"); NMTST_EXPECT_NM_INFO("Config: added 'bssid' value '11:22:33:44:55:66'*"); NMTST_EXPECT_NM_INFO("Config: added 'freq_list' value *"); - NMTST_EXPECT_NM_INFO("Config: added 'key_mgmt' value 'WPA-PSK WPA-PSK-SHA256'"); + switch (pmf) { + case NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE: + case NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL: + NMTST_EXPECT_NM_INFO("Config: added 'key_mgmt' value 'WPA-PSK WPA-PSK-SHA256'"); + break; + case NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED: + NMTST_EXPECT_NM_INFO("Config: added 'key_mgmt' value ' WPA-PSK-SHA256'"); + break; + default: + break; + } NMTST_EXPECT_NM_INFO("Config: added 'psk' value *"); NMTST_EXPECT_NM_INFO("Config: added 'proto' value 'WPA RSN'"); NMTST_EXPECT_NM_INFO("Config: added 'pairwise' value 'TKIP CCMP'"); @@ -421,11 +431,22 @@ test_wifi_wpa_psk(const char * detail, validate_opt(detail, config_dict, "scan_ssid", NM_SUPPL_OPT_TYPE_INT, GINT_TO_POINTER(1)); validate_opt(detail, config_dict, "ssid", NM_SUPPL_OPT_TYPE_BYTES, ssid); validate_opt(detail, config_dict, "bssid", NM_SUPPL_OPT_TYPE_KEYWORD, bssid_str); - validate_opt(detail, - config_dict, - "key_mgmt", - NM_SUPPL_OPT_TYPE_KEYWORD, - "WPA-PSK WPA-PSK-SHA256"); + switch (pmf) { + case NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE: + case NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL: + validate_opt(detail, + config_dict, + "key_mgmt", + NM_SUPPL_OPT_TYPE_KEYWORD, + "WPA-PSK WPA-PSK-SHA256"); + break; + case NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED: + validate_opt(detail, config_dict, "key_mgmt", NM_SUPPL_OPT_TYPE_KEYWORD, " WPA-PSK-SHA256"); + break; + default: + break; + } + validate_opt(detail, config_dict, "proto", NM_SUPPL_OPT_TYPE_KEYWORD, "WPA RSN"); validate_opt(detail, config_dict, "pairwise", NM_SUPPL_OPT_TYPE_KEYWORD, "TKIP CCMP"); validate_opt(detail, config_dict, "group", NM_SUPPL_OPT_TYPE_KEYWORD, "TKIP CCMP"); @@ -483,6 +504,7 @@ test_wifi_sae_psk(const char *psk) NMTST_EXPECT_NM_INFO("Config: added 'proto' value 'RSN'"); NMTST_EXPECT_NM_INFO("Config: added 'pairwise' value 'TKIP CCMP'"); NMTST_EXPECT_NM_INFO("Config: added 'group' value 'TKIP CCMP'"); + NMTST_EXPECT_NM_INFO("Config: added 'ieee80211w' value '2'"); config_dict = build_supplicant_config(connection, 1500, @@ -815,9 +837,10 @@ test_wifi_eap_suite_b_generation(void) NMTST_EXPECT_NM_INFO("Config: added 'scan_ssid' value '1'*"); NMTST_EXPECT_NM_INFO("Config: added 'bssid' value '11:22:33:44:55:66'*"); NMTST_EXPECT_NM_INFO("Config: added 'freq_list' value *"); + NMTST_EXPECT_NM_INFO("Config: added 'key_mgmt' value 'WPA-EAP-SUITE-B-192'"); NMTST_EXPECT_NM_INFO("Config: added 'pairwise' value 'GCMP-256'"); NMTST_EXPECT_NM_INFO("Config: added 'group' value 'GCMP-256'"); - NMTST_EXPECT_NM_INFO("Config: added 'key_mgmt' value 'WPA-EAP-SUITE-B-192'"); + NMTST_EXPECT_NM_INFO("Config: added 'ieee80211w' value '2'"); NMTST_EXPECT_NM_INFO("Config: added 'eap' value 'TLS'"); NMTST_EXPECT_NM_INFO("Config: added 'fragment_size' value '1086'"); NMTST_EXPECT_NM_INFO("Config: added 'ca_cert' value '*/test-ca-cert.pem'"); -- cgit 1.3.0-6-gf8a5 From 88c227d90a6b7b388c5c85d72802a0ca8f05ed5c Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Thu, 13 Jan 2022 22:30:39 +0100 Subject: New upstream version 1.34.0 --- src/core/supplicant/nm-supplicant-config.c | 2 +- src/core/supplicant/nm-supplicant-interface.c | 83 ++++++++++++++++++---- src/core/supplicant/nm-supplicant-interface.h | 4 ++ src/core/supplicant/nm-supplicant-manager.c | 3 +- .../supplicant/nm-supplicant-settings-verify.c | 2 +- src/core/supplicant/nm-supplicant-types.h | 4 +- 6 files changed, 80 insertions(+), 18 deletions(-) (limited to 'src/core/supplicant') diff --git a/src/core/supplicant/nm-supplicant-config.c b/src/core/supplicant/nm-supplicant-config.c index 1959a161..c486ba1d 100644 --- a/src/core/supplicant/nm-supplicant-config.c +++ b/src/core/supplicant/nm-supplicant-config.c @@ -417,7 +417,7 @@ nm_supplicant_config_add_setting_macsec(NMSupplicantConfig *self, port = nm_setting_macsec_get_port(setting); if (port > 0 && port < 65534) { - snprintf(buf, sizeof(buf), "%d", port); + g_snprintf(buf, sizeof(buf), "%d", port); if (!nm_supplicant_config_add_option(self, "macsec_port", buf, -1, NULL, error)) return FALSE; } diff --git a/src/core/supplicant/nm-supplicant-interface.c b/src/core/supplicant/nm-supplicant-interface.c index 1556e290..2d56b836 100644 --- a/src/core/supplicant/nm-supplicant-interface.c +++ b/src/core/supplicant/nm-supplicant-interface.c @@ -115,6 +115,9 @@ typedef struct _NMSupplicantInterfacePrivate { CList peer_lst_head; CList peer_initializing_lst_head; + in_addr_t p2p_assigned_addr; + guint8 p2p_assigned_plen; + gint64 last_scan_msec; NMSupplicantAuthState auth_state; @@ -693,7 +696,7 @@ _bss_info_properties_changed(NMSupplicantInterface *self, } else arr_len = 0; - if (!nm_utils_gbytes_equal_mem(bss_info->ssid, arr_data, arr_len)) { + if (!nm_g_bytes_equal_mem(bss_info->ssid, arr_data, arr_len)) { _nm_unused gs_unref_bytes GBytes *old_free = g_steal_pointer(&bss_info->ssid); bss_info->ssid = (arr_len == 0) ? NULL : g_bytes_new(arr_data, arr_len); @@ -915,23 +918,23 @@ _peer_info_properties_changed(NMSupplicantInterface *self, peer_info->signal_percent = nm_wifi_utils_level_to_quality(v_i32); if (nm_g_variant_lookup(properties, "DeviceName", "&s", &v_s)) - nm_utils_strdup_reset(&peer_info->device_name, v_s); + nm_strdup_reset(&peer_info->device_name, v_s); if (nm_g_variant_lookup(properties, "Manufacturer", "&s", &v_s)) - nm_utils_strdup_reset(&peer_info->manufacturer, v_s); + nm_strdup_reset(&peer_info->manufacturer, v_s); if (nm_g_variant_lookup(properties, "Model", "&s", &v_s)) - nm_utils_strdup_reset(&peer_info->model, v_s); + nm_strdup_reset(&peer_info->model, v_s); if (nm_g_variant_lookup(properties, "ModelNumber", "&s", &v_s)) - nm_utils_strdup_reset(&peer_info->model_number, v_s); + nm_strdup_reset(&peer_info->model_number, v_s); if (nm_g_variant_lookup(properties, "Serial", "&s", &v_s)) - nm_utils_strdup_reset(&peer_info->serial, v_s); + nm_strdup_reset(&peer_info->serial, v_s); if (nm_g_variant_lookup(properties, "Groups", "^a&o", &v_strv)) { g_free(peer_info->groups); - peer_info->groups = nm_utils_strv_dup_packed(v_strv, -1); + peer_info->groups = nm_strv_dup_packed(v_strv, -1); g_free(v_strv); } @@ -967,7 +970,7 @@ _peer_info_properties_changed(NMSupplicantInterface *self, v_v = nm_g_variant_lookup_value(properties, "IEs", G_VARIANT_TYPE_BYTESTRING); if (v_v) { arr_data = g_variant_get_fixed_array(v_v, &arr_len, 1); - if (!nm_utils_gbytes_equal_mem(peer_info->ies, arr_data, arr_len)) { + if (!nm_g_bytes_equal_mem(peer_info->ies, arr_data, arr_len)) { _nm_unused gs_unref_bytes GBytes *old_free = g_steal_pointer(&peer_info->ies); peer_info->ies = g_bytes_new(arr_data, arr_len); @@ -1904,11 +1907,11 @@ _properties_changed_main(NMSupplicantInterface *self, GVariant *properties) } if (nm_g_variant_lookup(properties, "Ifname", "&s", &v_s)) { - if (nm_utils_strdup_reset(&priv->ifname, v_s)) + if (nm_strdup_reset(&priv->ifname, v_s)) do_log_driver_info = TRUE; } if (nm_g_variant_lookup(properties, "Driver", "&s", &v_s)) { - if (nm_utils_strdup_reset(&priv->driver, v_s)) + if (nm_strdup_reset(&priv->driver, v_s)) do_log_driver_info = TRUE; } @@ -2305,7 +2308,7 @@ assoc_add_network_cb(GObject *source, GAsyncResult *result, gpointer user_data) self, NM_WPAS_DBUS_IFACE_INTERFACE, "AddBlob", - g_variant_new("(s@ay)", blob_name, nm_utils_gbytes_to_variant_ay(blob_data)), + g_variant_new("(s@ay)", blob_name, nm_g_bytes_to_variant_ay(blob_data)), G_VARIANT_TYPE("()"), G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT_MSEC, @@ -2609,7 +2612,7 @@ nm_supplicant_interface_request_scan(NMSupplicantInterface * se g_variant_builder_init(&ssids_builder, G_VARIANT_TYPE_BYTESTRING_ARRAY); for (i = 0; i < ssids_len; i++) { nm_assert(ssids[i]); - g_variant_builder_add(&ssids_builder, "@ay", nm_utils_gbytes_to_variant_ay(ssids[i])); + g_variant_builder_add(&ssids_builder, "@ay", nm_g_bytes_to_variant_ay(ssids[i])); } g_variant_builder_add(&builder, "{sv}", "SSIDs", g_variant_builder_end(&ssids_builder)); } @@ -2942,6 +2945,15 @@ _get_all_p2p_device_cb(GVariant *result, GError *error, gpointer user_data) _properties_changed(user_data, NM_WPAS_DBUS_IFACE_INTERFACE_P2P_DEVICE, properties, TRUE); } +static void +_set_p2p_assigned_addr(NMSupplicantInterface *self, gconstpointer addr, guint8 plen) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + + nm_ip_addr_set(AF_INET, &priv->p2p_assigned_addr, addr); + priv->p2p_assigned_plen = plen; +} + static void _signal_handle(NMSupplicantInterface *self, const char * signal_interface_name, @@ -3036,6 +3048,7 @@ _signal_handle(NMSupplicantInterface *self, gs_unref_object NMSupplicantInterface *iface = NULL; const char * group_path; const char * iface_path; + GVariant * v_v = NULL; g_variant_get(parameters, "(@a{sv})", &args); if (!g_variant_lookup(args, "group_object", "&o", &group_path)) @@ -3057,6 +3070,34 @@ _signal_handle(NMSupplicantInterface *self, } } + v_v = g_variant_lookup_value(args, "IpAddr", G_VARIANT_TYPE_BYTESTRING); + if (v_v) { + const guint8 *addr_data; + gsize addr_len = 0; + const guint8 *mask_data = NULL; + gsize mask_len = 0; + + /* The address is passed in network-byte-order */ + addr_data = g_variant_get_fixed_array(v_v, &addr_len, 1); + + /* TODO: Should we expose IpAddrGo? If yes, maybe as gateway? */ + v_v = g_variant_lookup_value(args, "IpAddrMask", G_VARIANT_TYPE_BYTESTRING); + if (v_v) + mask_data = g_variant_get_fixed_array(v_v, &mask_len, 1); + + if (addr_len == NM_AF_INET_SIZE && mask_len == NM_AF_INET_SIZE) { + guint32 netmask; + + memcpy(&netmask, mask_data, NM_AF_INET_SIZE); + + _set_p2p_assigned_addr(iface, + addr_data, + nm_utils_ip4_netmask_to_prefix(netmask)); + } else { + _LOGW("P2P: GroupStarted signaled invalid IP Address information"); + } + } + /* Signal existence of the (new) interface. */ g_signal_emit(self, signals[GROUP_STARTED], 0, iface); } @@ -3137,6 +3178,24 @@ nm_supplicant_interface_get_p2p_group_owner(NMSupplicantInterface *self) return NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self)->p2p_group_owner_cached; } +gboolean +nm_supplicant_interface_get_p2p_assigned_addr(NMSupplicantInterface *self, + in_addr_t * addr, + guint8 * plen) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + + if (nm_ip_addr_is_null(AF_INET, &priv->p2p_assigned_addr)) + return FALSE; + + if (addr) + nm_ip_addr_set(AF_INET, addr, &priv->p2p_assigned_addr); + if (plen) + *plen = priv->p2p_assigned_plen; + + return TRUE; +} + /*****************************************************************************/ static void diff --git a/src/core/supplicant/nm-supplicant-interface.h b/src/core/supplicant/nm-supplicant-interface.h index a62eeb62..4c5d8f64 100644 --- a/src/core/supplicant/nm-supplicant-interface.h +++ b/src/core/supplicant/nm-supplicant-interface.h @@ -164,6 +164,10 @@ const char *nm_supplicant_interface_get_p2p_group_path(NMSupplicantInterface *se gboolean nm_supplicant_interface_get_p2p_group_owner(NMSupplicantInterface *self); +gboolean nm_supplicant_interface_get_p2p_assigned_addr(NMSupplicantInterface *self, + in_addr_t * assigned_addr, + guint8 * plen); + void nm_supplicant_interface_p2p_start_find(NMSupplicantInterface *self, guint timeout); void nm_supplicant_interface_p2p_stop_find(NMSupplicantInterface *self); diff --git a/src/core/supplicant/nm-supplicant-manager.c b/src/core/supplicant/nm-supplicant-manager.c index e432889b..52beae78 100644 --- a/src/core/supplicant/nm-supplicant-manager.c +++ b/src/core/supplicant/nm-supplicant-manager.c @@ -244,8 +244,7 @@ nm_supplicant_manager_set_wfd_ies(NMSupplicantManager *self, GBytes *wfd_ies) g_variant_builder_add(¶ms, "s", NM_WPAS_DBUS_INTERFACE); g_variant_builder_add(¶ms, "s", "WFDIEs"); - g_variant_builder_add_value(¶ms, - g_variant_new_variant(nm_utils_gbytes_to_variant_ay(wfd_ies))); + g_variant_builder_add_value(¶ms, g_variant_new_variant(nm_g_bytes_to_variant_ay(wfd_ies))); g_dbus_connection_call(priv->dbus_connection, priv->name_owner->str, diff --git a/src/core/supplicant/nm-supplicant-settings-verify.c b/src/core/supplicant/nm-supplicant-settings-verify.c index 5e77b207..ceb4b6ae 100644 --- a/src/core/supplicant/nm-supplicant-settings-verify.c +++ b/src/core/supplicant/nm-supplicant-settings-verify.c @@ -223,7 +223,7 @@ validate_type_keyword(const struct Opt *opt, const char *value, const guint32 le s++; } - if (nm_utils_strv_find_first((char **) opt->str_allowed, -1, value) < 0) + if (nm_strv_find_first(opt->str_allowed, -1, value) < 0) return FALSE; if (!s) diff --git a/src/core/supplicant/nm-supplicant-types.h b/src/core/supplicant/nm-supplicant-types.h index c9b72de1..743ef8f0 100644 --- a/src/core/supplicant/nm-supplicant-types.h +++ b/src/core/supplicant/nm-supplicant-types.h @@ -14,9 +14,9 @@ #define NM_WPAS_DBUS_INTERFACE "fi.w1.wpa_supplicant1" #if HAVE_WEXT - #define NM_WPAS_DEFAULT_WIFI_DRIVER "nl80211,wext" +#define NM_WPAS_DEFAULT_WIFI_DRIVER "nl80211,wext" #else - #define NM_WPAS_DEFAULT_WIFI_DRIVER "nl80211" +#define NM_WPAS_DEFAULT_WIFI_DRIVER "nl80211" #endif #define NM_WPAS_DBUS_IFACE_INTERFACE NM_WPAS_DBUS_INTERFACE ".Interface" -- cgit 1.3.0-6-gf8a5