diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-07-31 13:58:29 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-07-31 15:35:04 +0300 |
commit | 3b8d6b19e647501133124c02350d85e5c29525cb (patch) | |
tree | 012f71acc933d4bfbef69cd15d4b04e712452694 | |
parent | 5f432163133e64d248cc0ec209c08f5c8a2af1b5 (diff) | |
download | bluez-3b8d6b19e647501133124c02350d85e5c29525cb.tar.gz |
monitor: Add mode and channel to struct l2cap_frame
This make it simpler to pass it around.
-rw-r--r-- | monitor/l2cap.c | 28 | ||||
-rw-r--r-- | monitor/l2cap.h | 19 | ||||
-rw-r--r-- | monitor/sdp.c | 4 | ||||
-rw-r--r-- | monitor/sdp.h | 2 |
4 files changed, 28 insertions, 25 deletions
diff --git a/monitor/l2cap.c b/monitor/l2cap.c index b286787d3..1a82f8d53 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 851b5c497..a0f844bbe 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 8acc8bd2d..1b904eee1 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 ca2cd45ab..c8a9bb0cd 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); |