wps.h 23 KB

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