From 3b912fd1b12f40a23fe8534cf10a58fe1a08d6ed Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 18 Sep 2004 12:11:51 +0000 Subject: [PATCH] hcidump: Better handling for dynamic channels --- tools/parser/parser.c | 15 ++++++++++++--- tools/parser/rfcomm.c | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/parser/parser.c b/tools/parser/parser.c index 9e6283193..6444b811a 100644 --- a/tools/parser/parser.c +++ b/tools/parser/parser.c @@ -35,6 +35,7 @@ #include #include "parser.h" +#include "rfcomm.h" struct parser_t parser; @@ -64,9 +65,12 @@ void set_proto(uint16_t handle, uint16_t psm, uint8_t channel, uint32_t proto) { int i, pos = -1; - if (psm > 0 && psm < 0x1000) + if (psm > 0 && psm < 0x1000 && !channel) return; + if (!psm && channel) + psm = RFCOMM_PSM; + for (i = 0; i < PROTO_TABLE_SIZE; i++) { if (proto_table[i].handle == handle && proto_table[i].psm == psm && proto_table[i].channel == channel) { pos = i; @@ -90,12 +94,17 @@ uint32_t get_proto(uint16_t handle, uint16_t psm, uint8_t channel) { int i, pos = -1; + if (!psm && channel) + psm = RFCOMM_PSM; + for (i = 0; i < PROTO_TABLE_SIZE; i++) { 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 || (!proto_table[i].psm && proto_table[i].channel == channel))) - pos = i; + if (!proto_table[i].handle) { + if (proto_table[i].psm == psm && proto_table[i].channel == channel) + pos = i; + } } return (pos < 0) ? 0 : proto_table[pos].proto; diff --git a/tools/parser/rfcomm.c b/tools/parser/rfcomm.c index a5ce993fa..40c68cf84 100644 --- a/tools/parser/rfcomm.c +++ b/tools/parser/rfcomm.c @@ -266,7 +266,7 @@ static inline void uih_frame(int level, struct frame *frm, long_frame_head *head frm->len--; frm->channel = head->addr.server_chn; - proto = get_proto(frm->handle, 0, frm->channel); + proto = get_proto(frm->handle, RFCOMM_PSM, frm->channel); if (frm->len > 0) { switch (proto) { -- 2.47.3