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