P2P: Store P2P Device Address in per-device PSK records
[mech_eap.git] / src / wps / wps.h
index 4227f3c..15137a8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Wi-Fi Protected Setup
- * Copyright (c) 2007-2012, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2007-2013, Jouni Malinen <j@w1.fi>
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -246,14 +246,15 @@ struct wps_registrar_config {
         * new_psk_cb - Callback for new PSK
         * @ctx: Higher layer context data (cb_ctx)
         * @mac_addr: MAC address of the Enrollee
+        * @p2p_dev_addr: P2P Device Address of the Enrollee or all zeros if not
         * @psk: The new PSK
         * @psk_len: The length of psk in octets
         * Returns: 0 on success, -1 on failure
         *
         * This callback is called when a new per-device PSK is provisioned.
         */
-       int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *psk,
-                         size_t psk_len);
+       int (*new_psk_cb)(void *ctx, const u8 *mac_addr, const u8 *p2p_dev_addr,
+                         const u8 *psk, size_t psk_len);
 
        /**
         * set_ie_cb - Callback for WPS IE changes
@@ -382,6 +383,14 @@ struct wps_registrar_config {
         * dualband - Whether this is a concurrent dualband AP
         */
        int dualband;
+
+       /**
+        * force_per_enrollee_psk - Force per-Enrollee random PSK
+        *
+        * This forces per-Enrollee random PSK to be generated even if a default
+        * PSK is set for a network.
+        */
+       int force_per_enrollee_psk;
 };
 
 
@@ -420,6 +429,16 @@ enum wps_event {
        WPS_EV_PBC_TIMEOUT,
 
        /**
+        * WPS_EV_PBC_ACTIVE - PBC mode was activated
+        */
+       WPS_EV_PBC_ACTIVE,
+
+       /**
+        * WPS_EV_PBC_DISABLE - PBC mode was disabled
+        */
+       WPS_EV_PBC_DISABLE,
+
+       /**
         * WPS_EV_ER_AP_ADD - ER: AP added
         */
        WPS_EV_ER_AP_ADD,
@@ -487,11 +506,17 @@ union wps_event_data {
                int msg;
                u16 config_error;
                u16 error_indication;
+               u8 peer_macaddr[ETH_ALEN];
        } fail;
 
+       struct wps_event_success {
+               u8 peer_macaddr[ETH_ALEN];
+       } success;
+
        struct wps_event_pwd_auth_fail {
                int enrollee;
                int part;
+               u8 peer_macaddr[ETH_ALEN];
        } pwd_auth_fail;
 
        struct wps_event_er_ap {
@@ -730,6 +755,13 @@ struct wps_context {
                         union wps_event_data *data);
 
        /**
+        * rf_band_cb - Fetch currently used RF band
+        * @ctx: Higher layer context data (cb_ctx)
+        * Return: Current used RF band or 0 if not known
+        */
+       int (*rf_band_cb)(void *ctx);
+
+       /**
         * cb_ctx: Higher layer context data for callbacks
         */
        void *cb_ctx;
@@ -786,6 +818,7 @@ void wps_free_pending_msgs(struct upnp_pending_message *msgs);
 struct wpabuf * wps_get_oob_cred(struct wps_context *wps);
 int wps_oob_use_cred(struct wps_context *wps, struct wps_parse_attr *attr);
 int wps_attr_text(struct wpabuf *data, char *buf, char *end);
+const char * wps_ei_str(enum wps_error_indication ei);
 
 struct wps_er * wps_er_init(struct wps_context *wps, const char *ifname,
                            const char *filter);
@@ -793,14 +826,19 @@ 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,
                        u16 sel_reg_config_methods);
-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_set_config(struct wps_er *er, const u8 *uuid,
+int wps_er_pbc(struct wps_er *er, const u8 *uuid, const u8 *addr);
+const u8 * wps_er_get_sta_uuid(struct wps_er *er, const u8 *addr);
+int wps_er_learn(struct wps_er *er, const u8 *uuid, const u8 *addr,
+                const u8 *pin, size_t pin_len);
+int wps_er_set_config(struct wps_er *er, const u8 *uuid, const u8 *addr,
                      const struct wps_credential *cred);
-int wps_er_config(struct wps_er *er, const u8 *uuid, const u8 *pin,
-                 size_t pin_len, const struct wps_credential *cred);
-struct wpabuf * wps_er_nfc_config_token(struct wps_er *er, const u8 *uuid);
+int wps_er_config(struct wps_er *er, const u8 *uuid, const u8 *addr,
+                 const u8 *pin, size_t pin_len,
+                 const struct wps_credential *cred);
+struct wpabuf * wps_er_config_token_from_cred(struct wps_context *wps,
+                                             struct wps_credential *cred);
+struct wpabuf * wps_er_nfc_config_token(struct wps_er *er, const u8 *uuid,
+                                       const u8 *addr);
 
 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,
@@ -810,6 +848,8 @@ u16 wps_config_methods_str2bin(const char *str);
 struct wpabuf * wps_build_nfc_pw_token(u16 dev_pw_id,
                                       const struct wpabuf *pubkey,
                                       const struct wpabuf *dev_pw);
+struct wpabuf * wps_nfc_token_build(int ndef, int id, struct wpabuf *pubkey,
+                                   struct wpabuf *dev_pw);
 struct wpabuf * wps_nfc_token_gen(int ndef, int *id, struct wpabuf **pubkey,
                                  struct wpabuf **privkey,
                                  struct wpabuf **dev_pw);