diff --git a/tools/parser/l2cap.c b/tools/parser/l2cap.c
index 587dd1b..6f913ce 100644
--- a/tools/parser/l2cap.c
+++ b/tools/parser/l2cap.c
case 1:
return *ptr;
case 2:
- return btohs(get_unaligned((uint16_t *) ptr));
+ return btohs(bt_get_unaligned((uint16_t *) ptr));
case 4:
- return btohl(get_unaligned((uint32_t *) ptr));
+ return btohl(bt_get_unaligned((uint32_t *) ptr));
}
return 0;
}
if (p_filter(FILT_L2CAP))
return;
- psm = btohs(get_unaligned((uint16_t*)frm->ptr));
+ psm = btohs(bt_get_unaligned((uint16_t*)frm->ptr));
frm->len -= 2;
p_indent(level, frm);
diff --git a/tools/parser/parser.h b/tools/parser/parser.h
index a79dc4e..e95a209 100644
--- a/tools/parser/parser.h
+++ b/tools/parser/parser.h
#ifndef __PARSER_H
#define __PARSER_H
+#include <bluetooth/bluetooth.h>
+
struct frame {
void *data;
int data_len;
/* get_uXX functions do byte swaping */
-/* use memmove to prevent gcc from using builtin memcpy */
-#define get_unaligned(p) \
- ({ __typeof__(*(p)) t; memmove(&t, (p), sizeof(t)); t; })
-
static inline uint8_t get_u8(struct frame *frm)
{
uint8_t *u8_ptr = frm->ptr;
uint16_t *u16_ptr = frm->ptr;
frm->ptr += 2;
frm->len -= 2;
- return ntohs(get_unaligned(u16_ptr));
+ return ntohs(bt_get_unaligned(u16_ptr));
}
static inline uint32_t get_u32(struct frame *frm)
uint32_t *u32_ptr = frm->ptr;
frm->ptr += 4;
frm->len -= 4;
- return ntohl(get_unaligned(u32_ptr));
+ return ntohl(bt_get_unaligned(u32_ptr));
}
static inline uint64_t get_u64(struct frame *frm)
{
uint64_t *u64_ptr = frm->ptr;
- uint64_t u64 = get_unaligned(u64_ptr), tmp;
+ uint64_t u64 = bt_get_unaligned(u64_ptr), tmp;
frm->ptr += 8;
frm->len -= 8;
tmp = ntohl(u64 & 0xffffffff);