From 022d24474bbea5b8df9cc4d44e25f2ad13d24ec2 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 13 Sep 2016 15:57:16 -0500 Subject: [PATCH] wscutil: Add wsc_parse_association_response --- src/wscutil.c | 20 ++++++++++++++++++++ src/wscutil.h | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/src/wscutil.c b/src/wscutil.c index ef47e799..c626360d 100644 --- a/src/wscutil.c +++ b/src/wscutil.c @@ -1088,6 +1088,26 @@ done: return 0; } +int wsc_parse_association_response(const uint8_t *pdu, uint32_t len, + struct wsc_association_response *out) +{ + int r; + struct wsc_wfa_ext_iter iter; + uint8_t version; + + memset(out, 0, sizeof(struct wsc_association_response)); + + r = wsc_parse_attrs(pdu, len, &out->version2, &iter, 0, NULL, + REQUIRED(VERSION, &version), + REQUIRED(RESPONSE_TYPE, &out->response_type), + WSC_ATTR_INVALID); + + if (r < 0) + return r; + + return 0; +} + int wsc_parse_m1(const uint8_t *pdu, uint32_t len, struct wsc_m1 *out) { int r; diff --git a/src/wscutil.h b/src/wscutil.h index 1e22f10f..627c8d0c 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_response { + bool version2; + enum wsc_response_type response_type; +}; + struct wsc_m1 { bool version2; uint8_t uuid_e[16]; @@ -543,6 +548,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_response(const uint8_t *pdu, uint32_t len, + struct wsc_association_response *out); int wsc_parse_m1(const uint8_t *pdu, uint32_t len, struct wsc_m1 *out); int wsc_parse_m2(const uint8_t *pdu, uint32_t len, struct wsc_m2 *out);