Skip to content

Commit

Permalink
Fix: missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr. Martin Luetzelberger authored and Dr. Martin Luetzelberger committed Jul 15, 2016
1 parent 25b4720 commit 8431b78
Show file tree
Hide file tree
Showing 3 changed files with 299 additions and 0 deletions.
178 changes: 178 additions & 0 deletions doc/btsnoop.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
BTSnoop/Monitor protocol formats
********************************

Opcode definitions
==================

New Index
---------

Code: 0x0000
Parameters: Type (1 Octet
Bus (1 Octet)
BD_Addr (6 Octets)
Name (8 Octets)

This opcode indicates that a new controller instance with a
given index was added. With some protocols, like the TTY-based
one there is only a single supported controller, meaning the
index is implicitly 0.

Deleted Index
-------------

Code: 0x0001

This opcode indicates that the controller with a specific index
was removed.

Command Packet
--------------

Code: 0x0002

HCI command packet.

Event Packet
------------

Code: 0x0003

HCI event packet.

ACL TX Packet
-------------

Code: 0x0004

Outgoing ACL packet.

ACL RX Packet
-------------

Code: 0x0005

Incoming ACL packet.

SCO TX Packet
--------------

Code: 0x0006

Outgoing SCO packet.

SCO RX Packet
-------------

Code: 0x0007

Incomnig SCO packet.

Open Index
----------

Code: 0x0008

The HCI transport for the specified controller has been opened.

Close Index
-----------

Code: 0x0009

The HCI transport for the specified controller has been closed.

Index Information
-----------------

Code: 0x000a
Parameters: BD_Addr (6 Octets)
Manufacturer (2 Octets)

Information about a specific controller.

Vendor Diagnostics
------------------

Code: 0x000b

Vendor diagnostic information.

System Note
-----------

Code: 0x000c

System note.

User Logging
------------

Code: 0x000d
Parameters: Priority (1 Octet)
Ident_Length (1 Octet)
Ident (Ident_Length Octets)

User logging information.


TTY-based protocol
==================

This section covers the protocol that can be parsed by btmon when
passing it the --tty parameter. The protocol is little endian, packet
based, and has the following header for each packet:

struct tty_hdr {
uint16_t data_len;
uint16_t opcode;
uint8_t flags;
uint8_t hdr_len;
uint8_t ext_hdr[0];
} __attribute__ ((packed));

The actual payload starts at ext_hdr + hdr_len and has the length of
data_len - 4 - hdr_len. Each field of the header is defined as follows:

data_len:
This is the total length of the entire packet, excuding the
data_len field itself.

opcode:
The BTSnoop opcode

flags:
Special flags for the packet. Currently no flags are defined.

hdr_len:
Length of the extended header.

ext_hdr:
This is a sequence of header extension fields formatted as:

struct {
uint8_t type;
uint8_t value[length];
}

The length of the value is dependent on the type. Currently the
following types are defined:

Type Length Meaning
----------------------------------------------------------------
1 Command drops 1 byte Dropped HCI command packets
2 Event drops 1 byte Dropped HCI event packets
3 ACL TX drops 1 byte Dropped ACL TX packets
4 ACL RX drops 1 byte Dropped ACL RX packets
5 SCO TX drops 1 byte Dropped SCO TX packets
6 SCO RX drops 1 byte Dropped SCO RX packets
7 Other drops 1 byte Dropped other packets
8 32-bit timestamp 4 bytes Timestamp in 1/10th ms

The drops fields indicate the number of packets that the
implementation had to drop (e.g. due to lack of buffers) since
the last reported drop count.

The fields of the extended header must be sorted by increasing
type. This is essential so that unknown types can be ignored and
the parser can jump to processing the payload.
41 changes: 41 additions & 0 deletions monitor/tty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2016 Intel Corporation
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

#include <stdint.h>

struct tty_hdr {
uint16_t data_len;
uint16_t opcode;
uint8_t flags;
uint8_t hdr_len;
uint8_t ext_hdr[0];
} __attribute__ ((packed));

#define TTY_EXTHDR_COMMAND_DROPS 1
#define TTY_EXTHDR_EVENT_DROPS 2
#define TTY_EXTHDR_ACL_TX_DROPS 3
#define TTY_EXTHDR_ACL_RX_DROPS 4
#define TTY_EXTHDR_SCO_TX_DROPS 5
#define TTY_EXTHDR_SCO_RX_DROPS 6
#define TTY_EXTHDR_OTHER_DROPS 7
#define TTY_EXTHDR_TS32 8
80 changes: 80 additions & 0 deletions src/shared/tty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2016 Intel Corporation. All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

#include <termios.h>

static inline unsigned int tty_get_speed(int speed)
{
switch (speed) {
case 9600:
return B9600;
case 19200:
return B19200;
case 38400:
return B38400;
case 57600:
return B57600;
case 115200:
return B115200;
case 230400:
return B230400;
case 460800:
return B460800;
case 500000:
return B500000;
case 576000:
return B576000;
case 921600:
return B921600;
case 1000000:
return B1000000;
case 1152000:
return B1152000;
case 1500000:
return B1500000;
case 2000000:
return B2000000;
#ifdef B2500000
case 2500000:
return B2500000;
#endif
#ifdef B3000000
case 3000000:
return B3000000;
#endif
#ifdef B3500000
case 3500000:
return B3500000;
#endif
#ifdef B3710000
case 3710000:
return B3710000;
#endif
#ifdef B4000000
case 4000000:
return B4000000;
#endif
}

return 0;
}

0 comments on commit 8431b78

Please sign in to comment.