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