Diff between f7f2120f0d5e66108873b496a42d7acd0209bc99 and 3b912fd1b12f40a23fe8534cf10a58fe1a08d6ed

Changed Files

File Additions Deletions Status
tools/parser/parser.c +12 -3 modified
tools/parser/rfcomm.c +1 -1 modified

Full Patch

diff --git a/tools/parser/parser.c b/tools/parser/parser.c
index 9e62831..6444b81 100644
--- a/tools/parser/parser.c
+++ b/tools/parser/parser.c
@@ -35,6 +35,7 @@
 #include <netinet/in.h>
 
 #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 a5ce993..40c68cf 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) {