Add parsing of BT 3.0+HS signals
Subsystems (3)
v4 cover Add parsing of BT 3.0+HS signals
v4 - Content unchanged but A2MP definitions added to own file
Sending again after reading the send-email prompts more carefully...
Peter Krystad (5):
Add L2CAP Create/Move Channel definitions
Add A2MP definitions
Add parsing of L2CAP Create/Move Channel signals
Add parsing of A2MP signals
Minor indentation cleanup and fix display of physical link key
Makefile.am | 2 +- lib/a2mp.h | 115 ++++++++++++++ lib/l2cap.h | 45 ++++++ parser/hci.c | 15 ++- parser/l2cap.c | 450 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ parser/parser.h | 1 + src/hcidump.c | 1 + 7 files changed, 623 insertions(+), 6 deletions(-)
Signature · 6 lines
1.7.4.1 -- Peter Krystad Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
PATCH v4 1/5 Add L2CAP Create/Move Channel definitions
--- lib/l2cap.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)
lib/l2cap.h +45 -0
@@ -5,6 +5,7 @@* Copyright (C) 2000-2001 Qualcomm Incorporated * Copyright (C) 2002-2003 Maxim Krasnyansky <[email protected]> * Copyright (C) 2002-2010 Marcel Holtmann <[email protected]> +* Copyright (c) 2012 Code Aurora Forum. All rights reserved. * * * This program is free software; you can redistribute it and/or modify
@@ -82,6 +83,12 @@ struct l2cap_conninfo {#define L2CAP_ECHO_RSP 0x09#define L2CAP_INFO_REQ 0x0a#define L2CAP_INFO_RSP 0x0b +#define L2CAP_CREATE_REQ 0x0c +#define L2CAP_CREATE_RSP 0x0d +#define L2CAP_MOVE_REQ 0x0e +#define L2CAP_MOVE_RSP 0x0f +#define L2CAP_MOVE_CFM 0x10 +#define L2CAP_MOVE_CFM_RSP 0x11/* L2CAP extended feature mask */ #define L2CAP_FEAT_FLOWCTL 0x00000001
@@ -270,6 +277,44 @@ typedef struct {#define L2CAP_IR_SUCCESS 0x0000#define L2CAP_IR_NOTSUPP 0x0001 +typedef struct { +uint16_t psm; +uint16_t scid; +uint8_t id; +} __attribute__ ((packed))l2cap_create_req ; +#define L2CAP_CREATE_REQ_SIZE 5 + +typedef struct { +uint16_t dcid; +uint16_t scid; +uint16_t result; +uint16_t status; +} __attribute__ ((packed))l2cap_create_rsp ; +#define L2CAP_CREATE_RSP_SIZE 8 + +typedef struct { +uint16_t icid; +uint8_t id; +} __attribute__ ((packed))l2cap_move_req ; +#define L2CAP_MOVE_REQ_SIZE 3 + +typedef struct { +uint16_t icid; +uint16_t result; +} __attribute__ ((packed))l2cap_move_rsp ; +#define L2CAP_MOVE_RSP_SIZE 4 + +typedef struct { +uint16_t icid; +uint16_t result; +} __attribute__ ((packed))l2cap_move_cfm ; +#define L2CAP_MOVE_CFM_SIZE 4 + +typedef struct { +uint16_t icid; +} __attribute__ ((packed))l2cap_move_cfm_rsp ; +#define L2CAP_MOVE_CFM_RSP_SIZE 2 + #ifdef __cplusplus }#endif
Signature · 7 lines
1.7.4.1 -- Peter Krystad Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
Re: [PATCH v4 1/5] Add L2CAP Create/Move Channel definitions
Hi Peter,
Quoted 3 lines · Peter Krystad
--- lib/l2cap.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-)
I've applied this one to both bluez-hcidump.git as well as bluez.git (after adding a lib: prefix that should be used for all lib patches).
Since any patches to lib/* should be appliable to both hcidump and bluez please don't mix Makefile.am changes into them. Once you've split those into separate patches I can apply them as well as the rest of this set. Thanks.
Johan
PATCH v4 2/5 Add A2MP definitions
In reply to Peter Krystad--- Makefile.am | 2 +- lib/a2mp.h | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 1 deletions(-)
Makefile.am +1 -1
@@ -2,7 +2,7 @@ AM_MAKEFLAGS = --no-print-directory library_sources = lib/bluetooth.h lib/bluetooth.c \ - lib/hci_lib.h lib/hci.h lib/hci.c lib/l2cap.h + lib/hci_lib.h lib/hci.h lib/hci.c lib/l2cap.h lib/a2mp.h parser_sources = parser/parser.h parser/parser.c \ parser/lmp.c \
lib/a2mp.h +115 -0
127 lines not on this page · raw message
Signature · 7 lines
1.7.4.1 -- Peter Krystad Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
PATCH v4 3/5 Add parsing of L2CAP Create/Move Channel signals
In reply to Peter Krystad--- parser/l2cap.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 96 insertions(+), 0 deletions(-)
parser/l2cap.c +96 -0
@@ -868,6 +868,78 @@ static void l2cap_ctrl_parse(int level, struct frame *frm, uint32_t ctrl)printf (" F-bit" ); } +static inline void create_req (int level,l2cap_cmd_hdr *cmd,struct frame *frm) +{ +l2cap_create_req *h = frm->ptr; +uint16_t psm =btohs (h->psm); +uint16_t scid =btohs (h->scid); + +if (p_filter (FILT_L2CAP )) +return ; + +printf ("Create req: psm %d scid 0x%4.4x id %d\n" , psm, scid, h->id); +} + +static inline void create_rsp (int level,l2cap_cmd_hdr *cmd,struct frame *frm) +{ +l2cap_create_rsp *h = frm->ptr; +uint16_t scid =btohs (h->scid); +uint16_t dcid =btohs (h->dcid); +uint16_t result =btohs (h->result); +uint16_t status =btohs (h->status); + +if (p_filter (FILT_L2CAP )) +return ; + +printf ("Create rsp: dcid 0x%4.4x scid 0x%4.4x result %d status %d\n" , dcid, scid, result, status); +} + +static inline void move_req (int level,l2cap_cmd_hdr *cmd,struct frame *frm) +{ +l2cap_move_req *h = frm->ptr; +uint16_t icid =btohs (h->icid); + +if (p_filter (FILT_L2CAP )) +return ; + +printf ("Move req: icid 0x%4.4x id %d\n" , icid, h->id); +} + +static inline void move_rsp (int level,l2cap_cmd_hdr *cmd,struct frame *frm) +{ +l2cap_move_rsp *h = frm->ptr; +uint16_t icid =btohs (h->icid); +uint16_t result =btohs (h->result); + +if (p_filter (FILT_L2CAP )) +return ; + +printf ("Move rsp: icid 0x%4.4x result %d\n" , icid, result); +} + +static inline void move_cfm (int level,l2cap_cmd_hdr *cmd,struct frame *frm) +{ +l2cap_move_cfm *h = frm->ptr; +uint16_t icid =btohs (h->icid); +uint16_t result =btohs (h->result); + +if (p_filter (FILT_L2CAP )) +return ; + +printf ("Move cfm: icid 0x%4.4x result %d\n" , icid, result); +} + +static inline void move_cfm_rsp (int level,l2cap_cmd_hdr *cmd,struct frame *frm) +{ +l2cap_move_cfm_rsp *h = frm->ptr; +uint16_t icid =btohs (h->icid); + +if (p_filter (FILT_L2CAP )) +return ; + +printf ("Move cfm rsp: icid 0x%4.4x\n" , icid); +} +static void l2cap_parse (int level,struct frame *frm) {l2cap_hdr *hdr = (void *)frm->ptr;
@@ -937,6 +1009,30 @@ static void l2cap_parse(int level, struct frame *frm)info_rsp (level, hdr, frm);break ; +case L2CAP_CREATE_REQ : +create_req (level, hdr, frm); +break ; + +case L2CAP_CREATE_RSP : +create_rsp (level, hdr, frm); +break ; + +case L2CAP_MOVE_REQ : +move_req (level, hdr, frm); +break ; + +case L2CAP_MOVE_RSP : +move_rsp (level, hdr, frm); +break ; + +case L2CAP_MOVE_CFM : +move_cfm (level, hdr, frm); +break ; + +case L2CAP_MOVE_CFM_RSP : +move_cfm_rsp (level, hdr, frm); +break ; +default :if (p_filter (FILT_L2CAP ))break ;
Signature · 7 lines
1.7.4.1 -- Peter Krystad Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
PATCH v4 4/5 Add parsing of A2MP signals
In reply to Peter Krystad--- parser/l2cap.c | 354 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ parser/parser.h | 1 + src/hcidump.c | 1 + 3 files changed, 356 insertions(+), 0 deletions(-)
parser/l2cap.c +354 -0
@@ -37,6 +37,7 @@#include "parser/sdp.h" #include "lib/hci.h" #include "lib/l2cap.h" +#include "lib/a2mp.h" typedef struct { uint16_t handle;
@@ -269,6 +270,16 @@ static char *reason2str(uint16_t reason) } } +static char *a2mpreason2str (uint16_t reason) +{ +switch (reason) { +case A2MP_COMMAND_NOT_RECOGNIZED : +return "Command not recognized" ; +default : +return "Reserved" ; + } +} +static char *connresult2str (uint16_t result) {switch (result) {
@@ -409,6 +420,89 @@ static char *supervisory2str(uint8_t supervisory) } } +static char *ampctrltype2str (uint8_t type) +{ +switch (type) { +case HCI_BREDR : +return "BR-EDR" ; +case HCI_AMP : +return "802.11 AMP" ; +default : +return "Reserved" ; + } +} + +static char *ampctrlstatus2str (uint8_t status) +{ +switch (status) { +case AMP_CTRL_POWERED_DOWN : +return "Powered down" ; +case AMP_CTRL_BLUETOOTH_ONLY : +return "Bluetooth only" ; +case AMP_CTRL_NO_CAPACITY : +return "No capacity" ; +case AMP_CTRL_LOW_CAPACITY : +return "Low capacity" ; +case AMP_CTRL_MEDIUM_CAPACITY : +return "Medium capacity" ; +case AMP_CTRL_HIGH_CAPACITY : +return "High capacity" ; +case AMP_CTRL_FULL_CAPACITY : +return "Full capacity" ; +default : +return "Reserved" ; + + } +} + +static char *a2mpstatus2str (uint8_t status) +{ +switch (status) { +case A2MP_STATUS_SUCCESS : +return "Success" ; +case A2MP_STATUS_INVALID_CTRL_ID : +return "Invalid Controller ID" ; +default : +return "Reserved" ; + } +} + +static char *a2mpcplstatus2str (uint8_t status) +{ +switch (status) { +case A2MP_STATUS_SUCCESS : +return "Success" ; +case A2MP_STATUS_INVALID_CTRL_ID : +return "Invalid Controller ID" ; +case A2MP_STATUS_UNABLE_START_LINK_CREATION : +return "Failed - Unable to start link creation" ; +case A2MP_STATUS_COLLISION_OCCURED : +return "Failed - Collision occured" ; +case A2MP_STATUS_DISCONN_REQ_RECVD : +return "Failed - Disconnect physical link received" ; +case A2MP_STATUS_PHYS_LINK_EXISTS : +return "Failed - Physical link already exists" ; +case A2MP_STATUS_SECURITY_VIOLATION : +return "Failed - Security violation" ; +default : +return "Reserved" ; + } +} + +static char *a2mpdplstatus2str (uint8_t status) +{ +switch (status) { +case A2MP_STATUS_SUCCESS : +return "Success" ; +case A2MP_STATUS_INVALID_CTRL_ID : +return "Invalid Controller ID" ; +case A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS : +return "Failed - No Physical Link exists" ; +default : +return "Reserved" ; + } +} +static inline void command_rej (int level,struct frame *frm) {l2cap_cmd_rej *h = frm->ptr;
@@ -940,6 +1034,196 @@ static inline void move_cfm_rsp(int level, l2cap_cmd_hdr *cmd, struct frame *frmprintf ("Move cfm rsp: icid 0x%4.4x\n" , icid); } +static inline void a2mp_command_rej (int level,struct frame *frm) +{ +struct a2mp_command_rej *h = frm->ptr; +uint16_t reason =btohs (h->reason); + +printf ("Command Reject: reason %d\n" , reason); +p_indent (level +1 ,0 ); +printf ("%s\n" ,a2mpreason2str (reason)); +} + +static inline void a2mp_discover_req (int level,struct frame *frm,uint16_t len) +{ +struct a2mp_discover_req *h = frm->ptr; +uint16_t mtu =btohs (h->mtu); +uint8_t *octet = (uint8_t *)&(h->mask); +uint16_t mask; +uint8_t extension; + +printf ("Discover req: mtu/mps %d " , mtu); + len -=2 ; + +printf ("mask:" ); + +do { + len -=2 ; + mask =btohs (*(uint16_t *)(&octet[0 ])); +printf (" 0x%4.4x" , mask); + + extension = octet[1 ] &0x80 ; + octet +=2 ; + }while ((extension !=0 ) && (len >=2 )); + +printf ("\n" ); +} + +static inline void a2mp_ctrl_list_dump (int level,struct a2mp_ctrl *list,uint16_t len) +{ +p_indent (level,0 ); +printf ("Controller list:\n" ); + +while (len >=3 ) { +p_indent (level +1 ,0 ); +printf ("id %d type %d (%s) status 0x%2.2x (%s)\n" , + list->id, list->type,ampctrltype2str (list->type), list->status,ampctrlstatus2str (list->status)); + list++; + len -=3 ; + } + +} + +static inline void a2mp_discover_rsp (int level,struct frame *frm,uint16_t len) +{ +struct a2mp_discover_rsp *h = frm->ptr; +uint16_t mtu =btohs (h->mtu); +uint8_t *octet = (uint8_t *)&(h->mask); +uint16_t mask; +uint8_t extension; + +printf ("Discover rsp: mtu/mps %d " , mtu); + len -=2 ; + +printf ("mask:" ); + +do { + len -=2 ; + mask =btohs (*(uint16_t *)(&octet[0 ])); +printf (" 0x%4.4x" , mask); + + extension = octet[1 ] &0x80 ; + octet +=2 ; + }while ((extension !=0 ) && (len >=2 )); + +printf ("\n" ); + +if (len >=3 ) { +a2mp_ctrl_list_dump (level +1 , (struct a2mp_ctrl *) octet, len); + } +} + +static inline void a2mp_change_notify (int level,struct frame *frm,uint16_t len) +{ +struct a2mp_ctrl *list = frm->ptr; + +printf ("Change Notify\n" ); + +if (len >=3 ) { +a2mp_ctrl_list_dump (level +1 , list, len); + } +} + +static inline void a2mp_change_rsp (int level,struct frame *frm) +{ +printf ("Change Response\n" ); +} + +static inline void a2mp_info_req (int level,struct frame *frm) +{ +struct a2mp_info_req *h = frm->ptr; + +printf ("Get Info req: id %d\n" , h->id); +} + +static inline void a2mp_info_rsp (int level,struct frame *frm) +{ +struct a2mp_info_rsp *h = frm->ptr; + +printf ("Get Info rsp: id %d status %d (%s)\n" , + h->id, h->status,a2mpstatus2str (h->status)); + +p_indent (level +1 ,0 ); +printf ("Total bandwidth %d\n" ,btohl (h->total_bw)); +p_indent (level +1 ,0 ); +printf ("Max guaranteed bandwidth %d\n" ,btohl (h->max_bw)); +p_indent (level +1 ,0 ); +printf ("Min latency %d\n" ,btohl (h->min_latency)); +p_indent (level +1 ,0 ); +printf ("Pal capabilities 0x%4.4x\n" ,btohs (h->pal_caps)); +p_indent (level +1 ,0 ); +printf ("Assoc size %d\n" ,btohs (h->assoc_size)); +} + +static inline void a2mp_assoc_req (int level,struct frame *frm) +{ +struct a2mp_assoc_req *h = frm->ptr; + +printf ("Get AMP Assoc req: id %d\n" , h->id); +} + +static inline void a2mp_assoc_dump (int level,uint8_t *assoc,uint16_t len) +{ +int i; + +p_indent (level,0 ); +printf ("Assoc data:" ); +for (i =0 ; i < len; i++) { +if (!(i%16 )) { +printf ("\n" ); +p_indent (level+1 ,0 ); + } +printf ("%2.2x " ,*assoc++); + } +printf ("\n" ); +} + +static inline void a2mp_assoc_rsp (int level,struct frame *frm,uint16_t len) +{ +struct a2mp_assoc_rsp *h = frm->ptr; + +printf ("Get AMP Assoc rsp: id %d status (%d) %s \n" , + h->id, h->status,a2mpstatus2str (h->status)); +a2mp_assoc_dump (level +1 , (uint8_t *) &h->assoc_data, len -2 ); +} + +static inline void a2mp_create_req (int level,struct frame *frm,uint16_t len) +{ +struct a2mp_create_req *h = frm->ptr; + +printf ("Create Physical Link req: local id %d remote id %d\n" , + h->local_id, h->remote_id); +a2mp_assoc_dump (level +1 , (uint8_t *) &h->assoc_data, len -2 ); +} + +static inline void a2mp_create_rsp (int level,struct frame *frm) +{ +struct a2mp_create_rsp *h = frm->ptr; + +printf ("Create Physical Link rsp: local id %d remote id %d status %d\n" , + h->local_id, h->remote_id, h->status); +p_indent (level+1 ,0 ); +printf ("%s\n" ,a2mpcplstatus2str (h->status)); +} + +static inline void a2mp_disconn_req (int level,struct frame *frm) +{ +struct a2mp_disconn_req *h = frm->ptr; + +printf ("Disconnect Physical Link req: local id %d remote id %d\n" , + h->local_id, h->remote_id); +} + +static inline void a2mp_disconn_rsp (int level,struct frame *frm) +{ +struct a2mp_disconn_rsp *h = frm->ptr; + +printf ("Disconnect Physical Link rsp: local id %d remote id %d status %d\n" , + h->local_id, h->remote_id, h->status); +p_indent (level+1 ,0 ); +printf ("%s\n" ,a2mpdplstatus2str (h->status)); +} +static void l2cap_parse (int level,struct frame *frm) {l2cap_hdr *hdr = (void *)frm->ptr;
@@ -1060,6 +1344,76 @@ static void l2cap_parse(int level, struct frame *frm)p_indent (level, frm);printf ("L2CAP(c): len %d psm %d\n" , dlen, psm);raw_dump (level, frm); + }else if (cid ==0x3 ) { +/* AMP Manager channel */ + +if (p_filter (FILT_A2MP )) +return ; + +/* Adjust for ERTM control bytes */ + frm->ptr +=2 ; + frm->len -=2 ; + +while (frm->len >=A2MP_HDR_SIZE ) { +struct a2mp_hdr *hdr = frm->ptr; + + frm->ptr +=A2MP_HDR_SIZE ; + frm->len -=A2MP_HDR_SIZE ; + +p_indent (level, frm); +printf ("A2MP: " ); + +switch (hdr->code) { +case A2MP_COMMAND_REJ : +a2mp_command_rej (level, frm); +break ; +case A2MP_DISCOVER_REQ : +a2mp_discover_req (level, frm,btohs (hdr->len)); +break ; +case A2MP_DISCOVER_RSP : +a2mp_discover_rsp (level, frm,btohs (hdr->len)); +break ; +case A2MP_CHANGE_NOTIFY : +a2mp_change_notify (level, frm,btohs (hdr->len)); +break ; +case A2MP_CHANGE_RSP : +a2mp_change_rsp (level, frm); +break ; +case A2MP_INFO_REQ : +a2mp_info_req (level, frm); +break ; +case A2MP_INFO_RSP : +a2mp_info_rsp (level, frm); +break ; +case A2MP_ASSOC_REQ : +a2mp_assoc_req (level, frm); +break ; +case A2MP_ASSOC_RSP : +a2mp_assoc_rsp (level, frm,btohs (hdr->len)); +break ; +case A2MP_CREATE_REQ : +a2mp_create_req (level, frm,btohs (hdr->len)); +break ; +case A2MP_CREATE_RSP : +a2mp_create_rsp (level, frm); +break ; +case A2MP_DISCONN_REQ : +a2mp_disconn_req (level, frm); +break ; +case A2MP_DISCONN_RSP : +a2mp_disconn_rsp (level, frm); +break ; +default : +printf ("code 0x%2.2x ident %d len %d\n" , + hdr->code, hdr->ident,btohs (hdr->len)); +raw_dump (level, frm); + } +if (frm->len >btohs (hdr->len)) { + frm->len -=btohs (hdr->len); + frm->ptr +=btohs (hdr->len); + }else + frm->len =0 ; + } }else if (cid ==0x04 ) {if (!p_filter (FILT_ATT ))att_dump (level, frm);
parser/parser.h +1 -0
@@ -80,6 +80,7 @@ struct frame {#define FILT_AVCTP 0x0800#define FILT_ATT 0x1000#define FILT_SMP 0x2000 +#define FILT_A2MP 0x4000#define FILT_OBEX 0x00010000#define FILT_CAPI 0x00020000
src/hcidump.c +1 -0
@@ -802,6 +802,7 @@ static struct { { "hci", FILT_HCI }, { "sco", FILT_SCO }, { "l2cap", FILT_L2CAP }, + { "a2mp", FILT_A2MP }, { "rfcomm", FILT_RFCOMM }, { "sdp", FILT_SDP }, { "bnep", FILT_BNEP },
Signature · 7 lines
1.7.4.1 -- Peter Krystad Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
PATCH v4 5/5 Minor indentation cleanup and fix display of physical link key
In reply to Peter Krystad--- parser/hci.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)
parser/hci.c +10 -5
@@ -1124,12 +1124,11 @@ static inline void create_physical_link_dump(int level, struct frame *frm)int i;p_indent (level, frm); -printf ("handle %d key length %d key type %d\n" , cp->handle, cp->key_length, cp->key_type); +p_indent (level, frm);printf ("key " ); - -for (i =0 ; i < cp->key_length && cp->key_length <32 ; i++) +for (i =0 ; i < cp->key_length && cp->key_length <=32 ; i++)printf ("%2.2x" , cp->key[i]);printf ("\n" ); }
@@ -1140,12 +1139,16 @@ static inline void create_logical_link_dump(int level, struct frame *frm)int i;p_indent (level, frm); -printf ("handle %d\n" , cp->handle); + +p_indent (level, frm);printf ("tx_flow " );for (i =0 ; i <16 ; i++)printf ("%2.2x" , cp->tx_flow[i]); -printf ("\nrx_flow " ); +printf ("\n" ); + +p_indent (level, frm); +printf ("rx_flow " );for (i =0 ; i <16 ; i++)printf ("%2.2x" , cp->rx_flow[i]);printf ("\n" );
@@ -2605,6 +2608,8 @@ static inline void read_local_amp_assoc_dump(int level, struct frame *frm)p_indent (level, frm);printf ("Error: %s\n" ,status2str (rp->status)); }else { +p_indent (level, frm); +printf ("assoc data" );for (i =0 ; i < len; i++) {if (!(i %16 )) {printf ("\n" );
Signature · 7 lines
1.7.4.1 -- Peter Krystad Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum