2 * WPA Supplicant / dbus-based control interface (WPS)
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
10 #include <dbus/dbus.h>
13 #include "../config.h"
14 #include "../wpa_supplicant_i.h"
15 #include "../wps_supplicant.h"
17 #include "dbus_old_handlers.h"
20 * wpas_dbus_iface_wps_pbc - Request credentials using WPS PBC method
21 * @message: Pointer to incoming dbus message
22 * @wpa_s: %wpa_supplicant data structure
23 * Returns: A dbus message containing a UINT32 indicating success (1) or
26 * Handler function for "wpsPbc" method call
28 DBusMessage * wpas_dbus_iface_wps_pbc(DBusMessage *message,
29 struct wpa_supplicant *wpa_s)
31 char *arg_bssid = NULL;
35 if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg_bssid,
37 return wpas_dbus_new_invalid_opts_error(message, NULL);
39 if (!os_strcmp(arg_bssid, "any"))
40 ret = wpas_wps_start_pbc(wpa_s, NULL, 0);
41 else if (!hwaddr_aton(arg_bssid, bssid))
42 ret = wpas_wps_start_pbc(wpa_s, bssid, 0);
44 return wpas_dbus_new_invalid_opts_error(message,
49 return dbus_message_new_error(message,
50 WPAS_ERROR_WPS_PBC_ERROR,
51 "Could not start PBC "
55 return wpas_dbus_new_success_reply(message);
60 * wpas_dbus_iface_wps_pin - Establish the PIN number of the enrollee
61 * @message: Pointer to incoming dbus message
62 * @wpa_s: %wpa_supplicant data structure
63 * Returns: A dbus message containing a UINT32 indicating success (1) or
66 * Handler function for "wpsPin" method call
68 DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message,
69 struct wpa_supplicant *wpa_s)
71 DBusMessage *reply = NULL;
74 u8 bssid[ETH_ALEN], *_bssid = NULL;
78 if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg_bssid,
79 DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID))
80 return wpas_dbus_new_invalid_opts_error(message, NULL);
82 if (!os_strcmp(arg_bssid, "any"))
84 else if (!hwaddr_aton(arg_bssid, bssid))
87 return wpas_dbus_new_invalid_opts_error(message,
91 if (os_strlen(pin) > 0)
92 ret = wpas_wps_start_pin(wpa_s, _bssid, pin, 0,
95 ret = wpas_wps_start_pin(wpa_s, _bssid, NULL, 0,
99 return dbus_message_new_error(message,
100 WPAS_ERROR_WPS_PIN_ERROR,
101 "Could not init PIN");
104 reply = dbus_message_new_method_return(message);
109 os_snprintf(npin, sizeof(npin), "%08d", ret);
112 dbus_message_append_args(reply, DBUS_TYPE_STRING, &pin,
119 * wpas_dbus_iface_wps_reg - Request credentials using the PIN of the AP
120 * @message: Pointer to incoming dbus message
121 * @wpa_s: %wpa_supplicant data structure
122 * Returns: A dbus message containing a UINT32 indicating success (1) or
125 * Handler function for "wpsReg" method call
127 DBusMessage * wpas_dbus_iface_wps_reg(DBusMessage *message,
128 struct wpa_supplicant *wpa_s)
135 if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &arg_bssid,
136 DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID))
137 return wpas_dbus_new_invalid_opts_error(message, NULL);
139 if (!hwaddr_aton(arg_bssid, bssid))
140 ret = wpas_wps_start_reg(wpa_s, bssid, pin, NULL);
142 return wpas_dbus_new_invalid_opts_error(message,
147 return dbus_message_new_error(message,
148 WPAS_ERROR_WPS_PBC_ERROR,
149 "Could not request credentials");
152 return wpas_dbus_new_success_reply(message);