diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-08-24 01:58:19 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-08-24 01:58:19 +0000 |
commit | 466452630ca4b126bdd54e46b1da28604d0968f2 (patch) | |
tree | a8ff50eeb38bf8ca59724b53c71c8d8afc5d5bdb /sdpd | |
parent | 0e8c93725dbdc6ce76ca48da92f9d15b2a706111 (diff) |
Include all UUID-16 values in the extended inquiry response
Diffstat (limited to 'sdpd')
-rw-r--r-- | sdpd/service.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/sdpd/service.c b/sdpd/service.c index bbc7fcc8..e51f4aed 100644 --- a/sdpd/service.c +++ b/sdpd/service.c @@ -141,18 +141,61 @@ void set_service_classes_callback(service_classes_callback_t callback) void create_ext_inquiry_response(const char *name, uint8_t *data) { + sdp_list_t *list = sdp_get_record_list(); + uint8_t *ptr = data; + uint16_t uuid[24]; + int i, index = 0; + if (name) { int len = strlen(name); if (len > 48) { len = 48; - data[1] = 0x08; + ptr[1] = 0x08; } else - data[1] = 0x09; + ptr[1] = 0x09; + + ptr[0] = len + 1; + + memcpy(ptr + 2, name, len); + + ptr += len + 2; + } + + ptr[1] = 0x03; + + for (; list; list = list->next) { + sdp_record_t *rec = (sdp_record_t *) list->data; + + if (rec->svclass.type != SDP_UUID16) + continue; + + if (rec->svclass.value.uuid16 < 0x1100) + continue; + + if (index > 23) { + ptr[1] = 0x02; + break; + } - data[0] = len + 1; + for (i = 0; i < index; i++) + if (uuid[i] == rec->svclass.value.uuid16) + break; - memcpy(data + 2, name, len); + if (i == index - 1) + continue; + + uuid[index++] = rec->svclass.value.uuid16; + } + + if (index > 0) { + ptr[0] = (index * 2) + 1; + ptr += 2; + + for (i = 0; i < index; i++) { + *ptr++ = (uuid[i] & 0x00ff); + *ptr++ = (uuid[i] & 0xff00) >> 8; + } } } |