diff options
Diffstat (limited to 'src/core/devices/wifi')
| -rw-r--r-- | src/core/devices/wifi/nm-device-iwd-p2p.c | 6 | ||||
| -rw-r--r-- | src/core/devices/wifi/nm-device-olpc-mesh.c | 6 | ||||
| -rw-r--r-- | src/core/devices/wifi/nm-device-wifi-p2p.c | 89 | ||||
| -rw-r--r-- | src/core/devices/wifi/nm-device-wifi.c | 35 | ||||
| -rw-r--r-- | src/core/devices/wifi/nm-iwd-manager.c | 9 | ||||
| -rw-r--r-- | src/core/devices/wifi/nm-wifi-ap.c | 41 | ||||
| -rw-r--r-- | src/core/devices/wifi/nm-wifi-ap.h | 3 | ||||
| -rw-r--r-- | src/core/devices/wifi/nm-wifi-common.c | 11 |
8 files changed, 155 insertions, 45 deletions
diff --git a/src/core/devices/wifi/nm-device-iwd-p2p.c b/src/core/devices/wifi/nm-device-iwd-p2p.c index 73fd4716..fadc6722 100644 --- a/src/core/devices/wifi/nm-device-iwd-p2p.c +++ b/src/core/devices/wifi/nm-device-iwd-p2p.c @@ -1144,7 +1144,11 @@ static const NMDBusInterfaceInfoExtended interface_info_device_wifi_p2p = { .signals = NM_DEFINE_GDBUS_SIGNAL_INFOS(&nm_signal_info_wifi_p2p_peer_added, &nm_signal_info_wifi_p2p_peer_removed, ), .properties = NM_DEFINE_GDBUS_PROPERTY_INFOS( - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("HwAddress", "s", NM_DEVICE_HW_ADDRESS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE( + "HwAddress", + "s", + NM_DEVICE_HW_ADDRESS, + .annotations = NM_GDBUS_ANNOTATION_INFO_LIST_DEPRECATED(), ), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Peers", "ao", NM_DEVICE_IWD_P2P_PEERS), ), ), diff --git a/src/core/devices/wifi/nm-device-olpc-mesh.c b/src/core/devices/wifi/nm-device-olpc-mesh.c index 436c7847..8e1e779b 100644 --- a/src/core/devices/wifi/nm-device-olpc-mesh.c +++ b/src/core/devices/wifi/nm-device-olpc-mesh.c @@ -497,7 +497,11 @@ static const NMDBusInterfaceInfoExtended interface_info_device_olpc_mesh = { .parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT( NM_DBUS_INTERFACE_DEVICE_OLPC_MESH, .properties = NM_DEFINE_GDBUS_PROPERTY_INFOS( - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("HwAddress", "s", NM_DEVICE_HW_ADDRESS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE( + "HwAddress", + "s", + NM_DEVICE_HW_ADDRESS, + .annotations = NM_GDBUS_ANNOTATION_INFO_LIST_DEPRECATED(), ), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Companion", "o", NM_DEVICE_OLPC_MESH_COMPANION), diff --git a/src/core/devices/wifi/nm-device-wifi-p2p.c b/src/core/devices/wifi/nm-device-wifi-p2p.c index fa8cb8fa..981811a3 100644 --- a/src/core/devices/wifi/nm-device-wifi-p2p.c +++ b/src/core/devices/wifi/nm-device-wifi-p2p.c @@ -15,6 +15,7 @@ #include "NetworkManagerUtils.h" #include "devices/nm-device-private.h" #include "libnm-core-aux-intern/nm-libnm-core-utils.h" +#include "libnm-core-aux-intern/nm-common-macros.h" #include "libnm-core-intern/nm-core-internal.h" #include "libnm-glib-aux/nm-ref-string.h" #include "libnm-platform/nm-platform.h" @@ -982,23 +983,24 @@ device_state_changed(NMDevice *device, } static void -impl_device_wifi_p2p_start_find(NMDBusObject *obj, - const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended *method_info, - GDBusConnection *connection, - const char *sender, - GDBusMethodInvocation *invocation, - GVariant *parameters) +p2p_start_find_auth_cb(NMDevice *device, + GDBusMethodInvocation *invocation, + NMAuthSubject *subject, + GError *error, + gpointer user_data) { - NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(obj); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); - gs_unref_variant GVariant *options = NULL; + gs_unref_variant GVariant *options = user_data; const char *opts_key; GVariant *opts_val; GVariantIter iter; gint32 timeout = 30; - g_variant_get(parameters, "(@a{sv})", &options); + if (error) { + g_dbus_method_invocation_return_gerror(invocation, error); + return; + } g_variant_iter_init(&iter, options); while (g_variant_iter_next(&iter, "{&sv}", &opts_key, &opts_val)) { @@ -1050,17 +1052,43 @@ impl_device_wifi_p2p_start_find(NMDBusObject *obj, } static void -impl_device_wifi_p2p_stop_find(NMDBusObject *obj, - const NMDBusInterfaceInfoExtended *interface_info, - const NMDBusMethodInfoExtended *method_info, - GDBusConnection *connection, - const char *sender, - GDBusMethodInvocation *invocation, - GVariant *parameters) +impl_device_wifi_p2p_start_find(NMDBusObject *obj, + const NMDBusInterfaceInfoExtended *interface_info, + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) +{ + gs_unref_variant GVariant *options = NULL; + + g_variant_get(parameters, "(@a{sv})", &options); + + nm_device_auth_request(NM_DEVICE(obj), + invocation, + NULL, + NM_AUTH_PERMISSION_WIFI_SCAN, + TRUE, + NULL, + p2p_start_find_auth_cb, + g_steal_pointer(&options)); +} + +static void +p2p_stop_find_auth_cb(NMDevice *device, + GDBusMethodInvocation *invocation, + NMAuthSubject *subject, + GError *error, + gpointer user_data) { - NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(obj); + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); + if (error) { + g_dbus_method_invocation_return_gerror(invocation, error); + return; + } + if (!priv->mgmt_iface) { g_dbus_method_invocation_return_error_literal( invocation, @@ -1075,6 +1103,25 @@ impl_device_wifi_p2p_stop_find(NMDBusObject *obj, g_dbus_method_invocation_return_value(invocation, NULL); } +static void +impl_device_wifi_p2p_stop_find(NMDBusObject *obj, + const NMDBusInterfaceInfoExtended *interface_info, + const NMDBusMethodInfoExtended *method_info, + GDBusConnection *connection, + const char *sender, + GDBusMethodInvocation *invocation, + GVariant *parameters) +{ + nm_device_auth_request(NM_DEVICE(obj), + invocation, + NULL, + NM_AUTH_PERMISSION_WIFI_SCAN, + TRUE, + NULL, + p2p_stop_find_auth_cb, + NULL); +} + /*****************************************************************************/ NMSupplicantInterface * @@ -1171,7 +1218,11 @@ static const NMDBusInterfaceInfoExtended interface_info_device_wifi_p2p = { .signals = NM_DEFINE_GDBUS_SIGNAL_INFOS(&nm_signal_info_wifi_p2p_peer_added, &nm_signal_info_wifi_p2p_peer_removed, ), .properties = NM_DEFINE_GDBUS_PROPERTY_INFOS( - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("HwAddress", "s", NM_DEVICE_HW_ADDRESS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE( + "HwAddress", + "s", + NM_DEVICE_HW_ADDRESS, + .annotations = NM_GDBUS_ANNOTATION_INFO_LIST_DEPRECATED(), ), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Peers", "ao", NM_DEVICE_WIFI_P2P_PEERS), ), ), diff --git a/src/core/devices/wifi/nm-device-wifi.c b/src/core/devices/wifi/nm-device-wifi.c index 43772834..2cd41b27 100644 --- a/src/core/devices/wifi/nm-device-wifi.c +++ b/src/core/devices/wifi/nm-device-wifi.c @@ -3191,27 +3191,28 @@ ensure_hotspot_frequency(NMDeviceWifi *self, NMSettingWireless *s_wifi, NMWifiAP GBytes *ssid; gsize ssid_len; const guint8 *ssid_data; - const guint8 random_seed[16] = {0x9a, - 0xdc, - 0x86, - 0x9a, - 0xa8, - 0xa2, - 0x07, - 0x97, - 0xbe, - 0x6d, - 0xe6, - 0x99, - 0x9f, - 0xa8, - 0x09, - 0x2b}; /* Calculate a stable "random" number based on the SSID. */ ssid = nm_setting_wireless_get_ssid(s_wifi); ssid_data = g_bytes_get_data(ssid, &ssid_len); - rnd = c_siphash_hash(random_seed, ssid_data, ssid_len); + rnd = c_siphash_hash(NM_HASH_SEED_16(0x9a, + 0xdc, + 0x86, + 0x9a, + 0xa8, + 0xa2, + 0x07, + 0x97, + 0xbe, + 0x6d, + 0xe6, + 0x99, + 0x9f, + 0xa8, + 0x09, + 0x2b), + ssid_data, + ssid_len); } if (nm_streq0(band, "a")) { diff --git a/src/core/devices/wifi/nm-iwd-manager.c b/src/core/devices/wifi/nm-iwd-manager.c index 0d4daf21..76a342e2 100644 --- a/src/core/devices/wifi/nm-iwd-manager.c +++ b/src/core/devices/wifi/nm-iwd-manager.c @@ -810,7 +810,7 @@ sett_conn_changed(NMSettingsConnection *sett_conn, nm_log_dbg(LOGD_WIFI, "iwd: profile at %s not removed: %s (%i)", orig_full_path, - strerror(errno), + nm_strerror_native(errno), errno); removed = TRUE; @@ -1431,7 +1431,10 @@ try_delete_file: if (g_remove(full_path) == 0) _LOGD("IWD profile at %s removed", full_path); else if (errno != ENOENT) - _LOGD("IWD profile at %s not removed: %s (%i)", full_path, strerror(errno), errno); + _LOGD("IWD profile at %s not removed: %s (%i)", + full_path, + nm_strerror_native(errno), + errno); } static void @@ -1899,7 +1902,7 @@ nm_iwd_manager_get_ap_mirror_connection(NMIwdManager *self, NMWifiAP *ap) NM80211ApSecurityFlags sec_flags = nm_wifi_ap_get_wpa_flags(ap) | nm_wifi_ap_get_rsn_flags(ap); ssid_bytes = g_bytes_get_data(nm_wifi_ap_get_ssid(ap), &ssid_len); - ssid_len = MIN(ssid_len, 32); + ssid_len = NM_MIN(ssid_len, 32u); memcpy(name_buf, ssid_bytes, ssid_len); name_buf[ssid_len] = '\0'; diff --git a/src/core/devices/wifi/nm-wifi-ap.c b/src/core/devices/wifi/nm-wifi-ap.c index 825a5aa8..d4d3815e 100644 --- a/src/core/devices/wifi/nm-wifi-ap.c +++ b/src/core/devices/wifi/nm-wifi-ap.c @@ -36,6 +36,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMWifiAP, PROP_HW_ADDRESS, PROP_MODE, PROP_MAX_BITRATE, + PROP_BANDWIDTH, PROP_STRENGTH, PROP_LAST_SEEN, ); @@ -47,6 +48,7 @@ struct _NMWifiAPPrivate { guint8 strength; guint32 freq; /* Frequency in MHz; ie 2412 (== 2.412 GHz) */ guint32 max_bitrate; /* Maximum bitrate of the AP in Kbit/s (ie 54000 Kb/s == 54Mbit/s) */ + guint32 bandwidth; /* Bandwidth of the AP in MHz */ gint64 last_seen_msec; /* Timestamp when the AP was seen lastly (in nm_utils_get_monotonic_timestamp_*() scale). @@ -277,6 +279,32 @@ nm_wifi_ap_get_max_bitrate(NMWifiAP *ap) return NM_WIFI_AP_GET_PRIVATE(ap)->max_bitrate; } +guint32 +nm_wifi_ap_get_bandwidth(NMWifiAP *ap) +{ + g_return_val_if_fail(NM_IS_WIFI_AP(ap), 0); + g_return_val_if_fail(nm_dbus_object_is_exported(NM_DBUS_OBJECT(ap)), 0); + + return NM_WIFI_AP_GET_PRIVATE(ap)->bandwidth; +} + +gboolean +nm_wifi_ap_set_bandwidth(NMWifiAP *ap, guint32 bandwidth) +{ + NMWifiAPPrivate *priv; + + g_return_val_if_fail(NM_IS_WIFI_AP(ap), FALSE); + + priv = NM_WIFI_AP_GET_PRIVATE(ap); + + if (priv->bandwidth != bandwidth) { + priv->bandwidth = bandwidth; + _notify(ap, PROP_BANDWIDTH); + return TRUE; + } + return FALSE; +} + gboolean nm_wifi_ap_set_max_bitrate(NMWifiAP *ap, guint32 bitrate) { @@ -393,6 +421,7 @@ nm_wifi_ap_update_from_properties(NMWifiAP *ap, const NMSupplicantBssInfo *bss_i } changed |= nm_wifi_ap_set_max_bitrate(ap, bss_info->max_rate); + changed |= nm_wifi_ap_set_bandwidth(ap, bss_info->bandwidth); if (priv->metered != bss_info->metered) { priv->metered = bss_info->metered; @@ -683,6 +712,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_MAX_BITRATE: g_value_set_uint(value, priv->max_bitrate); break; + case PROP_BANDWIDTH: + g_value_set_uint(value, priv->bandwidth); + break; case PROP_STRENGTH: g_value_set_uchar(value, priv->strength); break; @@ -873,6 +905,7 @@ static const NMDBusInterfaceInfoExtended interface_info_access_point = { NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("MaxBitrate", "u", NM_WIFI_AP_MAX_BITRATE), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Bandwidth", "u", NM_WIFI_AP_BANDWIDTH), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Strength", "y", NM_WIFI_AP_STRENGTH), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("LastSeen", "i", @@ -979,6 +1012,14 @@ nm_wifi_ap_class_init(NMWifiAPClass *ap_class) -1, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_BANDWIDTH] = g_param_spec_uint(NM_WIFI_AP_BANDWIDTH, + "", + "", + 0, + G_MAXUINT32, + 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); } diff --git a/src/core/devices/wifi/nm-wifi-ap.h b/src/core/devices/wifi/nm-wifi-ap.h index 93dc8edf..0f229640 100644 --- a/src/core/devices/wifi/nm-wifi-ap.h +++ b/src/core/devices/wifi/nm-wifi-ap.h @@ -27,6 +27,7 @@ #define NM_WIFI_AP_HW_ADDRESS "hw-address" #define NM_WIFI_AP_MODE "mode" #define NM_WIFI_AP_MAX_BITRATE "max-bitrate" +#define NM_WIFI_AP_BANDWIDTH "bandwidth" #define NM_WIFI_AP_STRENGTH "strength" #define NM_WIFI_AP_LAST_SEEN "last-seen" @@ -78,6 +79,8 @@ guint32 nm_wifi_ap_get_freq(NMWifiAP *ap); gboolean nm_wifi_ap_set_freq(NMWifiAP *ap, guint32 freq); guint32 nm_wifi_ap_get_max_bitrate(NMWifiAP *ap); gboolean nm_wifi_ap_set_max_bitrate(NMWifiAP *ap, guint32 bitrate); +guint32 nm_wifi_ap_get_bandwidth(NMWifiAP *ap); +gboolean nm_wifi_ap_set_bandwidth(NMWifiAP *ap, guint32 bandwidth); gboolean nm_wifi_ap_get_fake(const NMWifiAP *ap); gboolean nm_wifi_ap_set_fake(NMWifiAP *ap, gboolean fake); NM80211ApFlags nm_wifi_ap_get_flags(const NMWifiAP *self); diff --git a/src/core/devices/wifi/nm-wifi-common.c b/src/core/devices/wifi/nm-wifi-common.c index 681d9cb5..e3639ec5 100644 --- a/src/core/devices/wifi/nm-wifi-common.c +++ b/src/core/devices/wifi/nm-wifi-common.c @@ -132,7 +132,8 @@ const NMDBusInterfaceInfoExtended nm_interface_info_device_wireless = { NM_DEFINE_GDBUS_METHOD_INFO_INIT( "GetAccessPoints", .out_args = NM_DEFINE_GDBUS_ARG_INFOS( - NM_DEFINE_GDBUS_ARG_INFO("access_points", "ao"), ), ), + NM_DEFINE_GDBUS_ARG_INFO("access_points", "ao"), ), + .annotations = NM_GDBUS_ANNOTATION_INFO_LIST_DEPRECATED(), ), .handle = impl_device_wifi_get_access_points, ), NM_DEFINE_DBUS_METHOD_INFO_EXTENDED( NM_DEFINE_GDBUS_METHOD_INFO_INIT( @@ -150,9 +151,11 @@ const NMDBusInterfaceInfoExtended nm_interface_info_device_wireless = { &nm_signal_info_wireless_access_point_removed, ), .properties = NM_DEFINE_GDBUS_PROPERTY_INFOS( NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("HwAddress", "s", NM_DEVICE_HW_ADDRESS), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("PermHwAddress", - "s", - NM_DEVICE_PERM_HW_ADDRESS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE( + "PermHwAddress", + "s", + NM_DEVICE_PERM_HW_ADDRESS, + .annotations = NM_GDBUS_ANNOTATION_INFO_LIST_DEPRECATED(), ), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Mode", "u", NM_DEVICE_WIFI_MODE), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Bitrate", "u", NM_DEVICE_WIFI_BITRATE), NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("AccessPoints", |