mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-05 12:52:37 +01:00
ie: Add ie_tlv_encapsulate_p2p_payload
This commit is contained in:
parent
5cb07ff116
commit
3bd265e02f
16
src/ie.c
16
src/ie.c
@ -209,6 +209,7 @@ void *ie_tlv_extract_p2p_payload(const unsigned char *ies, size_t len,
|
|||||||
static void *ie_tlv_vendor_ie_encapsulate(const unsigned char oui[],
|
static void *ie_tlv_vendor_ie_encapsulate(const unsigned char oui[],
|
||||||
uint8_t type,
|
uint8_t type,
|
||||||
const void *data, size_t len,
|
const void *data, size_t len,
|
||||||
|
bool build_empty,
|
||||||
size_t *out_len)
|
size_t *out_len)
|
||||||
{
|
{
|
||||||
size_t overhead;
|
size_t overhead;
|
||||||
@ -222,6 +223,9 @@ static void *ie_tlv_vendor_ie_encapsulate(const unsigned char oui[],
|
|||||||
*/
|
*/
|
||||||
overhead = (len + 250) / 251 * 6;
|
overhead = (len + 250) / 251 * 6;
|
||||||
|
|
||||||
|
if (len == 0 && build_empty)
|
||||||
|
overhead = 6;
|
||||||
|
|
||||||
ret = l_malloc(len + overhead);
|
ret = l_malloc(len + overhead);
|
||||||
|
|
||||||
if (out_len)
|
if (out_len)
|
||||||
@ -229,7 +233,7 @@ static void *ie_tlv_vendor_ie_encapsulate(const unsigned char oui[],
|
|||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
while (len) {
|
while (overhead) {
|
||||||
ie_len = len <= 251 ? len : 251;
|
ie_len = len <= 251 ? len : 251;
|
||||||
ret[offset++] = IE_TYPE_VENDOR_SPECIFIC;
|
ret[offset++] = IE_TYPE_VENDOR_SPECIFIC;
|
||||||
ret[offset++] = ie_len + 4;
|
ret[offset++] = ie_len + 4;
|
||||||
@ -240,6 +244,7 @@ static void *ie_tlv_vendor_ie_encapsulate(const unsigned char oui[],
|
|||||||
|
|
||||||
data += ie_len;
|
data += ie_len;
|
||||||
len -= ie_len;
|
len -= ie_len;
|
||||||
|
overhead -= 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -249,7 +254,14 @@ void *ie_tlv_encapsulate_wsc_payload(const uint8_t *data, size_t len,
|
|||||||
size_t *out_len)
|
size_t *out_len)
|
||||||
{
|
{
|
||||||
return ie_tlv_vendor_ie_encapsulate(microsoft_oui, 0x04,
|
return ie_tlv_vendor_ie_encapsulate(microsoft_oui, 0x04,
|
||||||
data, len, out_len);
|
data, len, false, out_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *ie_tlv_encapsulate_p2p_payload(const uint8_t *data, size_t len,
|
||||||
|
size_t *out_len)
|
||||||
|
{
|
||||||
|
return ie_tlv_vendor_ie_encapsulate(wifi_alliance_oui, 0x09,
|
||||||
|
data, len, true, out_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TLV_HEADER_LEN 2
|
#define TLV_HEADER_LEN 2
|
||||||
|
2
src/ie.h
2
src/ie.h
@ -414,6 +414,8 @@ void *ie_tlv_encapsulate_wsc_payload(const uint8_t *data, size_t len,
|
|||||||
|
|
||||||
void *ie_tlv_extract_p2p_payload(const uint8_t *ies, size_t len,
|
void *ie_tlv_extract_p2p_payload(const uint8_t *ies, size_t len,
|
||||||
ssize_t *out_len);
|
ssize_t *out_len);
|
||||||
|
void *ie_tlv_encapsulate_p2p_payload(const uint8_t *data, size_t len,
|
||||||
|
size_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);
|
||||||
|
Loading…
Reference in New Issue
Block a user