diff options
| author | Michael Biebl <biebl@debian.org> | 2022-01-13 22:30:39 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2022-01-13 22:30:39 +0100 |
| commit | 88c227d90a6b7b388c5c85d72802a0ca8f05ed5c (patch) | |
| tree | 71f32df6617802270e8a78574bd8e1637dc532f4 /src/core/supplicant/nm-supplicant-interface.c | |
| parent | e74c568b07b50b97873fb4ee1d776dedefbd54d6 (diff) | |
New upstream version 1.34.0 upstream/1.34.0
Diffstat (limited to 'src/core/supplicant/nm-supplicant-interface.c')
| -rw-r--r-- | src/core/supplicant/nm-supplicant-interface.c | 83 |
1 files changed, 71 insertions, 12 deletions
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)); } @@ -2943,6 +2946,15 @@ _get_all_p2p_device_cb(GVariant *result, GError *error, gpointer user_data) } 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, const char * signal_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 |