12 #include "common/ieee802_11_defs.h" 48 u8 ssid[SSID_MAX_LEN];
55 u8 mac_addr[ETH_ALEN];
60 #define WPS_DEV_TYPE_LEN 8 61 #define WPS_DEV_TYPE_BUFSIZE 21 62 #define WPS_SEC_DEV_TYPE_MAX_LEN 128 64 #define MAX_WPS_VENDOR_EXTENSIONS 10 66 #define WPS_MAX_VENDOR_EXT_LEN 1024 68 #define MAX_WPS_PARSE_VENDOR_EXT 10 86 u8 mac_addr[ETH_ALEN];
92 u8 pri_dev_type[WPS_DEV_TYPE_LEN];
93 #define WPS_SEC_DEVICE_TYPES 5 94 u8 sec_dev_type[WPS_SEC_DEVICE_TYPES][WPS_DEV_TYPE_LEN];
99 struct wpabuf *vendor_ext_m1;
100 struct wpabuf *vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
194 void wps_deinit(
struct wps_data *data);
199 enum wps_process_res {
221 enum wps_process_res wps_process_msg(
struct wps_data *
wps,
222 enum wsc_op_code op_code,
223 const struct wpabuf *msg);
225 struct wpabuf * wps_get_msg(
struct wps_data *wps,
enum wsc_op_code *op_code);
227 int wps_is_selected_pbc_registrar(
const struct wpabuf *msg);
228 int wps_is_selected_pin_registrar(
const struct wpabuf *msg);
229 int wps_ap_priority_compar(
const struct wpabuf *wps_a,
230 const struct wpabuf *wps_b);
231 int wps_is_addr_authorized(
const struct wpabuf *msg,
const u8 *addr,
233 const u8 * wps_get_uuid_e(
const struct wpabuf *msg);
234 int wps_is_20(
const struct wpabuf *msg);
236 struct wpabuf * wps_build_assoc_req_ie(
enum wps_request_type req_type);
237 struct wpabuf * wps_build_assoc_resp_ie(
void);
240 enum wps_request_type req_type,
241 unsigned int num_req_dev_types,
242 const u8 *req_dev_types);
260 int (*new_psk_cb)(
void *ctx,
const u8 *mac_addr,
const u8 *p2p_dev_addr,
261 const u8 *psk,
size_t psk_len);
274 int (*set_ie_cb)(
void *ctx,
struct wpabuf *beacon_ie,
275 struct wpabuf *probe_resp_ie);
287 void (*pin_needed_cb)(
void *ctx,
const u8 *uuid_e,
301 void (*reg_success_cb)(
void *ctx,
const u8 *mac_addr,
302 const u8 *uuid_e,
const u8 *dev_pw,
320 void (*set_sel_reg_cb)(
void *ctx,
int sel_reg, u16 dev_passwd_id,
321 u16 sel_reg_config_methods);
334 void (*enrollee_seen_cb)(
void *ctx,
const u8 *addr,
const u8 *uuid_e,
335 const u8 *pri_dev_type, u16 config_methods,
336 u16 dev_password_id, u8 request_type,
337 const char *dev_name);
423 WPS_EV_PWD_AUTH_FAIL,
458 WPS_EV_ER_ENROLLEE_ADD,
463 WPS_EV_ER_ENROLLEE_REMOVE,
468 WPS_EV_ER_AP_SETTINGS,
473 WPS_EV_ER_SET_SELECTED_REGISTRAR,
478 WPS_EV_AP_PIN_SUCCESS
490 const u8 *manufacturer;
491 size_t manufacturer_len;
492 const u8 *model_name;
493 size_t model_name_len;
494 const u8 *model_number;
495 size_t model_number_len;
496 const u8 *serial_number;
497 size_t serial_number_len;
500 const u8 *primary_dev_type;
512 u16 error_indication;
513 u8 peer_macaddr[ETH_ALEN];
517 u8 peer_macaddr[ETH_ALEN];
523 u8 peer_macaddr[ETH_ALEN];
529 const char *friendly_name;
530 const char *manufacturer;
531 const char *manufacturer_url;
532 const char *model_description;
533 const char *model_name;
534 const char *model_number;
535 const char *model_url;
536 const char *serial_number;
538 const u8 *pri_dev_type;
548 const u8 *pri_dev_type;
549 const char *dev_name;
550 const char *manufacturer;
551 const char *model_name;
552 const char *model_number;
553 const char *serial_number;
565 u16 sel_reg_config_methods;
567 WPS_ER_SET_SEL_REG_START,
568 WPS_ER_SET_SEL_REG_DONE,
569 WPS_ER_SET_SEL_REG_FAILED
585 enum wps_msg_type type;
608 enum wps_state wps_state;
627 u8 ssid[SSID_MAX_LEN];
778 void (*event_cb)(
void *ctx,
enum wps_event event,
786 int (*rf_band_cb)(
void *ctx);
798 u16 ap_nfc_dev_pw_id;
799 struct wpabuf *ap_nfc_dh_pubkey;
800 struct wpabuf *ap_nfc_dh_privkey;
801 struct wpabuf *ap_nfc_dev_pw;
808 int wps_registrar_add_pin(
struct wps_registrar *reg,
const u8 *addr,
809 const u8 *uuid,
const u8 *pin,
size_t pin_len,
811 int wps_registrar_invalidate_pin(
struct wps_registrar *reg,
const u8 *uuid);
813 int wps_registrar_unlock_pin(
struct wps_registrar *reg,
const u8 *uuid);
815 const u8 *p2p_dev_addr);
816 void wps_registrar_complete(
struct wps_registrar *registrar,
const u8 *uuid_e,
817 const u8 *dev_pw,
size_t dev_pw_len);
818 void wps_registrar_probe_req_rx(
struct wps_registrar *reg,
const u8 *addr,
822 int wps_registrar_get_info(
struct wps_registrar *reg,
const u8 *addr,
823 char *buf,
size_t buflen);
826 int wps_registrar_add_nfc_pw_token(
struct wps_registrar *reg,
827 const u8 *pubkey_hash, u16 pw_id,
828 const u8 *dev_pw,
size_t dev_pw_len,
829 int pk_hash_provided_oob);
830 int wps_registrar_add_nfc_password_token(
struct wps_registrar *reg,
831 const u8 *oob_dev_pw,
832 size_t oob_dev_pw_len);
835 int wps_build_credential_wrap(
struct wpabuf *msg,
838 unsigned int wps_pin_checksum(
unsigned int pin);
839 unsigned int wps_pin_valid(
unsigned int pin);
840 int wps_generate_pin(
unsigned int *pin);
841 int wps_pin_str_valid(
const char *pin);
847 int wps_attr_text(
struct wpabuf *data,
char *buf,
char *end);
848 const char * wps_ei_str(
enum wps_error_indication ei);
852 void wps_er_refresh(
struct wps_er *er);
853 void wps_er_deinit(
struct wps_er *er,
void (*cb)(
void *ctx),
void *ctx);
854 void wps_er_set_sel_reg(
struct wps_er *er,
int sel_reg, u16 dev_passwd_id,
855 u16 sel_reg_config_methods);
856 int wps_er_pbc(
struct wps_er *er,
const u8 *uuid,
const u8 *addr);
857 const u8 * wps_er_get_sta_uuid(
struct wps_er *er,
const u8 *addr);
858 int wps_er_learn(
struct wps_er *er,
const u8 *uuid,
const u8 *addr,
859 const u8 *pin,
size_t pin_len);
860 int wps_er_set_config(
struct wps_er *er,
const u8 *uuid,
const u8 *addr,
862 int wps_er_config(
struct wps_er *er,
const u8 *uuid,
const u8 *addr,
863 const u8 *pin,
size_t pin_len,
867 struct wpabuf * wps_er_nfc_config_token(
struct wps_er *er,
const u8 *uuid,
869 struct wpabuf * wps_er_nfc_handover_sel(
struct wps_er *er,
871 const u8 *addr,
struct wpabuf *pubkey);
873 int wps_dev_type_str2bin(
const char *str, u8 dev_type[WPS_DEV_TYPE_LEN]);
874 char * wps_dev_type_bin2str(
const u8 dev_type[WPS_DEV_TYPE_LEN],
char *buf,
876 void uuid_gen_mac_addr(
const u8 *mac_addr, u8 *uuid);
877 u16 wps_config_methods_str2bin(
const char *str);
878 struct wpabuf * wps_build_nfc_pw_token(u16 dev_pw_id,
879 const struct wpabuf *pubkey,
880 const struct wpabuf *dev_pw);
881 struct wpabuf * wps_nfc_token_build(
int ndef,
int id,
struct wpabuf *pubkey,
883 int wps_nfc_gen_dh(
struct wpabuf **pubkey,
struct wpabuf **privkey);
884 struct wpabuf * wps_nfc_token_gen(
int ndef,
int *
id,
struct wpabuf **pubkey,
888 struct wpabuf *nfc_dh_pubkey);
890 struct wpabuf *nfc_dh_pubkey,
891 const u8 *bssid,
int freq);
893 struct wpabuf *nfc_dh_pubkey);
896 struct wpabuf *nfc_dh_pubkey,
897 struct wpabuf *nfc_dev_pw);
900 struct wpabuf * ndef_parse_wifi(
const struct wpabuf *buf);
901 struct wpabuf * ndef_build_wifi(
const struct wpabuf *buf);
902 struct wpabuf * ndef_parse_p2p(
const struct wpabuf *buf);
903 struct wpabuf * ndef_build_p2p(
const struct wpabuf *buf);
905 #ifdef CONFIG_WPS_STRICT 906 int wps_validate_beacon(
const struct wpabuf *wps_ie);
907 int wps_validate_beacon_probe_resp(
const struct wpabuf *wps_ie,
int probe,
909 int wps_validate_probe_req(
const struct wpabuf *wps_ie,
const u8 *addr);
910 int wps_validate_assoc_req(
const struct wpabuf *wps_ie);
911 int wps_validate_assoc_resp(
const struct wpabuf *wps_ie);
912 int wps_validate_m1(
const struct wpabuf *tlvs);
913 int wps_validate_m2(
const struct wpabuf *tlvs);
914 int wps_validate_m2d(
const struct wpabuf *tlvs);
915 int wps_validate_m3(
const struct wpabuf *tlvs);
916 int wps_validate_m4(
const struct wpabuf *tlvs);
917 int wps_validate_m4_encr(
const struct wpabuf *tlvs,
int wps2);
918 int wps_validate_m5(
const struct wpabuf *tlvs);
919 int wps_validate_m5_encr(
const struct wpabuf *tlvs,
int wps2);
920 int wps_validate_m6(
const struct wpabuf *tlvs);
921 int wps_validate_m6_encr(
const struct wpabuf *tlvs,
int wps2);
922 int wps_validate_m7(
const struct wpabuf *tlvs);
923 int wps_validate_m7_encr(
const struct wpabuf *tlvs,
int ap,
int wps2);
924 int wps_validate_m8(
const struct wpabuf *tlvs);
925 int wps_validate_m8_encr(
const struct wpabuf *tlvs,
int ap,
int wps2);
926 int wps_validate_wsc_ack(
const struct wpabuf *tlvs);
927 int wps_validate_wsc_nack(
const struct wpabuf *tlvs);
928 int wps_validate_wsc_done(
const struct wpabuf *tlvs);
929 int wps_validate_upnp_set_selected_registrar(
const struct wpabuf *tlvs);
931 static inline int wps_validate_beacon(
const struct wpabuf *wps_ie){
935 static inline int wps_validate_beacon_probe_resp(
const struct wpabuf *wps_ie,
936 int probe,
const u8 *addr)
941 static inline int wps_validate_probe_req(
const struct wpabuf *wps_ie,
947 static inline int wps_validate_assoc_req(
const struct wpabuf *wps_ie)
952 static inline int wps_validate_assoc_resp(
const struct wpabuf *wps_ie)
957 static inline int wps_validate_m1(
const struct wpabuf *tlvs)
962 static inline int wps_validate_m2(
const struct wpabuf *tlvs)
967 static inline int wps_validate_m2d(
const struct wpabuf *tlvs)
972 static inline int wps_validate_m3(
const struct wpabuf *tlvs)
977 static inline int wps_validate_m4(
const struct wpabuf *tlvs)
982 static inline int wps_validate_m4_encr(
const struct wpabuf *tlvs,
int wps2)
987 static inline int wps_validate_m5(
const struct wpabuf *tlvs)
992 static inline int wps_validate_m5_encr(
const struct wpabuf *tlvs,
int wps2)
997 static inline int wps_validate_m6(
const struct wpabuf *tlvs)
1002 static inline int wps_validate_m6_encr(
const struct wpabuf *tlvs,
int wps2)
1007 static inline int wps_validate_m7(
const struct wpabuf *tlvs)
1012 static inline int wps_validate_m7_encr(
const struct wpabuf *tlvs,
int ap,
1018 static inline int wps_validate_m8(
const struct wpabuf *tlvs)
1023 static inline int wps_validate_m8_encr(
const struct wpabuf *tlvs,
int ap,
1029 static inline int wps_validate_wsc_ack(
const struct wpabuf *tlvs)
1034 static inline int wps_validate_wsc_nack(
const struct wpabuf *tlvs)
1039 static inline int wps_validate_wsc_done(
const struct wpabuf *tlvs)
1044 static inline int wps_validate_upnp_set_selected_registrar(
1045 const struct wpabuf *tlvs)
int use_psk_key
use_psk_key - Use PSK format key in Credential
Definition: wps.h:161
const u8 * extra_cred
extra_cred: Additional Credential attribute(s)
Definition: wps.h:362
void * cb_ctx
cb_ctx: Higher layer context data for Registrar callbacks
Definition: wps.h:342
struct wps_event_m2d - M2D event data
Definition: wps.h:488
char * model_description
model_description - Model Description (recommended for UPnP)
Definition: wps.h:752
char * upc
upc - Universal Product Code (optional for UPnP)
Definition: wps.h:762
struct wps_data - WPS registration protocol data
Definition: wps_i.h:23
size_t pin_len
pin_len - Length on pin in octets
Definition: wps.h:127
size_t ssid_len
ssid_len - Length of ssid in octets
Definition: wps.h:632
struct upnp_pending_message - Pending PutWLANResponse messages : Pointer to next pending message or N...
Definition: wps.h:581
struct wps_context * wps
wps - Pointer to long term WPS context
Definition: wps_i.h:27
u16 auth_types
auth_types - Authentication types (bit field of WPS_AUTH_*)
Definition: wps.h:679
const u8 * peer_pubkey_hash
peer_pubkey_hash - Peer public key hash or NULL if not known
Definition: wps.h:189
int ap
ap - Whether the local end is an access point
Definition: wps.h:598
Definition: wps_registrar.c:141
int registrar
registrar - Whether this end is a Registrar
Definition: wps.h:117
int dualband
dualband - Whether this is a concurrent dualband AP
Definition: wps.h:389
Definition: wps_upnp_i.h:123
char * friendly_name
friendly_name - Friendly Name (required for UPnP)
Definition: wps.h:742
int disable_auto_conf
disable_auto_conf - Disable auto-configuration on first registration
Definition: wps.h:379
struct wps_config - WPS configuration for a single registration protocol run
Definition: wps.h:108
u16 dev_pw_id
dev_pw_id - Device Password ID for Enrollee when PIN is used
Definition: wps.h:166
u16 ap_auth_type
ap_auth_type - Current AP authentication types (WPS_AUTH_*)
Definition: wps.h:689
int pbc
pbc - Whether this is protocol run uses PBC
Definition: wps.h:132
int ap_setup_locked
ap_setup_locked - Whether AP setup is locked (only used at AP)
Definition: wps.h:613
union wps_event_data - WPS event data
Definition: wps.h:484
struct wps_event_fail - Registration failure information : enum wps_msg_type
Definition: wps.h:509
struct wps_device_data - WPS Device Data : Device MAC address : Device Name (0..32 octets encoded in ...
Definition: wps.h:85
struct wps_registrar * registrar
registrar - Pointer to WPS registrar data from wps_registrar_init()
Definition: wps.h:603
int psk_set
psk_set - Whether psk value is set
Definition: wps.h:724
void * dh_ctx
dh_ctx - Context data for Diffie-Hellman operation
Definition: wps.h:642
size_t network_key_len
network_key_len - Length of network_key in octets
Definition: wps.h:711
u16 config_methods
config_methods - Enabled configuration methods
Definition: wps.h:659
const u8 * peer_addr
peer_addr: MAC address of the peer in AP; NULL if not AP
Definition: wps.h:152
struct wpabuf * dh_pubkey
dh_pubkey_oob - Diffie-Hellman public key
Definition: wps.h:652
int pbc_in_m1
pbc_in_m1 - Do not remove PushButton config method in M1 (AP)
Definition: wps.h:184
struct wpabuf * dh_privkey
dh_privkey - Diffie-Hellman private key
Definition: wps.h:647
const u8 * p2p_dev_addr
p2p_dev_addr - P2P Device Address from (Re)Association Request
Definition: wps.h:176
int force_per_enrollee_psk
force_per_enrollee_psk - Force per-Enrollee random PSK
Definition: wps.h:397
u16 ap_encr_type
encr_types - Current AP encryption type (WPS_ENCR_*)
Definition: wps.h:684
u16 encr_types
encr_types - Enabled encryption types (bit field of WPS_ENCR_*)
Definition: wps.h:664
Definition: wps_attr_parse.h:14
size_t extra_cred_len
extra_cred_len: Length of extra_cred in octets
Definition: wps.h:367
char * manufacturer_url
manufacturer_url - Manufacturer URL (optional for UPnP)
Definition: wps.h:747
u8 * network_key
network_key - The current Network Key (PSK) or NULL to generate new
Definition: wps.h:706
struct wps_context * wps
wps - Pointer to long term WPS context
Definition: wps.h:112
struct wps_credential - WPS Credential : SSID : Length of SSID : Authentication Type (WPS_AUTH_OPEN...
Definition: wps.h:47
struct wps_registrar_config - WPS Registrar configuration
Definition: wps.h:248
u16 encr_types_wpa
encr_types_wpa - Enabled encryption types for WPA (WPS_ENCR_*)
Definition: wps.h:674
u16 encr_types_rsn
encr_types_rsn - Enabled encryption types for RSN (WPS_ENCR_*)
Definition: wps.h:669
u8 * ap_settings
ap_settings - AP Settings override for M7 (only used at AP)
Definition: wps.h:732
const u8 * pin
pin - Enrollee Device Password (NULL for Registrar or PBC)
Definition: wps.h:122
size_t ap_settings_len
ap_settings_len - Length of ap_settings in octets
Definition: wps.h:737
char * model_url
model_url - Model URL (optional for UPnP)
Definition: wps.h:757
int skip_cred_build
skip_cred_build: Do not build credential
Definition: wps.h:352
const struct wps_credential * new_ap_settings
new_ap_settings - New AP settings (NULL if not used)
Definition: wps.h:147
struct wps_context - Long term WPS context data
Definition: wps.h:594
void * cb_ctx
cb_ctx: Higher layer context data for callbacks
Definition: wps.h:791
const struct wpabuf * assoc_wps_ie
assoc_wps_ie: (Re)AssocReq WPS IE (in AP; NULL if not AP)
Definition: wps.h:137
int static_wep_only
static_wep_only - Whether the BSS supports only static WEP
Definition: wps.h:384