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