On Tue, 2018-11-27 at 18:07 +0900, Jeonghwan Yoon wrote: > From: "jeonghwan.yoon" <jeonghwan.yoon@xxxxxxx> > > 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 | 102 ++++++++++++++++++ > wpa_supplicant/dbus/dbus_new.c | 63 +++++++++++ > wpa_supplicant/dbus/dbus_new.h | 5 + > wpa_supplicant/dbus/dbus_new_handlers.c | 185 > ++++++++++++++++++++++++++++++++ > wpa_supplicant/dbus/dbus_new_handlers.h | 18 ++++ > 5 files changed, 373 insertions(+) > > diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen > index 2ca40ae..7905557 100644 > --- a/doc/dbus.doxygen > +++ b/doc/dbus.doxygen > @@ -11,6 +11,7 @@ Interfaces: > - \ref dbus_interface > - \ref dbus_wps > - \ref dbus_p2pdevice > +- \ref dbus_dppdevice > - \ref dbus_bss > - \ref dbus_network > - \ref dbus_peer > @@ -1325,6 +1326,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>DppBootstrapGen ( s : type, s : channel list, s : mac ) --> With D-Bus the methods are namespaced, so the "Dpp" in the method name is redundant with the "DPPDevice" interface. I would drop the "Dpp" prefix from all the methods under the "DPPDevice" interface. Dan > 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>DppBootstrapRemove ( 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>DppListen ( 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>DppListenStop ( )--> nothing</h3> > + <p>Stop DPP listen operation.</p> > + </li> > + > + <li> > + <h3>DppConfiguratorAdd ( ) --> 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>DppPkexAdd ( 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>DppPkexRemove ( 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 d4deb0f..67bef7b 100644 > --- a/wpa_supplicant/dbus/dbus_new.c > +++ b/wpa_supplicant/dbus/dbus_new.c > @@ -25,6 +25,7 @@ > #include "dbus_new_handlers_p2p.h" > #include "p2p/p2p.h" > #include "../p2p_supplicant.h" > +#include "common/dpp.h" > > #ifdef CONFIG_AP /* until needed by something else */ > > @@ -3278,6 +3279,68 @@ static const struct wpa_dbus_method_desc > wpas_dbus_interface_methods[] = { > END_ARGS > } > }, > + > +#ifdef CONFIG_DPP > + { "DppConfiguratorParams", WPAS_DBUS_NEW_IFACE_DPPDEVICE, > + (WPADBusMethodHandler)wpas_dbus_handler_dpp_configurato > r_params, > + { > + { "cmd","s",ARG_IN}, > + { "res","s",ARG_OUT}, > + END_ARGS > + } > + }, > + { "DppBootstrapGen", WPAS_DBUS_NEW_IFACE_DPPDEVICE, > + (WPADBusMethodHandler)wpas_dbus_handler_dpp_bootstrap_g > en, > + { > + { "type", "s", ARG_IN }, > + { "own_id","i",ARG_OUT}, > + END_ARGS > + } > + }, > + { "DppBootstrapRemove", WPAS_DBUS_NEW_IFACE_DPPDEVICE, > + (WPADBusMethodHandler)wpas_dbus_handler_dpp_bootstrap_r > emove, > + { > + { "id", "s", ARG_IN }, > + END_ARGS > + } > + }, > + { "DppPkexAdd", WPAS_DBUS_NEW_IFACE_DPPDEVICE, > + (WPADBusMethodHandler)wpas_dbus_handler_dpp_pkex_add, > + { > + { "cmd","s", ARG_IN }, > + { "res","i",ARG_OUT}, > + END_ARGS > + } > + }, > + { "DppPkexRemove", WPAS_DBUS_NEW_IFACE_DPPDEVICE, > + (WPADBusMethodHandler)wpas_dbus_handler_dpp_pkex_remove > , > + { > + { "id","s", ARG_IN }, > + END_ARGS > + } > + }, > + { "DppListen", WPAS_DBUS_NEW_IFACE_DPPDEVICE, > + (WPADBusMethodHandler)wpas_dbus_handler_dpp_listen, > + { > + { "cmd", "s", ARG_IN }, > + { "res","i",ARG_OUT}, > + END_ARGS > + } > + }, > + { "DppListenStop", WPAS_DBUS_NEW_IFACE_DPPDEVICE, > + (WPADBusMethodHandler)wpas_dbus_handler_dpp_listen_stop > , > + { > + END_ARGS > + } > + }, > + { "DppConfiguratorAdd", WPAS_DBUS_NEW_IFACE_DPPDEVICE, > + (WPADBusMethodHandler)wpas_dbus_handler_dpp_configurato > r_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 40ae133..b53a218 100644 > --- a/wpa_supplicant/dbus/dbus_new.h > +++ b/wpa_supplicant/dbus/dbus_new.h > @@ -66,6 +66,11 @@ enum wpas_dbus_bss_prop { > > #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 94773b3..1ada1fd 100644 > --- a/wpa_supplicant/dbus/dbus_new_handlers.c > +++ b/wpa_supplicant/dbus/dbus_new_handlers.c > @@ -4882,3 +4882,188 @@ 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; > + DBusMessageIter iter; > + 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_INVA > LID)){ > + 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; > + DBusMessageIter iter; > + 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 6f952cc..7128e3e 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 */ _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap