WPS ER: Add command for configuring an AP
[mech_eap.git] / src / wps / wps.h
index 7fc16d9..41082aa 100644 (file)
@@ -147,6 +147,15 @@ struct wps_config {
         * peer_addr: MAC address of the peer in AP; %NULL if not AP
         */
        const u8 *peer_addr;
+
+       /**
+        * use_psk_key - Use PSK format key in Credential
+        *
+        * Force PSK format to be used instead of ASCII passphrase when
+        * building Credential for an Enrollee. The PSK value is set in
+        * struct wpa_context::psk.
+        */
+       int use_psk_key;
 };
 
 struct wps_data * wps_init(const struct wps_config *cfg);
@@ -189,6 +198,7 @@ int wps_is_selected_pin_registrar(const struct wpabuf *msg);
 const u8 * wps_get_uuid_e(const struct wpabuf *msg);
 
 struct wpabuf * wps_build_assoc_req_ie(enum wps_request_type req_type);
+struct wpabuf * wps_build_assoc_resp_ie(void);
 struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
                                       const u8 *uuid,
                                       enum wps_request_type req_type);
@@ -215,16 +225,15 @@ struct wps_registrar_config {
         * set_ie_cb - Callback for WPS IE changes
         * @ctx: Higher layer context data (cb_ctx)
         * @beacon_ie: WPS IE for Beacon
-        * @beacon_ie_len: WPS IE length for Beacon
         * @probe_resp_ie: WPS IE for Probe Response
-        * @probe_resp_ie_len: WPS IE length for Probe Response
         * Returns: 0 on success, -1 on failure
         *
         * This callback is called whenever the WPS IE in Beacon or Probe
-        * Response frames needs to be changed (AP only).
+        * Response frames needs to be changed (AP only). Callee is responsible
+        * for freeing the buffers.
         */
-       int (*set_ie_cb)(void *ctx, const u8 *beacon_ie, size_t beacon_ie_len,
-                        const u8 *probe_resp_ie, size_t probe_resp_ie_len);
+       int (*set_ie_cb)(void *ctx, struct wpabuf *beacon_ie,
+                        struct wpabuf *probe_resp_ie);
 
        /**
         * pin_needed_cb - Callback for requesting a PIN
@@ -270,6 +279,22 @@ struct wps_registrar_config {
                               u16 sel_reg_config_methods);
 
        /**
+        * enrollee_seen_cb - Callback for reporting Enrollee based on ProbeReq
+        * @ctx: Higher layer context data (cb_ctx)
+        * @addr: MAC address of the Enrollee
+        * @uuid_e: UUID of the Enrollee
+        * @pri_dev_type: Primary device type
+        * @config_methods: Config Methods
+        * @dev_password_id: Device Password ID
+        * @request_type: Request Type
+        * @dev_name: Device Name (if available)
+        */
+       void (*enrollee_seen_cb)(void *ctx, const u8 *addr, const u8 *uuid_e,
+                                const u8 *pri_dev_type, u16 config_methods,
+                                u16 dev_password_id, u8 request_type,
+                                const char *dev_name);
+
+       /**
         * cb_ctx: Higher layer context data for Registrar callbacks
         */
        void *cb_ctx;
@@ -370,7 +395,12 @@ enum wps_event {
        /**
         * WPS_EV_ER_ENROLLEE_REMOVE - ER: Enrollee removed
         */
-       WPS_EV_ER_ENROLLEE_REMOVE
+       WPS_EV_ER_ENROLLEE_REMOVE,
+
+       /**
+        * WPS_EV_ER_AP_SETTINGS - ER: AP Settings learned
+        */
+       WPS_EV_ER_AP_SETTINGS
 };
 
 /**
@@ -439,6 +469,11 @@ union wps_event_data {
                const char *model_number;
                const char *serial_number;
        } enrollee;
+
+       struct wps_event_er_ap_settings {
+               const u8 *uuid;
+               const struct wps_credential *cred;
+       } ap_settings;
 };
 
 /**
@@ -554,6 +589,14 @@ struct wps_context {
         * If %NULL, Registrar will generate per-device PSK. In addition, AP
         * uses this when acting as an Enrollee to notify Registrar of the
         * current configuration.
+        *
+        * When using WPA/WPA2-Person, this key can be either the ASCII
+        * passphrase (8..63 characters) or the 32-octet PSK (64 hex
+        * characters). When this is set to the ASCII passphrase, the PSK can
+        * be provided in the psk buffer and used per-Enrollee to control which
+        * key type is included in the Credential (e.g., to reduce calculation
+        * need on low-powered devices by provisioning PSK while still allowing
+        * other devices to get the passphrase).
         */
        u8 *network_key;
 
@@ -563,6 +606,19 @@ struct wps_context {
        size_t network_key_len;
 
        /**
+        * psk - The current network PSK
+        *
+        * This optional value can be used to provide the current PSK if
+        * network_key is set to the ASCII passphrase.
+        */
+       u8 psk[32];
+
+       /**
+        * psk_set - Whether psk value is set
+        */
+       int psk_set;
+
+       /**
         * ap_settings - AP Settings override for M7 (only used at AP)
         *
         * If %NULL, AP Settings attributes will be generated based on the
@@ -672,7 +728,8 @@ int wps_process_oob(struct wps_context *wps, struct oob_device_data *oob_dev,
                    int registrar);
 int wps_attr_text(struct wpabuf *data, char *buf, char *end);
 
-struct wps_er * wps_er_init(struct wps_context *wps, const char *ifname);
+struct wps_er * wps_er_init(struct wps_context *wps, const char *ifname,
+                           const char *filter);
 void wps_er_refresh(struct wps_er *er);
 void wps_er_deinit(struct wps_er *er, void (*cb)(void *ctx), void *ctx);
 void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id,
@@ -680,10 +737,13 @@ void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id,
 int wps_er_pbc(struct wps_er *er, const u8 *uuid);
 int wps_er_learn(struct wps_er *er, const u8 *uuid, const u8 *pin,
                 size_t pin_len);
+int wps_er_config(struct wps_er *er, const u8 *uuid, const u8 *pin,
+                 size_t pin_len, const struct wps_credential *cred);
 
 int wps_dev_type_str2bin(const char *str, u8 dev_type[WPS_DEV_TYPE_LEN]);
 char * wps_dev_type_bin2str(const u8 dev_type[WPS_DEV_TYPE_LEN], char *buf,
                            size_t buf_len);
 void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid);
+u16 wps_config_methods_str2bin(const char *str);
 
 #endif /* WPS_H */