Merge branch 'hcidump_master'
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 0000000..2cce80c
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1 @@
+André Dieb Martins <andre.dieb@signove.com>	<andre.dieb@signove.com>
diff --git a/AUTHORS b/AUTHORS
index 804e2f6..a808dd2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -3,3 +3,4 @@
 Wayne Lee <waynelee@qualcomm.com>
 Ricky Yuen <ryuen@qualcomm.com>
 Takashi Sasai <sasai@sm.sony.co.jp>
+Andre Dieb Martins <andre.dieb@signove.com>
diff --git a/parser/att.c b/parser/att.c
index a0fb135..a6f42df 100644
--- a/parser/att.c
+++ b/parser/att.c
@@ -330,6 +330,34 @@
 	}
 }
 
+static void att_find_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)));
+	uint16_t uuid = btohs(htons(get_u16(frm)));
+
+	p_indent(level, frm);
+	printf("start 0x%4.4x, end 0x%4.4x, uuid 0x%4.4x\n", start, end, uuid);
+
+	p_indent(level, frm);
+	printf("value");
+	while (frm->len > 0)
+		printf(" 0x%2.2x", get_u8(frm));
+	printf("\n");
+}
+
+static void att_find_by_type_resp_dump(int level, struct frame *frm)
+{
+	while (frm->len > 0) {
+		uint16_t uuid = btohs(htons(get_u16(frm)));
+		uint16_t end = btohs(htons(get_u16(frm)));
+
+		p_indent(level, frm);
+		printf("Found attr 0x%4.4x, group end handle 0x%4.4x\n",
+								uuid, end);
+	}
+}
+
 static void att_read_by_type_req_dump(int level, struct frame *frm)
 {
 	uint16_t start = btohs(htons(get_u16(frm)));
@@ -337,11 +365,11 @@
 	int i;
 
 	p_indent(level, frm);
-	printf("start 0x%2.2x, end 0x%2.2x\n", start, end);
+	printf("start 0x%4.4x, end 0x%4.4x\n", start, end);
 
 	p_indent(level, frm);
 	if (frm->len == 2) {
-		printf("type-uuid 0x%2.2x\n", btohs(htons(get_u16(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++) {
@@ -386,18 +414,139 @@
 	printf("handle 0x%2.2x\n", handle);
 }
 
+static void att_read_blob_req_dump(int level, struct frame *frm)
+{
+	uint16_t handle = btohs(htons(get_u16(frm)));
+	uint16_t offset = btohs(htons(get_u16(frm)));
+
+	p_indent(level, frm);
+	printf("handle 0x%4.4x offset 0x%4.4x\n", handle, offset);
+}
+
+static void att_read_blob_resp_dump(int level, struct frame *frm)
+{
+	p_indent(level, frm);
+	printf("value");
+
+	while (frm->len > 0)
+		printf(" 0x%2.2x", get_u8(frm));
+	printf("\n");
+}
+
+static void att_read_multi_req_dump(int level, struct frame *frm)
+{
+	p_indent(level, frm);
+	printf("Handles\n");
+
+	while (frm->len > 0) {
+		p_indent(level, frm);
+		printf("handle 0x%4.4x\n", btohs(htons(get_u16(frm))));
+	}
+}
+
+static void att_read_multi_resp_dump(int level, struct frame *frm)
+{
+	p_indent(level, frm);
+	printf("values");
+
+	while (frm->len > 0)
+		printf(" 0x%2.2x", get_u8(frm));
+	printf("\n");
+}
+
+static void att_read_by_group_resp_dump(int level, struct frame *frm)
+{
+	uint8_t length = get_u8(frm);
+
+	while (frm->len > 0) {
+		uint16_t attr_handle = btohs(htons(get_u16(frm)));
+		uint16_t end_grp_handle = btohs(htons(get_u16(frm)));
+		uint8_t remaining = length - 4;
+
+		p_indent(level, frm);
+		printf("attr handle 0x%4.4x, end group handle 0x%4.4x\n",
+						attr_handle, end_grp_handle);
+
+		p_indent(level, frm);
+		printf("value");
+		while (remaining > 0) {
+			printf(" 0x%2.2x", get_u8(frm));
+		}
+		printf("\n");
+	}
+}
+
+static void att_write_req_dump(int level, struct frame *frm)
+{
+	uint16_t handle = btohs(htons(get_u16(frm)));
+
+	p_indent(level, frm);
+	printf("handle 0x%4.4x value ", handle);
+
+	while (frm->len > 0)
+		printf(" 0x%2.2x", get_u8(frm));
+	printf("\n");
+}
+
+static void att_signed_write_dump(int level, struct frame *frm)
+{
+	uint16_t handle = btohs(htons(get_u16(frm)));
+	int value_len = frm->len - 12; /* handle:2 already accounted, sig: 12 */
+
+	p_indent(level, frm);
+	printf("handle 0x%4.4x value ", handle);
+
+	while (value_len--)
+		printf(" 0x%2.2x", get_u8(frm));
+	printf("\n");
+
+	p_indent(level, frm);
+	printf("auth signature ");
+	while (frm->len > 0)
+		printf(" 0x%2.2x", get_u8(frm));
+	printf("\n");
+}
+
+static void att_prep_write_dump(int level, struct frame *frm)
+{
+	uint16_t handle = btohs(htons(get_u16(frm)));
+	uint16_t val_offset = btohs(htons(get_u16(frm)));
+
+	p_indent(level, frm);
+	printf("attr handle 0x%4.4x, value offset 0x%4.4x\n", handle,
+								val_offset);
+
+	p_indent(level, frm);
+	printf("part attr value ");
+	while (frm->len > 0)
+		printf(" 0x%2.2x", get_u8(frm));
+	printf("\n");
+}
+
+static void att_exec_write_req_dump(int level, struct frame *frm)
+{
+	uint8_t flags = get_u8(frm);
+
+	p_indent(level, frm);
+	if (flags == 0x00)
+		printf("cancel all prepared writes ");
+	else
+		printf("immediatelly write all pending prepared values ");
+
+	printf("(0x%2.2x)\n", flags);
+}
+
 static void att_handle_notify_dump(int level, struct frame *frm)
 {
 	uint16_t handle = btohs(htons(get_u16(frm)));
 
 	p_indent(level, frm);
-	printf("handle 0x%2.2x\n", handle);
+	printf("handle 0x%4.4x\n", handle);
 
 	p_indent(level, frm);
 	printf("value ");
-	while (frm->len > 0) {
+	while (frm->len > 0)
 		printf("0x%.2x ", get_u8(frm));
-	}
 	printf("\n");
 }
 
@@ -426,7 +575,14 @@
 		case ATT_OP_FIND_INFO_RESP:
 			att_find_info_resp_dump(level + 1, frm);
 			break;
+		case ATT_OP_FIND_BY_TYPE_REQ:
+			att_find_by_type_req_dump(level + 1, frm);
+			break;
+		case ATT_OP_FIND_BY_TYPE_RESP:
+			att_find_by_type_resp_dump(level + 1, frm);
+			break;
 		case ATT_OP_READ_BY_TYPE_REQ:
+		case ATT_OP_READ_BY_GROUP_REQ: /* exact same parsing */
 			att_read_by_type_req_dump(level + 1, frm);
 			break;
 		case ATT_OP_READ_BY_TYPE_RESP:
@@ -438,6 +594,35 @@
 		case ATT_OP_READ_RESP:
 			raw_dump(level + 1, frm);
 			break;
+		case ATT_OP_READ_BLOB_REQ:
+			att_read_blob_req_dump(level + 1, frm);
+			break;
+		case ATT_OP_READ_BLOB_RESP:
+			att_read_blob_resp_dump(level + 1, frm);
+			break;
+		case ATT_OP_READ_MULTI_REQ:
+			att_read_multi_req_dump(level + 1, frm);
+			break;
+		case ATT_OP_READ_MULTI_RESP:
+			att_read_multi_resp_dump(level + 1, frm);
+			break;
+		case ATT_OP_READ_BY_GROUP_RESP:
+			att_read_by_group_resp_dump(level + 1, frm);
+			break;
+		case ATT_OP_WRITE_REQ:
+		case ATT_OP_WRITE_CMD:
+			att_write_req_dump(level + 1, frm);
+			break;
+		case ATT_OP_SIGNED_WRITE_CMD:
+			att_signed_write_dump(level + 1, frm);
+			break;
+		case ATT_OP_PREP_WRITE_REQ:
+		case ATT_OP_PREP_WRITE_RESP:
+			att_prep_write_dump(level + 1, frm);
+			break;
+		case ATT_OP_EXEC_WRITE_REQ:
+			att_exec_write_req_dump(level + 1, frm);
+			break;
 		case ATT_OP_HANDLE_NOTIFY:
 			att_handle_notify_dump(level + 1, frm);
 			break;
diff --git a/src/hcidump.c b/src/hcidump.c
index af086c7..f865ad6 100644
--- a/src/hcidump.c
+++ b/src/hcidump.c
@@ -50,22 +50,6 @@
 #include "parser/parser.h"
 #include "parser/sdp.h"
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static inline uint64_t ntoh64(uint64_t n)
-{
-	uint64_t h;
-	uint64_t tmp = ntohl(n & 0x00000000ffffffff);
-	h = ntohl(n >> 32);
-	h |= tmp << 32;
-	return h;
-}
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define ntoh64(x) (x)
-#else
-#error "Unknown byte order"
-#endif
-#define hton64(x) ntoh64(x)
-
 #define SNAP_LEN 	HCI_MAX_FRAME_SIZE
 #define DEFAULT_PORT	"10839";
 
@@ -297,9 +281,11 @@
 
 		cmsg = CMSG_FIRSTHDR(&msg);
 		while (cmsg) {
+			int dir;
 			switch (cmsg->cmsg_type) {
 			case HCI_CMSG_DIR:
-				memcpy(&frm.in, CMSG_DATA(cmsg), sizeof(int));
+				memcpy(&dir, CMSG_DATA(cmsg), sizeof(int));
+				frm.in = (uint8_t) dir;
 				break;
 			case HCI_CMSG_TSTAMP:
 				memcpy(&frm.ts, CMSG_DATA(cmsg),