[PATCH v2 1/3] dbus: Enabled dpp functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Defines new dbus interface for dpp devices.
Also, added dbus methods related to bootstrapping and listen operation.
This patch will help to make new dpp application using dbus interfaces.

Signed-off-by: Jeonghwan Yoon <jeonghwan.yoon@xxxxxxx>
---
 doc/dbus.doxygen                        | 101 +++++++++++++
 wpa_supplicant/dbus/dbus_new.c          |  61 ++++++++
 wpa_supplicant/dbus/dbus_new.h          |   4 +
 wpa_supplicant/dbus/dbus_new_handlers.c | 187 ++++++++++++++++++++++++
 wpa_supplicant/dbus/dbus_new_handlers.h |  18 +++
 5 files changed, 371 insertions(+)

diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen
index 2ca40ae9b..1f754e3f2 100644
--- a/doc/dbus.doxygen
+++ b/doc/dbus.doxygen
@@ -1325,6 +1325,107 @@ Interface for performing WPS (Wi-Fi Simple Config) operations.
     </ul>
 
 
+\section dbus_dpp fi.w1.wpa_supplicant1.Interface.DPPDevice
+
+Interface for performing DPP (Device Provisioning Protocol) Device operations.
+
+\subsection dbus_dppdevice_methods Methods
+
+<ul>
+  <li>
+    <h3>BootstrapGen ( s : type, s : channel list, s : mac ) --> i</h3>
+    <p>Generate bootstrap info.</p>
+    <h4>Arguments</h4>
+    <dl>
+      <dt>s : type</dt>
+      <dd>
+	Bootstrap type. Possible values are: "pkex", "qrcode"
+      </dd>
+      <dt>s : channel list</dt>
+      <dd>
+	List of global operating class/channel pairs: ex) "81/1" or "81/1,115/36"
+      </dd>
+      <dt>s : mac</dt>
+      <dd>
+	Device mac address
+      </dd>
+    </dl>
+    <h4>Returns</h4>
+    <dl>
+      <dt>i : id</dt>
+      <dd>
+	ID for new bootstrap info
+      </dd>
+    </dl>
+  </li>
+
+  <li>
+    <h3>BootstrapRemove ( s : id ) --> nothing</h3>
+    <p>Remove bootstrap info.</p>
+    <h4>Arguments</h4>
+    <dl>
+      <dt>s : id</dt>
+      <dd>
+	Bootstrap ID to remove
+      </dd>
+    </dl>
+  </li>
+
+  <li>
+    <h3>Listen ( s : id ) --> nothing</h3>
+    <p>Start DPP listen operation.</p>
+    <h4>Arguments</h4>
+    <dl>
+      <dt>s : frequency</dt>
+      <dd>
+	Operating frequency in MHz
+      </dd>
+    </dl>
+  </li>
+
+  <li>
+    <h3>ListenStop ( )--> nothing</h3>
+    <p>Stop DPP listen operation.</p>
+  </li>
+
+  <li>
+    <h3>ConfiguratorAdd ( ) --> s : id</h3>
+    <p>Add new configurator.</p>
+    <h4>Returns</h4>
+    <dl>
+      <dt>s : id for configurator</dt>
+      <dd>
+	ID for the added configurator.
+      </dd>
+    </dl>
+  </li>
+
+  <li>
+    <h3>PkexAdd ( s : cmd ) --> nothing</h3>
+    <p>Oprating pkex process.</p>
+    <h4>Arguments</h4>
+    <dl>
+      <dt>s : command for pkex operation</dt>
+      <dd>
+		for responder : own=(id) identifier=(identifier for pkex)] code=(code for pkex) <br>
+		for initiator : own=(id) identifier=(identifier for pkex) init=(0 or 1) conf=(sta-psk or sta-dpp) configurator=(configurator's id) ssid=(ssid) pass=(passphrase) code=(code for pkex)
+      </dd>
+    </dl>
+  </li>
+
+  <li>
+    <h3>PkexRemove ( s : id ) --> nothing</h3>
+    <p>Remove pkex info.</p>
+    <h4>Arguments</h4>
+    <dl>
+      <dt>s : id</dt>
+      <dd>
+	  Pkex ID to remove or "*" (all)
+      </dd>
+    </dl>
+  </li>
+
+</ul>
 \section dbus_p2pdevice fi.w1.wpa_supplicant1.Interface.P2PDevice
 
 Interface for performing P2P (Wi-Fi Peer-to-Peer) P2P Device operations.
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index d4deb0fe3..d9edf7379 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -3278,6 +3278,67 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
 		  END_ARGS
 	  }
 	},
+#ifdef CONFIG_DPP
+	{ "ConfiguratorParams", WPAS_DBUS_NEW_IFACE_DPPDEVICE,
+		(WPADBusMethodHandler)wpas_dbus_handler_dpp_configurator_params,
+		{
+			{ "cmd","s",ARG_IN},
+			{ "res","s",ARG_OUT},
+			END_ARGS
+		}
+	},
+	{ "BootstrapGen", WPAS_DBUS_NEW_IFACE_DPPDEVICE,
+		(WPADBusMethodHandler)wpas_dbus_handler_dpp_bootstrap_gen,
+		{
+			{ "type", "s", ARG_IN },
+			{ "own_id","i",ARG_OUT},
+			END_ARGS
+		}
+	},
+	{ "BootstrapRemove", WPAS_DBUS_NEW_IFACE_DPPDEVICE,
+		(WPADBusMethodHandler)wpas_dbus_handler_dpp_bootstrap_remove,
+		{
+			{ "id", "s", ARG_IN },
+			END_ARGS
+		}
+	},
+	{ "PkexAdd", WPAS_DBUS_NEW_IFACE_DPPDEVICE,
+		(WPADBusMethodHandler)wpas_dbus_handler_dpp_pkex_add,
+		{
+			{ "cmd","s", ARG_IN },
+			{ "res","i",ARG_OUT},
+			END_ARGS
+		}
+	},
+	{ "PkexRemove", WPAS_DBUS_NEW_IFACE_DPPDEVICE,
+		(WPADBusMethodHandler)wpas_dbus_handler_dpp_pkex_remove,
+		{
+			{ "id","s", ARG_IN },
+			END_ARGS
+		}
+	},
+	{ "Listen", WPAS_DBUS_NEW_IFACE_DPPDEVICE,
+		(WPADBusMethodHandler)wpas_dbus_handler_dpp_listen,
+		{
+			{ "cmd", "s", ARG_IN },
+			{ "res","i",ARG_OUT},
+			END_ARGS
+		}
+	},
+	{ "ListenStop", WPAS_DBUS_NEW_IFACE_DPPDEVICE,
+		(WPADBusMethodHandler)wpas_dbus_handler_dpp_listen_stop,
+		{
+			END_ARGS
+		}
+	},
+	{ "ConfiguratorAdd", WPAS_DBUS_NEW_IFACE_DPPDEVICE,
+		(WPADBusMethodHandler)wpas_dbus_handler_dpp_configurator_add,
+		{
+			{ "res","i",ARG_OUT},
+			END_ARGS
+		}
+	},
+#endif /* CONFIG_DPP */
 	{ NULL, NULL, NULL, { END_ARGS } }
 };
 
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
index 40ae133b2..054afad85 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -65,6 +65,10 @@ enum wpas_dbus_bss_prop {
 		WPAS_DBUS_NEW_IFACE_INTERFACE ".P2PDevice"
 
 #define WPAS_DBUS_NEW_IFACE_MESH WPAS_DBUS_NEW_IFACE_INTERFACE ".Mesh"
+#ifdef CONFIG_DPP
+#define WPAS_DBUS_NEW_IFACE_DPPDEVICE        \
+		WPAS_DBUS_NEW_IFACE_INTERFACE ".DPPDevice"
+#endif /* CONFIG_DPP */
 
 /*
  * Groups correspond to P2P groups where this device is a GO (owner)
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 94773b329..50aee9989 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -32,6 +32,10 @@
 #include "ap/hostapd.h"
 #include "ap/sta_info.h"
 #endif /* CONFIG_MESH */
+#ifdef CONFIG_DPP
+#include "../ctrl_iface.h"
+#include "../dpp_supplicant.h"
+#endif
 
 static const char * const debug_strings[] = {
 	"excessive", "msgdump", "debug", "info", "warning", "error", NULL
@@ -4882,3 +4886,186 @@ dbus_bool_t wpas_dbus_getter_mesh_group(
 }
 
 #endif /* CONFIG_MESH */
+
+#ifdef CONFIG_DPP
+DBusMessage * wpas_dbus_handler_dpp_configurator_params(DBusMessage *message,
+		struct wpa_supplicant *wpa_s){
+	DBusMessage *reply = NULL;
+	const char* cmd;
+	char cmd_buf[256];
+	char *res = NULL;
+	size_t resp_len;
+
+	dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &cmd,
+			      DBUS_TYPE_INVALID);
+	snprintf(cmd_buf, sizeof(cmd_buf), "SET dpp_configurator_params %s", cmd);
+	res = wpa_supplicant_ctrl_iface_process(wpa_s, cmd_buf, &resp_len);
+	res[resp_len] = '\0';
+	reply = dbus_message_new_method_return(message);
+
+	if ((resp_len != 3) || (os_strncmp(res, "OK\n", 3) != 0))
+		reply = wpas_dbus_error_iface_unknown(message);
+	if (!dbus_message_append_args(reply,DBUS_TYPE_STRING,&res,DBUS_TYPE_INVALID)){
+		dbus_message_unref(reply);
+		return wpas_dbus_error_no_memory(message);
+	}
+	return reply;
+}
+
+DBusMessage * wpas_dbus_handler_dpp_bootstrap_gen(DBusMessage *message,
+		struct wpa_supplicant *wpa_s)
+{
+	DBusMessage *reply = NULL;
+	const char *type;
+	int id;
+
+	dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &type,
+			      DBUS_TYPE_INVALID);
+
+	id = wpas_dpp_bootstrap_gen(wpa_s, type);
+	reply = dbus_message_new_method_return(message);
+	if (!reply)
+		return wpas_dbus_error_no_memory(message);
+
+	if (id == -1)
+		return wpas_dbus_error_iface_unknown(message);
+	if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &id, DBUS_TYPE_INVALID)) {
+		dbus_message_unref(reply);
+		return wpas_dbus_error_no_memory(message);
+	}
+
+	return reply;
+}
+
+DBusMessage * wpas_dbus_handler_dpp_bootstrap_remove(DBusMessage *message,
+		struct wpa_supplicant *wpa_s)
+{
+	DBusMessage *reply = NULL;
+	const char *id;
+	int result;
+
+	dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &id,
+			      DBUS_TYPE_INVALID);
+
+	result = wpas_dpp_bootstrap_remove(wpa_s, id);
+	reply = dbus_message_new_method_return(message);
+	if (!reply)
+		return wpas_dbus_error_no_memory(message);
+
+	if (result == -1)
+		return wpas_dbus_error_iface_unknown(message);
+	if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &id, DBUS_TYPE_INVALID)) {
+		dbus_message_unref(reply);
+		return wpas_dbus_error_no_memory(message);
+	}
+
+	return reply;
+}
+
+DBusMessage * wpas_dbus_handler_dpp_pkex_add(DBusMessage *message,
+		struct wpa_supplicant *wpa_s)
+{
+	DBusMessage *reply = NULL;
+	const char *cmd;
+	int result;
+
+	dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &cmd,
+			      DBUS_TYPE_INVALID);
+
+	result = wpas_dpp_pkex_add(wpa_s, cmd);
+	reply = dbus_message_new_method_return(message);
+	if (!reply)
+		return wpas_dbus_error_no_memory(message);
+
+	if (result == -1)
+		return wpas_dbus_error_iface_unknown(message);
+	if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID)) {
+		dbus_message_unref(reply);
+		return wpas_dbus_error_no_memory(message);
+	}
+
+	return reply;
+}
+
+DBusMessage * wpas_dbus_handler_dpp_pkex_remove(DBusMessage *message,
+		struct wpa_supplicant *wpa_s)
+{
+	DBusMessage *reply = NULL;
+	const char *id;
+	int result;
+
+	dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &id,
+			      DBUS_TYPE_INVALID);
+
+	result = wpas_dpp_pkex_remove(wpa_s, id);
+	reply = dbus_message_new_method_return(message);
+	if (!reply)
+		return wpas_dbus_error_no_memory(message);
+
+	if (result == -1)
+		return wpas_dbus_error_iface_unknown(message);
+	if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID)) {
+		dbus_message_unref(reply);
+		return wpas_dbus_error_no_memory(message);
+	}
+
+	return reply;
+}
+
+DBusMessage * wpas_dbus_handler_dpp_listen(DBusMessage *message,
+		struct wpa_supplicant *wpa_s)
+{
+	DBusMessage *reply = NULL;
+	const char* cmd;
+	int result;
+
+	dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &cmd,
+		      DBUS_TYPE_INVALID);
+
+	result = wpas_dpp_listen(wpa_s, cmd);
+	reply = dbus_message_new_method_return(message);
+	if (!reply)
+		return wpas_dbus_error_no_memory(message);
+
+	if (result == -1)
+		return wpas_dbus_error_iface_unknown(message);
+	if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID)) {
+		dbus_message_unref(reply);
+		return wpas_dbus_error_no_memory(message);
+	}
+
+	return reply;
+}
+
+DBusMessage * wpas_dbus_handler_dpp_listen_stop(DBusMessage *message,
+		struct wpa_supplicant *wpa_s)
+{
+	wpas_dpp_stop(wpa_s);
+	wpas_dpp_listen_stop(wpa_s);
+
+	return NULL;
+}
+
+DBusMessage * wpas_dbus_handler_dpp_configurator_add(DBusMessage *message,
+		struct wpa_supplicant *wpa_s)
+{
+	DBusMessage *reply = NULL;
+	const char *cmd = "";
+	int result = -1;
+
+	result = wpas_dpp_configurator_add(wpa_s, cmd);
+	reply = dbus_message_new_method_return(message);
+	if (!reply)
+		return wpas_dbus_error_no_memory(message);
+
+	if (result == -1)
+		return wpas_dbus_error_iface_unknown(message);
+	if (!dbus_message_append_args(reply, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID)) {
+		dbus_message_unref(reply);
+		return wpas_dbus_error_no_memory(message);
+	}
+
+	return reply;
+}
+
+#endif /* CONFIG_DPP */
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index 6f952cc39..7128e3ef0 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -245,4 +245,22 @@ DBusMessage * wpas_dbus_handler_subscribe_preq(
 DBusMessage * wpas_dbus_handler_unsubscribe_preq(
 	DBusMessage *message, struct wpa_supplicant *wpa_s);
 
+#ifdef CONFIG_DPP
+DBusMessage * wpas_dbus_handler_dpp_configurator_params(
+	DBusMessage *message,struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_dpp_bootstrap_gen(
+	DBusMessage *message,struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_dpp_bootstrap_remove(
+	DBusMessage *message,struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_dpp_pkex_add(
+	DBusMessage *message,struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_dpp_pkex_remove(
+	DBusMessage *message,struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_dpp_listen(
+	DBusMessage *message,struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_dpp_listen_stop(
+	DBusMessage *message,struct wpa_supplicant *wpa_s);
+DBusMessage * wpas_dbus_handler_dpp_configurator_add(
+	DBusMessage *message,struct wpa_supplicant *wpa_s);
+#endif /* CONFIG_DPP */
 #endif /* CTRL_IFACE_DBUS_HANDLERS_NEW_H */
-- 
2.17.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux