diff options
author | Jouni Malinen <j@w1.fi> | 2012-06-28 16:35:51 +0300 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2012-06-28 16:35:51 +0300 |
commit | 1cea09a9e2a69749a179d489be5a53d7d51f7e60 (patch) | |
tree | 937f891fa3f7a82658268e2ec398b62bc7e0c268 /src/wps | |
parent | 71892384da8fbed65dc4bf88e44e27b4ed60d6eb (diff) | |
download | external_wpa_supplicant_8_ti-1cea09a9e2a69749a179d489be5a53d7d51f7e60.zip external_wpa_supplicant_8_ti-1cea09a9e2a69749a179d489be5a53d7d51f7e60.tar.gz external_wpa_supplicant_8_ti-1cea09a9e2a69749a179d489be5a53d7d51f7e60.tar.bz2 |
WPS ER: Add support for building NFC configuration token
WPS_ER_NFC_CONFIG_TOKEN command can now be used to build a NFC
configuration token based on AP Settings learnt with WPS_ER_LEARN
or set with WPS_ER_CONFIG.
Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src/wps')
-rw-r--r-- | src/wps/wps.h | 1 | ||||
-rw-r--r-- | src/wps/wps_er.c | 40 |
2 files changed, 40 insertions, 1 deletions
diff --git a/src/wps/wps.h b/src/wps/wps.h index dd84f1b..c5871af 100644 --- a/src/wps/wps.h +++ b/src/wps/wps.h @@ -835,6 +835,7 @@ int wps_er_set_config(struct wps_er *er, const u8 *uuid, 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_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, diff --git a/src/wps/wps_er.c b/src/wps/wps_er.c index 0655a3a..95a0dec 100644 --- a/src/wps/wps_er.c +++ b/src/wps/wps_er.c @@ -1,6 +1,6 @@ /* * Wi-Fi Protected Setup - External Registrar - * Copyright (c) 2009, Jouni Malinen <j@w1.fi> + * Copyright (c) 2009-2012, Jouni Malinen <j@w1.fi> * * This software may be distributed under the terms of the BSD license. * See README for more details. @@ -1996,3 +1996,41 @@ int wps_er_config(struct wps_er *er, const u8 *uuid, const u8 *pin, return 0; } + + +#ifdef CONFIG_WPS_NFC +struct wpabuf * wps_er_nfc_config_token(struct wps_er *er, const u8 *uuid) +{ + struct wps_er_ap *ap; + struct wpabuf *ret; + struct wps_data data; + + if (er == NULL) + return NULL; + + ap = wps_er_ap_get(er, NULL, uuid); + if (ap == NULL) + return NULL; + if (ap->ap_settings == NULL) { + wpa_printf(MSG_DEBUG, "WPS ER: No settings known for the " + "selected AP"); + return NULL; + } + + ret = wpabuf_alloc(500); + if (ret == NULL) + return NULL; + + os_memset(&data, 0, sizeof(data)); + data.wps = er->wps; + data.use_cred = ap->ap_settings; + if (wps_build_version(ret) || + wps_build_cred(&data, ret) || + wps_build_wfa_ext(ret, 0, NULL, 0)) { + wpabuf_free(ret); + return NULL; + } + + return ret; +} +#endif /* CONFIG_WPS_NFC */ |