aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-01-23 19:08:55 (GMT)
committerJouni Malinen <j@w1.fi>2009-02-08 10:18:54 (GMT)
commite51609f083579fb3de4bfb9e6eb9a6f6f8256b51 (patch)
tree0c459375c4f5c2dbe7d2d061058eb7c311d39b35
parent4d88c94f7ba6c3acfe236feb2550fa3f68cc0304 (diff)
downloadhostap-06-e51609f083579fb3de4bfb9e6eb9a6f6f8256b51.zip
hostap-06-e51609f083579fb3de4bfb9e6eb9a6f6f8256b51.tar.gz
hostap-06-e51609f083579fb3de4bfb9e6eb9a6f6f8256b51.tar.bz2
Added ap_settings option for overriding WPS AP Settings in M7
This optional configuration parameter can be used to override AP Settings attributes in M7 similarly to extra_cred option for Credential attribute(s) in M8. (cherry picked from commit 4c29cae9320ccc6675b59f41dddf652b997fdc71)
-rw-r--r--hostapd/config.c11
-rw-r--r--hostapd/config.h2
-rw-r--r--hostapd/hostapd.conf7
-rw-r--r--hostapd/wps_hostapd.c3
-rw-r--r--src/wps/wps.h13
-rw-r--r--src/wps/wps_enrollee.c28
6 files changed, 56 insertions, 8 deletions
diff --git a/hostapd/config.c b/hostapd/config.c
index e5fa803..213d8b4 100644
--- a/hostapd/config.c
+++ b/hostapd/config.c
@@ -2219,6 +2219,16 @@ struct hostapd_config * hostapd_config_read(const char *fname)
}
} else if (os_strcmp(buf, "wps_cred_processing") == 0) {
bss->wps_cred_processing = atoi(pos);
+ } else if (os_strcmp(buf, "ap_settings") == 0) {
+ os_free(bss->ap_settings);
+ bss->ap_settings =
+ (u8 *) os_readfile(pos, &bss->ap_settings_len);
+ if (bss->ap_settings == NULL) {
+ wpa_printf(MSG_ERROR, "Line %d: could not "
+ "read AP Settings from '%s'",
+ line, pos);
+ errors++;
+ }
#endif /* CONFIG_WPS */
} else {
wpa_printf(MSG_ERROR, "Line %d: unknown configuration "
@@ -2425,6 +2435,7 @@ static void hostapd_config_free_bss(struct hostapd_bss_config *conf)
os_free(conf->config_methods);
os_free(conf->ap_pin);
os_free(conf->extra_cred);
+ os_free(conf->ap_settings);
#endif /* CONFIG_WPS */
}
diff --git a/hostapd/config.h b/hostapd/config.h
index f799d9c..87be506 100644
--- a/hostapd/config.h
+++ b/hostapd/config.h
@@ -304,6 +304,8 @@ struct hostapd_bss_config {
u8 *extra_cred;
size_t extra_cred_len;
int wps_cred_processing;
+ u8 *ap_settings;
+ size_t ap_settings_len;
#endif /* CONFIG_WPS */
};
diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf
index b423be5..24709ee 100644
--- a/hostapd/hostapd.conf
+++ b/hostapd/hostapd.conf
@@ -958,6 +958,13 @@ own_ip_addr=127.0.0.1
# extra_cred be used to provide the Credential data for Enrollees.
#wps_cred_processing=0
+# AP Settings Attributes for M7
+# By default, hostapd generates the AP Settings Attributes for M7 based on the
+# current configuration. It is possible to override this by providing a file
+# with pre-configured attributes. This is similar to extra_cred file format,
+# but the AP Settings attributes are not encapsulated in a Credential
+# attribute.
+#ap_settings=hostapd.ap_settings
##### Multiple BSSID support ##################################################
#
diff --git a/hostapd/wps_hostapd.c b/hostapd/wps_hostapd.c
index a863c7c..4f50649 100644
--- a/hostapd/wps_hostapd.c
+++ b/hostapd/wps_hostapd.c
@@ -545,6 +545,9 @@ int hostapd_init_wps(struct hostapd_data *hapd,
wps->encr_types = WPS_ENCR_AES | WPS_ENCR_TKIP;
}
+ wps->ap_settings = conf->ap_settings;
+ wps->ap_settings_len = conf->ap_settings_len;
+
cfg.new_psk_cb = hostapd_wps_new_psk_cb;
cfg.set_ie_cb = hostapd_wps_set_ie_cb;
cfg.pin_needed_cb = hostapd_wps_pin_needed_cb;
diff --git a/src/wps/wps.h b/src/wps/wps.h
index 4847332..7524acb 100644
--- a/src/wps/wps.h
+++ b/src/wps/wps.h
@@ -397,6 +397,19 @@ struct wps_context {
size_t network_key_len;
/**
+ * ap_settings - AP Settings override for M7 (only used at AP)
+ *
+ * If %NULL, AP Settings attributes will be generated based on the
+ * current network configuration.
+ */
+ u8 *ap_settings;
+
+ /**
+ * ap_settings_len - Length of ap_settings in octets
+ */
+ size_t ap_settings_len;
+
+ /**
* cred_cb - Callback to notify that new Credentials were received
* @ctx: Higher layer context data (cb_ctx)
* @cred: The received Credential
diff --git a/src/wps/wps_enrollee.c b/src/wps/wps_enrollee.c
index 59f3b19..dda8fc6 100644
--- a/src/wps/wps_enrollee.c
+++ b/src/wps/wps_enrollee.c
@@ -268,17 +268,34 @@ static int wps_build_cred_mac_addr(struct wps_data *wps, struct wpabuf *msg)
}
+static int wps_build_ap_settings(struct wps_data *wps, struct wpabuf *plain)
+{
+ if (wps->wps->ap_settings) {
+ wpa_printf(MSG_DEBUG, "WPS: * AP Settings (pre-configured)");
+ wpabuf_put_data(plain, wps->wps->ap_settings,
+ wps->wps->ap_settings_len);
+ return 0;
+ }
+
+ return wps_build_cred_ssid(wps, plain) ||
+ wps_build_cred_mac_addr(wps, plain) ||
+ wps_build_cred_auth_type(wps, plain) ||
+ wps_build_cred_encr_type(wps, plain) ||
+ wps_build_cred_network_key(wps, plain);
+}
+
+
static struct wpabuf * wps_build_m7(struct wps_data *wps)
{
struct wpabuf *msg, *plain;
wpa_printf(MSG_DEBUG, "WPS: Building Message M7");
- plain = wpabuf_alloc(500);
+ plain = wpabuf_alloc(500 + wps->wps->ap_settings_len);
if (plain == NULL)
return NULL;
- msg = wpabuf_alloc(1000);
+ msg = wpabuf_alloc(1000 + wps->wps->ap_settings_len);
if (msg == NULL) {
wpabuf_free(plain);
return NULL;
@@ -288,12 +305,7 @@ static struct wpabuf * wps_build_m7(struct wps_data *wps)
wps_build_msg_type(msg, WPS_M7) ||
wps_build_registrar_nonce(wps, msg) ||
wps_build_e_snonce2(wps, plain) ||
- (wps->wps->ap &&
- (wps_build_cred_ssid(wps, plain) ||
- wps_build_cred_mac_addr(wps, plain) ||
- wps_build_cred_auth_type(wps, plain) ||
- wps_build_cred_encr_type(wps, plain) ||
- wps_build_cred_network_key(wps, plain))) ||
+ (wps->wps->ap && wps_build_ap_settings(wps, plain)) ||
wps_build_key_wrap_auth(wps, plain) ||
wps_build_encr_settings(wps, msg, plain) ||
wps_build_authenticator(wps, msg)) {