fix ad_data_contains_uuid128 to accept uuid in big endian

This commit is contained in:
Matthias Ringwald 2015-03-31 22:13:25 +02:00
parent 0d3b00a243
commit 6771095235

View File

@ -124,6 +124,9 @@ int ad_data_contains_uuid16(uint8_t ad_len, uint8_t * ad_data, uint16_t uuid16){
int ad_data_contains_uuid128(uint8_t ad_len, uint8_t * ad_data, uint8_t * uuid128){
ad_context_t context;
// input in big endian/network order, bluetooth data in little endian
uint8_t uuid128_le[16];
swap128(uuid128, uuid128_le);
for (ad_iterator_init(&context, ad_len, ad_data) ; ad_iterator_has_more(&context) ; ad_iterator_next(&context)){
uint8_t data_type = ad_iterator_get_data_type(&context);
uint8_t data_len = ad_iterator_get_data_len(&context);
@ -131,7 +134,8 @@ int ad_data_contains_uuid128(uint8_t ad_len, uint8_t * ad_data, uint8_t * uuid12
int i;
uint8_t ad_uuid128[16];
switch (data_type){
case IncompleteList16:
case CompleteList16:
@ -139,14 +143,14 @@ int ad_data_contains_uuid128(uint8_t ad_len, uint8_t * ad_data, uint8_t * uuid12
uint16_t uuid16 = READ_BT_16(data, i);
sdp_normalize_uuid(ad_uuid128, uuid16);
if (memcmp(ad_uuid128, uuid128, 16) == 0) return 1;
if (memcmp(ad_uuid128, uuid128_le, 16) == 0) return 1;
}
break;
case IncompleteList128:
case CompleteList128:
for (i=0; i<data_len; i+=16){
if (memcmp(uuid128, &data[i], 16) == 0) return 1;
if (memcmp(uuid128_le, &data[i], 16) == 0) return 1;
}
break;
default: