supplicant: Add API to set WFD IEs

This API allows setting the global WFDIEs property of wpa_supplicant.
Ideally it would be better if this property was per-device, but this is
a limitation of wpa_supplicant.
This commit is contained in:
Benjamin Berg 2019-02-18 15:04:27 +01:00 committed by Thomas Haller
parent 3d12dbc0a7
commit 642f15f2f6
2 changed files with 67 additions and 0 deletions

View file

@ -123,6 +123,70 @@ _sup_iface_last_ref (gpointer data,
g_object_remove_toggle_ref ((GObject *) sup_iface, _sup_iface_last_ref, self);
}
static void
on_supplicant_wfd_ies_set (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
gs_unref_variant GVariant *result = NULL;
gs_free_error GError *error = NULL;
result = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object), res, &error);
if (!result)
_LOGW ("failed to set WFD IEs on wpa_supplicant: %s", error->message);
}
/**
* nm_supplicant_manager_set_wfd_ies:
* @self: the #NMSupplicantManager
* @wfd_ies: a #GBytes with the WFD IEs or %NULL
*
* This function sets the global WFD IEs on wpa_supplicant. Note that
* it would make more sense if this was per-device, but wpa_supplicant
* simply does not work that way.
* */
void
nm_supplicant_manager_set_wfd_ies (NMSupplicantManager *self,
GBytes *wfd_ies)
{
NMSupplicantManagerPrivate *priv;
GVariantBuilder params = G_VARIANT_BUILDER_INIT(G_VARIANT_TYPE ("(ssv)"));
GVariant *val;
g_return_if_fail (NM_IS_SUPPLICANT_MANAGER (self));
priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
_LOGD ("setting WFD IEs for P2P operation");
if (wfd_ies)
val = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
g_bytes_get_data (wfd_ies, NULL),
g_bytes_get_size (wfd_ies),
sizeof (guint8));
else
val = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,
NULL, 0, sizeof (guint8));
g_variant_builder_add (&params, "s", g_dbus_proxy_get_interface_name (priv->proxy));
g_variant_builder_add (&params, "s", "WFDIEs");
g_variant_builder_add_value (&params, g_variant_new_variant (val));
g_dbus_connection_call (g_dbus_proxy_get_connection (priv->proxy),
g_dbus_proxy_get_name (priv->proxy),
g_dbus_proxy_get_object_path (priv->proxy),
"org.freedesktop.DBus.Properties",
"Set",
g_variant_builder_end (&params),
G_VARIANT_TYPE_UNIT,
G_DBUS_CALL_FLAGS_NO_AUTO_START,
1000,
NULL,
on_supplicant_wfd_ies_set,
NULL);
}
/**
* nm_supplicant_manager_create_interface:
* @self: the #NMSupplicantManager

View file

@ -38,6 +38,9 @@ GType nm_supplicant_manager_get_type (void);
NMSupplicantManager *nm_supplicant_manager_get (void);
void nm_supplicant_manager_set_wfd_ies (NMSupplicantManager *self,
GBytes *wfd_ies);
NMSupplicantInterface *nm_supplicant_manager_create_interface (NMSupplicantManager *mgr,
const char *ifname,
NMSupplicantDriver driver);