aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-02-01 08:05:26 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-01 08:05:26 +0200
commit032e2719842bdb66072adb366e419c6c934e496f (patch)
treeb4fa3363bee2ceeaaa79baae63bdfb4c34e032c1
parentd25ab0fa3d8f422c413a4c474425e1d60554dd44 (diff)
downloadbluez-hcidump-032e2719842bdb66072adb366e419c6c934e496f.tar.gz
bluez-hcidump-032e2719842bdb66072adb366e419c6c934e496f.tar.xz
bluez-hcidump-032e2719842bdb66072adb366e419c6c934e496f.zip
att: Fix UUID-128 parsing
ATT UUIDs are in little-endian format (in contrast to e.g. SDP).
-rw-r--r--parser/att.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/parser/att.c b/parser/att.c
index 040da32..2f16619 100644
--- a/parser/att.c
+++ b/parser/att.c
@@ -292,6 +292,21 @@ static void att_find_info_req_dump(int level, struct frame *frm)
printf("start 0x%4.4x, end 0x%4.4x\n", start, end);
}
+static void print_uuid128(struct frame *frm)
+{
+ uint8_t uuid[16];
+ int i;
+
+ for (i = 0; i < 16; i++)
+ uuid[15 - i] = get_u8(frm);
+
+ for (i = 0; i < 16; i++) {
+ printf("%02x", uuid[i]);
+ if (i == 3 || i == 5 || i == 7 || i == 9)
+ printf("-");
+ }
+}
+
static void att_find_info_resp_dump(int level, struct frame *frm)
{
uint8_t fmt = get_u8(frm);
@@ -313,15 +328,10 @@ static void att_find_info_resp_dump(int level, struct frame *frm)
while (frm->len > 0) {
uint16_t handle = btohs(htons(get_u16(frm)));
- int i;
p_indent(level + 1, frm);
printf("handle 0x%4.4x, uuid ", handle);
- for (i = 0; i < 16; i++) {
- printf("%02x", get_u8(frm));
- if (i == 3 || i == 5 || i == 7 || i == 9)
- printf("-");
- }
+ print_uuid128(frm);
printf("\n");
}
}
@@ -359,7 +369,6 @@ static void att_read_by_type_req_dump(int level, struct frame *frm)
{
uint16_t start = btohs(htons(get_u16(frm)));
uint16_t end = btohs(htons(get_u16(frm)));
- int i;
p_indent(level, frm);
printf("start 0x%4.4x, end 0x%4.4x\n", start, end);
@@ -369,11 +378,7 @@ static void att_read_by_type_req_dump(int level, struct frame *frm)
printf("type-uuid 0x%4.4x\n", btohs(htons(get_u16(frm))));
} else if (frm->len == 16) {
printf("type-uuid ");
- for (i = 0; i < 16; i++) {
- printf("%02x", get_u8(frm));
- if (i == 3 || i == 5 || i == 7 || i == 9)
- printf("-");
- }
+ print_uuid128(frm);
printf("\n");
} else {
printf("malformed uuid (expected 2 or 16 octets)\n");