16d49e1aeSJan Lentfer /*
26d49e1aeSJan Lentfer * Wi-Fi Protected Setup
3*a1157835SDaniel Fojt * Copyright (c) 2007-2016, Jouni Malinen <j@w1.fi>
46d49e1aeSJan Lentfer *
53ff40c12SJohn Marino * This software may be distributed under the terms of the BSD license.
63ff40c12SJohn Marino * See README for more details.
76d49e1aeSJan Lentfer */
86d49e1aeSJan Lentfer
96d49e1aeSJan Lentfer #ifndef WPS_H
106d49e1aeSJan Lentfer #define WPS_H
116d49e1aeSJan Lentfer
12*a1157835SDaniel Fojt #include "common/ieee802_11_defs.h"
136d49e1aeSJan Lentfer #include "wps_defs.h"
146d49e1aeSJan Lentfer
156d49e1aeSJan Lentfer /**
166d49e1aeSJan Lentfer * enum wsc_op_code - EAP-WSC OP-Code values
176d49e1aeSJan Lentfer */
186d49e1aeSJan Lentfer enum wsc_op_code {
196d49e1aeSJan Lentfer WSC_UPnP = 0 /* No OP Code in UPnP transport */,
206d49e1aeSJan Lentfer WSC_Start = 0x01,
216d49e1aeSJan Lentfer WSC_ACK = 0x02,
226d49e1aeSJan Lentfer WSC_NACK = 0x03,
236d49e1aeSJan Lentfer WSC_MSG = 0x04,
246d49e1aeSJan Lentfer WSC_Done = 0x05,
256d49e1aeSJan Lentfer WSC_FRAG_ACK = 0x06
266d49e1aeSJan Lentfer };
276d49e1aeSJan Lentfer
286d49e1aeSJan Lentfer struct wps_registrar;
296d49e1aeSJan Lentfer struct upnp_wps_device_sm;
303ff40c12SJohn Marino struct wps_er;
313ff40c12SJohn Marino struct wps_parse_attr;
326d49e1aeSJan Lentfer
336d49e1aeSJan Lentfer /**
346d49e1aeSJan Lentfer * struct wps_credential - WPS Credential
356d49e1aeSJan Lentfer * @ssid: SSID
366d49e1aeSJan Lentfer * @ssid_len: Length of SSID
376d49e1aeSJan Lentfer * @auth_type: Authentication Type (WPS_AUTH_OPEN, .. flags)
386d49e1aeSJan Lentfer * @encr_type: Encryption Type (WPS_ENCR_NONE, .. flags)
396d49e1aeSJan Lentfer * @key_idx: Key index
406d49e1aeSJan Lentfer * @key: Key
416d49e1aeSJan Lentfer * @key_len: Key length in octets
426d49e1aeSJan Lentfer * @mac_addr: MAC address of the Credential receiver
436d49e1aeSJan Lentfer * @cred_attr: Unparsed Credential attribute data (used only in cred_cb());
446d49e1aeSJan Lentfer * this may be %NULL, if not used
456d49e1aeSJan Lentfer * @cred_attr_len: Length of cred_attr in octets
466d49e1aeSJan Lentfer */
476d49e1aeSJan Lentfer struct wps_credential {
48*a1157835SDaniel Fojt u8 ssid[SSID_MAX_LEN];
496d49e1aeSJan Lentfer size_t ssid_len;
506d49e1aeSJan Lentfer u16 auth_type;
516d49e1aeSJan Lentfer u16 encr_type;
526d49e1aeSJan Lentfer u8 key_idx;
536d49e1aeSJan Lentfer u8 key[64];
546d49e1aeSJan Lentfer size_t key_len;
556d49e1aeSJan Lentfer u8 mac_addr[ETH_ALEN];
566d49e1aeSJan Lentfer const u8 *cred_attr;
576d49e1aeSJan Lentfer size_t cred_attr_len;
586d49e1aeSJan Lentfer };
596d49e1aeSJan Lentfer
603ff40c12SJohn Marino #define WPS_DEV_TYPE_LEN 8
613ff40c12SJohn Marino #define WPS_DEV_TYPE_BUFSIZE 21
623ff40c12SJohn Marino #define WPS_SEC_DEV_TYPE_MAX_LEN 128
633ff40c12SJohn Marino /* maximum number of advertised WPS vendor extension attributes */
643ff40c12SJohn Marino #define MAX_WPS_VENDOR_EXTENSIONS 10
653ff40c12SJohn Marino /* maximum size of WPS Vendor extension attribute */
663ff40c12SJohn Marino #define WPS_MAX_VENDOR_EXT_LEN 1024
673ff40c12SJohn Marino /* maximum number of parsed WPS vendor extension attributes */
683ff40c12SJohn Marino #define MAX_WPS_PARSE_VENDOR_EXT 10
693ff40c12SJohn Marino
706d49e1aeSJan Lentfer /**
716d49e1aeSJan Lentfer * struct wps_device_data - WPS Device Data
726d49e1aeSJan Lentfer * @mac_addr: Device MAC address
736d49e1aeSJan Lentfer * @device_name: Device Name (0..32 octets encoded in UTF-8)
746d49e1aeSJan Lentfer * @manufacturer: Manufacturer (0..64 octets encoded in UTF-8)
756d49e1aeSJan Lentfer * @model_name: Model Name (0..32 octets encoded in UTF-8)
766d49e1aeSJan Lentfer * @model_number: Model Number (0..32 octets encoded in UTF-8)
776d49e1aeSJan Lentfer * @serial_number: Serial Number (0..32 octets encoded in UTF-8)
783ff40c12SJohn Marino * @pri_dev_type: Primary Device Type
793ff40c12SJohn Marino * @sec_dev_type: Array of secondary device types
803ff40c12SJohn Marino * @num_sec_dev_type: Number of secondary device types
816d49e1aeSJan Lentfer * @os_version: OS Version
82*a1157835SDaniel Fojt * @rf_bands: RF bands (WPS_RF_24GHZ, WPS_RF_50GHZ, WPS_RF_60GHZ flags)
833ff40c12SJohn Marino * @p2p: Whether the device is a P2P device
846d49e1aeSJan Lentfer */
856d49e1aeSJan Lentfer struct wps_device_data {
866d49e1aeSJan Lentfer u8 mac_addr[ETH_ALEN];
876d49e1aeSJan Lentfer char *device_name;
886d49e1aeSJan Lentfer char *manufacturer;
896d49e1aeSJan Lentfer char *model_name;
906d49e1aeSJan Lentfer char *model_number;
916d49e1aeSJan Lentfer char *serial_number;
923ff40c12SJohn Marino u8 pri_dev_type[WPS_DEV_TYPE_LEN];
933ff40c12SJohn Marino #define WPS_SEC_DEVICE_TYPES 5
943ff40c12SJohn Marino u8 sec_dev_type[WPS_SEC_DEVICE_TYPES][WPS_DEV_TYPE_LEN];
953ff40c12SJohn Marino u8 num_sec_dev_types;
966d49e1aeSJan Lentfer u32 os_version;
976d49e1aeSJan Lentfer u8 rf_bands;
983ff40c12SJohn Marino u16 config_methods;
993ff40c12SJohn Marino struct wpabuf *vendor_ext_m1;
1003ff40c12SJohn Marino struct wpabuf *vendor_ext[MAX_WPS_VENDOR_EXTENSIONS];
1013ff40c12SJohn Marino
1023ff40c12SJohn Marino int p2p;
103*a1157835SDaniel Fojt u8 multi_ap_ext;
1046d49e1aeSJan Lentfer };
1056d49e1aeSJan Lentfer
1066d49e1aeSJan Lentfer /**
1076d49e1aeSJan Lentfer * struct wps_config - WPS configuration for a single registration protocol run
1086d49e1aeSJan Lentfer */
1096d49e1aeSJan Lentfer struct wps_config {
1106d49e1aeSJan Lentfer /**
1116d49e1aeSJan Lentfer * wps - Pointer to long term WPS context
1126d49e1aeSJan Lentfer */
1136d49e1aeSJan Lentfer struct wps_context *wps;
1146d49e1aeSJan Lentfer
1156d49e1aeSJan Lentfer /**
1166d49e1aeSJan Lentfer * registrar - Whether this end is a Registrar
1176d49e1aeSJan Lentfer */
1186d49e1aeSJan Lentfer int registrar;
1196d49e1aeSJan Lentfer
1206d49e1aeSJan Lentfer /**
1216d49e1aeSJan Lentfer * pin - Enrollee Device Password (%NULL for Registrar or PBC)
1226d49e1aeSJan Lentfer */
1236d49e1aeSJan Lentfer const u8 *pin;
1246d49e1aeSJan Lentfer
1256d49e1aeSJan Lentfer /**
1266d49e1aeSJan Lentfer * pin_len - Length on pin in octets
1276d49e1aeSJan Lentfer */
1286d49e1aeSJan Lentfer size_t pin_len;
1296d49e1aeSJan Lentfer
1306d49e1aeSJan Lentfer /**
1316d49e1aeSJan Lentfer * pbc - Whether this is protocol run uses PBC
1326d49e1aeSJan Lentfer */
1336d49e1aeSJan Lentfer int pbc;
1346d49e1aeSJan Lentfer
1356d49e1aeSJan Lentfer /**
1366d49e1aeSJan Lentfer * assoc_wps_ie: (Re)AssocReq WPS IE (in AP; %NULL if not AP)
1376d49e1aeSJan Lentfer */
1386d49e1aeSJan Lentfer const struct wpabuf *assoc_wps_ie;
1393ff40c12SJohn Marino
1403ff40c12SJohn Marino /**
1413ff40c12SJohn Marino * new_ap_settings - New AP settings (%NULL if not used)
1423ff40c12SJohn Marino *
1433ff40c12SJohn Marino * This parameter provides new AP settings when using a wireless
1443ff40c12SJohn Marino * stations as a Registrar to configure the AP. %NULL means that AP
1453ff40c12SJohn Marino * will not be reconfigured, i.e., the station will only learn the
1463ff40c12SJohn Marino * current AP settings by using AP PIN.
1473ff40c12SJohn Marino */
1483ff40c12SJohn Marino const struct wps_credential *new_ap_settings;
1493ff40c12SJohn Marino
1503ff40c12SJohn Marino /**
1513ff40c12SJohn Marino * peer_addr: MAC address of the peer in AP; %NULL if not AP
1523ff40c12SJohn Marino */
1533ff40c12SJohn Marino const u8 *peer_addr;
1543ff40c12SJohn Marino
1553ff40c12SJohn Marino /**
1563ff40c12SJohn Marino * use_psk_key - Use PSK format key in Credential
1573ff40c12SJohn Marino *
1583ff40c12SJohn Marino * Force PSK format to be used instead of ASCII passphrase when
1593ff40c12SJohn Marino * building Credential for an Enrollee. The PSK value is set in
1603ff40c12SJohn Marino * struct wpa_context::psk.
1613ff40c12SJohn Marino */
1623ff40c12SJohn Marino int use_psk_key;
1633ff40c12SJohn Marino
1643ff40c12SJohn Marino /**
1653ff40c12SJohn Marino * dev_pw_id - Device Password ID for Enrollee when PIN is used
1663ff40c12SJohn Marino */
1673ff40c12SJohn Marino u16 dev_pw_id;
1683ff40c12SJohn Marino
1693ff40c12SJohn Marino /**
1703ff40c12SJohn Marino * p2p_dev_addr - P2P Device Address from (Re)Association Request
1713ff40c12SJohn Marino *
1723ff40c12SJohn Marino * On AP/GO, this is set to the P2P Device Address of the associating
1733ff40c12SJohn Marino * P2P client if a P2P IE is included in the (Re)Association Request
1743ff40c12SJohn Marino * frame and the P2P Device Address is included. Otherwise, this is set
1753ff40c12SJohn Marino * to %NULL to indicate the station does not have a P2P Device Address.
1763ff40c12SJohn Marino */
1773ff40c12SJohn Marino const u8 *p2p_dev_addr;
1783ff40c12SJohn Marino
1793ff40c12SJohn Marino /**
1803ff40c12SJohn Marino * pbc_in_m1 - Do not remove PushButton config method in M1 (AP)
1813ff40c12SJohn Marino *
1823ff40c12SJohn Marino * This can be used to enable a workaround to allow Windows 7 to use
1833ff40c12SJohn Marino * PBC with the AP.
1843ff40c12SJohn Marino */
1853ff40c12SJohn Marino int pbc_in_m1;
1863ff40c12SJohn Marino
1873ff40c12SJohn Marino /**
1883ff40c12SJohn Marino * peer_pubkey_hash - Peer public key hash or %NULL if not known
1893ff40c12SJohn Marino */
1903ff40c12SJohn Marino const u8 *peer_pubkey_hash;
191*a1157835SDaniel Fojt
192*a1157835SDaniel Fojt /**
193*a1157835SDaniel Fojt * multi_ap_backhaul_sta - Whether this is a Multi-AP backhaul STA
194*a1157835SDaniel Fojt * enrollee
195*a1157835SDaniel Fojt */
196*a1157835SDaniel Fojt int multi_ap_backhaul_sta;
1976d49e1aeSJan Lentfer };
1986d49e1aeSJan Lentfer
1996d49e1aeSJan Lentfer struct wps_data * wps_init(const struct wps_config *cfg);
2006d49e1aeSJan Lentfer
2016d49e1aeSJan Lentfer void wps_deinit(struct wps_data *data);
2026d49e1aeSJan Lentfer
2036d49e1aeSJan Lentfer /**
2046d49e1aeSJan Lentfer * enum wps_process_res - WPS message processing result
2056d49e1aeSJan Lentfer */
2066d49e1aeSJan Lentfer enum wps_process_res {
2076d49e1aeSJan Lentfer /**
2086d49e1aeSJan Lentfer * WPS_DONE - Processing done
2096d49e1aeSJan Lentfer */
2106d49e1aeSJan Lentfer WPS_DONE,
2116d49e1aeSJan Lentfer
2126d49e1aeSJan Lentfer /**
2136d49e1aeSJan Lentfer * WPS_CONTINUE - Processing continues
2146d49e1aeSJan Lentfer */
2156d49e1aeSJan Lentfer WPS_CONTINUE,
2166d49e1aeSJan Lentfer
2176d49e1aeSJan Lentfer /**
2186d49e1aeSJan Lentfer * WPS_FAILURE - Processing failed
2196d49e1aeSJan Lentfer */
2206d49e1aeSJan Lentfer WPS_FAILURE,
2216d49e1aeSJan Lentfer
2226d49e1aeSJan Lentfer /**
2236d49e1aeSJan Lentfer * WPS_PENDING - Processing continues, but waiting for an external
2246d49e1aeSJan Lentfer * event (e.g., UPnP message from an external Registrar)
2256d49e1aeSJan Lentfer */
2266d49e1aeSJan Lentfer WPS_PENDING
2276d49e1aeSJan Lentfer };
2286d49e1aeSJan Lentfer enum wps_process_res wps_process_msg(struct wps_data *wps,
2296d49e1aeSJan Lentfer enum wsc_op_code op_code,
2306d49e1aeSJan Lentfer const struct wpabuf *msg);
2316d49e1aeSJan Lentfer
2326d49e1aeSJan Lentfer struct wpabuf * wps_get_msg(struct wps_data *wps, enum wsc_op_code *op_code);
2336d49e1aeSJan Lentfer
2346d49e1aeSJan Lentfer int wps_is_selected_pbc_registrar(const struct wpabuf *msg);
2356d49e1aeSJan Lentfer int wps_is_selected_pin_registrar(const struct wpabuf *msg);
2363ff40c12SJohn Marino int wps_ap_priority_compar(const struct wpabuf *wps_a,
2373ff40c12SJohn Marino const struct wpabuf *wps_b);
2383ff40c12SJohn Marino int wps_is_addr_authorized(const struct wpabuf *msg, const u8 *addr,
2393ff40c12SJohn Marino int ver1_compat);
2406d49e1aeSJan Lentfer const u8 * wps_get_uuid_e(const struct wpabuf *msg);
2413ff40c12SJohn Marino int wps_is_20(const struct wpabuf *msg);
2426d49e1aeSJan Lentfer
2436d49e1aeSJan Lentfer struct wpabuf * wps_build_assoc_req_ie(enum wps_request_type req_type);
2443ff40c12SJohn Marino struct wpabuf * wps_build_assoc_resp_ie(void);
2453ff40c12SJohn Marino struct wpabuf * wps_build_probe_req_ie(u16 pw_id, struct wps_device_data *dev,
2466d49e1aeSJan Lentfer const u8 *uuid,
2473ff40c12SJohn Marino enum wps_request_type req_type,
2483ff40c12SJohn Marino unsigned int num_req_dev_types,
2493ff40c12SJohn Marino const u8 *req_dev_types);
2506d49e1aeSJan Lentfer
2516d49e1aeSJan Lentfer
2526d49e1aeSJan Lentfer /**
2536d49e1aeSJan Lentfer * struct wps_registrar_config - WPS Registrar configuration
2546d49e1aeSJan Lentfer */
2556d49e1aeSJan Lentfer struct wps_registrar_config {
2566d49e1aeSJan Lentfer /**
2576d49e1aeSJan Lentfer * new_psk_cb - Callback for new PSK
2586d49e1aeSJan Lentfer * @ctx: Higher layer context data (cb_ctx)
2596d49e1aeSJan Lentfer * @mac_addr: MAC address of the Enrollee
2603ff40c12SJohn Marino * @p2p_dev_addr: P2P Device Address of the Enrollee or all zeros if not
2616d49e1aeSJan Lentfer * @psk: The new PSK
2626d49e1aeSJan Lentfer * @psk_len: The length of psk in octets
2636d49e1aeSJan Lentfer * Returns: 0 on success, -1 on failure
2646d49e1aeSJan Lentfer *
2656d49e1aeSJan Lentfer * This callback is called when a new per-device PSK is provisioned.
2666d49e1aeSJan Lentfer */
2673ff40c12SJohn Marino int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *p2p_dev_addr,
2683ff40c12SJohn Marino const u8 *psk, size_t psk_len);
2696d49e1aeSJan Lentfer
2706d49e1aeSJan Lentfer /**
2716d49e1aeSJan Lentfer * set_ie_cb - Callback for WPS IE changes
2726d49e1aeSJan Lentfer * @ctx: Higher layer context data (cb_ctx)
2736d49e1aeSJan Lentfer * @beacon_ie: WPS IE for Beacon
2746d49e1aeSJan Lentfer * @probe_resp_ie: WPS IE for Probe Response
2756d49e1aeSJan Lentfer * Returns: 0 on success, -1 on failure
2766d49e1aeSJan Lentfer *
2776d49e1aeSJan Lentfer * This callback is called whenever the WPS IE in Beacon or Probe
2783ff40c12SJohn Marino * Response frames needs to be changed (AP only). Callee is responsible
2793ff40c12SJohn Marino * for freeing the buffers.
2806d49e1aeSJan Lentfer */
2813ff40c12SJohn Marino int (*set_ie_cb)(void *ctx, struct wpabuf *beacon_ie,
2823ff40c12SJohn Marino struct wpabuf *probe_resp_ie);
2836d49e1aeSJan Lentfer
2846d49e1aeSJan Lentfer /**
2856d49e1aeSJan Lentfer * pin_needed_cb - Callback for requesting a PIN
2866d49e1aeSJan Lentfer * @ctx: Higher layer context data (cb_ctx)
2876d49e1aeSJan Lentfer * @uuid_e: UUID-E of the unknown Enrollee
2886d49e1aeSJan Lentfer * @dev: Device Data from the unknown Enrollee
2896d49e1aeSJan Lentfer *
2906d49e1aeSJan Lentfer * This callback is called whenever an unknown Enrollee requests to use
2916d49e1aeSJan Lentfer * PIN method and a matching PIN (Device Password) is not found in
2926d49e1aeSJan Lentfer * Registrar data.
2936d49e1aeSJan Lentfer */
2946d49e1aeSJan Lentfer void (*pin_needed_cb)(void *ctx, const u8 *uuid_e,
2956d49e1aeSJan Lentfer const struct wps_device_data *dev);
2966d49e1aeSJan Lentfer
2976d49e1aeSJan Lentfer /**
2986d49e1aeSJan Lentfer * reg_success_cb - Callback for reporting successful registration
2996d49e1aeSJan Lentfer * @ctx: Higher layer context data (cb_ctx)
3006d49e1aeSJan Lentfer * @mac_addr: MAC address of the Enrollee
3016d49e1aeSJan Lentfer * @uuid_e: UUID-E of the Enrollee
3023ff40c12SJohn Marino * @dev_pw: Device Password (PIN) used during registration
3033ff40c12SJohn Marino * @dev_pw_len: Length of dev_pw in octets
3046d49e1aeSJan Lentfer *
3056d49e1aeSJan Lentfer * This callback is called whenever an Enrollee completes registration
3066d49e1aeSJan Lentfer * successfully.
3076d49e1aeSJan Lentfer */
3086d49e1aeSJan Lentfer void (*reg_success_cb)(void *ctx, const u8 *mac_addr,
3093ff40c12SJohn Marino const u8 *uuid_e, const u8 *dev_pw,
3103ff40c12SJohn Marino size_t dev_pw_len);
3113ff40c12SJohn Marino
3123ff40c12SJohn Marino /**
3133ff40c12SJohn Marino * set_sel_reg_cb - Callback for reporting selected registrar changes
3143ff40c12SJohn Marino * @ctx: Higher layer context data (cb_ctx)
3153ff40c12SJohn Marino * @sel_reg: Whether the Registrar is selected
3163ff40c12SJohn Marino * @dev_passwd_id: Device Password ID to indicate with method or
3173ff40c12SJohn Marino * specific password the Registrar intends to use
3183ff40c12SJohn Marino * @sel_reg_config_methods: Bit field of active config methods
3193ff40c12SJohn Marino *
3203ff40c12SJohn Marino * This callback is called whenever the Selected Registrar state
3213ff40c12SJohn Marino * changes (e.g., a new PIN becomes available or PBC is invoked). This
3223ff40c12SJohn Marino * callback is only used by External Registrar implementation;
3233ff40c12SJohn Marino * set_ie_cb() is used by AP implementation in similar caes, but it
3243ff40c12SJohn Marino * provides the full WPS IE data instead of just the minimal Registrar
3253ff40c12SJohn Marino * state information.
3263ff40c12SJohn Marino */
3273ff40c12SJohn Marino void (*set_sel_reg_cb)(void *ctx, int sel_reg, u16 dev_passwd_id,
3283ff40c12SJohn Marino u16 sel_reg_config_methods);
3293ff40c12SJohn Marino
3303ff40c12SJohn Marino /**
3313ff40c12SJohn Marino * enrollee_seen_cb - Callback for reporting Enrollee based on ProbeReq
3323ff40c12SJohn Marino * @ctx: Higher layer context data (cb_ctx)
3333ff40c12SJohn Marino * @addr: MAC address of the Enrollee
3343ff40c12SJohn Marino * @uuid_e: UUID of the Enrollee
3353ff40c12SJohn Marino * @pri_dev_type: Primary device type
3363ff40c12SJohn Marino * @config_methods: Config Methods
3373ff40c12SJohn Marino * @dev_password_id: Device Password ID
3383ff40c12SJohn Marino * @request_type: Request Type
3393ff40c12SJohn Marino * @dev_name: Device Name (if available)
3403ff40c12SJohn Marino */
3413ff40c12SJohn Marino void (*enrollee_seen_cb)(void *ctx, const u8 *addr, const u8 *uuid_e,
3423ff40c12SJohn Marino const u8 *pri_dev_type, u16 config_methods,
3433ff40c12SJohn Marino u16 dev_password_id, u8 request_type,
3443ff40c12SJohn Marino const char *dev_name);
3456d49e1aeSJan Lentfer
3466d49e1aeSJan Lentfer /**
3476d49e1aeSJan Lentfer * cb_ctx: Higher layer context data for Registrar callbacks
3486d49e1aeSJan Lentfer */
3496d49e1aeSJan Lentfer void *cb_ctx;
3506d49e1aeSJan Lentfer
3516d49e1aeSJan Lentfer /**
3526d49e1aeSJan Lentfer * skip_cred_build: Do not build credential
3536d49e1aeSJan Lentfer *
3546d49e1aeSJan Lentfer * This option can be used to disable internal code that builds
3556d49e1aeSJan Lentfer * Credential attribute into M8 based on the current network
3566d49e1aeSJan Lentfer * configuration and Enrollee capabilities. The extra_cred data will
3576d49e1aeSJan Lentfer * then be used as the Credential(s).
3586d49e1aeSJan Lentfer */
3596d49e1aeSJan Lentfer int skip_cred_build;
3606d49e1aeSJan Lentfer
3616d49e1aeSJan Lentfer /**
3626d49e1aeSJan Lentfer * extra_cred: Additional Credential attribute(s)
3636d49e1aeSJan Lentfer *
3646d49e1aeSJan Lentfer * This optional data (set to %NULL to disable) can be used to add
3656d49e1aeSJan Lentfer * Credential attribute(s) for other networks into M8. If
3666d49e1aeSJan Lentfer * skip_cred_build is set, this will also override the automatically
3676d49e1aeSJan Lentfer * generated Credential attribute.
3686d49e1aeSJan Lentfer */
3696d49e1aeSJan Lentfer const u8 *extra_cred;
3706d49e1aeSJan Lentfer
3716d49e1aeSJan Lentfer /**
3726d49e1aeSJan Lentfer * extra_cred_len: Length of extra_cred in octets
3736d49e1aeSJan Lentfer */
3746d49e1aeSJan Lentfer size_t extra_cred_len;
3756d49e1aeSJan Lentfer
3766d49e1aeSJan Lentfer /**
3776d49e1aeSJan Lentfer * disable_auto_conf - Disable auto-configuration on first registration
3786d49e1aeSJan Lentfer *
3796d49e1aeSJan Lentfer * By default, the AP that is started in not configured state will
3806d49e1aeSJan Lentfer * generate a random PSK and move to configured state when the first
3816d49e1aeSJan Lentfer * registration protocol run is completed successfully. This option can
3826d49e1aeSJan Lentfer * be used to disable this functionality and leave it up to an external
3836d49e1aeSJan Lentfer * program to take care of configuration. This requires the extra_cred
3846d49e1aeSJan Lentfer * to be set with a suitable Credential and skip_cred_build being used.
3856d49e1aeSJan Lentfer */
3866d49e1aeSJan Lentfer int disable_auto_conf;
3876d49e1aeSJan Lentfer
3886d49e1aeSJan Lentfer /**
3896d49e1aeSJan Lentfer * static_wep_only - Whether the BSS supports only static WEP
3906d49e1aeSJan Lentfer */
3916d49e1aeSJan Lentfer int static_wep_only;
3923ff40c12SJohn Marino
3933ff40c12SJohn Marino /**
3943ff40c12SJohn Marino * dualband - Whether this is a concurrent dualband AP
3953ff40c12SJohn Marino */
3963ff40c12SJohn Marino int dualband;
3973ff40c12SJohn Marino
3983ff40c12SJohn Marino /**
3993ff40c12SJohn Marino * force_per_enrollee_psk - Force per-Enrollee random PSK
4003ff40c12SJohn Marino *
4013ff40c12SJohn Marino * This forces per-Enrollee random PSK to be generated even if a default
4023ff40c12SJohn Marino * PSK is set for a network.
4033ff40c12SJohn Marino */
4043ff40c12SJohn Marino int force_per_enrollee_psk;
405*a1157835SDaniel Fojt
406*a1157835SDaniel Fojt /**
407*a1157835SDaniel Fojt * multi_ap_backhaul_ssid - SSID to supply to a Multi-AP backhaul
408*a1157835SDaniel Fojt * enrollee
409*a1157835SDaniel Fojt *
410*a1157835SDaniel Fojt * This SSID is used by the Registrar to fill in information for
411*a1157835SDaniel Fojt * Credentials when the enrollee advertises it is a Multi-AP backhaul
412*a1157835SDaniel Fojt * STA.
413*a1157835SDaniel Fojt */
414*a1157835SDaniel Fojt const u8 *multi_ap_backhaul_ssid;
415*a1157835SDaniel Fojt
416*a1157835SDaniel Fojt /**
417*a1157835SDaniel Fojt * multi_ap_backhaul_ssid_len - Length of multi_ap_backhaul_ssid in
418*a1157835SDaniel Fojt * octets
419*a1157835SDaniel Fojt */
420*a1157835SDaniel Fojt size_t multi_ap_backhaul_ssid_len;
421*a1157835SDaniel Fojt
422*a1157835SDaniel Fojt /**
423*a1157835SDaniel Fojt * multi_ap_backhaul_network_key - The Network Key (PSK) for the
424*a1157835SDaniel Fojt * Multi-AP backhaul enrollee.
425*a1157835SDaniel Fojt *
426*a1157835SDaniel Fojt * This key can be either the ASCII passphrase (8..63 characters) or the
427*a1157835SDaniel Fojt * 32-octet PSK (64 hex characters).
428*a1157835SDaniel Fojt */
429*a1157835SDaniel Fojt const u8 *multi_ap_backhaul_network_key;
430*a1157835SDaniel Fojt
431*a1157835SDaniel Fojt /**
432*a1157835SDaniel Fojt * multi_ap_backhaul_network_key_len - Length of
433*a1157835SDaniel Fojt * multi_ap_backhaul_network_key in octets
434*a1157835SDaniel Fojt */
435*a1157835SDaniel Fojt size_t multi_ap_backhaul_network_key_len;
4366d49e1aeSJan Lentfer };
4376d49e1aeSJan Lentfer
4386d49e1aeSJan Lentfer
4396d49e1aeSJan Lentfer /**
4406d49e1aeSJan Lentfer * enum wps_event - WPS event types
4416d49e1aeSJan Lentfer */
4426d49e1aeSJan Lentfer enum wps_event {
4436d49e1aeSJan Lentfer /**
4446d49e1aeSJan Lentfer * WPS_EV_M2D - M2D received (Registrar did not know us)
4456d49e1aeSJan Lentfer */
4466d49e1aeSJan Lentfer WPS_EV_M2D,
4476d49e1aeSJan Lentfer
4486d49e1aeSJan Lentfer /**
4496d49e1aeSJan Lentfer * WPS_EV_FAIL - Registration failed
4506d49e1aeSJan Lentfer */
4516d49e1aeSJan Lentfer WPS_EV_FAIL,
4526d49e1aeSJan Lentfer
4536d49e1aeSJan Lentfer /**
4546d49e1aeSJan Lentfer * WPS_EV_SUCCESS - Registration succeeded
4556d49e1aeSJan Lentfer */
4566d49e1aeSJan Lentfer WPS_EV_SUCCESS,
4576d49e1aeSJan Lentfer
4586d49e1aeSJan Lentfer /**
4596d49e1aeSJan Lentfer * WPS_EV_PWD_AUTH_FAIL - Password authentication failed
4606d49e1aeSJan Lentfer */
4616d49e1aeSJan Lentfer WPS_EV_PWD_AUTH_FAIL,
4626d49e1aeSJan Lentfer
4636d49e1aeSJan Lentfer /**
4646d49e1aeSJan Lentfer * WPS_EV_PBC_OVERLAP - PBC session overlap detected
4656d49e1aeSJan Lentfer */
4666d49e1aeSJan Lentfer WPS_EV_PBC_OVERLAP,
4676d49e1aeSJan Lentfer
4686d49e1aeSJan Lentfer /**
4696d49e1aeSJan Lentfer * WPS_EV_PBC_TIMEOUT - PBC walktime expired before protocol run start
4706d49e1aeSJan Lentfer */
4713ff40c12SJohn Marino WPS_EV_PBC_TIMEOUT,
4723ff40c12SJohn Marino
4733ff40c12SJohn Marino /**
4743ff40c12SJohn Marino * WPS_EV_PBC_ACTIVE - PBC mode was activated
4753ff40c12SJohn Marino */
4763ff40c12SJohn Marino WPS_EV_PBC_ACTIVE,
4773ff40c12SJohn Marino
4783ff40c12SJohn Marino /**
4793ff40c12SJohn Marino * WPS_EV_PBC_DISABLE - PBC mode was disabled
4803ff40c12SJohn Marino */
4813ff40c12SJohn Marino WPS_EV_PBC_DISABLE,
4823ff40c12SJohn Marino
4833ff40c12SJohn Marino /**
4843ff40c12SJohn Marino * WPS_EV_ER_AP_ADD - ER: AP added
4853ff40c12SJohn Marino */
4863ff40c12SJohn Marino WPS_EV_ER_AP_ADD,
4873ff40c12SJohn Marino
4883ff40c12SJohn Marino /**
4893ff40c12SJohn Marino * WPS_EV_ER_AP_REMOVE - ER: AP removed
4903ff40c12SJohn Marino */
4913ff40c12SJohn Marino WPS_EV_ER_AP_REMOVE,
4923ff40c12SJohn Marino
4933ff40c12SJohn Marino /**
4943ff40c12SJohn Marino * WPS_EV_ER_ENROLLEE_ADD - ER: Enrollee added
4953ff40c12SJohn Marino */
4963ff40c12SJohn Marino WPS_EV_ER_ENROLLEE_ADD,
4973ff40c12SJohn Marino
4983ff40c12SJohn Marino /**
4993ff40c12SJohn Marino * WPS_EV_ER_ENROLLEE_REMOVE - ER: Enrollee removed
5003ff40c12SJohn Marino */
5013ff40c12SJohn Marino WPS_EV_ER_ENROLLEE_REMOVE,
5023ff40c12SJohn Marino
5033ff40c12SJohn Marino /**
5043ff40c12SJohn Marino * WPS_EV_ER_AP_SETTINGS - ER: AP Settings learned
5053ff40c12SJohn Marino */
5063ff40c12SJohn Marino WPS_EV_ER_AP_SETTINGS,
5073ff40c12SJohn Marino
5083ff40c12SJohn Marino /**
5093ff40c12SJohn Marino * WPS_EV_ER_SET_SELECTED_REGISTRAR - ER: SetSelectedRegistrar event
5103ff40c12SJohn Marino */
5113ff40c12SJohn Marino WPS_EV_ER_SET_SELECTED_REGISTRAR,
5123ff40c12SJohn Marino
5133ff40c12SJohn Marino /**
5143ff40c12SJohn Marino * WPS_EV_AP_PIN_SUCCESS - External Registrar used correct AP PIN
5153ff40c12SJohn Marino */
5163ff40c12SJohn Marino WPS_EV_AP_PIN_SUCCESS
5176d49e1aeSJan Lentfer };
5186d49e1aeSJan Lentfer
5196d49e1aeSJan Lentfer /**
5206d49e1aeSJan Lentfer * union wps_event_data - WPS event data
5216d49e1aeSJan Lentfer */
5226d49e1aeSJan Lentfer union wps_event_data {
5236d49e1aeSJan Lentfer /**
5246d49e1aeSJan Lentfer * struct wps_event_m2d - M2D event data
5256d49e1aeSJan Lentfer */
5266d49e1aeSJan Lentfer struct wps_event_m2d {
5276d49e1aeSJan Lentfer u16 config_methods;
5286d49e1aeSJan Lentfer const u8 *manufacturer;
5296d49e1aeSJan Lentfer size_t manufacturer_len;
5306d49e1aeSJan Lentfer const u8 *model_name;
5316d49e1aeSJan Lentfer size_t model_name_len;
5326d49e1aeSJan Lentfer const u8 *model_number;
5336d49e1aeSJan Lentfer size_t model_number_len;
5346d49e1aeSJan Lentfer const u8 *serial_number;
5356d49e1aeSJan Lentfer size_t serial_number_len;
5366d49e1aeSJan Lentfer const u8 *dev_name;
5376d49e1aeSJan Lentfer size_t dev_name_len;
5386d49e1aeSJan Lentfer const u8 *primary_dev_type; /* 8 octets */
5396d49e1aeSJan Lentfer u16 config_error;
5406d49e1aeSJan Lentfer u16 dev_password_id;
5416d49e1aeSJan Lentfer } m2d;
5426d49e1aeSJan Lentfer
5436d49e1aeSJan Lentfer /**
5446d49e1aeSJan Lentfer * struct wps_event_fail - Registration failure information
5456d49e1aeSJan Lentfer * @msg: enum wps_msg_type
5466d49e1aeSJan Lentfer */
5476d49e1aeSJan Lentfer struct wps_event_fail {
5486d49e1aeSJan Lentfer int msg;
5493ff40c12SJohn Marino u16 config_error;
5503ff40c12SJohn Marino u16 error_indication;
5513ff40c12SJohn Marino u8 peer_macaddr[ETH_ALEN];
5526d49e1aeSJan Lentfer } fail;
5536d49e1aeSJan Lentfer
5543ff40c12SJohn Marino struct wps_event_success {
5553ff40c12SJohn Marino u8 peer_macaddr[ETH_ALEN];
5563ff40c12SJohn Marino } success;
5573ff40c12SJohn Marino
5586d49e1aeSJan Lentfer struct wps_event_pwd_auth_fail {
5596d49e1aeSJan Lentfer int enrollee;
5606d49e1aeSJan Lentfer int part;
5613ff40c12SJohn Marino u8 peer_macaddr[ETH_ALEN];
5626d49e1aeSJan Lentfer } pwd_auth_fail;
5633ff40c12SJohn Marino
5643ff40c12SJohn Marino struct wps_event_er_ap {
5653ff40c12SJohn Marino const u8 *uuid;
5663ff40c12SJohn Marino const u8 *mac_addr;
5673ff40c12SJohn Marino const char *friendly_name;
5683ff40c12SJohn Marino const char *manufacturer;
5693ff40c12SJohn Marino const char *manufacturer_url;
5703ff40c12SJohn Marino const char *model_description;
5713ff40c12SJohn Marino const char *model_name;
5723ff40c12SJohn Marino const char *model_number;
5733ff40c12SJohn Marino const char *model_url;
5743ff40c12SJohn Marino const char *serial_number;
5753ff40c12SJohn Marino const char *upc;
5763ff40c12SJohn Marino const u8 *pri_dev_type;
5773ff40c12SJohn Marino u8 wps_state;
5783ff40c12SJohn Marino } ap;
5793ff40c12SJohn Marino
5803ff40c12SJohn Marino struct wps_event_er_enrollee {
5813ff40c12SJohn Marino const u8 *uuid;
5823ff40c12SJohn Marino const u8 *mac_addr;
5833ff40c12SJohn Marino int m1_received;
5843ff40c12SJohn Marino u16 config_methods;
5853ff40c12SJohn Marino u16 dev_passwd_id;
5863ff40c12SJohn Marino const u8 *pri_dev_type;
5873ff40c12SJohn Marino const char *dev_name;
5883ff40c12SJohn Marino const char *manufacturer;
5893ff40c12SJohn Marino const char *model_name;
5903ff40c12SJohn Marino const char *model_number;
5913ff40c12SJohn Marino const char *serial_number;
5923ff40c12SJohn Marino } enrollee;
5933ff40c12SJohn Marino
5943ff40c12SJohn Marino struct wps_event_er_ap_settings {
5953ff40c12SJohn Marino const u8 *uuid;
5963ff40c12SJohn Marino const struct wps_credential *cred;
5973ff40c12SJohn Marino } ap_settings;
5983ff40c12SJohn Marino
5993ff40c12SJohn Marino struct wps_event_er_set_selected_registrar {
6003ff40c12SJohn Marino const u8 *uuid;
6013ff40c12SJohn Marino int sel_reg;
6023ff40c12SJohn Marino u16 dev_passwd_id;
6033ff40c12SJohn Marino u16 sel_reg_config_methods;
6043ff40c12SJohn Marino enum {
6053ff40c12SJohn Marino WPS_ER_SET_SEL_REG_START,
6063ff40c12SJohn Marino WPS_ER_SET_SEL_REG_DONE,
6073ff40c12SJohn Marino WPS_ER_SET_SEL_REG_FAILED
6083ff40c12SJohn Marino } state;
6093ff40c12SJohn Marino } set_sel_reg;
6106d49e1aeSJan Lentfer };
6116d49e1aeSJan Lentfer
6126d49e1aeSJan Lentfer /**
6136d49e1aeSJan Lentfer * struct upnp_pending_message - Pending PutWLANResponse messages
6146d49e1aeSJan Lentfer * @next: Pointer to next pending message or %NULL
6156d49e1aeSJan Lentfer * @addr: NewWLANEventMAC
6166d49e1aeSJan Lentfer * @msg: NewMessage
6176d49e1aeSJan Lentfer * @type: Message Type
6186d49e1aeSJan Lentfer */
6196d49e1aeSJan Lentfer struct upnp_pending_message {
6206d49e1aeSJan Lentfer struct upnp_pending_message *next;
6216d49e1aeSJan Lentfer u8 addr[ETH_ALEN];
6226d49e1aeSJan Lentfer struct wpabuf *msg;
6236d49e1aeSJan Lentfer enum wps_msg_type type;
6246d49e1aeSJan Lentfer };
6256d49e1aeSJan Lentfer
6266d49e1aeSJan Lentfer /**
6276d49e1aeSJan Lentfer * struct wps_context - Long term WPS context data
6286d49e1aeSJan Lentfer *
6296d49e1aeSJan Lentfer * This data is stored at the higher layer Authenticator or Supplicant data
6306d49e1aeSJan Lentfer * structures and it is maintained over multiple registration protocol runs.
6316d49e1aeSJan Lentfer */
6326d49e1aeSJan Lentfer struct wps_context {
6336d49e1aeSJan Lentfer /**
6346d49e1aeSJan Lentfer * ap - Whether the local end is an access point
6356d49e1aeSJan Lentfer */
6366d49e1aeSJan Lentfer int ap;
6376d49e1aeSJan Lentfer
6386d49e1aeSJan Lentfer /**
6396d49e1aeSJan Lentfer * registrar - Pointer to WPS registrar data from wps_registrar_init()
6406d49e1aeSJan Lentfer */
6416d49e1aeSJan Lentfer struct wps_registrar *registrar;
6426d49e1aeSJan Lentfer
6436d49e1aeSJan Lentfer /**
6446d49e1aeSJan Lentfer * wps_state - Current WPS state
6456d49e1aeSJan Lentfer */
6466d49e1aeSJan Lentfer enum wps_state wps_state;
6476d49e1aeSJan Lentfer
6486d49e1aeSJan Lentfer /**
6496d49e1aeSJan Lentfer * ap_setup_locked - Whether AP setup is locked (only used at AP)
6506d49e1aeSJan Lentfer */
6516d49e1aeSJan Lentfer int ap_setup_locked;
6526d49e1aeSJan Lentfer
6536d49e1aeSJan Lentfer /**
6546d49e1aeSJan Lentfer * uuid - Own UUID
6556d49e1aeSJan Lentfer */
6566d49e1aeSJan Lentfer u8 uuid[16];
6576d49e1aeSJan Lentfer
6586d49e1aeSJan Lentfer /**
6596d49e1aeSJan Lentfer * ssid - SSID
6606d49e1aeSJan Lentfer *
6616d49e1aeSJan Lentfer * This SSID is used by the Registrar to fill in information for
6626d49e1aeSJan Lentfer * Credentials. In addition, AP uses it when acting as an Enrollee to
6636d49e1aeSJan Lentfer * notify Registrar of the current configuration.
6646d49e1aeSJan Lentfer */
665*a1157835SDaniel Fojt u8 ssid[SSID_MAX_LEN];
6666d49e1aeSJan Lentfer
6676d49e1aeSJan Lentfer /**
6686d49e1aeSJan Lentfer * ssid_len - Length of ssid in octets
6696d49e1aeSJan Lentfer */
6706d49e1aeSJan Lentfer size_t ssid_len;
6716d49e1aeSJan Lentfer
6726d49e1aeSJan Lentfer /**
6736d49e1aeSJan Lentfer * dev - Own WPS device data
6746d49e1aeSJan Lentfer */
6756d49e1aeSJan Lentfer struct wps_device_data dev;
6766d49e1aeSJan Lentfer
6776d49e1aeSJan Lentfer /**
6783ff40c12SJohn Marino * dh_ctx - Context data for Diffie-Hellman operation
6793ff40c12SJohn Marino */
6803ff40c12SJohn Marino void *dh_ctx;
6813ff40c12SJohn Marino
6823ff40c12SJohn Marino /**
6833ff40c12SJohn Marino * dh_privkey - Diffie-Hellman private key
6843ff40c12SJohn Marino */
6853ff40c12SJohn Marino struct wpabuf *dh_privkey;
6863ff40c12SJohn Marino
6873ff40c12SJohn Marino /**
6883ff40c12SJohn Marino * dh_pubkey_oob - Diffie-Hellman public key
6893ff40c12SJohn Marino */
6903ff40c12SJohn Marino struct wpabuf *dh_pubkey;
6913ff40c12SJohn Marino
6923ff40c12SJohn Marino /**
6936d49e1aeSJan Lentfer * config_methods - Enabled configuration methods
6946d49e1aeSJan Lentfer *
6956d49e1aeSJan Lentfer * Bit field of WPS_CONFIG_*
6966d49e1aeSJan Lentfer */
6976d49e1aeSJan Lentfer u16 config_methods;
6986d49e1aeSJan Lentfer
6996d49e1aeSJan Lentfer /**
7006d49e1aeSJan Lentfer * encr_types - Enabled encryption types (bit field of WPS_ENCR_*)
7016d49e1aeSJan Lentfer */
7026d49e1aeSJan Lentfer u16 encr_types;
7036d49e1aeSJan Lentfer
7046d49e1aeSJan Lentfer /**
705*a1157835SDaniel Fojt * encr_types_rsn - Enabled encryption types for RSN (WPS_ENCR_*)
706*a1157835SDaniel Fojt */
707*a1157835SDaniel Fojt u16 encr_types_rsn;
708*a1157835SDaniel Fojt
709*a1157835SDaniel Fojt /**
710*a1157835SDaniel Fojt * encr_types_wpa - Enabled encryption types for WPA (WPS_ENCR_*)
711*a1157835SDaniel Fojt */
712*a1157835SDaniel Fojt u16 encr_types_wpa;
713*a1157835SDaniel Fojt
714*a1157835SDaniel Fojt /**
7156d49e1aeSJan Lentfer * auth_types - Authentication types (bit field of WPS_AUTH_*)
7166d49e1aeSJan Lentfer */
7176d49e1aeSJan Lentfer u16 auth_types;
7186d49e1aeSJan Lentfer
7196d49e1aeSJan Lentfer /**
720*a1157835SDaniel Fojt * encr_types - Current AP encryption type (WPS_ENCR_*)
721*a1157835SDaniel Fojt */
722*a1157835SDaniel Fojt u16 ap_encr_type;
723*a1157835SDaniel Fojt
724*a1157835SDaniel Fojt /**
725*a1157835SDaniel Fojt * ap_auth_type - Current AP authentication types (WPS_AUTH_*)
726*a1157835SDaniel Fojt */
727*a1157835SDaniel Fojt u16 ap_auth_type;
728*a1157835SDaniel Fojt
729*a1157835SDaniel Fojt /**
7306d49e1aeSJan Lentfer * network_key - The current Network Key (PSK) or %NULL to generate new
7316d49e1aeSJan Lentfer *
7326d49e1aeSJan Lentfer * If %NULL, Registrar will generate per-device PSK. In addition, AP
7336d49e1aeSJan Lentfer * uses this when acting as an Enrollee to notify Registrar of the
7346d49e1aeSJan Lentfer * current configuration.
7353ff40c12SJohn Marino *
736*a1157835SDaniel Fojt * When using WPA/WPA2-Personal, this key can be either the ASCII
7373ff40c12SJohn Marino * passphrase (8..63 characters) or the 32-octet PSK (64 hex
7383ff40c12SJohn Marino * characters). When this is set to the ASCII passphrase, the PSK can
7393ff40c12SJohn Marino * be provided in the psk buffer and used per-Enrollee to control which
7403ff40c12SJohn Marino * key type is included in the Credential (e.g., to reduce calculation
7413ff40c12SJohn Marino * need on low-powered devices by provisioning PSK while still allowing
7423ff40c12SJohn Marino * other devices to get the passphrase).
7436d49e1aeSJan Lentfer */
7446d49e1aeSJan Lentfer u8 *network_key;
7456d49e1aeSJan Lentfer
7466d49e1aeSJan Lentfer /**
7476d49e1aeSJan Lentfer * network_key_len - Length of network_key in octets
7486d49e1aeSJan Lentfer */
7496d49e1aeSJan Lentfer size_t network_key_len;
7506d49e1aeSJan Lentfer
7516d49e1aeSJan Lentfer /**
7523ff40c12SJohn Marino * psk - The current network PSK
7533ff40c12SJohn Marino *
7543ff40c12SJohn Marino * This optional value can be used to provide the current PSK if
7553ff40c12SJohn Marino * network_key is set to the ASCII passphrase.
7563ff40c12SJohn Marino */
7573ff40c12SJohn Marino u8 psk[32];
7583ff40c12SJohn Marino
7593ff40c12SJohn Marino /**
7603ff40c12SJohn Marino * psk_set - Whether psk value is set
7613ff40c12SJohn Marino */
7623ff40c12SJohn Marino int psk_set;
7633ff40c12SJohn Marino
7643ff40c12SJohn Marino /**
7656d49e1aeSJan Lentfer * ap_settings - AP Settings override for M7 (only used at AP)
7666d49e1aeSJan Lentfer *
7676d49e1aeSJan Lentfer * If %NULL, AP Settings attributes will be generated based on the
7686d49e1aeSJan Lentfer * current network configuration.
7696d49e1aeSJan Lentfer */
7706d49e1aeSJan Lentfer u8 *ap_settings;
7716d49e1aeSJan Lentfer
7726d49e1aeSJan Lentfer /**
7736d49e1aeSJan Lentfer * ap_settings_len - Length of ap_settings in octets
7746d49e1aeSJan Lentfer */
7756d49e1aeSJan Lentfer size_t ap_settings_len;
7766d49e1aeSJan Lentfer
7776d49e1aeSJan Lentfer /**
7786d49e1aeSJan Lentfer * friendly_name - Friendly Name (required for UPnP)
7796d49e1aeSJan Lentfer */
7806d49e1aeSJan Lentfer char *friendly_name;
7816d49e1aeSJan Lentfer
7826d49e1aeSJan Lentfer /**
7836d49e1aeSJan Lentfer * manufacturer_url - Manufacturer URL (optional for UPnP)
7846d49e1aeSJan Lentfer */
7856d49e1aeSJan Lentfer char *manufacturer_url;
7866d49e1aeSJan Lentfer
7876d49e1aeSJan Lentfer /**
7886d49e1aeSJan Lentfer * model_description - Model Description (recommended for UPnP)
7896d49e1aeSJan Lentfer */
7906d49e1aeSJan Lentfer char *model_description;
7916d49e1aeSJan Lentfer
7926d49e1aeSJan Lentfer /**
7936d49e1aeSJan Lentfer * model_url - Model URL (optional for UPnP)
7946d49e1aeSJan Lentfer */
7956d49e1aeSJan Lentfer char *model_url;
7966d49e1aeSJan Lentfer
7976d49e1aeSJan Lentfer /**
7986d49e1aeSJan Lentfer * upc - Universal Product Code (optional for UPnP)
7996d49e1aeSJan Lentfer */
8006d49e1aeSJan Lentfer char *upc;
8016d49e1aeSJan Lentfer
8026d49e1aeSJan Lentfer /**
8036d49e1aeSJan Lentfer * cred_cb - Callback to notify that new Credentials were received
8046d49e1aeSJan Lentfer * @ctx: Higher layer context data (cb_ctx)
8056d49e1aeSJan Lentfer * @cred: The received Credential
8066d49e1aeSJan Lentfer * Return: 0 on success, -1 on failure
8076d49e1aeSJan Lentfer */
8086d49e1aeSJan Lentfer int (*cred_cb)(void *ctx, const struct wps_credential *cred);
8096d49e1aeSJan Lentfer
8106d49e1aeSJan Lentfer /**
8116d49e1aeSJan Lentfer * event_cb - Event callback (state information about progress)
8126d49e1aeSJan Lentfer * @ctx: Higher layer context data (cb_ctx)
8136d49e1aeSJan Lentfer * @event: Event type
8146d49e1aeSJan Lentfer * @data: Event data
8156d49e1aeSJan Lentfer */
8166d49e1aeSJan Lentfer void (*event_cb)(void *ctx, enum wps_event event,
8176d49e1aeSJan Lentfer union wps_event_data *data);
8186d49e1aeSJan Lentfer
8196d49e1aeSJan Lentfer /**
8203ff40c12SJohn Marino * rf_band_cb - Fetch currently used RF band
8213ff40c12SJohn Marino * @ctx: Higher layer context data (cb_ctx)
8223ff40c12SJohn Marino * Return: Current used RF band or 0 if not known
8233ff40c12SJohn Marino */
8243ff40c12SJohn Marino int (*rf_band_cb)(void *ctx);
8253ff40c12SJohn Marino
8263ff40c12SJohn Marino /**
8276d49e1aeSJan Lentfer * cb_ctx: Higher layer context data for callbacks
8286d49e1aeSJan Lentfer */
8296d49e1aeSJan Lentfer void *cb_ctx;
8306d49e1aeSJan Lentfer
8316d49e1aeSJan Lentfer struct upnp_wps_device_sm *wps_upnp;
8326d49e1aeSJan Lentfer
8336d49e1aeSJan Lentfer /* Pending messages from UPnP PutWLANResponse */
8346d49e1aeSJan Lentfer struct upnp_pending_message *upnp_msgs;
8356d49e1aeSJan Lentfer
8363ff40c12SJohn Marino u16 ap_nfc_dev_pw_id;
8373ff40c12SJohn Marino struct wpabuf *ap_nfc_dh_pubkey;
8383ff40c12SJohn Marino struct wpabuf *ap_nfc_dh_privkey;
8393ff40c12SJohn Marino struct wpabuf *ap_nfc_dev_pw;
8403ff40c12SJohn Marino };
8416d49e1aeSJan Lentfer
8426d49e1aeSJan Lentfer struct wps_registrar *
8436d49e1aeSJan Lentfer wps_registrar_init(struct wps_context *wps,
8446d49e1aeSJan Lentfer const struct wps_registrar_config *cfg);
8456d49e1aeSJan Lentfer void wps_registrar_deinit(struct wps_registrar *reg);
8463ff40c12SJohn Marino int wps_registrar_add_pin(struct wps_registrar *reg, const u8 *addr,
8473ff40c12SJohn Marino const u8 *uuid, const u8 *pin, size_t pin_len,
8483ff40c12SJohn Marino int timeout);
8496d49e1aeSJan Lentfer int wps_registrar_invalidate_pin(struct wps_registrar *reg, const u8 *uuid);
8503ff40c12SJohn Marino int wps_registrar_wps_cancel(struct wps_registrar *reg);
8516d49e1aeSJan Lentfer int wps_registrar_unlock_pin(struct wps_registrar *reg, const u8 *uuid);
8523ff40c12SJohn Marino int wps_registrar_button_pushed(struct wps_registrar *reg,
8533ff40c12SJohn Marino const u8 *p2p_dev_addr);
8543ff40c12SJohn Marino void wps_registrar_complete(struct wps_registrar *registrar, const u8 *uuid_e,
8553ff40c12SJohn Marino const u8 *dev_pw, size_t dev_pw_len);
8566d49e1aeSJan Lentfer void wps_registrar_probe_req_rx(struct wps_registrar *reg, const u8 *addr,
8573ff40c12SJohn Marino const struct wpabuf *wps_data,
8583ff40c12SJohn Marino int p2p_wildcard);
8596d49e1aeSJan Lentfer int wps_registrar_update_ie(struct wps_registrar *reg);
8603ff40c12SJohn Marino int wps_registrar_get_info(struct wps_registrar *reg, const u8 *addr,
8613ff40c12SJohn Marino char *buf, size_t buflen);
8623ff40c12SJohn Marino int wps_registrar_config_ap(struct wps_registrar *reg,
8633ff40c12SJohn Marino struct wps_credential *cred);
8643ff40c12SJohn Marino int wps_registrar_add_nfc_pw_token(struct wps_registrar *reg,
8653ff40c12SJohn Marino const u8 *pubkey_hash, u16 pw_id,
8663ff40c12SJohn Marino const u8 *dev_pw, size_t dev_pw_len,
8673ff40c12SJohn Marino int pk_hash_provided_oob);
8683ff40c12SJohn Marino int wps_registrar_add_nfc_password_token(struct wps_registrar *reg,
8693ff40c12SJohn Marino const u8 *oob_dev_pw,
8703ff40c12SJohn Marino size_t oob_dev_pw_len);
871*a1157835SDaniel Fojt void wps_registrar_flush(struct wps_registrar *reg);
8723ff40c12SJohn Marino
8733ff40c12SJohn Marino int wps_build_credential_wrap(struct wpabuf *msg,
8743ff40c12SJohn Marino const struct wps_credential *cred);
8756d49e1aeSJan Lentfer
8766d49e1aeSJan Lentfer unsigned int wps_pin_checksum(unsigned int pin);
8776d49e1aeSJan Lentfer unsigned int wps_pin_valid(unsigned int pin);
878*a1157835SDaniel Fojt int wps_generate_pin(unsigned int *pin);
8793ff40c12SJohn Marino int wps_pin_str_valid(const char *pin);
8806d49e1aeSJan Lentfer void wps_free_pending_msgs(struct upnp_pending_message *msgs);
8816d49e1aeSJan Lentfer
8823ff40c12SJohn Marino struct wpabuf * wps_get_oob_cred(struct wps_context *wps, int rf_band,
8833ff40c12SJohn Marino int channel);
8843ff40c12SJohn Marino int wps_oob_use_cred(struct wps_context *wps, struct wps_parse_attr *attr);
8853ff40c12SJohn Marino int wps_attr_text(struct wpabuf *data, char *buf, char *end);
8863ff40c12SJohn Marino const char * wps_ei_str(enum wps_error_indication ei);
8873ff40c12SJohn Marino
8883ff40c12SJohn Marino struct wps_er * wps_er_init(struct wps_context *wps, const char *ifname,
8893ff40c12SJohn Marino const char *filter);
8903ff40c12SJohn Marino void wps_er_refresh(struct wps_er *er);
8913ff40c12SJohn Marino void wps_er_deinit(struct wps_er *er, void (*cb)(void *ctx), void *ctx);
8923ff40c12SJohn Marino void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id,
8933ff40c12SJohn Marino u16 sel_reg_config_methods);
8943ff40c12SJohn Marino int wps_er_pbc(struct wps_er *er, const u8 *uuid, const u8 *addr);
8953ff40c12SJohn Marino const u8 * wps_er_get_sta_uuid(struct wps_er *er, const u8 *addr);
8963ff40c12SJohn Marino int wps_er_learn(struct wps_er *er, const u8 *uuid, const u8 *addr,
8973ff40c12SJohn Marino const u8 *pin, size_t pin_len);
8983ff40c12SJohn Marino int wps_er_set_config(struct wps_er *er, const u8 *uuid, const u8 *addr,
8993ff40c12SJohn Marino const struct wps_credential *cred);
9003ff40c12SJohn Marino int wps_er_config(struct wps_er *er, const u8 *uuid, const u8 *addr,
9013ff40c12SJohn Marino const u8 *pin, size_t pin_len,
9023ff40c12SJohn Marino const struct wps_credential *cred);
9033ff40c12SJohn Marino struct wpabuf * wps_er_config_token_from_cred(struct wps_context *wps,
9043ff40c12SJohn Marino struct wps_credential *cred);
9053ff40c12SJohn Marino struct wpabuf * wps_er_nfc_config_token(struct wps_er *er, const u8 *uuid,
9063ff40c12SJohn Marino const u8 *addr);
9073ff40c12SJohn Marino struct wpabuf * wps_er_nfc_handover_sel(struct wps_er *er,
9083ff40c12SJohn Marino struct wps_context *wps, const u8 *uuid,
9093ff40c12SJohn Marino const u8 *addr, struct wpabuf *pubkey);
9103ff40c12SJohn Marino
9113ff40c12SJohn Marino int wps_dev_type_str2bin(const char *str, u8 dev_type[WPS_DEV_TYPE_LEN]);
9123ff40c12SJohn Marino char * wps_dev_type_bin2str(const u8 dev_type[WPS_DEV_TYPE_LEN], char *buf,
9133ff40c12SJohn Marino size_t buf_len);
9143ff40c12SJohn Marino void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid);
9153ff40c12SJohn Marino u16 wps_config_methods_str2bin(const char *str);
9163ff40c12SJohn Marino struct wpabuf * wps_build_nfc_pw_token(u16 dev_pw_id,
9173ff40c12SJohn Marino const struct wpabuf *pubkey,
9183ff40c12SJohn Marino const struct wpabuf *dev_pw);
9193ff40c12SJohn Marino struct wpabuf * wps_nfc_token_build(int ndef, int id, struct wpabuf *pubkey,
9203ff40c12SJohn Marino struct wpabuf *dev_pw);
9213ff40c12SJohn Marino int wps_nfc_gen_dh(struct wpabuf **pubkey, struct wpabuf **privkey);
9223ff40c12SJohn Marino struct wpabuf * wps_nfc_token_gen(int ndef, int *id, struct wpabuf **pubkey,
9233ff40c12SJohn Marino struct wpabuf **privkey,
9243ff40c12SJohn Marino struct wpabuf **dev_pw);
9253ff40c12SJohn Marino struct wpabuf * wps_build_nfc_handover_req(struct wps_context *ctx,
9263ff40c12SJohn Marino struct wpabuf *nfc_dh_pubkey);
9273ff40c12SJohn Marino struct wpabuf * wps_build_nfc_handover_sel(struct wps_context *ctx,
9283ff40c12SJohn Marino struct wpabuf *nfc_dh_pubkey,
9293ff40c12SJohn Marino const u8 *bssid, int freq);
9303ff40c12SJohn Marino struct wpabuf * wps_build_nfc_handover_req_p2p(struct wps_context *ctx,
9313ff40c12SJohn Marino struct wpabuf *nfc_dh_pubkey);
9323ff40c12SJohn Marino struct wpabuf * wps_build_nfc_handover_sel_p2p(struct wps_context *ctx,
9333ff40c12SJohn Marino int nfc_dev_pw_id,
9343ff40c12SJohn Marino struct wpabuf *nfc_dh_pubkey,
9353ff40c12SJohn Marino struct wpabuf *nfc_dev_pw);
9363ff40c12SJohn Marino
9373ff40c12SJohn Marino /* ndef.c */
9383ff40c12SJohn Marino struct wpabuf * ndef_parse_wifi(const struct wpabuf *buf);
9393ff40c12SJohn Marino struct wpabuf * ndef_build_wifi(const struct wpabuf *buf);
9403ff40c12SJohn Marino struct wpabuf * ndef_parse_p2p(const struct wpabuf *buf);
9413ff40c12SJohn Marino struct wpabuf * ndef_build_p2p(const struct wpabuf *buf);
9423ff40c12SJohn Marino
9433ff40c12SJohn Marino #ifdef CONFIG_WPS_STRICT
9443ff40c12SJohn Marino int wps_validate_beacon(const struct wpabuf *wps_ie);
9453ff40c12SJohn Marino int wps_validate_beacon_probe_resp(const struct wpabuf *wps_ie, int probe,
9463ff40c12SJohn Marino const u8 *addr);
9473ff40c12SJohn Marino int wps_validate_probe_req(const struct wpabuf *wps_ie, const u8 *addr);
9483ff40c12SJohn Marino int wps_validate_assoc_req(const struct wpabuf *wps_ie);
9493ff40c12SJohn Marino int wps_validate_assoc_resp(const struct wpabuf *wps_ie);
9503ff40c12SJohn Marino int wps_validate_m1(const struct wpabuf *tlvs);
9513ff40c12SJohn Marino int wps_validate_m2(const struct wpabuf *tlvs);
9523ff40c12SJohn Marino int wps_validate_m2d(const struct wpabuf *tlvs);
9533ff40c12SJohn Marino int wps_validate_m3(const struct wpabuf *tlvs);
9543ff40c12SJohn Marino int wps_validate_m4(const struct wpabuf *tlvs);
9553ff40c12SJohn Marino int wps_validate_m4_encr(const struct wpabuf *tlvs, int wps2);
9563ff40c12SJohn Marino int wps_validate_m5(const struct wpabuf *tlvs);
9573ff40c12SJohn Marino int wps_validate_m5_encr(const struct wpabuf *tlvs, int wps2);
9583ff40c12SJohn Marino int wps_validate_m6(const struct wpabuf *tlvs);
9593ff40c12SJohn Marino int wps_validate_m6_encr(const struct wpabuf *tlvs, int wps2);
9603ff40c12SJohn Marino int wps_validate_m7(const struct wpabuf *tlvs);
9613ff40c12SJohn Marino int wps_validate_m7_encr(const struct wpabuf *tlvs, int ap, int wps2);
9623ff40c12SJohn Marino int wps_validate_m8(const struct wpabuf *tlvs);
9633ff40c12SJohn Marino int wps_validate_m8_encr(const struct wpabuf *tlvs, int ap, int wps2);
9643ff40c12SJohn Marino int wps_validate_wsc_ack(const struct wpabuf *tlvs);
9653ff40c12SJohn Marino int wps_validate_wsc_nack(const struct wpabuf *tlvs);
9663ff40c12SJohn Marino int wps_validate_wsc_done(const struct wpabuf *tlvs);
9673ff40c12SJohn Marino int wps_validate_upnp_set_selected_registrar(const struct wpabuf *tlvs);
9683ff40c12SJohn Marino #else /* CONFIG_WPS_STRICT */
wps_validate_beacon(const struct wpabuf * wps_ie)9693ff40c12SJohn Marino static inline int wps_validate_beacon(const struct wpabuf *wps_ie){
9703ff40c12SJohn Marino return 0;
9713ff40c12SJohn Marino }
9723ff40c12SJohn Marino
wps_validate_beacon_probe_resp(const struct wpabuf * wps_ie,int probe,const u8 * addr)9733ff40c12SJohn Marino static inline int wps_validate_beacon_probe_resp(const struct wpabuf *wps_ie,
9743ff40c12SJohn Marino int probe, const u8 *addr)
9753ff40c12SJohn Marino {
9763ff40c12SJohn Marino return 0;
9773ff40c12SJohn Marino }
9783ff40c12SJohn Marino
wps_validate_probe_req(const struct wpabuf * wps_ie,const u8 * addr)9793ff40c12SJohn Marino static inline int wps_validate_probe_req(const struct wpabuf *wps_ie,
9803ff40c12SJohn Marino const u8 *addr)
9813ff40c12SJohn Marino {
9823ff40c12SJohn Marino return 0;
9833ff40c12SJohn Marino }
9843ff40c12SJohn Marino
wps_validate_assoc_req(const struct wpabuf * wps_ie)9853ff40c12SJohn Marino static inline int wps_validate_assoc_req(const struct wpabuf *wps_ie)
9863ff40c12SJohn Marino {
9873ff40c12SJohn Marino return 0;
9883ff40c12SJohn Marino }
9893ff40c12SJohn Marino
wps_validate_assoc_resp(const struct wpabuf * wps_ie)9903ff40c12SJohn Marino static inline int wps_validate_assoc_resp(const struct wpabuf *wps_ie)
9913ff40c12SJohn Marino {
9923ff40c12SJohn Marino return 0;
9933ff40c12SJohn Marino }
9943ff40c12SJohn Marino
wps_validate_m1(const struct wpabuf * tlvs)9953ff40c12SJohn Marino static inline int wps_validate_m1(const struct wpabuf *tlvs)
9963ff40c12SJohn Marino {
9973ff40c12SJohn Marino return 0;
9983ff40c12SJohn Marino }
9993ff40c12SJohn Marino
wps_validate_m2(const struct wpabuf * tlvs)10003ff40c12SJohn Marino static inline int wps_validate_m2(const struct wpabuf *tlvs)
10013ff40c12SJohn Marino {
10023ff40c12SJohn Marino return 0;
10033ff40c12SJohn Marino }
10043ff40c12SJohn Marino
wps_validate_m2d(const struct wpabuf * tlvs)10053ff40c12SJohn Marino static inline int wps_validate_m2d(const struct wpabuf *tlvs)
10063ff40c12SJohn Marino {
10073ff40c12SJohn Marino return 0;
10083ff40c12SJohn Marino }
10093ff40c12SJohn Marino
wps_validate_m3(const struct wpabuf * tlvs)10103ff40c12SJohn Marino static inline int wps_validate_m3(const struct wpabuf *tlvs)
10113ff40c12SJohn Marino {
10123ff40c12SJohn Marino return 0;
10133ff40c12SJohn Marino }
10143ff40c12SJohn Marino
wps_validate_m4(const struct wpabuf * tlvs)10153ff40c12SJohn Marino static inline int wps_validate_m4(const struct wpabuf *tlvs)
10163ff40c12SJohn Marino {
10173ff40c12SJohn Marino return 0;
10183ff40c12SJohn Marino }
10193ff40c12SJohn Marino
wps_validate_m4_encr(const struct wpabuf * tlvs,int wps2)10203ff40c12SJohn Marino static inline int wps_validate_m4_encr(const struct wpabuf *tlvs, int wps2)
10213ff40c12SJohn Marino {
10223ff40c12SJohn Marino return 0;
10233ff40c12SJohn Marino }
10243ff40c12SJohn Marino
wps_validate_m5(const struct wpabuf * tlvs)10253ff40c12SJohn Marino static inline int wps_validate_m5(const struct wpabuf *tlvs)
10263ff40c12SJohn Marino {
10273ff40c12SJohn Marino return 0;
10283ff40c12SJohn Marino }
10293ff40c12SJohn Marino
wps_validate_m5_encr(const struct wpabuf * tlvs,int wps2)10303ff40c12SJohn Marino static inline int wps_validate_m5_encr(const struct wpabuf *tlvs, int wps2)
10313ff40c12SJohn Marino {
10323ff40c12SJohn Marino return 0;
10333ff40c12SJohn Marino }
10343ff40c12SJohn Marino
wps_validate_m6(const struct wpabuf * tlvs)10353ff40c12SJohn Marino static inline int wps_validate_m6(const struct wpabuf *tlvs)
10363ff40c12SJohn Marino {
10373ff40c12SJohn Marino return 0;
10383ff40c12SJohn Marino }
10393ff40c12SJohn Marino
wps_validate_m6_encr(const struct wpabuf * tlvs,int wps2)10403ff40c12SJohn Marino static inline int wps_validate_m6_encr(const struct wpabuf *tlvs, int wps2)
10413ff40c12SJohn Marino {
10423ff40c12SJohn Marino return 0;
10433ff40c12SJohn Marino }
10443ff40c12SJohn Marino
wps_validate_m7(const struct wpabuf * tlvs)10453ff40c12SJohn Marino static inline int wps_validate_m7(const struct wpabuf *tlvs)
10463ff40c12SJohn Marino {
10473ff40c12SJohn Marino return 0;
10483ff40c12SJohn Marino }
10493ff40c12SJohn Marino
wps_validate_m7_encr(const struct wpabuf * tlvs,int ap,int wps2)10503ff40c12SJohn Marino static inline int wps_validate_m7_encr(const struct wpabuf *tlvs, int ap,
10513ff40c12SJohn Marino int wps2)
10523ff40c12SJohn Marino {
10533ff40c12SJohn Marino return 0;
10543ff40c12SJohn Marino }
10553ff40c12SJohn Marino
wps_validate_m8(const struct wpabuf * tlvs)10563ff40c12SJohn Marino static inline int wps_validate_m8(const struct wpabuf *tlvs)
10573ff40c12SJohn Marino {
10583ff40c12SJohn Marino return 0;
10593ff40c12SJohn Marino }
10603ff40c12SJohn Marino
wps_validate_m8_encr(const struct wpabuf * tlvs,int ap,int wps2)10613ff40c12SJohn Marino static inline int wps_validate_m8_encr(const struct wpabuf *tlvs, int ap,
10623ff40c12SJohn Marino int wps2)
10633ff40c12SJohn Marino {
10643ff40c12SJohn Marino return 0;
10653ff40c12SJohn Marino }
10663ff40c12SJohn Marino
wps_validate_wsc_ack(const struct wpabuf * tlvs)10673ff40c12SJohn Marino static inline int wps_validate_wsc_ack(const struct wpabuf *tlvs)
10683ff40c12SJohn Marino {
10693ff40c12SJohn Marino return 0;
10703ff40c12SJohn Marino }
10713ff40c12SJohn Marino
wps_validate_wsc_nack(const struct wpabuf * tlvs)10723ff40c12SJohn Marino static inline int wps_validate_wsc_nack(const struct wpabuf *tlvs)
10733ff40c12SJohn Marino {
10743ff40c12SJohn Marino return 0;
10753ff40c12SJohn Marino }
10763ff40c12SJohn Marino
wps_validate_wsc_done(const struct wpabuf * tlvs)10773ff40c12SJohn Marino static inline int wps_validate_wsc_done(const struct wpabuf *tlvs)
10783ff40c12SJohn Marino {
10793ff40c12SJohn Marino return 0;
10803ff40c12SJohn Marino }
10813ff40c12SJohn Marino
wps_validate_upnp_set_selected_registrar(const struct wpabuf * tlvs)10823ff40c12SJohn Marino static inline int wps_validate_upnp_set_selected_registrar(
10833ff40c12SJohn Marino const struct wpabuf *tlvs)
10843ff40c12SJohn Marino {
10853ff40c12SJohn Marino return 0;
10863ff40c12SJohn Marino }
10873ff40c12SJohn Marino #endif /* CONFIG_WPS_STRICT */
10883ff40c12SJohn Marino
10896d49e1aeSJan Lentfer #endif /* WPS_H */
1090