From da36b8753111b1ac7af33069fc4de6d3cc908495 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 13 Sep 2016 15:59:30 -0500 Subject: [PATCH] wscutil: Add wsc_parse_association_request --- src/wscutil.c | 20 ++++++++++++++++++++ src/wscutil.h | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/src/wscutil.c b/src/wscutil.c index c626360d..18149f28 100644 --- a/src/wscutil.c +++ b/src/wscutil.c @@ -1088,6 +1088,26 @@ done: return 0; } +int wsc_parse_association_request(const uint8_t *pdu, uint32_t len, + struct wsc_association_request *out) +{ + int r; + struct wsc_wfa_ext_iter iter; + uint8_t version; + + memset(out, 0, sizeof(struct wsc_association_request)); + + r = wsc_parse_attrs(pdu, len, &out->version2, &iter, 0, NULL, + REQUIRED(VERSION, &version), + REQUIRED(REQUEST_TYPE, &out->request_type), + WSC_ATTR_INVALID); + + if (r < 0) + return r; + + return 0; +} + int wsc_parse_association_response(const uint8_t *pdu, uint32_t len, struct wsc_association_response *out) { diff --git a/src/wscutil.h b/src/wscutil.h index 627c8d0c..cce334f2 100644 --- a/src/wscutil.h +++ b/src/wscutil.h @@ -399,6 +399,11 @@ struct wsc_probe_request { struct wsc_primary_device_type requested_device_type; }; +struct wsc_association_request { + bool version2; + enum wsc_request_type request_type; +}; + struct wsc_association_response { bool version2; enum wsc_response_type response_type; @@ -548,6 +553,8 @@ int wsc_parse_probe_response(const unsigned char *pdu, unsigned int len, struct wsc_probe_response *out); int wsc_parse_probe_request(const unsigned char *pdu, unsigned int len, struct wsc_probe_request *out); +int wsc_parse_association_request(const uint8_t *pdu, uint32_t len, + struct wsc_association_request *out); int wsc_parse_association_response(const uint8_t *pdu, uint32_t len, struct wsc_association_response *out);