summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2018-10-15 15:11:34 +0200
committerThomas Haller <thaller@redhat.com>2018-12-13 09:20:55 +0100
commit1371414e3d39fb0974db1282a136bb96448e6287 (patch)
tree3f0cdbc557794b62101a9015a31955c5b6e3ac1d
parentc05aa3b309835b4789ffbe502be82c087a3e4ef9 (diff)
downloadNetworkManager-1371414e3d39fb0974db1282a136bb96448e6287.tar.gz
supplicant: Add methods to start/stop a P2P Find operation
The timeout is limited to be in the range of 1-600s. This is arbitrary, but the point is that a timeout of 0 is not permitted to prevent a client from making us run a find continuously simply by forgetting to call the stop method.
-rw-r--r--src/supplicant/nm-supplicant-interface.c47
-rw-r--r--src/supplicant/nm-supplicant-interface.h4
2 files changed, 51 insertions, 0 deletions
diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c
index 6e29df60bd..6e4d178a05 100644
--- a/src/supplicant/nm-supplicant-interface.c
+++ b/src/supplicant/nm-supplicant-interface.c
@@ -2437,6 +2437,53 @@ nm_supplicant_interface_get_max_scan_ssids (NMSupplicantInterface *self)
/*****************************************************************************/
void
+nm_supplicant_interface_p2p_start_find (NMSupplicantInterface *self,
+ guint timeout)
+{
+ NMSupplicantInterfacePrivate *priv;
+ GVariantBuilder builder;
+
+ g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self));
+ g_return_if_fail (timeout > 0 && timeout <= 600);
+
+ priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
+
+ /* Find parameters */
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add (&builder, "{sv}", "Timeout", g_variant_new_int32 (timeout));
+
+ g_dbus_proxy_call (priv->p2p_proxy,
+ "Find",
+ g_variant_new ("(a{sv})", &builder),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ priv->other_cancellable,
+ (GAsyncReadyCallback) log_result_cb,
+ self);
+}
+
+void
+nm_supplicant_interface_p2p_stop_find (NMSupplicantInterface *self)
+{
+ NMSupplicantInterfacePrivate *priv;
+
+ g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (self));
+
+ priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
+
+ g_dbus_proxy_call (priv->p2p_proxy,
+ "StopFind",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ priv->other_cancellable,
+ (GAsyncReadyCallback) scan_request_cb,
+ self);
+}
+
+/*****************************************************************************/
+
+void
nm_supplicant_interface_p2p_connect (NMSupplicantInterface * self,
const char * peer,
const char * wps_method,
diff --git a/src/supplicant/nm-supplicant-interface.h b/src/supplicant/nm-supplicant-interface.h
index b9d1b28393..0aa7732ac4 100644
--- a/src/supplicant/nm-supplicant-interface.h
+++ b/src/supplicant/nm-supplicant-interface.h
@@ -146,6 +146,10 @@ gboolean nm_supplicant_interface_credentials_reply (NMSupplicantInterface *self,
const char *value,
GError **error);
+void nm_supplicant_interface_p2p_start_find (NMSupplicantInterface *self,
+ guint timeout);
+void nm_supplicant_interface_p2p_stop_find (NMSupplicantInterface *self);
+
void nm_supplicant_interface_p2p_connect (NMSupplicantInterface * self,
const char * peer,
const char * wps_method,