Diff between 13cb68651497f1fb4f56134239b5c08c61686a9d and 073282583f0860a4b20042ea1932c879ca389260

Changed Files

File Additions Deletions Status
tools/hcidump.c +12 -12 modified
tools/parser/avdtp.c +0 -1 modified
tools/parser/bnep.c +19 -1 modified
tools/parser/capi.c +0 -1 modified
tools/parser/cmtp.c +0 -1 modified
tools/parser/hci.c +4 -5 modified
tools/parser/hcrp.c +0 -1 modified
tools/parser/hidp.c +0 -1 modified
tools/parser/l2cap.c +0 -1 modified
tools/parser/parser.c +0 -1 modified
tools/parser/parser.h +1 -1 modified
tools/parser/rfcomm.c +0 -1 modified
tools/parser/rfcomm.h +16 -14 modified
tools/parser/sdp.c +2 -3 modified

Full Patch

diff --git a/tools/hcidump.c b/tools/hcidump.c
index 7ae4cd0..cf6003e 100644
--- a/tools/hcidump.c
+++ b/tools/hcidump.c
@@ -52,7 +52,6 @@
 #include "parser.h"
 #include "sdp.h"
 
-
 #define SNAP_LEN HCI_MAX_FRAME_SIZE
 
 /* Modes */
@@ -86,7 +85,7 @@ static inline int read_n(int fd, char *buf, int len)
 
 	while (len > 0) {
 		if ((w = read(fd, buf, len)) < 0) {
-			if( errno == EINTR || errno == EAGAIN )
+			if (errno == EINTR || errno == EAGAIN)
 				continue;
 			return -1;
 		}
@@ -103,7 +102,7 @@ static inline int write_n(int fd, char *buf, int len)
 
 	while (len > 0) {
 		if ((w = write(fd, buf, len)) < 0) {
-			if( errno == EINTR || errno == EAGAIN )
+			if (errno == EINTR || errno == EAGAIN)
 				continue;
 			return -1;
 		}
@@ -253,22 +252,22 @@ static int open_socket(int dev)
 {
 	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);
 	}
@@ -277,7 +276,7 @@ static int open_socket(int dev)
 	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);
 	}
@@ -285,12 +284,13 @@ static int open_socket(int dev)
 	/* 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 {
@@ -367,10 +367,10 @@ int main(int argc, char *argv[])
 
 	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
@@ -34,7 +34,6 @@
 
 #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
@@ -43,7 +43,6 @@
 
 #define PAYLOAD_RAW_DUMP
 
-
 /* BNEP Type */
 #define BNEP_GENERAL_ETHERNET			0x00
 #define BNEP_CONTROL				0x01
@@ -88,6 +87,7 @@ static void bnep_control(int level, struct frame *frm, int header_length)
 	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);
@@ -135,9 +135,11 @@ static void bnep_control(int level, struct frame *frm, int header_length)
 			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);
@@ -147,9 +149,11 @@ static void bnep_control(int level, struct frame *frm, int header_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);
@@ -159,9 +163,11 @@ static void bnep_control(int level, struct frame *frm, int header_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);
@@ -183,6 +189,7 @@ static void bnep_eval_extension(int level, struct frame *frm)
 		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);
@@ -233,14 +240,17 @@ static void ip_dump(int level, struct frame *frm)
 		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);
@@ -262,12 +272,14 @@ void bnep_dump(int level, struct frame *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);
@@ -276,6 +288,7 @@ void bnep_dump(int level, struct frame *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);
@@ -283,6 +296,7 @@ void bnep_dump(int level, struct frame *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);
@@ -290,6 +304,7 @@ void bnep_dump(int level, struct frame *frm)
 		proto = get_u16(frm);
 		printf("[proto 0x%04x]\n", proto);
 		break;
+
 	default:
 		printf("(Unknown packet type)\n");
 		return;
@@ -319,16 +334,19 @@ void bnep_dump(int level, struct frame *frm)
 		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
@@ -41,7 +41,6 @@
 #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
@@ -34,7 +34,6 @@
 
 #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
@@ -39,7 +39,6 @@
 
 #include "parser.h"
 
-
 static char *event_map[] = {
 	"Unknown",
 	"Inquiry Complete",
@@ -324,7 +323,7 @@ static inline void command_dump(int level, struct frame *frm)
 
 	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;
@@ -343,12 +342,12 @@ static inline void event_dump(int level, struct frame *frm)
 	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
@@ -34,7 +34,6 @@
 
 #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
@@ -34,7 +34,6 @@
 
 #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
@@ -41,7 +41,6 @@
 #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
@@ -36,7 +36,6 @@
 
 #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
@@ -91,7 +91,7 @@ static inline void p_indent(int level, struct frame *f)
 		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
@@ -40,7 +40,6 @@
 #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
@@ -38,34 +38,36 @@
 #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
 
@@ -198,8 +200,8 @@ typedef struct rpn_values{
 #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
@@ -36,7 +36,6 @@
 #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 */
@@ -125,8 +124,8 @@ static sdp_attr_id_nam_lookup_table_t sdp_attr_id_nam_lookup_table[] = {
 	{ 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 */