]> git.ipfire.org Git - thirdparty/hostap.git/blob - src/wps/wps.h
P2P: Allow WPS_PBC command on GO to select on P2P Device Address
[thirdparty/hostap.git] / src / wps / wps.h
1 /*
2 * Wi-Fi Protected Setup
3 * Copyright (c) 2007-2009, Jouni Malinen <j@w1.fi>
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
18 #include "wps_defs.h"
19
20 /**
21 * enum wsc_op_code - EAP-WSC OP-Code values
22 */
23 enum wsc_op_code {
24 WSC_UPnP = 0 /* No OP Code in UPnP transport */,
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;
34 struct upnp_wps_device_sm;
35 struct wps_er;
36
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
46 * @mac_addr: MAC address of the Credential receiver
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
50 */
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];
60 const u8 *cred_attr;
61 size_t cred_attr_len;
62 };
63
64 #define WPS_DEV_TYPE_LEN 8
65 #define WPS_DEV_TYPE_BUFSIZE 21
66
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)
75 * @pri_dev_type: Primary Device Type
76 * @os_version: OS Version
77 * @rf_bands: RF bands (WPS_RF_24GHZ, WPS_RF_50GHZ flags)
78 * @p2p: Whether the device is a P2P device
79 */
80 struct wps_device_data {
81 u8 mac_addr[ETH_ALEN];
82 char *device_name;
83 char *manufacturer;
84 char *model_name;
85 char *model_number;
86 char *serial_number;
87 u8 pri_dev_type[WPS_DEV_TYPE_LEN];
88 u32 os_version;
89 u8 rf_bands;
90
91 int p2p;
92 };
93
94 struct oob_conf_data {
95 enum {
96 OOB_METHOD_UNKNOWN = 0,
97 OOB_METHOD_DEV_PWD_E,
98 OOB_METHOD_DEV_PWD_R,
99 OOB_METHOD_CRED,
100 } oob_method;
101 struct wpabuf *dev_password;
102 struct wpabuf *pubkey_hash;
103 };
104
105 /**
106 * struct wps_config - WPS configuration for a single registration protocol run
107 */
108 struct wps_config {
109 /**
110 * wps - Pointer to long term WPS context
111 */
112 struct wps_context *wps;
113
114 /**
115 * registrar - Whether this end is a Registrar
116 */
117 int registrar;
118
119 /**
120 * pin - Enrollee Device Password (%NULL for Registrar or PBC)
121 */
122 const u8 *pin;
123
124 /**
125 * pin_len - Length on pin in octets
126 */
127 size_t pin_len;
128
129 /**
130 * pbc - Whether this is protocol run uses PBC
131 */
132 int pbc;
133
134 /**
135 * assoc_wps_ie: (Re)AssocReq WPS IE (in AP; %NULL if not AP)
136 */
137 const struct wpabuf *assoc_wps_ie;
138
139 /**
140 * new_ap_settings - New AP settings (%NULL if not used)
141 *
142 * This parameter provides new AP settings when using a wireless
143 * stations as a Registrar to configure the AP. %NULL means that AP
144 * will not be reconfigured, i.e., the station will only learn the
145 * current AP settings by using AP PIN.
146 */
147 const struct wps_credential *new_ap_settings;
148
149 /**
150 * peer_addr: MAC address of the peer in AP; %NULL if not AP
151 */
152 const u8 *peer_addr;
153
154 /**
155 * use_psk_key - Use PSK format key in Credential
156 *
157 * Force PSK format to be used instead of ASCII passphrase when
158 * building Credential for an Enrollee. The PSK value is set in
159 * struct wpa_context::psk.
160 */
161 int use_psk_key;
162
163 /**
164 * dev_pw_id - Device Password ID for Enrollee when PIN is used
165 */
166 u16 dev_pw_id;
167
168 /**
169 * p2p_dev_addr - P2P Device Address from (Re)Association Request
170 *
171 * On AP/GO, this is set to the P2P Device Address of the associating
172 * P2P client if a P2P IE is included in the (Re)Association Request
173 * frame and the P2P Device Address is included. Otherwise, this is set
174 * to %NULL to indicate the station does not have a P2P Device Address.
175 */
176 const u8 *p2p_dev_addr;
177 };
178
179 struct wps_data * wps_init(const struct wps_config *cfg);
180
181 void wps_deinit(struct wps_data *data);
182
183 /**
184 * enum wps_process_res - WPS message processing result
185 */
186 enum wps_process_res {
187 /**
188 * WPS_DONE - Processing done
189 */
190 WPS_DONE,
191
192 /**
193 * WPS_CONTINUE - Processing continues
194 */
195 WPS_CONTINUE,
196
197 /**
198 * WPS_FAILURE - Processing failed
199 */
200 WPS_FAILURE,
201
202 /**
203 * WPS_PENDING - Processing continues, but waiting for an external
204 * event (e.g., UPnP message from an external Registrar)
205 */
206 WPS_PENDING
207 };
208 enum wps_process_res wps_process_msg(struct wps_data *wps,
209 enum wsc_op_code op_code,
210 const struct wpabuf *msg);
211
212 struct wpabuf * wps_get_msg(struct wps_data *wps, enum wsc_op_code *op_code);
213
214 int wps_is_selected_pbc_registrar(const struct wpabuf *msg);
215 int wps_is_selected_pin_registrar(const struct wpabuf *msg);
216 int wps_ap_priority_compar(const struct wpabuf *wps_a,
217 const struct wpabuf *wps_b);
218 int wps_is_addr_authorized(const struct wpabuf *msg, const u8 *addr,
219 int ver1_compat);
220 const u8 * wps_get_uuid_e(const struct wpabuf *msg);
221
222 struct wpabuf * wps_build_assoc_req_ie(enum wps_request_type req_type);
223 struct wpabuf * wps_build_assoc_resp_ie(void);
224 struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
225 const u8 *uuid,
226 enum wps_request_type req_type);
227
228
229 /**
230 * struct wps_registrar_config - WPS Registrar configuration
231 */
232 struct wps_registrar_config {
233 /**
234 * new_psk_cb - Callback for new PSK
235 * @ctx: Higher layer context data (cb_ctx)
236 * @mac_addr: MAC address of the Enrollee
237 * @psk: The new PSK
238 * @psk_len: The length of psk in octets
239 * Returns: 0 on success, -1 on failure
240 *
241 * This callback is called when a new per-device PSK is provisioned.
242 */
243 int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *psk,
244 size_t psk_len);
245
246 /**
247 * set_ie_cb - Callback for WPS IE changes
248 * @ctx: Higher layer context data (cb_ctx)
249 * @beacon_ie: WPS IE for Beacon
250 * @probe_resp_ie: WPS IE for Probe Response
251 * Returns: 0 on success, -1 on failure
252 *
253 * This callback is called whenever the WPS IE in Beacon or Probe
254 * Response frames needs to be changed (AP only). Callee is responsible
255 * for freeing the buffers.
256 */
257 int (*set_ie_cb)(void *ctx, struct wpabuf *beacon_ie,
258 struct wpabuf *probe_resp_ie);
259
260 /**
261 * pin_needed_cb - Callback for requesting a PIN
262 * @ctx: Higher layer context data (cb_ctx)
263 * @uuid_e: UUID-E of the unknown Enrollee
264 * @dev: Device Data from the unknown Enrollee
265 *
266 * This callback is called whenever an unknown Enrollee requests to use
267 * PIN method and a matching PIN (Device Password) is not found in
268 * Registrar data.
269 */
270 void (*pin_needed_cb)(void *ctx, const u8 *uuid_e,
271 const struct wps_device_data *dev);
272
273 /**
274 * reg_success_cb - Callback for reporting successful registration
275 * @ctx: Higher layer context data (cb_ctx)
276 * @mac_addr: MAC address of the Enrollee
277 * @uuid_e: UUID-E of the Enrollee
278 *
279 * This callback is called whenever an Enrollee completes registration
280 * successfully.
281 */
282 void (*reg_success_cb)(void *ctx, const u8 *mac_addr,
283 const u8 *uuid_e);
284
285 /**
286 * set_sel_reg_cb - Callback for reporting selected registrar changes
287 * @ctx: Higher layer context data (cb_ctx)
288 * @sel_reg: Whether the Registrar is selected
289 * @dev_passwd_id: Device Password ID to indicate with method or
290 * specific password the Registrar intends to use
291 * @sel_reg_config_methods: Bit field of active config methods
292 *
293 * This callback is called whenever the Selected Registrar state
294 * changes (e.g., a new PIN becomes available or PBC is invoked). This
295 * callback is only used by External Registrar implementation;
296 * set_ie_cb() is used by AP implementation in similar caes, but it
297 * provides the full WPS IE data instead of just the minimal Registrar
298 * state information.
299 */
300 void (*set_sel_reg_cb)(void *ctx, int sel_reg, u16 dev_passwd_id,
301 u16 sel_reg_config_methods);
302
303 /**
304 * enrollee_seen_cb - Callback for reporting Enrollee based on ProbeReq
305 * @ctx: Higher layer context data (cb_ctx)
306 * @addr: MAC address of the Enrollee
307 * @uuid_e: UUID of the Enrollee
308 * @pri_dev_type: Primary device type
309 * @config_methods: Config Methods
310 * @dev_password_id: Device Password ID
311 * @request_type: Request Type
312 * @dev_name: Device Name (if available)
313 */
314 void (*enrollee_seen_cb)(void *ctx, const u8 *addr, const u8 *uuid_e,
315 const u8 *pri_dev_type, u16 config_methods,
316 u16 dev_password_id, u8 request_type,
317 const char *dev_name);
318
319 /**
320 * cb_ctx: Higher layer context data for Registrar callbacks
321 */
322 void *cb_ctx;
323
324 /**
325 * skip_cred_build: Do not build credential
326 *
327 * This option can be used to disable internal code that builds
328 * Credential attribute into M8 based on the current network
329 * configuration and Enrollee capabilities. The extra_cred data will
330 * then be used as the Credential(s).
331 */
332 int skip_cred_build;
333
334 /**
335 * extra_cred: Additional Credential attribute(s)
336 *
337 * This optional data (set to %NULL to disable) can be used to add
338 * Credential attribute(s) for other networks into M8. If
339 * skip_cred_build is set, this will also override the automatically
340 * generated Credential attribute.
341 */
342 const u8 *extra_cred;
343
344 /**
345 * extra_cred_len: Length of extra_cred in octets
346 */
347 size_t extra_cred_len;
348
349 /**
350 * disable_auto_conf - Disable auto-configuration on first registration
351 *
352 * By default, the AP that is started in not configured state will
353 * generate a random PSK and move to configured state when the first
354 * registration protocol run is completed successfully. This option can
355 * be used to disable this functionality and leave it up to an external
356 * program to take care of configuration. This requires the extra_cred
357 * to be set with a suitable Credential and skip_cred_build being used.
358 */
359 int disable_auto_conf;
360
361 /**
362 * static_wep_only - Whether the BSS supports only static WEP
363 */
364 int static_wep_only;
365
366 /**
367 * dualband - Whether this is a concurrent dualband AP
368 */
369 int dualband;
370 };
371
372
373 /**
374 * enum wps_event - WPS event types
375 */
376 enum wps_event {
377 /**
378 * WPS_EV_M2D - M2D received (Registrar did not know us)
379 */
380 WPS_EV_M2D,
381
382 /**
383 * WPS_EV_FAIL - Registration failed
384 */
385 WPS_EV_FAIL,
386
387 /**
388 * WPS_EV_SUCCESS - Registration succeeded
389 */
390 WPS_EV_SUCCESS,
391
392 /**
393 * WPS_EV_PWD_AUTH_FAIL - Password authentication failed
394 */
395 WPS_EV_PWD_AUTH_FAIL,
396
397 /**
398 * WPS_EV_PBC_OVERLAP - PBC session overlap detected
399 */
400 WPS_EV_PBC_OVERLAP,
401
402 /**
403 * WPS_EV_PBC_TIMEOUT - PBC walktime expired before protocol run start
404 */
405 WPS_EV_PBC_TIMEOUT,
406
407 /**
408 * WPS_EV_ER_AP_ADD - ER: AP added
409 */
410 WPS_EV_ER_AP_ADD,
411
412 /**
413 * WPS_EV_ER_AP_REMOVE - ER: AP removed
414 */
415 WPS_EV_ER_AP_REMOVE,
416
417 /**
418 * WPS_EV_ER_ENROLLEE_ADD - ER: Enrollee added
419 */
420 WPS_EV_ER_ENROLLEE_ADD,
421
422 /**
423 * WPS_EV_ER_ENROLLEE_REMOVE - ER: Enrollee removed
424 */
425 WPS_EV_ER_ENROLLEE_REMOVE,
426
427 /**
428 * WPS_EV_ER_AP_SETTINGS - ER: AP Settings learned
429 */
430 WPS_EV_ER_AP_SETTINGS,
431
432 /**
433 * WPS_EV_ER_SET_SELECTED_REGISTRAR - ER: SetSelectedRegistrar event
434 */
435 WPS_EV_ER_SET_SELECTED_REGISTRAR
436 };
437
438 /**
439 * union wps_event_data - WPS event data
440 */
441 union wps_event_data {
442 /**
443 * struct wps_event_m2d - M2D event data
444 */
445 struct wps_event_m2d {
446 u16 config_methods;
447 const u8 *manufacturer;
448 size_t manufacturer_len;
449 const u8 *model_name;
450 size_t model_name_len;
451 const u8 *model_number;
452 size_t model_number_len;
453 const u8 *serial_number;
454 size_t serial_number_len;
455 const u8 *dev_name;
456 size_t dev_name_len;
457 const u8 *primary_dev_type; /* 8 octets */
458 u16 config_error;
459 u16 dev_password_id;
460 } m2d;
461
462 /**
463 * struct wps_event_fail - Registration failure information
464 * @msg: enum wps_msg_type
465 */
466 struct wps_event_fail {
467 int msg;
468 u16 config_error;
469 u16 error_indication;
470 } fail;
471
472 struct wps_event_pwd_auth_fail {
473 int enrollee;
474 int part;
475 } pwd_auth_fail;
476
477 struct wps_event_er_ap {
478 const u8 *uuid;
479 const u8 *mac_addr;
480 const char *friendly_name;
481 const char *manufacturer;
482 const char *manufacturer_url;
483 const char *model_description;
484 const char *model_name;
485 const char *model_number;
486 const char *model_url;
487 const char *serial_number;
488 const char *upc;
489 const u8 *pri_dev_type;
490 u8 wps_state;
491 } ap;
492
493 struct wps_event_er_enrollee {
494 const u8 *uuid;
495 const u8 *mac_addr;
496 int m1_received;
497 u16 config_methods;
498 u16 dev_passwd_id;
499 const u8 *pri_dev_type;
500 const char *dev_name;
501 const char *manufacturer;
502 const char *model_name;
503 const char *model_number;
504 const char *serial_number;
505 } enrollee;
506
507 struct wps_event_er_ap_settings {
508 const u8 *uuid;
509 const struct wps_credential *cred;
510 } ap_settings;
511
512 struct wps_event_er_set_selected_registrar {
513 const u8 *uuid;
514 int sel_reg;
515 u16 dev_passwd_id;
516 u16 sel_reg_config_methods;
517 enum {
518 WPS_ER_SET_SEL_REG_START,
519 WPS_ER_SET_SEL_REG_DONE,
520 WPS_ER_SET_SEL_REG_FAILED
521 } state;
522 } set_sel_reg;
523 };
524
525 /**
526 * struct upnp_pending_message - Pending PutWLANResponse messages
527 * @next: Pointer to next pending message or %NULL
528 * @addr: NewWLANEventMAC
529 * @msg: NewMessage
530 * @type: Message Type
531 */
532 struct upnp_pending_message {
533 struct upnp_pending_message *next;
534 u8 addr[ETH_ALEN];
535 struct wpabuf *msg;
536 enum wps_msg_type type;
537 };
538
539 /**
540 * struct wps_context - Long term WPS context data
541 *
542 * This data is stored at the higher layer Authenticator or Supplicant data
543 * structures and it is maintained over multiple registration protocol runs.
544 */
545 struct wps_context {
546 /**
547 * ap - Whether the local end is an access point
548 */
549 int ap;
550
551 /**
552 * registrar - Pointer to WPS registrar data from wps_registrar_init()
553 */
554 struct wps_registrar *registrar;
555
556 /**
557 * wps_state - Current WPS state
558 */
559 enum wps_state wps_state;
560
561 /**
562 * ap_setup_locked - Whether AP setup is locked (only used at AP)
563 */
564 int ap_setup_locked;
565
566 /**
567 * uuid - Own UUID
568 */
569 u8 uuid[16];
570
571 /**
572 * ssid - SSID
573 *
574 * This SSID is used by the Registrar to fill in information for
575 * Credentials. In addition, AP uses it when acting as an Enrollee to
576 * notify Registrar of the current configuration.
577 */
578 u8 ssid[32];
579
580 /**
581 * ssid_len - Length of ssid in octets
582 */
583 size_t ssid_len;
584
585 /**
586 * dev - Own WPS device data
587 */
588 struct wps_device_data dev;
589
590 /**
591 * oob_conf - OOB Config data
592 */
593 struct oob_conf_data oob_conf;
594
595 /**
596 * oob_dev_pw_id - OOB Device password id
597 */
598 u16 oob_dev_pw_id;
599
600 /**
601 * dh_ctx - Context data for Diffie-Hellman operation
602 */
603 void *dh_ctx;
604
605 /**
606 * dh_privkey - Diffie-Hellman private key
607 */
608 struct wpabuf *dh_privkey;
609
610 /**
611 * dh_pubkey_oob - Diffie-Hellman public key
612 */
613 struct wpabuf *dh_pubkey;
614
615 /**
616 * config_methods - Enabled configuration methods
617 *
618 * Bit field of WPS_CONFIG_*
619 */
620 u16 config_methods;
621
622 /**
623 * encr_types - Enabled encryption types (bit field of WPS_ENCR_*)
624 */
625 u16 encr_types;
626
627 /**
628 * auth_types - Authentication types (bit field of WPS_AUTH_*)
629 */
630 u16 auth_types;
631
632 /**
633 * network_key - The current Network Key (PSK) or %NULL to generate new
634 *
635 * If %NULL, Registrar will generate per-device PSK. In addition, AP
636 * uses this when acting as an Enrollee to notify Registrar of the
637 * current configuration.
638 *
639 * When using WPA/WPA2-Person, this key can be either the ASCII
640 * passphrase (8..63 characters) or the 32-octet PSK (64 hex
641 * characters). When this is set to the ASCII passphrase, the PSK can
642 * be provided in the psk buffer and used per-Enrollee to control which
643 * key type is included in the Credential (e.g., to reduce calculation
644 * need on low-powered devices by provisioning PSK while still allowing
645 * other devices to get the passphrase).
646 */
647 u8 *network_key;
648
649 /**
650 * network_key_len - Length of network_key in octets
651 */
652 size_t network_key_len;
653
654 /**
655 * psk - The current network PSK
656 *
657 * This optional value can be used to provide the current PSK if
658 * network_key is set to the ASCII passphrase.
659 */
660 u8 psk[32];
661
662 /**
663 * psk_set - Whether psk value is set
664 */
665 int psk_set;
666
667 /**
668 * ap_settings - AP Settings override for M7 (only used at AP)
669 *
670 * If %NULL, AP Settings attributes will be generated based on the
671 * current network configuration.
672 */
673 u8 *ap_settings;
674
675 /**
676 * ap_settings_len - Length of ap_settings in octets
677 */
678 size_t ap_settings_len;
679
680 /**
681 * friendly_name - Friendly Name (required for UPnP)
682 */
683 char *friendly_name;
684
685 /**
686 * manufacturer_url - Manufacturer URL (optional for UPnP)
687 */
688 char *manufacturer_url;
689
690 /**
691 * model_description - Model Description (recommended for UPnP)
692 */
693 char *model_description;
694
695 /**
696 * model_url - Model URL (optional for UPnP)
697 */
698 char *model_url;
699
700 /**
701 * upc - Universal Product Code (optional for UPnP)
702 */
703 char *upc;
704
705 /**
706 * cred_cb - Callback to notify that new Credentials were received
707 * @ctx: Higher layer context data (cb_ctx)
708 * @cred: The received Credential
709 * Return: 0 on success, -1 on failure
710 */
711 int (*cred_cb)(void *ctx, const struct wps_credential *cred);
712
713 /**
714 * event_cb - Event callback (state information about progress)
715 * @ctx: Higher layer context data (cb_ctx)
716 * @event: Event type
717 * @data: Event data
718 */
719 void (*event_cb)(void *ctx, enum wps_event event,
720 union wps_event_data *data);
721
722 /**
723 * cb_ctx: Higher layer context data for callbacks
724 */
725 void *cb_ctx;
726
727 struct upnp_wps_device_sm *wps_upnp;
728
729 /* Pending messages from UPnP PutWLANResponse */
730 struct upnp_pending_message *upnp_msgs;
731 };
732
733 struct oob_device_data {
734 char *device_name;
735 char *device_path;
736 void * (*init_func)(struct wps_context *, struct oob_device_data *,
737 int);
738 struct wpabuf * (*read_func)(void *);
739 int (*write_func)(void *, struct wpabuf *);
740 void (*deinit_func)(void *);
741 };
742
743 struct oob_nfc_device_data {
744 int (*init_func)(char *);
745 void * (*read_func)(size_t *);
746 int (*write_func)(void *, size_t);
747 void (*deinit_func)(void);
748 };
749
750 struct wps_registrar *
751 wps_registrar_init(struct wps_context *wps,
752 const struct wps_registrar_config *cfg);
753 void wps_registrar_deinit(struct wps_registrar *reg);
754 int wps_registrar_add_pin(struct wps_registrar *reg, const u8 *addr,
755 const u8 *uuid, const u8 *pin, size_t pin_len,
756 int timeout);
757 int wps_registrar_invalidate_pin(struct wps_registrar *reg, const u8 *uuid);
758 int wps_registrar_wps_cancel(struct wps_registrar *reg);
759 int wps_registrar_unlock_pin(struct wps_registrar *reg, const u8 *uuid);
760 int wps_registrar_button_pushed(struct wps_registrar *reg,
761 const u8 *p2p_dev_addr);
762 void wps_registrar_probe_req_rx(struct wps_registrar *reg, const u8 *addr,
763 const struct wpabuf *wps_data,
764 int p2p_wildcard);
765 int wps_registrar_update_ie(struct wps_registrar *reg);
766 int wps_registrar_get_info(struct wps_registrar *reg, const u8 *addr,
767 char *buf, size_t buflen);
768 int wps_registrar_config_ap(struct wps_registrar *reg,
769 struct wps_credential *cred);
770
771 unsigned int wps_pin_checksum(unsigned int pin);
772 unsigned int wps_pin_valid(unsigned int pin);
773 unsigned int wps_generate_pin(void);
774 void wps_free_pending_msgs(struct upnp_pending_message *msgs);
775
776 struct oob_device_data * wps_get_oob_device(char *device_type);
777 struct oob_nfc_device_data * wps_get_oob_nfc_device(char *device_name);
778 int wps_get_oob_method(char *method);
779 int wps_process_oob(struct wps_context *wps, struct oob_device_data *oob_dev,
780 int registrar);
781 int wps_attr_text(struct wpabuf *data, char *buf, char *end);
782
783 struct wps_er * wps_er_init(struct wps_context *wps, const char *ifname,
784 const char *filter);
785 void wps_er_refresh(struct wps_er *er);
786 void wps_er_deinit(struct wps_er *er, void (*cb)(void *ctx), void *ctx);
787 void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id,
788 u16 sel_reg_config_methods);
789 int wps_er_pbc(struct wps_er *er, const u8 *uuid);
790 int wps_er_learn(struct wps_er *er, const u8 *uuid, const u8 *pin,
791 size_t pin_len);
792 int wps_er_set_config(struct wps_er *er, const u8 *uuid,
793 const struct wps_credential *cred);
794 int wps_er_config(struct wps_er *er, const u8 *uuid, const u8 *pin,
795 size_t pin_len, const struct wps_credential *cred);
796
797 int wps_dev_type_str2bin(const char *str, u8 dev_type[WPS_DEV_TYPE_LEN]);
798 char * wps_dev_type_bin2str(const u8 dev_type[WPS_DEV_TYPE_LEN], char *buf,
799 size_t buf_len);
800 void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid);
801 u16 wps_config_methods_str2bin(const char *str);
802
803 #ifdef CONFIG_WPS_STRICT
804 int wps_validate_beacon(const struct wpabuf *wps_ie);
805 int wps_validate_beacon_probe_resp(const struct wpabuf *wps_ie, int probe,
806 const u8 *addr);
807 int wps_validate_probe_req(const struct wpabuf *wps_ie, const u8 *addr);
808 int wps_validate_assoc_req(const struct wpabuf *wps_ie);
809 int wps_validate_assoc_resp(const struct wpabuf *wps_ie);
810 int wps_validate_m1(const struct wpabuf *tlvs);
811 int wps_validate_m2(const struct wpabuf *tlvs);
812 int wps_validate_m2d(const struct wpabuf *tlvs);
813 int wps_validate_m3(const struct wpabuf *tlvs);
814 int wps_validate_m4(const struct wpabuf *tlvs);
815 int wps_validate_m4_encr(const struct wpabuf *tlvs, int wps2);
816 int wps_validate_m5(const struct wpabuf *tlvs);
817 int wps_validate_m5_encr(const struct wpabuf *tlvs, int wps2);
818 int wps_validate_m6(const struct wpabuf *tlvs);
819 int wps_validate_m6_encr(const struct wpabuf *tlvs, int wps2);
820 int wps_validate_m7(const struct wpabuf *tlvs);
821 int wps_validate_m7_encr(const struct wpabuf *tlvs, int ap, int wps2);
822 int wps_validate_m8(const struct wpabuf *tlvs);
823 int wps_validate_m8_encr(const struct wpabuf *tlvs, int ap, int wps2);
824 int wps_validate_wsc_ack(const struct wpabuf *tlvs);
825 int wps_validate_wsc_nack(const struct wpabuf *tlvs);
826 int wps_validate_wsc_done(const struct wpabuf *tlvs);
827 int wps_validate_upnp_set_selected_registrar(const struct wpabuf *tlvs);
828 #else /* CONFIG_WPS_STRICT */
829 static inline int wps_validate_beacon(const struct wpabuf *wps_ie){
830 return 0;
831 }
832
833 static inline int wps_validate_beacon_probe_resp(const struct wpabuf *wps_ie,
834 int probe, const u8 *addr)
835 {
836 return 0;
837 }
838
839 static inline int wps_validate_probe_req(const struct wpabuf *wps_ie,
840 const u8 *addr)
841 {
842 return 0;
843 }
844
845 static inline int wps_validate_assoc_req(const struct wpabuf *wps_ie)
846 {
847 return 0;
848 }
849
850 static inline int wps_validate_assoc_resp(const struct wpabuf *wps_ie)
851 {
852 return 0;
853 }
854
855 static inline int wps_validate_m1(const struct wpabuf *tlvs)
856 {
857 return 0;
858 }
859
860 static inline int wps_validate_m2(const struct wpabuf *tlvs)
861 {
862 return 0;
863 }
864
865 static inline int wps_validate_m2d(const struct wpabuf *tlvs)
866 {
867 return 0;
868 }
869
870 static inline int wps_validate_m3(const struct wpabuf *tlvs)
871 {
872 return 0;
873 }
874
875 static inline int wps_validate_m4(const struct wpabuf *tlvs)
876 {
877 return 0;
878 }
879
880 static inline int wps_validate_m4_encr(const struct wpabuf *tlvs, int wps2)
881 {
882 return 0;
883 }
884
885 static inline int wps_validate_m5(const struct wpabuf *tlvs)
886 {
887 return 0;
888 }
889
890 static inline int wps_validate_m5_encr(const struct wpabuf *tlvs, int wps2)
891 {
892 return 0;
893 }
894
895 static inline int wps_validate_m6(const struct wpabuf *tlvs)
896 {
897 return 0;
898 }
899
900 static inline int wps_validate_m6_encr(const struct wpabuf *tlvs, int wps2)
901 {
902 return 0;
903 }
904
905 static inline int wps_validate_m7(const struct wpabuf *tlvs)
906 {
907 return 0;
908 }
909
910 static inline int wps_validate_m7_encr(const struct wpabuf *tlvs, int ap,
911 int wps2)
912 {
913 return 0;
914 }
915
916 static inline int wps_validate_m8(const struct wpabuf *tlvs)
917 {
918 return 0;
919 }
920
921 static inline int wps_validate_m8_encr(const struct wpabuf *tlvs, int ap,
922 int wps2)
923 {
924 return 0;
925 }
926
927 static inline int wps_validate_wsc_ack(const struct wpabuf *tlvs)
928 {
929 return 0;
930 }
931
932 static inline int wps_validate_wsc_nack(const struct wpabuf *tlvs)
933 {
934 return 0;
935 }
936
937 static inline int wps_validate_wsc_done(const struct wpabuf *tlvs)
938 {
939 return 0;
940 }
941
942 static inline int wps_validate_upnp_set_selected_registrar(
943 const struct wpabuf *tlvs)
944 {
945 return 0;
946 }
947 #endif /* CONFIG_WPS_STRICT */
948
949 #endif /* WPS_H */