mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-05 12:52:37 +01:00
wscutil: Make the primary device type parser public
The P2P IE parsers can take advantage of this function
This commit is contained in:
parent
5a40c49c44
commit
f8a51fe4c1
@ -423,26 +423,30 @@ static bool extract_public_key(struct wsc_attr_iter *iter, void *data)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool extract_primary_device_type(struct wsc_attr_iter *iter, void *data)
|
int wsc_parse_primary_device_type(const uint8_t *pdu, size_t len,
|
||||||
|
struct wsc_primary_device_type *out)
|
||||||
{
|
{
|
||||||
struct wsc_primary_device_type *out = data;
|
|
||||||
const uint8_t *p;
|
|
||||||
uint16_t category;
|
uint16_t category;
|
||||||
|
|
||||||
if (wsc_attr_iter_get_length(iter) != 8)
|
if (len != 8)
|
||||||
return false;
|
return -EINVAL;
|
||||||
|
|
||||||
p = wsc_attr_iter_get_data(iter);
|
|
||||||
category = l_get_be16(p);
|
|
||||||
|
|
||||||
|
category = l_get_be16(pdu);
|
||||||
if (category > 12 && category != 255)
|
if (category > 12 && category != 255)
|
||||||
return false;
|
return -EINVAL;
|
||||||
|
|
||||||
out->category = category;
|
out->category = category;
|
||||||
memcpy(out->oui, p + 2, 3);
|
memcpy(out->oui, pdu + 2, 3);
|
||||||
out->oui_type = p[5];
|
out->oui_type = pdu[5];
|
||||||
out->subcategory = l_get_be16(p + 6);
|
out->subcategory = l_get_be16(pdu + 6);
|
||||||
return true;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool extract_primary_device_type(struct wsc_attr_iter *iter, void *data)
|
||||||
|
{
|
||||||
|
return wsc_parse_primary_device_type(wsc_attr_iter_get_data(iter),
|
||||||
|
wsc_attr_iter_get_length(iter),
|
||||||
|
data) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool extract_request_type(struct wsc_attr_iter *iter, void *data)
|
static bool extract_request_type(struct wsc_attr_iter *iter, void *data)
|
||||||
|
@ -544,6 +544,9 @@ struct wsc_done {
|
|||||||
uint8_t registrar_nonce[16];
|
uint8_t registrar_nonce[16];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int wsc_parse_primary_device_type(const uint8_t *pdu, size_t len,
|
||||||
|
struct wsc_primary_device_type *out);
|
||||||
|
|
||||||
int wsc_parse_credential(const uint8_t *pdu, uint32_t len,
|
int wsc_parse_credential(const uint8_t *pdu, uint32_t len,
|
||||||
struct wsc_credential *out);
|
struct wsc_credential *out);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user