3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-10-04 02:18:49 +02:00

wscutil: Add wsc_parse_nack

This commit is contained in:
Denis Kenzior 2016-08-26 11:47:41 -05:00
parent fdeed24591
commit 334ccfce0f
2 changed files with 35 additions and 0 deletions

View File

@ -1134,6 +1134,32 @@ int wsc_parse_m4(const uint8_t *pdu, uint32_t len, struct wsc_m4 *out,
return 0;
}
int wsc_parse_nack(const uint8_t *pdu, uint32_t len, struct wsc_nack *out)
{
int r;
struct wsc_wfa_ext_iter iter;
uint8_t version;
enum wsc_message_type msg_type;
memset(out, 0, sizeof(struct wsc_nack));
r = wsc_parse_attrs(pdu, len, &out->version2, &iter, NULL,
REQUIRED(VERSION, &version),
REQUIRED(MESSAGE_TYPE, &msg_type),
REQUIRED(ENROLLEE_NONCE, &out->enrollee_nonce),
REQUIRED(REGISTRAR_NONCE, &out->registrar_nonce),
REQUIRED(CONFIGURATION_ERROR, &out->configuration_error),
WSC_ATTR_INVALID);
if (r < 0)
return r;
if (msg_type != WSC_MESSAGE_TYPE_WSC_NACK)
return -EBADMSG;
return 0;
}
struct wsc_attr_builder {
size_t capacity;
uint8_t *buf;

View File

@ -449,6 +449,13 @@ struct wsc_m4 {
uint8_t authenticator[8];
};
struct wsc_nack {
bool version2;
uint8_t enrollee_nonce[16];
uint8_t registrar_nonce[16];
enum wsc_configuration_error configuration_error;
};
int wsc_parse_beacon(const unsigned char *pdu, unsigned int len,
struct wsc_beacon *out);
int wsc_parse_probe_response(const unsigned char *pdu, unsigned int len,
@ -462,6 +469,8 @@ int wsc_parse_m3(const uint8_t *pdu, uint32_t len, struct wsc_m3 *out);
int wsc_parse_m4(const uint8_t *pdu, uint32_t len, struct wsc_m4 *out,
struct iovec *out_encrypted);
int wsc_parse_nack(const uint8_t *pdu, uint32_t len, struct wsc_nack *out);
uint8_t *wsc_build_probe_request(const struct wsc_probe_request *probe_request,
size_t *out_len);
uint8_t *wsc_build_m1(const struct wsc_m1 *m1, size_t *out_len);