monitor: Add support for logging host packets
Luiz Augusto von Dentz
maintainerRFC PATCH 1/1 monitor: Add support for logging host packets
From: Luiz Augusto von Dentz <[email protected]>
This adds support for logging host packets so their timing is visible in the logs:
l2cap-tester[41]: < HOST Data TX: len 12 [hci0] 15:50:02.974141
l2cap-tester[41]: < ACL Data T.. flags 0x00 dlen 12 #83 [hci0] 15:50:02.974199
Channel: 64 len 8 [PSM 4097 mode Basic (0x00)] {chan 0}
01 02 03 04 05 06 07 08 ........Quoted 1 line
ACL Data RX: Handle 42 flags
0x02dlen 12 #170 [hci0] 15:51:43.269961
Channel: 64 len 8 [PSM 4097 mode Basic (0x00)] {chan 0}
01 02 03 04 05 06 07 08 ........
[45]: > HOST Data RX: len 8 [hci0] 15:51:43.269976
---
monitor/display.h | 1 +
monitor/main.c | 7 ++++++-
monitor/packet.c | 29 +++++++++++++++++++++++++++++
monitor/packet.h | 3 +++
src/shared/btsnoop.h | 2 ++
5 files changed, 41 insertions(+), 1 deletion(-)monitor/display.h +1 -0
@@ -29,6 +29,7 @@ void set_monitor_color(enum monitor_color);#define COLOR_WHITE_BG "\x1B[0;47;30m"#define COLOR_HIGHLIGHT "\x1B[1;39m" +#define COLOR_GRAY_BOLD "\x1B[1;30m"#define COLOR_RED_BOLD "\x1B[1;31m"#define COLOR_GREEN_BOLD "\x1B[1;32m"#define COLOR_BLUE_BOLD "\x1B[1;34m"
monitor/main.c +6 -1
@@ -66,6 +66,7 @@ static void usage(void)"\t-S, --sco Dump SCO traffic\n" "\t-A, --a2dp Dump A2DP stream traffic\n" "\t-I, --iso Dump ISO traffic\n" +"\t-H, --host Dump HOST traffic\n" "\t-E, --ellisys [ip] Send Ellisys HCI Injection\n" "\t-P, --no-pager Disable pager usage\n" "\t-J --jlink <device>,[<serialno>],[<interface>],[<speed>]\n"
@@ -94,6 +95,7 @@ static const struct option main_options[] = { { "sco", no_argument, NULL, 'S' }, { "a2dp", no_argument, NULL, 'A' }, { "iso", no_argument, NULL, 'I' }, + { "host", no_argument, NULL, 'H' }, { "ellisys", required_argument, NULL, 'E' }, { "no-pager", no_argument, NULL, 'P' }, { "jlink", required_argument, NULL, 'J' },
@@ -131,7 +133,7 @@ int main(int argc, char *argv[])struct sockaddr_un addr; opt =getopt_long (argc, argv, -"r:w:a:s:p:i:d:B:V:MNtTSAIE:PJ:R:C:c:vh" , +"r:w:a:s:p:i:d:B:V:MNtTSAIHE:PJ:R:C:c:vh" , main_options,NULL );if (opt <0 )break ;
@@ -205,6 +207,9 @@ int main(int argc, char *argv[])case 'I' : filter_mask |=PACKET_FILTER_SHOW_ISO_DATA ;break ; +case 'H' : + filter_mask |=PACKET_FILTER_SHOW_HOST_DATA ; +break ;case 'E' : ellisys_server = optarg; ellisys_port =24352 ;
monitor/packet.c +29 -0
@@ -70,6 +70,7 @@#define COLOR_HCI_ACLDATA COLOR_CYAN#define COLOR_HCI_SCODATA COLOR_YELLOW#define COLOR_HCI_ISODATA COLOR_YELLOW +#define COLOR_HOSTDATA COLOR_GRAY_BOLD#define COLOR_UNKNOWN_ERROR COLOR_WHITE_BG#define COLOR_UNKNOWN_FEATURE_BIT COLOR_WHITE_BG
@@ -4316,6 +4317,12 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,case BTSNOOP_OPCODE_ISO_RX_PKT :packet_hci_isodata (tv, cred, index, true, data, size);break ; +case BTSNOOP_OPCODE_HOST_TX_PKT : +packet_host_data (tv, cred, index, false, data, size); +break ; +case BTSNOOP_OPCODE_HOST_RX_PKT : +packet_host_data (tv, cred, index, true, data, size); +break ;case BTSNOOP_OPCODE_OPEN_INDEX :if (index <MAX_INDEX )addr2str (index_list[index].bdaddr, str);
@@ -14120,6 +14127,28 @@ malformed:packet_hexdump (data, size); } +void packet_host_data (struct timeval *tv,struct ucred *cred,uint16_t index, +bool in,const void *data,uint16_t size) +{ +char str[10 ]; + +if (index >=MAX_INDEX ) { +print_field ("Invalid index (%d)." , index); +return ; + } + +sprintf (str,"len %u" , size); + +print_packet (tv, cred, in ?'>' :'<' , index,NULL ,COLOR_HOSTDATA , + in ?"HOST Data RX" :"HOST Data TX" , + str,NULL ); + +if (filter_mask &PACKET_FILTER_SHOW_HOST_DATA ) +packet_hexdump (data, size); + +return ; +} +void packet_ctrl_open (struct timeval *tv,struct ucred *cred,uint16_t index,const void *data,uint16_t size) {
monitor/packet.h +3 -0
@@ -23,6 +23,7 @@#define PACKET_FILTER_SHOW_A2DP_STREAM (1 << 6)#define PACKET_FILTER_SHOW_MGMT_SOCKET (1 << 7)#define PACKET_FILTER_SHOW_ISO_DATA (1 << 8) +#define PACKET_FILTER_SHOW_HOST_DATA (1 << 9)#define TV_MSEC (_tv) (long long)((_tv).tv_sec * 1000 + (_tv).tv_usec / 1000)struct packet_latency {
@@ -120,6 +121,8 @@ void packet_hci_scodata(struct timeval *tv, struct ucred *cred, uint16_t index, bool in, const void *data, uint16_t size);void packet_hci_isodata (struct timeval *tv,struct ucred *cred,uint16_t index,bool in,const void *data,uint16_t size); +void packet_host_data (struct timeval *tv,struct ucred *cred,uint16_t index, +bool in,const void *data,uint16_t size);void packet_ctrl_open (struct timeval *tv,struct ucred *cred,uint16_t index,const void *data,uint16_t size);
src/shared/btsnoop.h +2 -0
@@ -42,6 +42,8 @@#define BTSNOOP_OPCODE_CTRL_EVENT 17#define BTSNOOP_OPCODE_ISO_TX_PKT 18#define BTSNOOP_OPCODE_ISO_RX_PKT 19 +#define BTSNOOP_OPCODE_HOST_TX_PKT 22 +#define BTSNOOP_OPCODE_HOST_RX_PKT 23#define BTSNOOP_MAX_PACKET_SIZE (1486 + 4)
Signature · 1 line
2.50.1
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=987469
---Test result---
Test Summary:
CheckPatch PENDING 0.36 seconds GitLint PENDING 0.45 seconds BuildEll PASS 20.21 seconds BluezMake PASS 2673.43 seconds MakeCheck PASS 21.02 seconds MakeDistcheck PASS 184.12 seconds CheckValgrind PASS 233.05 seconds CheckSmatch WARNING 302.89 seconds bluezmakeextell PASS 126.91 seconds IncrementalBuild PENDING 0.38 seconds ScanBuild PASS 906.98 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:monitor/packet.c: note: in included file:monitor/display.h:83:26: warning: Variable length array is used.monitor/packet.c:1919:26: warning: Variable length array is used.monitor/packet.c: note: in included file:monitor/bt.h:3822:52: warning: array of flexible structures
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth