diff --git a/tools/hcidump.c b/tools/hcidump.c
index 7ae4cd0..cf6003e 100644
--- a/tools/hcidump.c
+++ b/tools/hcidump.c
#include "parser.h"
#include "sdp.h"
-
#define SNAP_LEN HCI_MAX_FRAME_SIZE
/* Modes */
while (len > 0) {
if ((w = read(fd, buf, len)) < 0) {
- if( errno == EINTR || errno == EAGAIN )
+ if (errno == EINTR || errno == EAGAIN)
continue;
return -1;
}
while (len > 0) {
if ((w = write(fd, buf, len)) < 0) {
- if( errno == EINTR || errno == EAGAIN )
+ if (errno == EINTR || errno == EAGAIN)
continue;
return -1;
}
{
struct sockaddr_hci addr;
struct hci_filter flt;
- int s, opt;
+ int sk, opt;
/* Create HCI socket */
- if ((s=socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) {
+ if ((sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) {
perror("Can't create HCI socket");
exit(1);
}
opt = 1;
- if (setsockopt(s, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
+ if (setsockopt(sk, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
perror("Can't enable data direction info");
exit(1);
}
opt = 1;
- if (setsockopt(s, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
+ if (setsockopt(sk, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
perror("Can't enable time stamp");
exit(1);
}
hci_filter_clear(&flt);
hci_filter_all_ptypes(&flt);
hci_filter_all_events(&flt);
- if (setsockopt(s, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
+ if (setsockopt(sk, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
perror("Can't set HCI filter");
exit(1);
}
/* Bind socket to the HCI device */
addr.hci_family = AF_BLUETOOTH;
addr.hci_dev = dev;
- if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
printf("Can't attach to device hci%d. %s(%d)\n",
dev, strerror(errno), errno);
exit(1);
}
- return s;
+
+ return sk;
}
static struct {
printf("HCIDump - HCI packet analyzer ver %s\n", VERSION);
- while ((opt=getopt_long(argc, argv, "i:s:p:w:r:txaRC:h", main_options, NULL)) != -1) {
+ while ((opt=getopt_long(argc, argv, "i:s:p:w:r:txaRC:H:h", main_options, NULL)) != -1) {
switch(opt) {
case 'i':
- device = atoi(optarg+3);
+ device = atoi(optarg + 3);
break;
case 's':
diff --git a/tools/parser/avdtp.c b/tools/parser/avdtp.c
index 96f7049..c68785f 100644
--- a/tools/parser/avdtp.c
+++ b/tools/parser/avdtp.c
#include "parser.h"
-
static char *si2str(uint8_t si)
{
switch (si & 0x7f) {
diff --git a/tools/parser/bnep.c b/tools/parser/bnep.c
index 2f977a1..869530a 100644
--- a/tools/parser/bnep.c
+++ b/tools/parser/bnep.c
#define PAYLOAD_RAW_DUMP
-
/* BNEP Type */
#define BNEP_GENERAL_ETHERNET 0x00
#define BNEP_CONTROL 0x01
case BNEP_CONTROL_COMMAND_NOT_UNDERSTOOD:
printf("Not Understood(0x%02x) type 0x%02x\n", type, get_u8(frm));
break;
+
case BNEP_SETUP_CONNECTION_REQUEST_MSG:
uuid_size = get_u8(frm);
printf("Setup Req(0x%02x) size 0x%02x ", type, uuid_size);
break;
}
break;
+
case BNEP_SETUP_CONNECTION_RESPONSE_MSG:
printf("Setup Rsp(0x%02x) res 0x%04x\n", type, get_u16(frm));
break;
+
case BNEP_FILTER_NET_TYPE_SET_MSG:
length = get_u16(frm);
printf("Filter NetType Set(0x%02x) len 0x%04x\n", type, length);
printf("0x%04x\n", get_u16(frm));
}
break;
+
case BNEP_FILTER_NET_TYPE_RESPONSE_MSG:
printf("Filter NetType Rsp(0x%02x) res 0x%04x\n", type, get_u16(frm));
break;
+
case BNEP_FILTER_MULT_ADDR_SET_MSG:
length = get_u16(frm);
printf("Filter MultAddr Set(0x%02x) len 0x%04x\n", type, length);
printf("%s\n", get_macaddr(frm));
}
break;
+
case BNEP_FILTER_MULT_ADDR_RESPONSE_MSG:
printf("Filter MultAddr Rsp(0x%02x) res 0x%04x\n", type, get_u16(frm));
break;
+
default:
printf("Unknown control type(0x%02x)\n", type);
raw_ndump(level + 1, frm, header_length - 1);
printf("Ext Control(0x%02x|%s) len 0x%02x\n", type & 0x7f, extension ? "1" : "0", length);
bnep_control(level, frm, length);
break;
+
default:
printf("Ext Unknown(0x%02x|%s) len 0x%02x\n", type & 0x7f, extension ? "1" : "0", length);
raw_ndump(level + 1, frm, length);
printf("TCP:\n");
raw_dump(level, frm);
break;
+
case IPPROTO_UDP:
printf("UDP:\n");
raw_dump(level, frm);
break;
+
case IPPROTO_ICMP:
printf("ICMP:\n");
raw_dump(level, frm);
break;
+
default:
printf("Unknown Protocol: 0x%02x\n", ip->ip_p);
raw_dump(level, frm);
printf("BNEP: Control(0x%02x|%s)\n", type & 0x7f, extension ? "1" : "0");
bnep_control(level, frm, -1);
break;
+
case BNEP_COMPRESSED_ETHERNET:
printf("BNEP: Compressed(0x%02x|%s)\n", type & 0x7f, extension ? "1" : "0");
p_indent(++level, frm);
proto = get_u16(frm);
printf("[proto 0x%04x]\n", proto);
break;
+
case BNEP_GENERAL_ETHERNET:
printf("BNEP: General ethernet(0x%02x|%s)\n", type & 0x7f, extension ? "1" : "0");
p_indent(++level, frm);
proto = get_u16(frm);
printf("[proto 0x%04x]\n", proto);
break;
+
case BNEP_COMPRESSED_ETHERNET_DEST_ONLY:
printf("BNEP: Compressed DestOnly(0x%02x|%s)\n", type & 0x7f, extension ? "1" : "0");
p_indent(++level, frm);
proto = get_u16(frm);
printf("[proto 0x%04x]\n", proto);
break;
+
case BNEP_COMPRESSED_ETHERNET_SOURCE_ONLY:
printf("BNEP: Compressed SrcOnly(0x%02x|%s)\n", type & 0x7f, extension ? "1" : "0");
p_indent(++level, frm);
proto = get_u16(frm);
printf("[proto 0x%04x]\n", proto);
break;
+
default:
printf("(Unknown packet type)\n");
return;
printf("ARP: ");
arp_dump(level, frm);
break;
+
case ETHERTYPE_REVARP:
p_indent(++level, frm);
printf("RARP: ");
arp_dump(level, frm);
break;
+
case ETHERTYPE_IP:
p_indent(++level, frm);
printf("IP: ");
ip_dump(level, frm);
break;
+
default:
raw_dump(level, frm);
}
diff --git a/tools/parser/capi.c b/tools/parser/capi.c
index aa02981..9b59f23 100644
--- a/tools/parser/capi.c
+++ b/tools/parser/capi.c
#define CAPI_U16(frm) (htobs(htons(get_u16(frm))))
#define CAPI_U32(frm) (htobl(htonl(get_u32(frm))))
-
static char *cmd2str(uint8_t cmd)
{
switch (cmd) {
diff --git a/tools/parser/cmtp.c b/tools/parser/cmtp.c
index 571c1a1..efa5c27 100644
--- a/tools/parser/cmtp.c
+++ b/tools/parser/cmtp.c
#include "parser.h"
-
#define TABLE_SIZE 10
static struct {
diff --git a/tools/parser/hci.c b/tools/parser/hci.c
index 984eacc..9fcb6e6 100644
--- a/tools/parser/hci.c
+++ b/tools/parser/hci.c
#include "parser.h"
-
static char *event_map[] = {
"Unknown",
"Inquiry Complete",
p_indent(level, frm);
- printf("HCI Command: %s(0x%2.2x|0x%4.4x) plen %d\n",
+ printf("HCI Command: %s (0x%2.2x|0x%4.4x) plen %d\n",
cmd, ogf, ocf, hdr->plen);
frm->ptr += HCI_COMMAND_HDR_SIZE;
p_indent(level, frm);
if (hdr->evt <= EVENT_NUM)
- printf("HCI Event: %s(0x%2.2x) plen %d\n",
+ printf("HCI Event: %s (0x%2.2x) plen %d\n",
event_map[hdr->evt], hdr->evt, hdr->plen);
else if (hdr->evt == EVT_TESTING)
- printf("HCI Event: Testing(0x%2.2x) plen %d\n", hdr->evt, hdr->plen);
+ printf("HCI Event: Testing (0x%2.2x) plen %d\n", hdr->evt, hdr->plen);
else if (hdr->evt == EVT_VENDOR)
- printf("HCI Event: Vendor(0x%2.2x) plen %d\n", hdr->evt, hdr->plen);
+ printf("HCI Event: Vendor (0x%2.2x) plen %d\n", hdr->evt, hdr->plen);
else
printf("HCI Event: code 0x%2.2x plen %d\n", hdr->evt, hdr->plen);
diff --git a/tools/parser/hcrp.c b/tools/parser/hcrp.c
index 6fb17ab..1fc6a3d 100644
--- a/tools/parser/hcrp.c
+++ b/tools/parser/hcrp.c
#include "parser.h"
-
static char *pid2str(uint16_t pid)
{
switch (pid) {
diff --git a/tools/parser/hidp.c b/tools/parser/hidp.c
index feeb33f..b1c8e28 100644
--- a/tools/parser/hidp.c
+++ b/tools/parser/hidp.c
#include "parser.h"
-
static char *type2str(uint8_t head)
{
switch (head & 0xf0) {
diff --git a/tools/parser/l2cap.c b/tools/parser/l2cap.c
index bae306a..7c90e5b 100644
--- a/tools/parser/l2cap.c
+++ b/tools/parser/l2cap.c
#include "parser.h"
#include "sdp.h"
-
typedef struct {
uint16_t handle;
struct frame frm;
diff --git a/tools/parser/parser.c b/tools/parser/parser.c
index 26260ff..008b8b5 100644
--- a/tools/parser/parser.c
+++ b/tools/parser/parser.c
#include "parser.h"
-
struct parser_t parser;
void init_parser(unsigned long flags, unsigned long filter, unsigned int defpsm)
diff --git a/tools/parser/parser.h b/tools/parser/parser.h
index 49f2d2b..a79dc4e 100644
--- a/tools/parser/parser.h
+++ b/tools/parser/parser.h
parser.state = 0;
return;
}
-
+
if (!parser.state) {
if (parser.flags & DUMP_TSTAMP)
printf("%8lu.%06lu ", f->ts.tv_sec, f->ts.tv_usec);
diff --git a/tools/parser/rfcomm.c b/tools/parser/rfcomm.c
index 287081c..2a99f97 100644
--- a/tools/parser/rfcomm.c
+++ b/tools/parser/rfcomm.c
#include "parser.h"
#include "rfcomm.h"
-
static char *cr_str[] = {
"RSP",
"CMD"
diff --git a/tools/parser/rfcomm.h b/tools/parser/rfcomm.h
index f3af024..e5535e9 100644
--- a/tools/parser/rfcomm.h
+++ b/tools/parser/rfcomm.h
#define GET_BIT(pos,bitfield) ((bitfield[(pos)/32]) & (1 << ((pos) % 32)))
#define SET_BIT(pos,bitfield) ((bitfield[(pos)/32]) |= (1 << ((pos) % 32)))
#define CLR_BIT(pos,bitfield) ((bitfield[(pos)/32]) &= ((1 << ((pos) % 32)) ^ (~0)))
-#define SET_PF(ctr) ((ctr) | (1 << 4))
+
+
/* Sets the P/F-bit in the control field */
+#define SET_PF(ctr) ((ctr) | (1 << 4))
+/* Clears the P/F-bit in the control field */
#define CLR_PF(ctr) ((ctr) & 0xef)
-/* clears the P/F-bit in the control field */
+/* Returns the P/F-bit */
#define GET_PF(ctr) (((ctr) >> 4) & 0x1)
-/* Returns the P/F bit */
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-/* endian-swapping macros for structs */
+/* Endian-swapping macros for structs */
#define swap_long_frame(x) ((x)->h.length.val = le16_to_cpu((x)->h.length.val))
#define swap_mcc_long_frame(x) (swap_long_frame(x))
+/* Used for UIH packets */
#define SHORT_CRC_CHECK 2
-/* Used for uih packets */
+/* Used for all packet exepts for the UIH packets */
#define LONG_CRC_CHECK 3
-/* Used for all packet exepts for the uih packets */
+/* Short header for short UIH packets */
#define SHORT_HDR 2
-/* Short header for short uih packets */
+/* Long header for long UIH packets */
#define LONG_HDR 3
-/* and long header for long uih packets */
-/* FIXME: Should thsi one be define here? */
+/* FIXME: Should this one be defined here? */
#define SHORT_PAYLOAD_SIZE 127
+/* Used for setting the EA field in different packets, really neccessary? */
#define EA 1
-/* Used for setting the EA field in different packets, really neccessary? */
-#define FCS_SIZE 1
/* Yes the FCS size is only one byte */
+#define FCS_SIZE 1
#define RFCOMM_MAX_HDR_SIZE 5
#endif
/* Typedefinitions of stuctures used for creating and parsing packets, for a
- further description of the structures please se the bluetooth core
- specification part F:1 and the ETSI TS 07.10 specification */
+ * further description of the structures please se the bluetooth core
+ * specification part F:1 and the ETSI TS 07.10 specification */
#ifdef __LITTLE_ENDIAN_BITFIELD
diff --git a/tools/parser/sdp.c b/tools/parser/sdp.c
index ce14597..a03188c 100644
--- a/tools/parser/sdp.c
+++ b/tools/parser/sdp.c
#include "parser.h"
#include "sdp.h"
-
static sdp_siz_idx_lookup_table_t sdp_siz_idx_lookup_table[] = {
{ 0, 1 }, /* Size index = 0 */
{ 0, 2 }, /* 1 */
{ SDP_ATTR_ID_SERVICE_DATABASE_STATE, "SrvDBState" },
{ SDP_ATTR_ID_SERVICE_VERSION, "SrvVersion" },
{ SDP_ATTR_ID_SECURITY_DESCRIPTION, "SecurityDescription"}, /* PAN */
- { SDP_ATTR_ID_SUPPORTED_DATA_STORES_LIST, "SuppDataStoresList" }, /* Synchronization */
- { SDP_ATTR_ID_SUPPORTED_FORMATS_LIST, "SuppFormatsList" }, /* OBEX Object Push */
+ { SDP_ATTR_ID_SUPPORTED_DATA_STORES_LIST, "SuppDataStoresList" }, /* Synchronization */
+ { SDP_ATTR_ID_SUPPORTED_FORMATS_LIST, "SuppFormatsList" }, /* OBEX Object Push */
{ SDP_ATTR_ID_NET_ACCESS_TYPE, "NetAccessType" }, /* PAN */
{ SDP_ATTR_ID_MAX_NET_ACCESS_RATE, "MaxNetAccessRate" }, /* PAN */
{ SDP_ATTR_ID_IPV4_SUBNET, "IPv4Subnet" }, /* PAN */