Diff between 5f432163133e64d248cc0ec209c08f5c8a2af1b5 and 3b8d6b19e647501133124c02350d85e5c29525cb

Changed Files

File Additions Deletions Status
monitor/l2cap.c +19 -9 modified
monitor/l2cap.h +6 -13 modified
monitor/sdp.c +2 -2 modified
monitor/sdp.h +1 -1 modified

Full Patch

diff --git a/monitor/l2cap.c b/monitor/l2cap.c
index b286787..1a82f8d 100644
--- a/monitor/l2cap.c
+++ b/monitor/l2cap.c
@@ -1113,6 +1113,21 @@ static const struct sig_opcode_data le_sig_opcode_table[] = {
 	{ },
 };
 
+static void l2cap_frame_init(struct l2cap_frame *frame,
+				uint16_t index, bool in, uint16_t handle,
+				uint16_t cid, const void *data, uint16_t size)
+{
+	frame->index  = index;
+	frame->in     = in;
+	frame->handle = handle;
+	frame->cid    = cid;
+	frame->data   = data;
+	frame->size   = size;
+	frame->psm    = get_psm(frame);
+	frame->mode   = get_mode(frame);
+	frame->chan   = get_chan(frame);
+}
+
 static void bredr_sig_packet(uint16_t index, bool in, uint16_t handle,
 				uint16_t cid, const void *data, uint16_t size)
 {
@@ -2596,8 +2611,6 @@ static void l2cap_frame(uint16_t index, bool in, uint16_t handle,
 			uint16_t cid, const void *data, uint16_t size)
 {
 	struct l2cap_frame frame;
-	uint16_t psm, chan;
-	uint8_t mode;
 
 	switch (cid) {
 	case 0x0001:
@@ -2620,18 +2633,15 @@ static void l2cap_frame(uint16_t index, bool in, uint16_t handle,
 		break;
 	default:
 		l2cap_frame_init(&frame, index, in, handle, cid, data, size);
-		psm = get_psm(&frame);
-		frame.psm = psm;
-		mode = get_mode(&frame);
-		chan = get_chan(&frame);
 
 		print_indent(6, COLOR_CYAN, "Channel:", "", COLOR_OFF,
 				" %d len %d [PSM %d mode %d] {chan %d}",
-						cid, size, psm, mode, chan);
+						cid, size, frame.psm,
+						frame.mode, frame.chan);
 
-		switch (psm) {
+		switch (frame.psm) {
 		case 0x0001:
-			sdp_packet(&frame, chan);
+			sdp_packet(&frame);
 			break;
 		case 0x001f:
 			att_packet(index, in, handle, cid, data, size);
diff --git a/monitor/l2cap.h b/monitor/l2cap.h
index 851b5c4..a0f844b 100644
--- a/monitor/l2cap.h
+++ b/monitor/l2cap.h
@@ -30,23 +30,13 @@ struct l2cap_frame {
 	bool in;
 	uint16_t handle;
 	uint16_t cid;
+	uint16_t psm;
+	uint16_t chan;
+	uint8_t mode;
 	const void *data;
 	uint16_t size;
-	uint16_t psm;
 };
 
-static inline void l2cap_frame_init(struct l2cap_frame *frame,
-				uint16_t index, bool in, uint16_t handle,
-				uint16_t cid, const void *data, uint16_t size)
-{
-	frame->index  = index;
-	frame->in     = in;
-	frame->handle = handle;
-	frame->cid    = cid;
-	frame->data   = data;
-	frame->size   = size;
-}
-
 static inline void l2cap_frame_pull(struct l2cap_frame *frame,
 				const struct l2cap_frame *source, uint16_t len)
 {
@@ -54,6 +44,9 @@ static inline void l2cap_frame_pull(struct l2cap_frame *frame,
 	frame->in      = source->in;
 	frame->handle  = source->handle;
 	frame->cid     = source->cid;
+	frame->psm     = source->psm;
+	frame->chan    = source->chan;
+	frame->mode    = source->mode;
 	frame->data    = source->data + len;
 	frame->size    = source->size - len;
 }
diff --git a/monitor/sdp.c b/monitor/sdp.c
index 8acc8bd..1b904ee 100644
--- a/monitor/sdp.c
+++ b/monitor/sdp.c
@@ -686,7 +686,7 @@ static const struct sdp_data sdp_table[] = {
 	{ }
 };
 
-void sdp_packet(const struct l2cap_frame *frame, uint16_t channel)
+void sdp_packet(const struct l2cap_frame *frame)
 {
 	uint8_t pdu;
 	uint16_t tid, plen;
@@ -737,7 +737,7 @@ void sdp_packet(const struct l2cap_frame *frame, uint16_t channel)
 	print_indent(6, pdu_color, "SDP: ", pdu_str, COLOR_OFF,
 				" (0x%2.2x) tid %d len %d", pdu, tid, plen);
 
-	tid_info = get_tid(tid, channel);
+	tid_info = get_tid(tid, frame->chan);
 
 	if (!sdp_data || !sdp_data->func || !tid_info) {
 		packet_hexdump(frame->data + 5, frame->size - 5);
diff --git a/monitor/sdp.h b/monitor/sdp.h
index ca2cd45..c8a9bb0 100644
--- a/monitor/sdp.h
+++ b/monitor/sdp.h
@@ -22,4 +22,4 @@
  *
  */
 
-void sdp_packet(const struct l2cap_frame *frame, uint16_t channel);
+void sdp_packet(const struct l2cap_frame *frame);