2 * WPA Supplicant / dbus-based control interface (WPS)
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #include "../config.h"
19 #include "../wpa_supplicant_i.h"
20 #include "../wps_supplicant.h"
22 #include "dbus_handlers.h"
25 * wpas_dbus_iface_wps_pbc - Request credentials using WPS PBC method
26 * @message: Pointer to incoming dbus message
27 * @wpa_s: %wpa_supplicant data structure
28 * Returns: A dbus message containing a UINT32 indicating success (1) or
31 * Handler function for "wpsPbc" method call
33 DBusMessage
* wpas_dbus_iface_wps_pbc(DBusMessage
*message
,
34 struct wpa_supplicant
*wpa_s
)
36 char *arg_bssid
= NULL
;
40 if (!dbus_message_get_args(message
, NULL
, DBUS_TYPE_STRING
, &arg_bssid
,
42 return wpas_dbus_new_invalid_opts_error(message
, NULL
);
44 if (!os_strcmp(arg_bssid
, "any"))
45 ret
= wpas_wps_start_pbc(wpa_s
, NULL
);
46 else if (!hwaddr_aton(arg_bssid
, bssid
))
47 ret
= wpas_wps_start_pbc(wpa_s
, bssid
);
49 return wpas_dbus_new_invalid_opts_error(message
,
54 return dbus_message_new_error(message
,
55 WPAS_ERROR_WPS_PBC_ERROR
,
56 "Could not start PBC "
60 return wpas_dbus_new_success_reply(message
);
65 * wpas_dbus_iface_wps_pin - Establish the PIN number of the enrollee
66 * @message: Pointer to incoming dbus message
67 * @wpa_s: %wpa_supplicant data structure
68 * Returns: A dbus message containing a UINT32 indicating success (1) or
71 * Handler function for "wpsPin" method call
73 DBusMessage
* wpas_dbus_iface_wps_pin(DBusMessage
*message
,
74 struct wpa_supplicant
*wpa_s
)
76 DBusMessage
*reply
= NULL
;
79 u8 bssid
[ETH_ALEN
], *_bssid
= NULL
;
82 if (!dbus_message_get_args(message
, NULL
, DBUS_TYPE_STRING
, &arg_bssid
,
83 DBUS_TYPE_STRING
, &pin
, DBUS_TYPE_INVALID
))
84 return wpas_dbus_new_invalid_opts_error(message
, NULL
);
86 if (!os_strcmp(arg_bssid
, "any"))
88 else if (!hwaddr_aton(arg_bssid
, bssid
))
91 return wpas_dbus_new_invalid_opts_error(message
,
95 if (os_strlen(pin
) > 0)
96 ret
= wpas_wps_start_pin(wpa_s
, _bssid
, pin
);
98 ret
= wpas_wps_start_pin(wpa_s
, _bssid
, NULL
);
101 return dbus_message_new_error(message
,
102 WPAS_ERROR_WPS_PIN_ERROR
,
103 "Could not init PIN");
106 reply
= dbus_message_new_method_return(message
);
111 dbus_message_append_args(reply
, DBUS_TYPE_STRING
, &pin
,
115 os_snprintf(npin
, sizeof(npin
), "%08d", ret
);
116 dbus_message_append_args(reply
, DBUS_TYPE_STRING
, &npin
,
124 * wpas_dbus_iface_wps_reg - Request credentials using the PIN of the AP
125 * @message: Pointer to incoming dbus message
126 * @wpa_s: %wpa_supplicant data structure
127 * Returns: A dbus message containing a UINT32 indicating success (1) or
130 * Handler function for "wpsReg" method call
132 DBusMessage
* wpas_dbus_iface_wps_reg(DBusMessage
*message
,
133 struct wpa_supplicant
*wpa_s
)
140 if (!dbus_message_get_args(message
, NULL
, DBUS_TYPE_STRING
, &arg_bssid
,
141 DBUS_TYPE_STRING
, &pin
, DBUS_TYPE_INVALID
))
142 return wpas_dbus_new_invalid_opts_error(message
, NULL
);
144 if (!os_strcmp(arg_bssid
, "any"))
145 ret
= wpas_wps_start_reg(wpa_s
, NULL
, pin
, NULL
);
146 else if (!hwaddr_aton(arg_bssid
, bssid
))
147 ret
= wpas_wps_start_reg(wpa_s
, bssid
, pin
, NULL
);
149 return wpas_dbus_new_invalid_opts_error(message
,
154 return dbus_message_new_error(message
,
155 WPAS_ERROR_WPS_PBC_ERROR
,
156 "Could not request credentials");
159 return wpas_dbus_new_success_reply(message
);