diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2012-10-03 15:18:17 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-10-03 22:40:42 +0300 |
commit | c7b884ab2b2a212b5e03c88dcfd4ffeeea191b0f (patch) | |
tree | 5b139bef8cb34b3b6578987dd4951c01587fa788 /src/eir.c | |
parent | 1748b9e5490ccb237efb36a8bcc7e44584c87024 (diff) | |
download | bluez-c7b884ab2b2a212b5e03c88dcfd4ffeeea191b0f.tar.gz |
eir: Add eir_parse_oob function
This will parse EIR received over OOB. Such EIR contains mandatory
and optional part.
Diffstat (limited to 'src/eir.c')
-rw-r--r-- | src/eir.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -38,6 +38,8 @@ #include "glib-helper.h" #include "eir.h" +#define EIR_OOB_MIN (2 + 6) + void eir_data_free(struct eir_data *eir) { g_slist_free_full(eir->services, g_free); @@ -195,6 +197,29 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len) return 0; } +int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len) +{ + + if (eir_len < EIR_OOB_MIN) + return -1; + + if (eir_len != bt_get_le16(eir_data)) + return -1; + + eir_data += sizeof(uint16_t); + eir_len -= sizeof(uint16_t); + + memcpy(&eir->addr, eir_data, sizeof(bdaddr_t)); + eir_data += sizeof(bdaddr_t); + eir_len -= sizeof(bdaddr_t); + + /* optional OOB EIR data */ + if (eir_len > 0) + return eir_parse(eir, eir_data, eir_len); + + return 0; +} + #define SIZEOF_UUID128 16 static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len) |