WPS: Send AP Settings as a wrapped Credential attribute to ctrl_iface
Wrap self-generated WPS credential for new AP settings and send that to control interface to provide the needed information in WPS-NEW-AP-SETTINGS for external processing.
This commit is contained in:
parent
7d232e23e2
commit
56aa082a1d
3 changed files with 45 additions and 9 deletions
|
@ -242,6 +242,20 @@ static void wps_reload_config(void *eloop_data, void *user_ctx)
|
|||
}
|
||||
|
||||
|
||||
static void hapd_new_ap_event(struct hostapd_data *hapd, const u8 *attr,
|
||||
size_t attr_len)
|
||||
{
|
||||
size_t blen = attr_len * 2 + 1;
|
||||
char *buf = os_malloc(blen);
|
||||
if (buf) {
|
||||
wpa_snprintf_hex(buf, blen, attr, attr_len);
|
||||
wpa_msg(hapd->msg_ctx, MSG_INFO,
|
||||
WPS_EVENT_NEW_AP_SETTINGS "%s", buf);
|
||||
os_free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int hapd_wps_cred_cb(struct hostapd_data *hapd, void *ctx)
|
||||
{
|
||||
const struct wps_credential *cred = ctx;
|
||||
|
@ -271,15 +285,15 @@ static int hapd_wps_cred_cb(struct hostapd_data *hapd, void *ctx)
|
|||
|
||||
if ((hapd->conf->wps_cred_processing == 1 ||
|
||||
hapd->conf->wps_cred_processing == 2) && cred->cred_attr) {
|
||||
size_t blen = cred->cred_attr_len * 2 + 1;
|
||||
char *_buf = os_malloc(blen);
|
||||
if (_buf) {
|
||||
wpa_snprintf_hex(_buf, blen,
|
||||
cred->cred_attr, cred->cred_attr_len);
|
||||
wpa_msg(hapd->msg_ctx, MSG_INFO, "%s%s",
|
||||
WPS_EVENT_NEW_AP_SETTINGS, _buf);
|
||||
os_free(_buf);
|
||||
}
|
||||
hapd_new_ap_event(hapd, cred->cred_attr, cred->cred_attr_len);
|
||||
} else if (hapd->conf->wps_cred_processing == 1 ||
|
||||
hapd->conf->wps_cred_processing == 2) {
|
||||
struct wpabuf *attr;
|
||||
attr = wpabuf_alloc(200);
|
||||
if (attr && wps_build_credential_wrap(attr, cred) == 0)
|
||||
hapd_new_ap_event(hapd, wpabuf_head_u8(attr),
|
||||
wpabuf_len(attr));
|
||||
wpabuf_free(attr);
|
||||
} else
|
||||
wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_NEW_AP_SETTINGS);
|
||||
|
||||
|
|
|
@ -793,6 +793,9 @@ int wps_registrar_get_info(struct wps_registrar *reg, const u8 *addr,
|
|||
int wps_registrar_config_ap(struct wps_registrar *reg,
|
||||
struct wps_credential *cred);
|
||||
|
||||
int wps_build_credential_wrap(struct wpabuf *msg,
|
||||
const struct wps_credential *cred);
|
||||
|
||||
unsigned int wps_pin_checksum(unsigned int pin);
|
||||
unsigned int wps_pin_valid(unsigned int pin);
|
||||
unsigned int wps_generate_pin(void);
|
||||
|
|
|
@ -1410,6 +1410,25 @@ static int wps_build_credential(struct wpabuf *msg,
|
|||
}
|
||||
|
||||
|
||||
int wps_build_credential_wrap(struct wpabuf *msg,
|
||||
const struct wps_credential *cred)
|
||||
{
|
||||
struct wpabuf *wbuf;
|
||||
wbuf = wpabuf_alloc(200);
|
||||
if (wbuf == NULL)
|
||||
return -1;
|
||||
if (wps_build_credential(wbuf, cred)) {
|
||||
wpabuf_free(wbuf);
|
||||
return -1;
|
||||
}
|
||||
wpabuf_put_be16(msg, ATTR_CRED);
|
||||
wpabuf_put_be16(msg, wpabuf_len(wbuf));
|
||||
wpabuf_put_buf(msg, wbuf);
|
||||
wpabuf_free(wbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wps_build_cred(struct wps_data *wps, struct wpabuf *msg)
|
||||
{
|
||||
struct wpabuf *cred;
|
||||
|
|
Loading…
Reference in a new issue