diff options
author | Gowtham Anandha Babu <gowtham.ab@samsung.com> | 2014-11-07 21:13:37 +0530 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-11-10 11:01:44 +0200 |
commit | 4ebdfcce8c6137e45ad717a99fd3a3211cf27792 (patch) | |
tree | af4d3531ce158976453c9d0e7d78daeebc8a804d /monitor/rfcomm.c | |
parent | 2f371db645a69423e4afd398987bfff395567073 (diff) | |
download | bluez-4ebdfcce8c6137e45ad717a99fd3a3211cf27792.tar.gz |
monitor/rfcomm: Add support for UIH frame decoding
Changes made to decode UIH frame in btmon.
In below UIH frame, MCC frame is present, so no credits field is printed.
RFCOMM: Unnumbered Info with Header Check (UIH)(0xef)
Address: 0x01 cr 0 dlci 0x00
Control: 0xef poll/final 0
Length: 10
FCS: 0xaa
81 11 20 e0 27 00 9a 02 00 07 aa .. .'......
In this UIH frame, no MCC frame, so credits field is printed.
RFCOMM: Unnumbered Info with Header Check (UIH)(0xef)
Address: 0x81 cr 0 dlci 0x20
Control: 0xff poll/final 1
Length: 0
FCS: 0x1e
Credits : 33
Diffstat (limited to 'monitor/rfcomm.c')
-rw-r--r-- | monitor/rfcomm.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c index 8149ab794..aa6ba361c 100644 --- a/monitor/rfcomm.c +++ b/monitor/rfcomm.c @@ -80,6 +80,31 @@ static void print_rfcomm_hdr(struct rfcomm_frame *rfcomm_frame, uint8_t indent) print_field("%*cFCS: 0x%2.2x", indent, ' ', hdr.fcs); } +static bool uih_frame(struct rfcomm_frame *rfcomm_frame, uint8_t indent) +{ + uint8_t credits; + struct l2cap_frame *frame = &rfcomm_frame->l2cap_frame; + struct rfcomm_lhdr *hdr = &rfcomm_frame->hdr; + + if (!RFCOMM_GET_CHANNEL(hdr->address)) { + /* MCC frame parser implementation */ + goto done; + } + + /* fetching credits from UIH frame */ + if (GET_PF(hdr->control)) { + if (!l2cap_frame_get_u8(frame, &credits)) + return false; + hdr->credits = credits; + print_field("%*cCredits: %d", indent, ' ', hdr->credits); + return true; + } + +done: + packet_hexdump(frame->data, frame->size); + return true; +} + struct rfcomm_data { uint8_t frame; const char *str; @@ -164,8 +189,9 @@ void rfcomm_packet(const struct l2cap_frame *frame) print_rfcomm_hdr(&rfcomm_frame, indent); /* UIH frame */ - if(ctype == 0xef) - packet_hexdump(l2cap_frame->data, l2cap_frame->size); + if (ctype == 0xef) + if (!uih_frame(&rfcomm_frame, indent)) + goto fail; return; |