static void data_packet(const void *data, uint8_t size) { const uint8_t *ptr = data; uint8_t llid, length; bool nesn, sn, md; const char *str; if (size < 2) { print_text(COLOR_ERROR, "packet too short"); packet_hexdump(data, size); return; } llid = ptr[0] & 0x03; nesn = !!(ptr[0] & 0x04); sn = !!(ptr[0] & 0x08); md = !!(ptr[0] & 0x10); length = ptr[1] & 0x1f; switch (llid) { case 0x01: if (length > 0) str = "Continuation fragement of L2CAP message"; else str = "Empty message"; break; case 0x02: str = "Start of L2CAP message"; break; case 0x03: str = "Control"; break; default: str = "Reserved"; break; } print_field("LLID: %s (0x%2.2x)", str, llid); print_field("Next expected sequence number: %u", nesn); print_field("Sequence number: %u", sn); print_field("More data: %u", md); print_field("Length: %u", length); switch (llid) { case 0x03: llcp_packet(data + 2, size - 2); break; default: packet_hexdump(data + 2, size - 2); break; } }
void broadcom_lm_diag(const void *data, uint8_t size) { uint8_t type; uint32_t clock; const uint8_t *addr; const char *str; if (size != 63) { packet_hexdump(data, size); return; } type = *((uint8_t *) data); clock = get_be32(data + 1); switch (type) { case 0x00: str = "LMP sent"; break; case 0x01: str = "LMP receive"; break; case 0x80: str = "LL sent"; break; case 0x81: str = "LL receive"; break; default: str = "Unknown"; break; } print_field("Type: %s (%u)", str, type); print_field("Clock: 0x%8.8x", clock); switch (type) { case 0x00: addr = data + 5; print_field("Address: --:--:%2.2X:%2.2X:%2.2X:%2.2X", addr[0], addr[1], addr[2], addr[3]); packet_hexdump(data + 9, 1); lmp_packet(data + 10, size - 10, true); break; case 0x01: addr = data + 5; print_field("Address: --:--:%2.2X:%2.2X:%2.2X:%2.2X", addr[0], addr[1], addr[2], addr[3]); packet_hexdump(data + 9, 4); lmp_packet(data + 13, size - 13, true); break; case 0x80: case 0x81: packet_hexdump(data + 5, 7); llcp_packet(data + 12, size - 12, true); break; default: packet_hexdump(data + 9, size - 9); break; } }