]>
Commit | Line | Data |
---|---|---|
ad08c363 JM |
1 | /* |
2 | * Wi-Fi Protected Setup | |
52eb293d | 3 | * Copyright (c) 2007-2009, Jouni Malinen <j@w1.fi> |
ad08c363 JM |
4 | * |
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. | |
8 | * | |
9 | * Alternatively, this software may be distributed under the terms of BSD | |
10 | * license. | |
11 | * | |
12 | * See README and COPYING for more details. | |
13 | */ | |
14 | ||
15 | #ifndef WPS_H | |
16 | #define WPS_H | |
17 | ||
f90c86d4 JM |
18 | #include "wps_defs.h" |
19 | ||
20 | /** | |
21 | * enum wsc_op_code - EAP-WSC OP-Code values | |
22 | */ | |
ad08c363 | 23 | enum wsc_op_code { |
f620268f | 24 | WSC_UPnP = 0 /* No OP Code in UPnP transport */, |
ad08c363 JM |
25 | WSC_Start = 0x01, |
26 | WSC_ACK = 0x02, | |
27 | WSC_NACK = 0x03, | |
28 | WSC_MSG = 0x04, | |
29 | WSC_Done = 0x05, | |
30 | WSC_FRAG_ACK = 0x06 | |
31 | }; | |
32 | ||
33 | struct wps_registrar; | |
f620268f | 34 | struct upnp_wps_device_sm; |
e9bcfebf | 35 | struct wps_er; |
ad08c363 | 36 | |
f90c86d4 JM |
37 | /** |
38 | * struct wps_credential - WPS Credential | |
39 | * @ssid: SSID | |
40 | * @ssid_len: Length of SSID | |
41 | * @auth_type: Authentication Type (WPS_AUTH_OPEN, .. flags) | |
42 | * @encr_type: Encryption Type (WPS_ENCR_NONE, .. flags) | |
43 | * @key_idx: Key index | |
44 | * @key: Key | |
45 | * @key_len: Key length in octets | |
4bdd5568 | 46 | * @mac_addr: MAC address of the Credential receiver |
eca6e0a9 JM |
47 | * @cred_attr: Unparsed Credential attribute data (used only in cred_cb()); |
48 | * this may be %NULL, if not used | |
49 | * @cred_attr_len: Length of cred_attr in octets | |
f90c86d4 | 50 | */ |
ad08c363 JM |
51 | struct wps_credential { |
52 | u8 ssid[32]; | |
53 | size_t ssid_len; | |
54 | u16 auth_type; | |
55 | u16 encr_type; | |
56 | u8 key_idx; | |
57 | u8 key[64]; | |
58 | size_t key_len; | |
59 | u8 mac_addr[ETH_ALEN]; | |
eca6e0a9 JM |
60 | const u8 *cred_attr; |
61 | size_t cred_attr_len; | |
ad08c363 JM |
62 | }; |
63 | ||
96750ea5 JM |
64 | #define WPS_DEV_TYPE_LEN 8 |
65 | #define WPS_DEV_TYPE_BUFSIZE 21 | |
66 | ||
f90c86d4 JM |
67 | /** |
68 | * struct wps_device_data - WPS Device Data | |
69 | * @mac_addr: Device MAC address | |
70 | * @device_name: Device Name (0..32 octets encoded in UTF-8) | |
71 | * @manufacturer: Manufacturer (0..64 octets encoded in UTF-8) | |
72 | * @model_name: Model Name (0..32 octets encoded in UTF-8) | |
73 | * @model_number: Model Number (0..32 octets encoded in UTF-8) | |
74 | * @serial_number: Serial Number (0..32 octets encoded in UTF-8) | |
96750ea5 | 75 | * @pri_dev_type: Primary Device Type |
f90c86d4 JM |
76 | * @os_version: OS Version |
77 | * @rf_bands: RF bands (WPS_RF_24GHZ, WPS_RF_50GHZ flags) | |
78 | */ | |
b8a8c299 JM |
79 | struct wps_device_data { |
80 | u8 mac_addr[ETH_ALEN]; | |
81 | char *device_name; | |
82 | char *manufacturer; | |
83 | char *model_name; | |
84 | char *model_number; | |
85 | char *serial_number; | |
96750ea5 | 86 | u8 pri_dev_type[WPS_DEV_TYPE_LEN]; |
b8a8c299 | 87 | u32 os_version; |
f90c86d4 | 88 | u8 rf_bands; |
b8a8c299 JM |
89 | }; |
90 | ||
46bdb83a MH |
91 | struct oob_conf_data { |
92 | enum { | |
93 | OOB_METHOD_UNKNOWN = 0, | |
94 | OOB_METHOD_DEV_PWD_E, | |
95 | OOB_METHOD_DEV_PWD_R, | |
96 | OOB_METHOD_CRED, | |
97 | } oob_method; | |
98 | struct wpabuf *dev_password; | |
99 | struct wpabuf *pubkey_hash; | |
100 | }; | |
101 | ||
f90c86d4 JM |
102 | /** |
103 | * struct wps_config - WPS configuration for a single registration protocol run | |
104 | */ | |
ad08c363 | 105 | struct wps_config { |
f90c86d4 JM |
106 | /** |
107 | * wps - Pointer to long term WPS context | |
108 | */ | |
ad08c363 | 109 | struct wps_context *wps; |
f90c86d4 JM |
110 | |
111 | /** | |
41c00105 | 112 | * registrar - Whether this end is a Registrar |
f90c86d4 | 113 | */ |
41c00105 | 114 | int registrar; |
f90c86d4 JM |
115 | |
116 | /** | |
117 | * pin - Enrollee Device Password (%NULL for Registrar or PBC) | |
118 | */ | |
119 | const u8 *pin; | |
120 | ||
121 | /** | |
122 | * pin_len - Length on pin in octets | |
123 | */ | |
ad08c363 | 124 | size_t pin_len; |
f90c86d4 JM |
125 | |
126 | /** | |
127 | * pbc - Whether this is protocol run uses PBC | |
128 | */ | |
ad08c363 | 129 | int pbc; |
f90c86d4 JM |
130 | |
131 | /** | |
132 | * assoc_wps_ie: (Re)AssocReq WPS IE (in AP; %NULL if not AP) | |
133 | */ | |
134 | const struct wpabuf *assoc_wps_ie; | |
52eb293d JM |
135 | |
136 | /** | |
137 | * new_ap_settings - New AP settings (%NULL if not used) | |
138 | * | |
139 | * This parameter provides new AP settings when using a wireless | |
140 | * stations as a Registrar to configure the AP. %NULL means that AP | |
141 | * will not be reconfigured, i.e., the station will only learn the | |
142 | * current AP settings by using AP PIN. | |
143 | */ | |
144 | const struct wps_credential *new_ap_settings; | |
2678509d JM |
145 | |
146 | /** | |
147 | * peer_addr: MAC address of the peer in AP; %NULL if not AP | |
148 | */ | |
149 | const u8 *peer_addr; | |
ad08c363 JM |
150 | }; |
151 | ||
152 | struct wps_data * wps_init(const struct wps_config *cfg); | |
153 | ||
154 | void wps_deinit(struct wps_data *data); | |
155 | ||
f90c86d4 JM |
156 | /** |
157 | * enum wps_process_res - WPS message processing result | |
158 | */ | |
ad08c363 | 159 | enum wps_process_res { |
f90c86d4 JM |
160 | /** |
161 | * WPS_DONE - Processing done | |
162 | */ | |
163 | WPS_DONE, | |
164 | ||
165 | /** | |
166 | * WPS_CONTINUE - Processing continues | |
167 | */ | |
168 | WPS_CONTINUE, | |
169 | ||
170 | /** | |
171 | * WPS_FAILURE - Processing failed | |
172 | */ | |
f620268f JM |
173 | WPS_FAILURE, |
174 | ||
175 | /** | |
176 | * WPS_PENDING - Processing continues, but waiting for an external | |
177 | * event (e.g., UPnP message from an external Registrar) | |
178 | */ | |
179 | WPS_PENDING | |
ad08c363 | 180 | }; |
f90c86d4 JM |
181 | enum wps_process_res wps_process_msg(struct wps_data *wps, |
182 | enum wsc_op_code op_code, | |
ad08c363 JM |
183 | const struct wpabuf *msg); |
184 | ||
f90c86d4 | 185 | struct wpabuf * wps_get_msg(struct wps_data *wps, enum wsc_op_code *op_code); |
ad08c363 | 186 | |
351f09a2 JM |
187 | int wps_is_selected_pbc_registrar(const struct wpabuf *msg); |
188 | int wps_is_selected_pin_registrar(const struct wpabuf *msg); | |
189 | const u8 * wps_get_uuid_e(const struct wpabuf *msg); | |
f90c86d4 JM |
190 | |
191 | struct wpabuf * wps_build_assoc_req_ie(enum wps_request_type req_type); | |
b8a8c299 | 192 | struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev, |
f90c86d4 JM |
193 | const u8 *uuid, |
194 | enum wps_request_type req_type); | |
ad08c363 JM |
195 | |
196 | ||
f90c86d4 JM |
197 | /** |
198 | * struct wps_registrar_config - WPS Registrar configuration | |
199 | */ | |
ad08c363 | 200 | struct wps_registrar_config { |
f90c86d4 JM |
201 | /** |
202 | * new_psk_cb - Callback for new PSK | |
203 | * @ctx: Higher layer context data (cb_ctx) | |
204 | * @mac_addr: MAC address of the Enrollee | |
205 | * @psk: The new PSK | |
206 | * @psk_len: The length of psk in octets | |
207 | * Returns: 0 on success, -1 on failure | |
208 | * | |
209 | * This callback is called when a new per-device PSK is provisioned. | |
210 | */ | |
ad08c363 JM |
211 | int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *psk, |
212 | size_t psk_len); | |
f90c86d4 JM |
213 | |
214 | /** | |
215 | * set_ie_cb - Callback for WPS IE changes | |
216 | * @ctx: Higher layer context data (cb_ctx) | |
217 | * @beacon_ie: WPS IE for Beacon | |
218 | * @beacon_ie_len: WPS IE length for Beacon | |
219 | * @probe_resp_ie: WPS IE for Probe Response | |
220 | * @probe_resp_ie_len: WPS IE length for Probe Response | |
221 | * Returns: 0 on success, -1 on failure | |
222 | * | |
223 | * This callback is called whenever the WPS IE in Beacon or Probe | |
224 | * Response frames needs to be changed (AP only). | |
225 | */ | |
ad08c363 JM |
226 | int (*set_ie_cb)(void *ctx, const u8 *beacon_ie, size_t beacon_ie_len, |
227 | const u8 *probe_resp_ie, size_t probe_resp_ie_len); | |
f90c86d4 JM |
228 | |
229 | /** | |
230 | * pin_needed_cb - Callback for requesting a PIN | |
231 | * @ctx: Higher layer context data (cb_ctx) | |
232 | * @uuid_e: UUID-E of the unknown Enrollee | |
233 | * @dev: Device Data from the unknown Enrollee | |
234 | * | |
235 | * This callback is called whenever an unknown Enrollee requests to use | |
236 | * PIN method and a matching PIN (Device Password) is not found in | |
237 | * Registrar data. | |
238 | */ | |
ad08c363 JM |
239 | void (*pin_needed_cb)(void *ctx, const u8 *uuid_e, |
240 | const struct wps_device_data *dev); | |
f90c86d4 | 241 | |
aabe26a1 JM |
242 | /** |
243 | * reg_success_cb - Callback for reporting successful registration | |
244 | * @ctx: Higher layer context data (cb_ctx) | |
245 | * @mac_addr: MAC address of the Enrollee | |
246 | * @uuid_e: UUID-E of the Enrollee | |
247 | * | |
248 | * This callback is called whenever an Enrollee completes registration | |
249 | * successfully. | |
250 | */ | |
251 | void (*reg_success_cb)(void *ctx, const u8 *mac_addr, | |
252 | const u8 *uuid_e); | |
253 | ||
72df2f5f JM |
254 | /** |
255 | * set_sel_reg_cb - Callback for reporting selected registrar changes | |
256 | * @ctx: Higher layer context data (cb_ctx) | |
257 | * @sel_reg: Whether the Registrar is selected | |
258 | * @dev_passwd_id: Device Password ID to indicate with method or | |
259 | * specific password the Registrar intends to use | |
260 | * @sel_reg_config_methods: Bit field of active config methods | |
261 | * | |
262 | * This callback is called whenever the Selected Registrar state | |
263 | * changes (e.g., a new PIN becomes available or PBC is invoked). This | |
264 | * callback is only used by External Registrar implementation; | |
265 | * set_ie_cb() is used by AP implementation in similar caes, but it | |
266 | * provides the full WPS IE data instead of just the minimal Registrar | |
267 | * state information. | |
268 | */ | |
269 | void (*set_sel_reg_cb)(void *ctx, int sel_reg, u16 dev_passwd_id, | |
270 | u16 sel_reg_config_methods); | |
271 | ||
f90c86d4 JM |
272 | /** |
273 | * cb_ctx: Higher layer context data for Registrar callbacks | |
274 | */ | |
ad08c363 | 275 | void *cb_ctx; |
6fa68a0e JM |
276 | |
277 | /** | |
278 | * skip_cred_build: Do not build credential | |
279 | * | |
280 | * This option can be used to disable internal code that builds | |
281 | * Credential attribute into M8 based on the current network | |
282 | * configuration and Enrollee capabilities. The extra_cred data will | |
283 | * then be used as the Credential(s). | |
284 | */ | |
285 | int skip_cred_build; | |
286 | ||
287 | /** | |
288 | * extra_cred: Additional Credential attribute(s) | |
289 | * | |
290 | * This optional data (set to %NULL to disable) can be used to add | |
291 | * Credential attribute(s) for other networks into M8. If | |
292 | * skip_cred_build is set, this will also override the automatically | |
293 | * generated Credential attribute. | |
294 | */ | |
295 | const u8 *extra_cred; | |
296 | ||
297 | /** | |
298 | * extra_cred_len: Length of extra_cred in octets | |
299 | */ | |
300 | size_t extra_cred_len; | |
aabe26a1 JM |
301 | |
302 | /** | |
303 | * disable_auto_conf - Disable auto-configuration on first registration | |
304 | * | |
305 | * By default, the AP that is started in not configured state will | |
306 | * generate a random PSK and move to configured state when the first | |
307 | * registration protocol run is completed successfully. This option can | |
308 | * be used to disable this functionality and leave it up to an external | |
309 | * program to take care of configuration. This requires the extra_cred | |
310 | * to be set with a suitable Credential and skip_cred_build being used. | |
311 | */ | |
312 | int disable_auto_conf; | |
143a4bf6 JM |
313 | |
314 | /** | |
315 | * static_wep_only - Whether the BSS supports only static WEP | |
316 | */ | |
317 | int static_wep_only; | |
ad08c363 JM |
318 | }; |
319 | ||
320 | ||
f90c86d4 JM |
321 | /** |
322 | * enum wps_event - WPS event types | |
323 | */ | |
4b68290e | 324 | enum wps_event { |
f90c86d4 JM |
325 | /** |
326 | * WPS_EV_M2D - M2D received (Registrar did not know us) | |
327 | */ | |
469fc3a4 | 328 | WPS_EV_M2D, |
f90c86d4 JM |
329 | |
330 | /** | |
331 | * WPS_EV_FAIL - Registration failed | |
332 | */ | |
ad5302a1 | 333 | WPS_EV_FAIL, |
f90c86d4 JM |
334 | |
335 | /** | |
336 | * WPS_EV_SUCCESS - Registration succeeded | |
337 | */ | |
3b2cf800 JM |
338 | WPS_EV_SUCCESS, |
339 | ||
340 | /** | |
341 | * WPS_EV_PWD_AUTH_FAIL - Password authentication failed | |
342 | */ | |
63330c68 OK |
343 | WPS_EV_PWD_AUTH_FAIL, |
344 | ||
345 | /** | |
346 | * WPS_EV_PBC_OVERLAP - PBC session overlap detected | |
347 | */ | |
348 | WPS_EV_PBC_OVERLAP, | |
349 | ||
350 | /** | |
351 | * WPS_EV_PBC_TIMEOUT - PBC walktime expired before protocol run start | |
352 | */ | |
b78bc3a3 JM |
353 | WPS_EV_PBC_TIMEOUT, |
354 | ||
355 | /** | |
356 | * WPS_EV_ER_AP_ADD - ER: AP added | |
357 | */ | |
358 | WPS_EV_ER_AP_ADD, | |
359 | ||
360 | /** | |
361 | * WPS_EV_ER_AP_REMOVE - ER: AP removed | |
362 | */ | |
363 | WPS_EV_ER_AP_REMOVE, | |
364 | ||
365 | /** | |
366 | * WPS_EV_ER_ENROLLEE_ADD - ER: Enrollee added | |
367 | */ | |
368 | WPS_EV_ER_ENROLLEE_ADD, | |
369 | ||
370 | /** | |
371 | * WPS_EV_ER_ENROLLEE_REMOVE - ER: Enrollee removed | |
372 | */ | |
373 | WPS_EV_ER_ENROLLEE_REMOVE | |
4b68290e JM |
374 | }; |
375 | ||
f90c86d4 JM |
376 | /** |
377 | * union wps_event_data - WPS event data | |
378 | */ | |
4b68290e | 379 | union wps_event_data { |
f90c86d4 JM |
380 | /** |
381 | * struct wps_event_m2d - M2D event data | |
382 | */ | |
4b68290e JM |
383 | struct wps_event_m2d { |
384 | u16 config_methods; | |
385 | const u8 *manufacturer; | |
386 | size_t manufacturer_len; | |
387 | const u8 *model_name; | |
388 | size_t model_name_len; | |
389 | const u8 *model_number; | |
390 | size_t model_number_len; | |
391 | const u8 *serial_number; | |
392 | size_t serial_number_len; | |
393 | const u8 *dev_name; | |
394 | size_t dev_name_len; | |
395 | const u8 *primary_dev_type; /* 8 octets */ | |
396 | u16 config_error; | |
397 | u16 dev_password_id; | |
398 | } m2d; | |
f90c86d4 JM |
399 | |
400 | /** | |
401 | * struct wps_event_fail - Registration failure information | |
402 | * @msg: enum wps_msg_type | |
403 | */ | |
469fc3a4 | 404 | struct wps_event_fail { |
f90c86d4 | 405 | int msg; |
469fc3a4 | 406 | } fail; |
3b2cf800 JM |
407 | |
408 | struct wps_event_pwd_auth_fail { | |
409 | int enrollee; | |
410 | int part; | |
411 | } pwd_auth_fail; | |
b78bc3a3 JM |
412 | |
413 | struct wps_event_er_ap { | |
414 | const u8 *uuid; | |
e694b344 | 415 | const u8 *mac_addr; |
b78bc3a3 JM |
416 | const char *friendly_name; |
417 | const char *manufacturer; | |
418 | const char *manufacturer_url; | |
419 | const char *model_description; | |
420 | const char *model_name; | |
421 | const char *model_number; | |
422 | const char *model_url; | |
423 | const char *serial_number; | |
424 | const char *upc; | |
e694b344 JM |
425 | const u8 *pri_dev_type; |
426 | u8 wps_state; | |
b78bc3a3 JM |
427 | } ap; |
428 | ||
429 | struct wps_event_er_enrollee { | |
430 | const u8 *uuid; | |
431 | const u8 *mac_addr; | |
432 | int m1_received; | |
433 | u16 config_methods; | |
434 | u16 dev_passwd_id; | |
435 | const u8 *pri_dev_type; | |
436 | const char *dev_name; | |
437 | const char *manufacturer; | |
438 | const char *model_name; | |
439 | const char *model_number; | |
440 | const char *serial_number; | |
441 | } enrollee; | |
4b68290e JM |
442 | }; |
443 | ||
915c1ba3 JM |
444 | /** |
445 | * struct upnp_pending_message - Pending PutWLANResponse messages | |
446 | * @next: Pointer to next pending message or %NULL | |
447 | * @addr: NewWLANEventMAC | |
448 | * @msg: NewMessage | |
449 | * @type: Message Type | |
450 | */ | |
451 | struct upnp_pending_message { | |
452 | struct upnp_pending_message *next; | |
453 | u8 addr[ETH_ALEN]; | |
454 | struct wpabuf *msg; | |
455 | enum wps_msg_type type; | |
456 | }; | |
457 | ||
e9ab39b4 JM |
458 | /** |
459 | * struct wps_context - Long term WPS context data | |
460 | * | |
461 | * This data is stored at the higher layer Authenticator or Supplicant data | |
462 | * structures and it is maintained over multiple registration protocol runs. | |
463 | */ | |
ad08c363 | 464 | struct wps_context { |
f90c86d4 JM |
465 | /** |
466 | * ap - Whether the local end is an access point | |
467 | */ | |
ad08c363 | 468 | int ap; |
f90c86d4 JM |
469 | |
470 | /** | |
471 | * registrar - Pointer to WPS registrar data from wps_registrar_init() | |
472 | */ | |
ad08c363 | 473 | struct wps_registrar *registrar; |
f90c86d4 JM |
474 | |
475 | /** | |
476 | * wps_state - Current WPS state | |
477 | */ | |
478 | enum wps_state wps_state; | |
479 | ||
480 | /** | |
481 | * ap_setup_locked - Whether AP setup is locked (only used at AP) | |
482 | */ | |
ad08c363 | 483 | int ap_setup_locked; |
f90c86d4 JM |
484 | |
485 | /** | |
486 | * uuid - Own UUID | |
487 | */ | |
ad08c363 | 488 | u8 uuid[16]; |
f90c86d4 JM |
489 | |
490 | /** | |
491 | * ssid - SSID | |
492 | * | |
493 | * This SSID is used by the Registrar to fill in information for | |
494 | * Credentials. In addition, AP uses it when acting as an Enrollee to | |
495 | * notify Registrar of the current configuration. | |
496 | */ | |
ad08c363 | 497 | u8 ssid[32]; |
f90c86d4 JM |
498 | |
499 | /** | |
500 | * ssid_len - Length of ssid in octets | |
501 | */ | |
ad08c363 | 502 | size_t ssid_len; |
f90c86d4 JM |
503 | |
504 | /** | |
505 | * dev - Own WPS device data | |
506 | */ | |
ad08c363 | 507 | struct wps_device_data dev; |
f90c86d4 | 508 | |
46bdb83a MH |
509 | /** |
510 | * oob_conf - OOB Config data | |
511 | */ | |
512 | struct oob_conf_data oob_conf; | |
513 | ||
514 | /** | |
515 | * oob_dev_pw_id - OOB Device password id | |
516 | */ | |
517 | u16 oob_dev_pw_id; | |
518 | ||
f042122a JM |
519 | /** |
520 | * dh_ctx - Context data for Diffie-Hellman operation | |
521 | */ | |
522 | void *dh_ctx; | |
523 | ||
46bdb83a MH |
524 | /** |
525 | * dh_privkey - Diffie-Hellman private key | |
526 | */ | |
527 | struct wpabuf *dh_privkey; | |
528 | ||
529 | /** | |
530 | * dh_pubkey_oob - Diffie-Hellman public key | |
531 | */ | |
532 | struct wpabuf *dh_pubkey; | |
533 | ||
f90c86d4 JM |
534 | /** |
535 | * config_methods - Enabled configuration methods | |
536 | * | |
537 | * Bit field of WPS_CONFIG_* | |
538 | */ | |
539 | u16 config_methods; | |
540 | ||
541 | /** | |
542 | * encr_types - Enabled encryption types (bit field of WPS_ENCR_*) | |
543 | */ | |
544 | u16 encr_types; | |
545 | ||
546 | /** | |
547 | * auth_types - Authentication types (bit field of WPS_AUTH_*) | |
548 | */ | |
549 | u16 auth_types; | |
550 | ||
551 | /** | |
552 | * network_key - The current Network Key (PSK) or %NULL to generate new | |
553 | * | |
554 | * If %NULL, Registrar will generate per-device PSK. In addition, AP | |
555 | * uses this when acting as an Enrollee to notify Registrar of the | |
556 | * current configuration. | |
557 | */ | |
558 | u8 *network_key; | |
559 | ||
560 | /** | |
561 | * network_key_len - Length of network_key in octets | |
562 | */ | |
ad08c363 JM |
563 | size_t network_key_len; |
564 | ||
4c29cae9 JM |
565 | /** |
566 | * ap_settings - AP Settings override for M7 (only used at AP) | |
567 | * | |
568 | * If %NULL, AP Settings attributes will be generated based on the | |
569 | * current network configuration. | |
570 | */ | |
571 | u8 *ap_settings; | |
572 | ||
573 | /** | |
574 | * ap_settings_len - Length of ap_settings in octets | |
575 | */ | |
576 | size_t ap_settings_len; | |
577 | ||
f620268f JM |
578 | /** |
579 | * friendly_name - Friendly Name (required for UPnP) | |
580 | */ | |
581 | char *friendly_name; | |
582 | ||
583 | /** | |
584 | * manufacturer_url - Manufacturer URL (optional for UPnP) | |
585 | */ | |
586 | char *manufacturer_url; | |
587 | ||
588 | /** | |
589 | * model_description - Model Description (recommended for UPnP) | |
590 | */ | |
591 | char *model_description; | |
592 | ||
593 | /** | |
594 | * model_url - Model URL (optional for UPnP) | |
595 | */ | |
596 | char *model_url; | |
597 | ||
598 | /** | |
599 | * upc - Universal Product Code (optional for UPnP) | |
600 | */ | |
601 | char *upc; | |
602 | ||
f90c86d4 JM |
603 | /** |
604 | * cred_cb - Callback to notify that new Credentials were received | |
605 | * @ctx: Higher layer context data (cb_ctx) | |
606 | * @cred: The received Credential | |
607 | * Return: 0 on success, -1 on failure | |
608 | */ | |
ad08c363 | 609 | int (*cred_cb)(void *ctx, const struct wps_credential *cred); |
f90c86d4 JM |
610 | |
611 | /** | |
612 | * event_cb - Event callback (state information about progress) | |
613 | * @ctx: Higher layer context data (cb_ctx) | |
614 | * @event: Event type | |
615 | * @data: Event data | |
616 | */ | |
4b68290e JM |
617 | void (*event_cb)(void *ctx, enum wps_event event, |
618 | union wps_event_data *data); | |
f90c86d4 JM |
619 | |
620 | /** | |
621 | * cb_ctx: Higher layer context data for callbacks | |
622 | */ | |
ad08c363 | 623 | void *cb_ctx; |
f620268f JM |
624 | |
625 | struct upnp_wps_device_sm *wps_upnp; | |
626 | ||
915c1ba3 JM |
627 | /* Pending messages from UPnP PutWLANResponse */ |
628 | struct upnp_pending_message *upnp_msgs; | |
ad08c363 JM |
629 | }; |
630 | ||
46bdb83a | 631 | struct oob_device_data { |
e1ee6b60 | 632 | char *device_name; |
46bdb83a | 633 | char *device_path; |
7cbf51bb JM |
634 | void * (*init_func)(struct wps_context *, struct oob_device_data *, |
635 | int); | |
70e07046 JM |
636 | struct wpabuf * (*read_func)(void *); |
637 | int (*write_func)(void *, struct wpabuf *); | |
638 | void (*deinit_func)(void *); | |
46bdb83a | 639 | }; |
ad08c363 | 640 | |
e1ee6b60 MH |
641 | struct oob_nfc_device_data { |
642 | int (*init_func)(char *); | |
643 | void * (*read_func)(size_t *); | |
644 | int (*write_func)(void *, size_t); | |
645 | void (*deinit_func)(void); | |
646 | }; | |
647 | ||
ad08c363 JM |
648 | struct wps_registrar * |
649 | wps_registrar_init(struct wps_context *wps, | |
650 | const struct wps_registrar_config *cfg); | |
651 | void wps_registrar_deinit(struct wps_registrar *reg); | |
652 | int wps_registrar_add_pin(struct wps_registrar *reg, const u8 *uuid, | |
077a781f | 653 | const u8 *pin, size_t pin_len, int timeout); |
ad08c363 JM |
654 | int wps_registrar_invalidate_pin(struct wps_registrar *reg, const u8 *uuid); |
655 | int wps_registrar_unlock_pin(struct wps_registrar *reg, const u8 *uuid); | |
656 | int wps_registrar_button_pushed(struct wps_registrar *reg); | |
657 | void wps_registrar_probe_req_rx(struct wps_registrar *reg, const u8 *addr, | |
658 | const struct wpabuf *wps_data); | |
3b2cf800 | 659 | int wps_registrar_update_ie(struct wps_registrar *reg); |
2678509d JM |
660 | int wps_registrar_get_info(struct wps_registrar *reg, const u8 *addr, |
661 | char *buf, size_t buflen); | |
ad08c363 | 662 | |
e05716d0 JM |
663 | unsigned int wps_pin_checksum(unsigned int pin); |
664 | unsigned int wps_pin_valid(unsigned int pin); | |
665 | unsigned int wps_generate_pin(void); | |
915c1ba3 | 666 | void wps_free_pending_msgs(struct upnp_pending_message *msgs); |
e05716d0 | 667 | |
46bdb83a | 668 | struct oob_device_data * wps_get_oob_device(char *device_type); |
e1ee6b60 | 669 | struct oob_nfc_device_data * wps_get_oob_nfc_device(char *device_name); |
46bdb83a | 670 | int wps_get_oob_method(char *method); |
7cbf51bb JM |
671 | int wps_process_oob(struct wps_context *wps, struct oob_device_data *oob_dev, |
672 | int registrar); | |
611ed491 | 673 | int wps_attr_text(struct wpabuf *data, char *buf, char *end); |
46bdb83a | 674 | |
e9bcfebf | 675 | struct wps_er * wps_er_init(struct wps_context *wps, const char *ifname); |
b3f371ca | 676 | void wps_er_refresh(struct wps_er *er); |
1a1bf008 | 677 | void wps_er_deinit(struct wps_er *er, void (*cb)(void *ctx), void *ctx); |
72df2f5f JM |
678 | void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id, |
679 | u16 sel_reg_config_methods); | |
564cd7fa | 680 | int wps_er_pbc(struct wps_er *er, const u8 *uuid); |
e64dcfd5 JM |
681 | int wps_er_learn(struct wps_er *er, const u8 *uuid, const u8 *pin, |
682 | size_t pin_len); | |
e9bcfebf | 683 | |
96750ea5 JM |
684 | int wps_dev_type_str2bin(const char *str, u8 dev_type[WPS_DEV_TYPE_LEN]); |
685 | char * wps_dev_type_bin2str(const u8 dev_type[WPS_DEV_TYPE_LEN], char *buf, | |
686 | size_t buf_len); | |
120158cc | 687 | void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid); |
96750ea5 | 688 | |
ad08c363 | 689 | #endif /* WPS_H */ |