3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 23:09:34 +01:00

ie: Add ie_tlv_extract_p2p_payload

This commit is contained in:
Andrew Zaborowski 2019-07-08 18:59:30 +02:00 committed by Denis Kenzior
parent b3a395091d
commit 5cb07ff116
2 changed files with 26 additions and 2 deletions

View File

@ -97,6 +97,7 @@ static void *ie_tlv_vendor_ie_concat(const unsigned char oui[],
unsigned char type, unsigned char type,
const unsigned char *ies, const unsigned char *ies,
unsigned int len, unsigned int len,
bool empty_ok,
ssize_t *out_len) ssize_t *out_len)
{ {
struct ie_tlv_iter iter; struct ie_tlv_iter iter;
@ -104,6 +105,7 @@ static void *ie_tlv_vendor_ie_concat(const unsigned char oui[],
unsigned int ie_len; unsigned int ie_len;
unsigned int concat_len = 0; unsigned int concat_len = 0;
unsigned char *ret; unsigned char *ret;
bool ie_found = false;
ie_tlv_iter_init(&iter, ies, len); ie_tlv_iter_init(&iter, ies, len);
@ -124,11 +126,12 @@ static void *ie_tlv_vendor_ie_concat(const unsigned char oui[],
continue; continue;
concat_len += ie_len - 4; concat_len += ie_len - 4;
ie_found = true;
} }
if (concat_len == 0) { if (concat_len == 0) {
if (out_len) if (out_len)
*out_len = -ENOENT; *out_len = (ie_found && empty_ok) ? 0 : -ENOENT;
return NULL; return NULL;
} }
@ -176,7 +179,25 @@ static void *ie_tlv_vendor_ie_concat(const unsigned char oui[],
void *ie_tlv_extract_wsc_payload(const unsigned char *ies, size_t len, void *ie_tlv_extract_wsc_payload(const unsigned char *ies, size_t len,
ssize_t *out_len) ssize_t *out_len)
{ {
return ie_tlv_vendor_ie_concat(microsoft_oui, 0x04, ies, len, out_len); return ie_tlv_vendor_ie_concat(microsoft_oui, 0x04,
ies, len, false, out_len);
}
/*
* Wi-Fi P2P Technical Specification v1.7, Section 8.2:
* "More than one P2P IE may be included in a single frame. If multiple P2P
* IEs are present, the complete P2P attribute data consists of the
* concatenation of the P2P Attribute fields of the P2P IEs. The P2P
* Attributes field of each P2P IE may be any length up to the maximum
* (251 octets). The order of the concatenated P2P attribute data shall be
* preserved in the ordering of the P2P IEs in the frame. All of the P2P IEs
* shall fit within a single frame and shall be adjacent in the frame."
*/
void *ie_tlv_extract_p2p_payload(const unsigned char *ies, size_t len,
ssize_t *out_len)
{
return ie_tlv_vendor_ie_concat(wifi_alliance_oui, 0x09,
ies, len, true, out_len);
} }
/* /*

View File

@ -412,6 +412,9 @@ void *ie_tlv_extract_wsc_payload(const uint8_t *ies, size_t len,
void *ie_tlv_encapsulate_wsc_payload(const uint8_t *data, size_t len, void *ie_tlv_encapsulate_wsc_payload(const uint8_t *data, size_t len,
size_t *out_len); size_t *out_len);
void *ie_tlv_extract_p2p_payload(const uint8_t *ies, size_t len,
ssize_t *out_len);
bool ie_tlv_builder_init(struct ie_tlv_builder *builder, unsigned char *buf, bool ie_tlv_builder_init(struct ie_tlv_builder *builder, unsigned char *buf,
size_t len); size_t len);
bool ie_tlv_builder_set_length(struct ie_tlv_builder *builder, bool ie_tlv_builder_set_length(struct ie_tlv_builder *builder,