diff options
Diffstat (limited to 'src/core/supplicant')
| -rw-r--r-- | src/core/supplicant/nm-supplicant-config.c | 2 | ||||
| -rw-r--r-- | src/core/supplicant/nm-supplicant-interface.c | 83 | ||||
| -rw-r--r-- | src/core/supplicant/nm-supplicant-interface.h | 4 | ||||
| -rw-r--r-- | src/core/supplicant/nm-supplicant-manager.c | 3 | ||||
| -rw-r--r-- | src/core/supplicant/nm-supplicant-settings-verify.c | 2 | ||||
| -rw-r--r-- | src/core/supplicant/nm-supplicant-types.h | 4 |
6 files changed, 80 insertions, 18 deletions
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)); } @@ -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 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" |