diff --git a/tools/hcidump.c b/tools/hcidump.c
index 659d730..bcf213f 100644
--- a/tools/hcidump.c
+++ b/tools/hcidump.c
break;
case 'C':
- set_proto(0, atoi(optarg), SDP_UUID_CMTP);
+ set_proto(0, atoi(optarg), 0, SDP_UUID_CMTP);
break;
case 'H':
- set_proto(0, atoi(optarg), SDP_UUID_HARDCOPY_CONTROL_CHANNEL);
+ set_proto(0, atoi(optarg), 0, SDP_UUID_HARDCOPY_CONTROL_CHANNEL);
break;
case 'h':
diff --git a/tools/parser/l2cap.c b/tools/parser/l2cap.c
index 6f913ce..3e95232 100644
--- a/tools/parser/l2cap.c
+++ b/tools/parser/l2cap.c
break;
default:
- proto = get_proto(frm->handle, psm);
+ proto = get_proto(frm->handle, psm, 0);
switch (proto) {
case SDP_UUID_CMTP:
fr->ptr = fr->data;
fr->in = frm->in;
fr->ts = frm->ts;
- fr->handle = frm->handle;
- fr->cid = frm->cid;
+ fr->handle = frm->handle;
+ fr->cid = frm->cid;
+ fr->channel = frm->channel;
} else {
if (!(fr = get_frame(frm->handle))) {
fprintf(stderr, "Not enough connection handles\n");
diff --git a/tools/parser/parser.c b/tools/parser/parser.c
index 7e6d3a3..b71d18e 100644
--- a/tools/parser/parser.c
+++ b/tools/parser/parser.c
static struct {
uint16_t handle;
uint16_t psm;
+ uint8_t channel;
uint32_t proto;
} proto_table[PROTO_TABLE_SIZE];
-void set_proto(uint16_t handle, uint16_t psm, uint32_t proto)
+void set_proto(uint16_t handle, uint16_t psm, uint8_t channel, uint32_t proto)
{
int i, pos = -1;
- if (psm < 0x1000)
+ if (psm > 0 && psm < 0x1000)
return;
for (i = 0; i < PROTO_TABLE_SIZE; i++) {
- if (proto_table[i].handle == handle && proto_table[i].psm == psm) {
+ if (proto_table[i].handle == handle && proto_table[i].psm == psm && proto_table[i].channel == channel) {
pos = i;
break;
}
- if (pos < 0 && !proto_table[i].handle && !proto_table[i].psm)
+ if (pos < 0 && !proto_table[i].handle && !proto_table[i].psm && !proto_table[i].channel)
pos = i;
}
if (pos < 0)
return;
- proto_table[pos].handle = handle;
- proto_table[pos].psm = psm;
- proto_table[pos].proto = proto;
+ proto_table[pos].handle = handle;
+ proto_table[pos].psm = psm;
+ proto_table[pos].channel = channel;
+ proto_table[pos].proto = proto;
}
-uint32_t get_proto(uint16_t handle, uint16_t psm)
+uint32_t get_proto(uint16_t handle, uint16_t psm, uint8_t channel)
{
int i, pos = -1;
for (i = 0; i < PROTO_TABLE_SIZE; i++) {
- if (proto_table[i].handle == handle && proto_table[i].psm == psm)
+ if (proto_table[i].handle == handle && proto_table[i].psm == psm && proto_table[i].channel == channel)
return proto_table[i].proto;
- if (!proto_table[i].handle && proto_table[i].psm == psm)
+ if (!proto_table[i].handle && (proto_table[i].psm == psm || (!proto_table[i].psm && proto_table[i].channel == channel)))
pos = i;
}
diff --git a/tools/parser/parser.h b/tools/parser/parser.h
index 8999b41..3237b16 100644
--- a/tools/parser/parser.h
+++ b/tools/parser/parser.h
int in;
int handle;
int cid;
+ int channel;
long flags;
struct timeval ts;
};
#define FILT_HCRP 0x0100
#define FILT_AVDTP 0x0200
-#define FILT_CAPI 0x00010000
+#define FILT_CAPI 0x00020000
#define FILT_CSR 0x1000000f
#define STRUCT_OFFSET(type, member) ((uint8_t *)&(((type *)NULL)->member) - \
char *get_uuid_name(int uuid);
-void set_proto(uint16_t handle, uint16_t psm, uint32_t proto);
-uint32_t get_proto(uint16_t handle, uint16_t psm);
+void set_proto(uint16_t handle, uint16_t psm, uint8_t channel, uint32_t proto);
+uint32_t get_proto(uint16_t handle, uint16_t psm, uint8_t channel);
void ascii_dump(int level, struct frame *frm, int num);
void hex_dump(int level, struct frame *frm, int num);
diff --git a/tools/parser/rfcomm.c b/tools/parser/rfcomm.c
index 8629d4a..f0ea8c1 100644
--- a/tools/parser/rfcomm.c
+++ b/tools/parser/rfcomm.c
#include "parser.h"
#include "rfcomm.h"
+#include "sdp.h"
static char *cr_str[] = {
"RSP",
static inline void uih_frame(int level, struct frame *frm, long_frame_head *head)
{
+ uint32_t proto;
+
if (!head->addr.server_chn) {
mcc_frame(level, frm, head);
} else {
printf("\n");
frm->len--;
- raw_dump(level, frm);
+ frm->channel = head->addr.server_chn;
+
+ proto = get_proto(frm->handle, 0, frm->channel);
+
+ switch (proto) {
+ default:
+ if (p_filter(FILT_RFCOMM))
+ break;
+
+ raw_dump(level, frm);
+ break;
+ }
}
}
diff --git a/tools/parser/sdp.c b/tools/parser/sdp.c
index a03188c..dc600c8 100644
--- a/tools/parser/sdp.c
+++ b/tools/parser/sdp.c
return de_type;
}
-static inline void print_int(uint8_t de_type, int level, int n, struct frame *frm, uint16_t *psm)
+static inline void print_int(uint8_t de_type, int level, int n, struct frame *frm, uint16_t *psm, uint8_t *channel)
{
uint64_t val, val2;
switch(n) {
case 1: /* 8-bit */
val = get_u8(frm);
+ if (channel && de_type == SDP_DE_UINT)
+ if (*channel == 0)
+ *channel = val;
break;
case 2: /* 16-bit */
val = get_u16(frm);
printf(" 0x%llx", val);
}
-static inline void print_uuid(int n, struct frame *frm, uint16_t *psm)
+static inline void print_uuid(int n, struct frame *frm, uint16_t *psm, uint8_t *channel)
{
uint32_t uuid = 0;
char* s;
}
if (psm && *psm > 0 && *psm != 0xffff) {
- set_proto(frm->handle, *psm, uuid);
+ set_proto(frm->handle, *psm, 0, uuid);
*psm = 0xffff;
}
+ if (channel && *channel > 0 && *channel != 0xff) {
+ set_proto(frm->handle, *psm, *channel, uuid);
+ *channel = 0xff;
+ }
+
printf(" %s 0x%04x", s, uuid);
if ((s = get_uuid_name(uuid)))
printf(" (%s)", s);
frm->len -= n;
}
-static inline void print_de(int, struct frame *frm, int *split, uint16_t *psm);
+static inline void print_de(int, struct frame *frm, int *split, uint16_t *psm, uint8_t *channel);
-static inline void print_des(uint8_t de_type, int level, int n, struct frame *frm, int *split, uint16_t *psm)
+static inline void print_des(uint8_t de_type, int level, int n, struct frame *frm, int *split, uint16_t *psm, uint8_t *channel)
{
int len = frm->len;
while (len - frm->len < n && frm->len > 0)
- print_de(level, frm, split, psm);
+ print_de(level, frm, split, psm, channel);
}
-static inline void print_de(int level, struct frame *frm, int *split, uint16_t *psm)
+static inline void print_de(int level, struct frame *frm, int *split, uint16_t *psm, uint8_t *channel)
{
int n;
uint8_t de_type = parse_de_hdr(frm, &n);
case SDP_DE_UINT:
case SDP_DE_INT:
case SDP_DE_BOOL:
- print_int(de_type, level, n, frm, psm);
+ print_int(de_type, level, n, frm, psm, channel);
break;
case SDP_DE_UUID:
if (split) {
}
++*split;
}
- print_uuid(n, frm, psm);
+ print_uuid(n, frm, psm, channel);
break;
case SDP_DE_URL:
case SDP_DE_STRING:
break;
case SDP_DE_SEQ:
printf(" <");
- print_des(de_type, level, n, frm, split, psm);
+ print_des(de_type, level, n, frm, split, psm, channel);
printf(" >");
break;
case SDP_DE_ALT:
printf(" [");
- print_des(de_type, level, n, frm, split, psm);
+ print_des(de_type, level, n, frm, split, psm, channel);
printf(" ]");
break;
}
len = frm->len;
while (len - frm->len < n1 && frm->len > 0) {
if (parse_de_hdr(frm,&n2) == SDP_DE_UUID) {
- print_uuid(n2, frm, NULL);
+ print_uuid(n2, frm, NULL, NULL);
} else {
printf("\nERROR: Unexpected syntax (UUID)\n");
raw_dump(level, frm);
static inline void print_attr_list(int level, struct frame *frm)
{
uint16_t attr_id, psm;
+ uint8_t channel;
int len, n1, n2, split;
if (parse_de_hdr(frm, &n1) == SDP_DE_SEQ) {
printf("aid 0x%04x (%s)\n", attr_id, name);
split = (attr_id != SDP_ATTR_ID_PROTOCOL_DESCRIPTOR_LIST);
psm = 0;
+ channel = 0;
/* Print AttributeValue */
p_indent(level + 1, 0);
print_de(level + 1, frm, split ? NULL: &split,
- attr_id == SDP_ATTR_ID_PROTOCOL_DESCRIPTOR_LIST ? &psm : NULL);
+ attr_id == SDP_ATTR_ID_PROTOCOL_DESCRIPTOR_LIST ? &psm : NULL,
+ attr_id == SDP_ATTR_ID_PROTOCOL_DESCRIPTOR_LIST ? &channel : NULL);
printf("\n");
} else {
printf("\nERROR: Unexpected syntax\n");