Adds an initial implementation for RFCOMM in Bluetooth monitor.
Implementation for Decoding MSC, RPN, RLS, PN, NSC frames
will be covered in the next patch-set.
v1: Added rfcomm.c file in Android.mk
Bharat Panda (2):
monitor/rfcomm: Add handlers for mcc frame type
monitor/rfcomm: Add mcc type handlers code
Gowtham Anandha Babu (4):
monitor/rfcomm: Add RFCOMM support to btmon
monitor/rfcomm: Add support for RFCOMM commands
monitor/rfcomm: Add support for UIH frame decoding
monitor/rfcomm: Add support for mcc frame decoding
Makefile.tools | 1 +
android/Android.mk | 1 +
monitor/l2cap.c | 4 +
monitor/l2cap.h | 1 +
monitor/rfcomm.c | 333 +++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 340 insertions(+)
create mode 100644 monitor/rfcomm.c
--
1.9.1
Hi,
On Tue, Nov 4, 2014 at 1:49 PM, Gowtham Anandha Babu
<[email protected]> wrote:
> Hi,
>
>> -----Original Message-----
>> From: Luiz Augusto von Dentz [mailto:[email protected]]
>> Sent: Monday, November 03, 2014 9:02 PM
>> To: Gowtham Anandha Babu
>> Cc: [email protected]; Dmitry Kasatkin; Bharat Panda;
>> [email protected]
>> Subject: Re: [PATCH v1 5/6] monitor/rfcomm: Add handlers for mcc frame
>> type
>>
>> Hi,
>>
>> On Mon, Nov 3, 2014 at 5:24 PM, Gowtham Anandha Babu
>> <[email protected]> wrote:
>> > Hi,
>> >
>> >> -----Original Message-----
>> >> From: Luiz Augusto von Dentz [mailto:[email protected]]
>> >> Sent: Monday, November 03, 2014 8:09 PM
>> >> To: Gowtham Anandha Babu
>> >> Cc: [email protected]; Dmitry Kasatkin; Bharat Panda;
>> >> [email protected]
>> >> Subject: Re: [PATCH v1 5/6] monitor/rfcomm: Add handlers for mcc
>> >> frame type
>> >>
>> >> Hi,
>> >>
>> >> On Mon, Nov 3, 2014 at 12:41 PM, Gowtham Anandha Babu
>> >> <[email protected]> wrote:
>> >> > From: Bharat Panda <[email protected]>
>> >> >
>> >> > Changes made to decode different mcc frame type in RFCOMM for
>> btmon.
>> >> > ---
>> >> > monitor/rfcomm.c | 78
>> >> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> -
>> >> > 1 file changed, 76 insertions(+), 2 deletions(-)
>> >> >
>> >> > diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c index
>> >> > a43b2a2..b85e8fd 100644
>> >> > --- a/monitor/rfcomm.c
>> >> > +++ b/monitor/rfcomm.c
>> >> > @@ -90,6 +90,51 @@ static void print_rfcomm_hdr(const struct
>> >> l2cap_frame *frame,
>> >> > print_field("FCS : (0x%2.2x)", fcs); }
>> >> >
>> >> > +static inline void mcc_test(const struct l2cap_frame *frame,
>> >> > + struct rfcomm_lhdr hdr, struct
>> >> > +rfcomm_lmcc mcc) { }
>> >> > +
>> >> > +static inline void mcc_fcon(const struct l2cap_frame *frame,
>> >> > + struct rfcomm_lhdr hdr, struct
>> >> > +rfcomm_lmcc mcc) { }
>> >> > +
>> >> > +static inline void mcc_fcoff(const struct l2cap_frame *frame,
>> >> > + struct rfcomm_lhdr hdr, struct
>> >> > +rfcomm_lmcc mcc) { }
>> >> > +
>> >> > +static inline void mcc_msc(const struct l2cap_frame *frame,
>> >> > + struct rfcomm_lhdr hdr, struct
>> >> > +rfcomm_lmcc mcc) {
>> >> > + packet_hexdump(frame->data, frame->size); }
>> >> > +
>> >> > +static inline void mcc_rpn(const struct l2cap_frame *frame,
>> >> > + struct rfcomm_lhdr hdr, struct
>> >> > +rfcomm_lmcc mcc) {
>> >> > + packet_hexdump(frame->data, frame->size); }
>> >> > +
>> >> > +static inline void mcc_rls(const struct l2cap_frame *frame,
>> >> > + struct rfcomm_lhdr hdr, struct
>> >> > +rfcomm_lmcc mcc) {
>> >> > + packet_hexdump(frame->data, frame->size); }
>> >> > +
>> >> > +static inline void mcc_pn(const struct l2cap_frame *frame,
>> >> > + struct rfcomm_lhdr hdr, struct
>> >> > +rfcomm_lmcc mcc) {
>> >> > + packet_hexdump(frame->data, frame->size); }
>> >> > +
>> >> > +static inline void mcc_nsc(const struct l2cap_frame *frame,
>> >> > + struct rfcomm_lhdr hdr, struct
>> >> > +rfcomm_lmcc mcc) {
>> >> > + packet_hexdump(frame->data, frame->size); }
>> >>
>> >> Im fine if you want to add parsing functions upfront but they should
>> >> do something useful other than just packet_hexdump otherwise don't
>> >> bother, btw please add the output that this changes are producing in
>> >> the description so we can more easily visualize the format you are
>> proposing.
>> >>
>> >> > static const char *type2str(uint8_t type) {
>> >> > switch (type) {
>> >> > @@ -141,8 +186,37 @@ static inline bool mcc_frame(const struct
>> >> l2cap_frame *frame,
>> >> > print_indent(7, opcode_color, "RFCOMM(s): ", "", COLOR_OFF,
>> >> > "%s
>> >> %s",
>> >> > type2str(type),
>> >> > CR_STR(mcc.type));
>> >> >
>> >> > - print_rfcomm_hdr(&rfcomm_frame, hdr);
>> >> > - packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
>> >> > + switch (type) {
>> >> > + case RFCOMM_TEST:
>> >> > + mcc_test(&rfcomm_frame, hdr, mcc);
>> >> > + packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
>> >> > + break;
>> >> > + case RFCOMM_FCON:
>> >> > + mcc_fcon(&rfcomm_frame, hdr, mcc);
>> >> > + break;
>> >> > + case RFCOMM_FCOFF:
>> >> > + mcc_fcoff(&rfcomm_frame, hdr, mcc);
>> >> > + break;
>> >> > + case RFCOMM_MSC:
>> >> > + mcc_msc(&rfcomm_frame, hdr, mcc);
>> >> > + break;
>> >> > + case RFCOMM_RPN:
>> >> > + mcc_rpn(&rfcomm_frame, hdr, mcc);
>> >> > + break;
>> >> > + case RFCOMM_RLS:
>> >> > + mcc_rls(&rfcomm_frame, hdr, mcc);
>> >> > + break;
>> >> > + case RFCOMM_PN:
>> >> > + mcc_pn(&rfcomm_frame, hdr, mcc);
>> >> > + break;
>> >> > + case RFCOMM_NSC:
>> >> > + mcc_nsc(&rfcomm_frame, hdr, mcc);
>> >> > + break;
>> >> > + default:
>> >> > + print_field("MCC message type 0x%02x: ", type);
>> >> > + print_rfcomm_hdr(&rfcomm_frame, hdr);
>> >> > + packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
>> >> > + }
>> >> >
>> >> > return true;
>> >> > }
>> >> > --
>> >> > 1.9.1
>> >> >
>> >> > --
>> >> > To unsubscribe from this list: send the line "unsubscribe
>> >> > linux-bluetooth" in the body of a message to
>> >> > [email protected] More majordomo info at
>> >> > http://vger.kernel.org/majordomo-info.html
>> >>
>> >>
>> >>
>> >> --
>> >> Luiz Augusto von Dentz
>> >
>> > I added Andoird.mk in the corresponding patch and included the logs in the
>> final patch and submitted v2 for the same. If you want the complete log, I am
>> ready to send it.
>>
>> I don't want the complete log just a single frame where we can see what the
>> patch does.
>>
>> > Btw we are almost done with the implementation for all the mcc frames. It
>> will not be the hexdump kind of things.
>> > Since it is an initial skeleton we proposed this kind of changes.
>>
>> I would understand if you add a skeleton to public function not for static
>> ones.
>>
>> --
>> Luiz Augusto von Dentz
>
> Here the frame means, a common structure for rfcomm packets. Like as below:
>
> Struct rfcomm_data {
> Struct rfcomm_lhdr hdr;
> Struct rfcomm_lmcc mcc;
> };
>
> Or just an explanation about all the frame in the patch description is enough?
I think you misunderstood me, Im talking about a data frame, each
patch should contain the output of single frame showing what it is
producing as output.
> You are expecting me to add skeleton only for public functions rather than static ones. Is that correct?
In this case yes since it does not effect any other part of the code,
btw you could use a function table if you wish.
--
Luiz Augusto von Dentz
Hi,
> -----Original Message-----
> From: Luiz Augusto von Dentz [mailto:[email protected]]
> Sent: Monday, November 03, 2014 9:02 PM
> To: Gowtham Anandha Babu
> Cc: [email protected]; Dmitry Kasatkin; Bharat Panda;
> [email protected]
> Subject: Re: [PATCH v1 5/6] monitor/rfcomm: Add handlers for mcc frame
> type
>
> Hi,
>
> On Mon, Nov 3, 2014 at 5:24 PM, Gowtham Anandha Babu
> <[email protected]> wrote:
> > Hi,
> >
> >> -----Original Message-----
> >> From: Luiz Augusto von Dentz [mailto:[email protected]]
> >> Sent: Monday, November 03, 2014 8:09 PM
> >> To: Gowtham Anandha Babu
> >> Cc: [email protected]; Dmitry Kasatkin; Bharat Panda;
> >> [email protected]
> >> Subject: Re: [PATCH v1 5/6] monitor/rfcomm: Add handlers for mcc
> >> frame type
> >>
> >> Hi,
> >>
> >> On Mon, Nov 3, 2014 at 12:41 PM, Gowtham Anandha Babu
> >> <[email protected]> wrote:
> >> > From: Bharat Panda <[email protected]>
> >> >
> >> > Changes made to decode different mcc frame type in RFCOMM for
> btmon.
> >> > ---
> >> > monitor/rfcomm.c | 78
> >> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> -
> >> > 1 file changed, 76 insertions(+), 2 deletions(-)
> >> >
> >> > diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c index
> >> > a43b2a2..b85e8fd 100644
> >> > --- a/monitor/rfcomm.c
> >> > +++ b/monitor/rfcomm.c
> >> > @@ -90,6 +90,51 @@ static void print_rfcomm_hdr(const struct
> >> l2cap_frame *frame,
> >> > print_field("FCS : (0x%2.2x)", fcs); }
> >> >
> >> > +static inline void mcc_test(const struct l2cap_frame *frame,
> >> > + struct rfcomm_lhdr hdr, struct
> >> > +rfcomm_lmcc mcc) { }
> >> > +
> >> > +static inline void mcc_fcon(const struct l2cap_frame *frame,
> >> > + struct rfcomm_lhdr hdr, struct
> >> > +rfcomm_lmcc mcc) { }
> >> > +
> >> > +static inline void mcc_fcoff(const struct l2cap_frame *frame,
> >> > + struct rfcomm_lhdr hdr, struct
> >> > +rfcomm_lmcc mcc) { }
> >> > +
> >> > +static inline void mcc_msc(const struct l2cap_frame *frame,
> >> > + struct rfcomm_lhdr hdr, struct
> >> > +rfcomm_lmcc mcc) {
> >> > + packet_hexdump(frame->data, frame->size); }
> >> > +
> >> > +static inline void mcc_rpn(const struct l2cap_frame *frame,
> >> > + struct rfcomm_lhdr hdr, struct
> >> > +rfcomm_lmcc mcc) {
> >> > + packet_hexdump(frame->data, frame->size); }
> >> > +
> >> > +static inline void mcc_rls(const struct l2cap_frame *frame,
> >> > + struct rfcomm_lhdr hdr, struct
> >> > +rfcomm_lmcc mcc) {
> >> > + packet_hexdump(frame->data, frame->size); }
> >> > +
> >> > +static inline void mcc_pn(const struct l2cap_frame *frame,
> >> > + struct rfcomm_lhdr hdr, struct
> >> > +rfcomm_lmcc mcc) {
> >> > + packet_hexdump(frame->data, frame->size); }
> >> > +
> >> > +static inline void mcc_nsc(const struct l2cap_frame *frame,
> >> > + struct rfcomm_lhdr hdr, struct
> >> > +rfcomm_lmcc mcc) {
> >> > + packet_hexdump(frame->data, frame->size); }
> >>
> >> Im fine if you want to add parsing functions upfront but they should
> >> do something useful other than just packet_hexdump otherwise don't
> >> bother, btw please add the output that this changes are producing in
> >> the description so we can more easily visualize the format you are
> proposing.
> >>
> >> > static const char *type2str(uint8_t type) {
> >> > switch (type) {
> >> > @@ -141,8 +186,37 @@ static inline bool mcc_frame(const struct
> >> l2cap_frame *frame,
> >> > print_indent(7, opcode_color, "RFCOMM(s): ", "", COLOR_OFF,
> >> > "%s
> >> %s",
> >> > type2str(type),
> >> > CR_STR(mcc.type));
> >> >
> >> > - print_rfcomm_hdr(&rfcomm_frame, hdr);
> >> > - packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
> >> > + switch (type) {
> >> > + case RFCOMM_TEST:
> >> > + mcc_test(&rfcomm_frame, hdr, mcc);
> >> > + packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
> >> > + break;
> >> > + case RFCOMM_FCON:
> >> > + mcc_fcon(&rfcomm_frame, hdr, mcc);
> >> > + break;
> >> > + case RFCOMM_FCOFF:
> >> > + mcc_fcoff(&rfcomm_frame, hdr, mcc);
> >> > + break;
> >> > + case RFCOMM_MSC:
> >> > + mcc_msc(&rfcomm_frame, hdr, mcc);
> >> > + break;
> >> > + case RFCOMM_RPN:
> >> > + mcc_rpn(&rfcomm_frame, hdr, mcc);
> >> > + break;
> >> > + case RFCOMM_RLS:
> >> > + mcc_rls(&rfcomm_frame, hdr, mcc);
> >> > + break;
> >> > + case RFCOMM_PN:
> >> > + mcc_pn(&rfcomm_frame, hdr, mcc);
> >> > + break;
> >> > + case RFCOMM_NSC:
> >> > + mcc_nsc(&rfcomm_frame, hdr, mcc);
> >> > + break;
> >> > + default:
> >> > + print_field("MCC message type 0x%02x: ", type);
> >> > + print_rfcomm_hdr(&rfcomm_frame, hdr);
> >> > + packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
> >> > + }
> >> >
> >> > return true;
> >> > }
> >> > --
> >> > 1.9.1
> >> >
> >> > --
> >> > To unsubscribe from this list: send the line "unsubscribe
> >> > linux-bluetooth" in the body of a message to
> >> > [email protected] More majordomo info at
> >> > http://vger.kernel.org/majordomo-info.html
> >>
> >>
> >>
> >> --
> >> Luiz Augusto von Dentz
> >
> > I added Andoird.mk in the corresponding patch and included the logs in the
> final patch and submitted v2 for the same. If you want the complete log, I am
> ready to send it.
>
> I don't want the complete log just a single frame where we can see what the
> patch does.
>
> > Btw we are almost done with the implementation for all the mcc frames. It
> will not be the hexdump kind of things.
> > Since it is an initial skeleton we proposed this kind of changes.
>
> I would understand if you add a skeleton to public function not for static
> ones.
>
> --
> Luiz Augusto von Dentz
Here the frame means, a common structure for rfcomm packets. Like as below:
Struct rfcomm_data {
Struct rfcomm_lhdr hdr;
Struct rfcomm_lmcc mcc;
};
Or just an explanation about all the frame in the patch description is enough?
You are expecting me to add skeleton only for public functions rather than static ones. Is that correct?
Regards,
Gowtham Anandha Babu
Hi,
On Mon, Nov 3, 2014 at 5:24 PM, Gowtham Anandha Babu
<[email protected]> wrote:
> Hi,
>
>> -----Original Message-----
>> From: Luiz Augusto von Dentz [mailto:[email protected]]
>> Sent: Monday, November 03, 2014 8:09 PM
>> To: Gowtham Anandha Babu
>> Cc: [email protected]; Dmitry Kasatkin; Bharat Panda;
>> [email protected]
>> Subject: Re: [PATCH v1 5/6] monitor/rfcomm: Add handlers for mcc frame
>> type
>>
>> Hi,
>>
>> On Mon, Nov 3, 2014 at 12:41 PM, Gowtham Anandha Babu
>> <[email protected]> wrote:
>> > From: Bharat Panda <[email protected]>
>> >
>> > Changes made to decode different mcc frame type in RFCOMM for btmon.
>> > ---
>> > monitor/rfcomm.c | 78
>> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>> > 1 file changed, 76 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c index
>> > a43b2a2..b85e8fd 100644
>> > --- a/monitor/rfcomm.c
>> > +++ b/monitor/rfcomm.c
>> > @@ -90,6 +90,51 @@ static void print_rfcomm_hdr(const struct
>> l2cap_frame *frame,
>> > print_field("FCS : (0x%2.2x)", fcs); }
>> >
>> > +static inline void mcc_test(const struct l2cap_frame *frame,
>> > + struct rfcomm_lhdr hdr, struct
>> > +rfcomm_lmcc mcc) { }
>> > +
>> > +static inline void mcc_fcon(const struct l2cap_frame *frame,
>> > + struct rfcomm_lhdr hdr, struct
>> > +rfcomm_lmcc mcc) { }
>> > +
>> > +static inline void mcc_fcoff(const struct l2cap_frame *frame,
>> > + struct rfcomm_lhdr hdr, struct
>> > +rfcomm_lmcc mcc) { }
>> > +
>> > +static inline void mcc_msc(const struct l2cap_frame *frame,
>> > + struct rfcomm_lhdr hdr, struct
>> > +rfcomm_lmcc mcc) {
>> > + packet_hexdump(frame->data, frame->size); }
>> > +
>> > +static inline void mcc_rpn(const struct l2cap_frame *frame,
>> > + struct rfcomm_lhdr hdr, struct
>> > +rfcomm_lmcc mcc) {
>> > + packet_hexdump(frame->data, frame->size); }
>> > +
>> > +static inline void mcc_rls(const struct l2cap_frame *frame,
>> > + struct rfcomm_lhdr hdr, struct
>> > +rfcomm_lmcc mcc) {
>> > + packet_hexdump(frame->data, frame->size); }
>> > +
>> > +static inline void mcc_pn(const struct l2cap_frame *frame,
>> > + struct rfcomm_lhdr hdr, struct
>> > +rfcomm_lmcc mcc) {
>> > + packet_hexdump(frame->data, frame->size); }
>> > +
>> > +static inline void mcc_nsc(const struct l2cap_frame *frame,
>> > + struct rfcomm_lhdr hdr, struct
>> > +rfcomm_lmcc mcc) {
>> > + packet_hexdump(frame->data, frame->size); }
>>
>> Im fine if you want to add parsing functions upfront but they should do
>> something useful other than just packet_hexdump otherwise don't bother,
>> btw please add the output that this changes are producing in the description
>> so we can more easily visualize the format you are proposing.
>>
>> > static const char *type2str(uint8_t type) {
>> > switch (type) {
>> > @@ -141,8 +186,37 @@ static inline bool mcc_frame(const struct
>> l2cap_frame *frame,
>> > print_indent(7, opcode_color, "RFCOMM(s): ", "", COLOR_OFF, "%s
>> %s",
>> > type2str(type),
>> > CR_STR(mcc.type));
>> >
>> > - print_rfcomm_hdr(&rfcomm_frame, hdr);
>> > - packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
>> > + switch (type) {
>> > + case RFCOMM_TEST:
>> > + mcc_test(&rfcomm_frame, hdr, mcc);
>> > + packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
>> > + break;
>> > + case RFCOMM_FCON:
>> > + mcc_fcon(&rfcomm_frame, hdr, mcc);
>> > + break;
>> > + case RFCOMM_FCOFF:
>> > + mcc_fcoff(&rfcomm_frame, hdr, mcc);
>> > + break;
>> > + case RFCOMM_MSC:
>> > + mcc_msc(&rfcomm_frame, hdr, mcc);
>> > + break;
>> > + case RFCOMM_RPN:
>> > + mcc_rpn(&rfcomm_frame, hdr, mcc);
>> > + break;
>> > + case RFCOMM_RLS:
>> > + mcc_rls(&rfcomm_frame, hdr, mcc);
>> > + break;
>> > + case RFCOMM_PN:
>> > + mcc_pn(&rfcomm_frame, hdr, mcc);
>> > + break;
>> > + case RFCOMM_NSC:
>> > + mcc_nsc(&rfcomm_frame, hdr, mcc);
>> > + break;
>> > + default:
>> > + print_field("MCC message type 0x%02x: ", type);
>> > + print_rfcomm_hdr(&rfcomm_frame, hdr);
>> > + packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
>> > + }
>> >
>> > return true;
>> > }
>> > --
>> > 1.9.1
>> >
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe
>> > linux-bluetooth" in the body of a message to [email protected]
>> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>>
>>
>> --
>> Luiz Augusto von Dentz
>
> I added Andoird.mk in the corresponding patch and included the logs in the final patch and submitted v2 for the same. If you want the complete log, I am ready to send it.
I don't want the complete log just a single frame where we can see
what the patch does.
> Btw we are almost done with the implementation for all the mcc frames. It will not be the hexdump kind of things.
> Since it is an initial skeleton we proposed this kind of changes.
I would understand if you add a skeleton to public function not for static ones.
--
Luiz Augusto von Dentz
Hi,
> -----Original Message-----
> From: Luiz Augusto von Dentz [mailto:[email protected]]
> Sent: Monday, November 03, 2014 8:09 PM
> To: Gowtham Anandha Babu
> Cc: [email protected]; Dmitry Kasatkin; Bharat Panda;
> [email protected]
> Subject: Re: [PATCH v1 5/6] monitor/rfcomm: Add handlers for mcc frame
> type
>
> Hi,
>
> On Mon, Nov 3, 2014 at 12:41 PM, Gowtham Anandha Babu
> <[email protected]> wrote:
> > From: Bharat Panda <[email protected]>
> >
> > Changes made to decode different mcc frame type in RFCOMM for btmon.
> > ---
> > monitor/rfcomm.c | 78
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> > 1 file changed, 76 insertions(+), 2 deletions(-)
> >
> > diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c index
> > a43b2a2..b85e8fd 100644
> > --- a/monitor/rfcomm.c
> > +++ b/monitor/rfcomm.c
> > @@ -90,6 +90,51 @@ static void print_rfcomm_hdr(const struct
> l2cap_frame *frame,
> > print_field("FCS : (0x%2.2x)", fcs); }
> >
> > +static inline void mcc_test(const struct l2cap_frame *frame,
> > + struct rfcomm_lhdr hdr, struct
> > +rfcomm_lmcc mcc) { }
> > +
> > +static inline void mcc_fcon(const struct l2cap_frame *frame,
> > + struct rfcomm_lhdr hdr, struct
> > +rfcomm_lmcc mcc) { }
> > +
> > +static inline void mcc_fcoff(const struct l2cap_frame *frame,
> > + struct rfcomm_lhdr hdr, struct
> > +rfcomm_lmcc mcc) { }
> > +
> > +static inline void mcc_msc(const struct l2cap_frame *frame,
> > + struct rfcomm_lhdr hdr, struct
> > +rfcomm_lmcc mcc) {
> > + packet_hexdump(frame->data, frame->size); }
> > +
> > +static inline void mcc_rpn(const struct l2cap_frame *frame,
> > + struct rfcomm_lhdr hdr, struct
> > +rfcomm_lmcc mcc) {
> > + packet_hexdump(frame->data, frame->size); }
> > +
> > +static inline void mcc_rls(const struct l2cap_frame *frame,
> > + struct rfcomm_lhdr hdr, struct
> > +rfcomm_lmcc mcc) {
> > + packet_hexdump(frame->data, frame->size); }
> > +
> > +static inline void mcc_pn(const struct l2cap_frame *frame,
> > + struct rfcomm_lhdr hdr, struct
> > +rfcomm_lmcc mcc) {
> > + packet_hexdump(frame->data, frame->size); }
> > +
> > +static inline void mcc_nsc(const struct l2cap_frame *frame,
> > + struct rfcomm_lhdr hdr, struct
> > +rfcomm_lmcc mcc) {
> > + packet_hexdump(frame->data, frame->size); }
>
> Im fine if you want to add parsing functions upfront but they should do
> something useful other than just packet_hexdump otherwise don't bother,
> btw please add the output that this changes are producing in the description
> so we can more easily visualize the format you are proposing.
>
> > static const char *type2str(uint8_t type) {
> > switch (type) {
> > @@ -141,8 +186,37 @@ static inline bool mcc_frame(const struct
> l2cap_frame *frame,
> > print_indent(7, opcode_color, "RFCOMM(s): ", "", COLOR_OFF, "%s
> %s",
> > type2str(type),
> > CR_STR(mcc.type));
> >
> > - print_rfcomm_hdr(&rfcomm_frame, hdr);
> > - packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
> > + switch (type) {
> > + case RFCOMM_TEST:
> > + mcc_test(&rfcomm_frame, hdr, mcc);
> > + packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
> > + break;
> > + case RFCOMM_FCON:
> > + mcc_fcon(&rfcomm_frame, hdr, mcc);
> > + break;
> > + case RFCOMM_FCOFF:
> > + mcc_fcoff(&rfcomm_frame, hdr, mcc);
> > + break;
> > + case RFCOMM_MSC:
> > + mcc_msc(&rfcomm_frame, hdr, mcc);
> > + break;
> > + case RFCOMM_RPN:
> > + mcc_rpn(&rfcomm_frame, hdr, mcc);
> > + break;
> > + case RFCOMM_RLS:
> > + mcc_rls(&rfcomm_frame, hdr, mcc);
> > + break;
> > + case RFCOMM_PN:
> > + mcc_pn(&rfcomm_frame, hdr, mcc);
> > + break;
> > + case RFCOMM_NSC:
> > + mcc_nsc(&rfcomm_frame, hdr, mcc);
> > + break;
> > + default:
> > + print_field("MCC message type 0x%02x: ", type);
> > + print_rfcomm_hdr(&rfcomm_frame, hdr);
> > + packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
> > + }
> >
> > return true;
> > }
> > --
> > 1.9.1
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe
> > linux-bluetooth" in the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
>
> --
> Luiz Augusto von Dentz
I added Andoird.mk in the corresponding patch and included the logs in the final patch and submitted v2 for the same. If you want the complete log, I am ready to send it.
Btw we are almost done with the implementation for all the mcc frames. It will not be the hexdump kind of things.
Since it is an initial skeleton we proposed this kind of changes.
Regards,
Gowtham Anandha Babu
Hi,
On Mon, Nov 3, 2014 at 12:41 PM, Gowtham Anandha Babu
<[email protected]> wrote:
> From: Bharat Panda <[email protected]>
>
> Changes made to decode different mcc frame type in RFCOMM
> for btmon.
> ---
> monitor/rfcomm.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 76 insertions(+), 2 deletions(-)
>
> diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
> index a43b2a2..b85e8fd 100644
> --- a/monitor/rfcomm.c
> +++ b/monitor/rfcomm.c
> @@ -90,6 +90,51 @@ static void print_rfcomm_hdr(const struct l2cap_frame *frame,
> print_field("FCS : (0x%2.2x)", fcs);
> }
>
> +static inline void mcc_test(const struct l2cap_frame *frame,
> + struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
> +{
> +}
> +
> +static inline void mcc_fcon(const struct l2cap_frame *frame,
> + struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
> +{
> +}
> +
> +static inline void mcc_fcoff(const struct l2cap_frame *frame,
> + struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
> +{
> +}
> +
> +static inline void mcc_msc(const struct l2cap_frame *frame,
> + struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
> +{
> + packet_hexdump(frame->data, frame->size);
> +}
> +
> +static inline void mcc_rpn(const struct l2cap_frame *frame,
> + struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
> +{
> + packet_hexdump(frame->data, frame->size);
> +}
> +
> +static inline void mcc_rls(const struct l2cap_frame *frame,
> + struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
> +{
> + packet_hexdump(frame->data, frame->size);
> +}
> +
> +static inline void mcc_pn(const struct l2cap_frame *frame,
> + struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
> +{
> + packet_hexdump(frame->data, frame->size);
> +}
> +
> +static inline void mcc_nsc(const struct l2cap_frame *frame,
> + struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
> +{
> + packet_hexdump(frame->data, frame->size);
> +}
Im fine if you want to add parsing functions upfront but they should
do something useful other than just packet_hexdump otherwise don't
bother, btw please add the output that this changes are producing in
the description so we can more easily visualize the format you are
proposing.
> static const char *type2str(uint8_t type)
> {
> switch (type) {
> @@ -141,8 +186,37 @@ static inline bool mcc_frame(const struct l2cap_frame *frame,
> print_indent(7, opcode_color, "RFCOMM(s): ", "", COLOR_OFF, "%s %s",
> type2str(type), CR_STR(mcc.type));
>
> - print_rfcomm_hdr(&rfcomm_frame, hdr);
> - packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
> + switch (type) {
> + case RFCOMM_TEST:
> + mcc_test(&rfcomm_frame, hdr, mcc);
> + packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
> + break;
> + case RFCOMM_FCON:
> + mcc_fcon(&rfcomm_frame, hdr, mcc);
> + break;
> + case RFCOMM_FCOFF:
> + mcc_fcoff(&rfcomm_frame, hdr, mcc);
> + break;
> + case RFCOMM_MSC:
> + mcc_msc(&rfcomm_frame, hdr, mcc);
> + break;
> + case RFCOMM_RPN:
> + mcc_rpn(&rfcomm_frame, hdr, mcc);
> + break;
> + case RFCOMM_RLS:
> + mcc_rls(&rfcomm_frame, hdr, mcc);
> + break;
> + case RFCOMM_PN:
> + mcc_pn(&rfcomm_frame, hdr, mcc);
> + break;
> + case RFCOMM_NSC:
> + mcc_nsc(&rfcomm_frame, hdr, mcc);
> + break;
> + default:
> + print_field("MCC message type 0x%02x: ", type);
> + print_rfcomm_hdr(&rfcomm_frame, hdr);
> + packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
> + }
>
> return true;
> }
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Luiz Augusto von Dentz
Hi,
On Mon, Nov 3, 2014 at 12:41 PM, Gowtham Anandha Babu
<[email protected]> wrote:
> Changes made to add initial code to support RFCOMM frame in btmon.
> ---
> Makefile.tools | 1 +
> monitor/l2cap.c | 4 ++++
> monitor/l2cap.h | 1 +
> monitor/rfcomm.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 67 insertions(+)
> create mode 100644 monitor/rfcomm.c
>
> diff --git a/Makefile.tools b/Makefile.tools
> index 42cccc6..75a6faa 100644
> --- a/Makefile.tools
> +++ b/Makefile.tools
> @@ -26,6 +26,7 @@ monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \
> monitor/l2cap.h monitor/l2cap.c \
> monitor/sdp.h monitor/sdp.c \
> monitor/avctp.h monitor/avctp.c \
> + monitor/rfcomm.h monitor/rfcomm.c \
> monitor/uuid.h monitor/uuid.c \
> monitor/hwdb.h monitor/hwdb.c \
> monitor/keys.h monitor/keys.c \
I suspect you need to do the change to Android.mk here when you start
modifying l2cap.c.
> diff --git a/monitor/l2cap.c b/monitor/l2cap.c
> index c004d6b..ebdd20f 100644
> --- a/monitor/l2cap.c
> +++ b/monitor/l2cap.c
> @@ -42,6 +42,7 @@
> #include "keys.h"
> #include "sdp.h"
> #include "avctp.h"
> +#include "rfcomm.h"
>
> #define MAX_CHAN 64
>
> @@ -2643,6 +2644,9 @@ static void l2cap_frame(uint16_t index, bool in, uint16_t handle,
> case 0x0001:
> sdp_packet(&frame);
> break;
> + case 0x0003:
> + rfcomm_packet(&frame);
> + break;
> case 0x001f:
> att_packet(index, in, handle, cid, data, size);
> break;
> diff --git a/monitor/l2cap.h b/monitor/l2cap.h
> index 5faaea6..1f70b68 100644
> --- a/monitor/l2cap.h
> +++ b/monitor/l2cap.h
> @@ -153,3 +153,4 @@ static inline bool l2cap_frame_get_le64(struct l2cap_frame *frame,
>
> void l2cap_packet(uint16_t index, bool in, uint16_t handle, uint8_t flags,
> const void *data, uint16_t size);
> +void rfcomm_packet(const struct l2cap_frame *frame);
> diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
> new file mode 100644
> index 0000000..7d38a28
> --- /dev/null
> +++ b/monitor/rfcomm.c
> @@ -0,0 +1,61 @@
> +/*
> + *
> + * BlueZ - Bluetooth protocol stack for Linux
> + *
> + * Copyright (C) 2011-2014 Intel Corporation
> + * Copyright (C) 2002-2010 Marcel Holtmann <[email protected]>
> + *
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <ctype.h>
> +#include <inttypes.h>
> +
> +#include <bluetooth/bluetooth.h>
> +
> +#include "src/shared/util.h"
> +#include "bt.h"
> +#include "packet.h"
> +#include "display.h"
> +#include "l2cap.h"
> +#include "uuid.h"
> +#include "keys.h"
> +#include "sdp.h"
> +#include "rfcomm.h"
> +
> +const char *opcode_color;
> +
> +void rfcomm_packet(const struct l2cap_frame *frame)
> +{
> + if (frame->in)
> + opcode_color = COLOR_MAGENTA;
> + else
> + opcode_color = COLOR_BLUE;
> +
> + print_indent(7, opcode_color, "RFCOMM: ", "",
> + COLOR_OFF, "");
> +
> + packet_hexdump(frame->data, frame->size);
> + return;
> +}
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Luiz Augusto von Dentz
From: Bharat Panda <[email protected]>
Adds different mcc type handlers code to print in btmon.
---
android/Android.mk | 1 +
monitor/rfcomm.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/android/Android.mk b/android/Android.mk
index aefe41c..eebd863 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -289,6 +289,7 @@ LOCAL_SRC_FILES := \
bluez/monitor/packet.c \
bluez/monitor/l2cap.c \
bluez/monitor/avctp.c \
+ bluez/monitor/rfcomm.c \
bluez/monitor/uuid.c \
bluez/monitor/sdp.c \
bluez/monitor/vendor.c \
diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
index b85e8fd..10dc4e8 100644
--- a/monitor/rfcomm.c
+++ b/monitor/rfcomm.c
@@ -90,48 +90,69 @@ static void print_rfcomm_hdr(const struct l2cap_frame *frame,
print_field("FCS : (0x%2.2x)", fcs);
}
+static void print_mcc(struct rfcomm_lmcc mcc)
+{
+ print_field("MCC Length %d", mcc.length);
+}
+
static inline void mcc_test(const struct l2cap_frame *frame,
struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
{
+ print_rfcomm_hdr(frame, hdr);
+ print_mcc(mcc);
}
static inline void mcc_fcon(const struct l2cap_frame *frame,
struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
{
+ print_rfcomm_hdr(frame, hdr);
+ print_mcc(mcc);
}
static inline void mcc_fcoff(const struct l2cap_frame *frame,
struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
{
+ print_rfcomm_hdr(frame, hdr);
+ print_mcc(mcc);
}
static inline void mcc_msc(const struct l2cap_frame *frame,
struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
{
+ print_rfcomm_hdr(frame, hdr);
+ print_mcc(mcc);
packet_hexdump(frame->data, frame->size);
}
static inline void mcc_rpn(const struct l2cap_frame *frame,
struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
{
+ print_rfcomm_hdr(frame, hdr);
+ print_mcc(mcc);
packet_hexdump(frame->data, frame->size);
}
static inline void mcc_rls(const struct l2cap_frame *frame,
struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
{
+ print_rfcomm_hdr(frame, hdr);
+ print_mcc(mcc);
packet_hexdump(frame->data, frame->size);
}
static inline void mcc_pn(const struct l2cap_frame *frame,
struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
{
+ print_rfcomm_hdr(frame, hdr);
+ print_mcc(mcc);
packet_hexdump(frame->data, frame->size);
}
static inline void mcc_nsc(const struct l2cap_frame *frame,
struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
{
+ print_rfcomm_hdr(frame, hdr);
+ print_mcc(mcc);
packet_hexdump(frame->data, frame->size);
}
--
1.9.1
From: Bharat Panda <[email protected]>
Changes made to decode different mcc frame type in RFCOMM
for btmon.
---
monitor/rfcomm.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 76 insertions(+), 2 deletions(-)
diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
index a43b2a2..b85e8fd 100644
--- a/monitor/rfcomm.c
+++ b/monitor/rfcomm.c
@@ -90,6 +90,51 @@ static void print_rfcomm_hdr(const struct l2cap_frame *frame,
print_field("FCS : (0x%2.2x)", fcs);
}
+static inline void mcc_test(const struct l2cap_frame *frame,
+ struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
+{
+}
+
+static inline void mcc_fcon(const struct l2cap_frame *frame,
+ struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
+{
+}
+
+static inline void mcc_fcoff(const struct l2cap_frame *frame,
+ struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
+{
+}
+
+static inline void mcc_msc(const struct l2cap_frame *frame,
+ struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
+{
+ packet_hexdump(frame->data, frame->size);
+}
+
+static inline void mcc_rpn(const struct l2cap_frame *frame,
+ struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
+{
+ packet_hexdump(frame->data, frame->size);
+}
+
+static inline void mcc_rls(const struct l2cap_frame *frame,
+ struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
+{
+ packet_hexdump(frame->data, frame->size);
+}
+
+static inline void mcc_pn(const struct l2cap_frame *frame,
+ struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
+{
+ packet_hexdump(frame->data, frame->size);
+}
+
+static inline void mcc_nsc(const struct l2cap_frame *frame,
+ struct rfcomm_lhdr hdr, struct rfcomm_lmcc mcc)
+{
+ packet_hexdump(frame->data, frame->size);
+}
+
static const char *type2str(uint8_t type)
{
switch (type) {
@@ -141,8 +186,37 @@ static inline bool mcc_frame(const struct l2cap_frame *frame,
print_indent(7, opcode_color, "RFCOMM(s): ", "", COLOR_OFF, "%s %s",
type2str(type), CR_STR(mcc.type));
- print_rfcomm_hdr(&rfcomm_frame, hdr);
- packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
+ switch (type) {
+ case RFCOMM_TEST:
+ mcc_test(&rfcomm_frame, hdr, mcc);
+ packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
+ break;
+ case RFCOMM_FCON:
+ mcc_fcon(&rfcomm_frame, hdr, mcc);
+ break;
+ case RFCOMM_FCOFF:
+ mcc_fcoff(&rfcomm_frame, hdr, mcc);
+ break;
+ case RFCOMM_MSC:
+ mcc_msc(&rfcomm_frame, hdr, mcc);
+ break;
+ case RFCOMM_RPN:
+ mcc_rpn(&rfcomm_frame, hdr, mcc);
+ break;
+ case RFCOMM_RLS:
+ mcc_rls(&rfcomm_frame, hdr, mcc);
+ break;
+ case RFCOMM_PN:
+ mcc_pn(&rfcomm_frame, hdr, mcc);
+ break;
+ case RFCOMM_NSC:
+ mcc_nsc(&rfcomm_frame, hdr, mcc);
+ break;
+ default:
+ print_field("MCC message type 0x%02x: ", type);
+ print_rfcomm_hdr(&rfcomm_frame, hdr);
+ packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
+ }
return true;
}
--
1.9.1
Changes made to decode MCC frame in RFCOMM for btmon.
---
monitor/rfcomm.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 80 insertions(+), 1 deletion(-)
diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
index 6994ffd..a43b2a2 100644
--- a/monitor/rfcomm.c
+++ b/monitor/rfcomm.c
@@ -44,8 +44,15 @@
#include "sdp.h"
#include "rfcomm.h"
+static char *cr_str[] = {
+ "RSP",
+ "CMD"
+};
+
+#define CR_STR(type) cr_str[GET_CR(type)]
#define GET_LEN8(length) ((length & 0xfe) >> 1)
#define GET_LEN16(length) ((length & 0xfffe) >> 1)
+#define GET_CR(type) ((type & 0x02) >> 1)
#define GET_PF(ctr) (((ctr) >> 4) & 0x1)
struct rfcomm_lhdr {
@@ -54,17 +61,89 @@ struct rfcomm_lhdr {
uint16_t length;
} __attribute__((packed));
+struct rfcomm_lmcc {
+ uint8_t type;
+ uint16_t length;
+} __attribute__((packed));
+
+
const char *opcode_color;
static void print_rfcomm_hdr(const struct l2cap_frame *frame,
struct rfcomm_lhdr hdr)
{
+ uint8_t pf, dlci, fcs, cr, ilen;
+ const void *ptr;
+
+ dlci = RFCOMM_GET_DLCI(hdr.address);
+ pf = GET_PF(hdr.control);
+ cr = GET_CR(hdr.address);
+ ilen = hdr.length;
+ ptr = (frame->data)+frame->size-1;
+ fcs = *(uint8_t *)(ptr);
+
+ print_field("Address : (0x%2.2x)", hdr.address);
+ print_field("CR Bit: %d", cr);
+ print_field("DLCI : (0x%2.2x)", dlci);
+ print_field("Poll/FInal Bit : %d", pf);
+ print_field("Length : %d", ilen);
+ print_field("FCS : (0x%2.2x)", fcs);
+}
+
+static const char *type2str(uint8_t type)
+{
+ switch (type) {
+ case RFCOMM_TEST:
+ return "TEST";
+ case RFCOMM_FCON:
+ return "FCON";
+ case RFCOMM_FCOFF:
+ return "FCOFF";
+ case RFCOMM_MSC:
+ return "MSC";
+ case RFCOMM_RPN:
+ return "RPN";
+ case RFCOMM_RLS:
+ return "RLS";
+ case RFCOMM_PN:
+ return "PN";
+ case RFCOMM_NSC:
+ return "NSC";
+ default:
+ return "Unknown";
+ }
}
static inline bool mcc_frame(const struct l2cap_frame *frame,
struct rfcomm_lhdr hdr)
{
- packet_hexdump(frame->data, frame->size);
+ uint8_t length, ex_length, type;
+ struct l2cap_frame rfcomm_frame;
+ struct rfcomm_lmcc mcc;
+
+ l2cap_frame_pull(&rfcomm_frame, frame, 0);
+
+ if (!l2cap_frame_get_u8(&rfcomm_frame, &mcc.type) ||
+ !l2cap_frame_get_u8(&rfcomm_frame, &length))
+ return false;
+
+ if (RFCOMM_TEST_EA(length))
+ mcc.length = (uint16_t) GET_LEN8(length);
+ else {
+ if (!l2cap_frame_get_u8(&rfcomm_frame, &ex_length))
+ return false;
+ mcc.length = ((uint16_t) length << 8) | ex_length;
+ mcc.length = GET_LEN16(hdr.length);
+ }
+
+ type = RFCOMM_GET_MCC_TYPE(mcc.type);
+
+ print_indent(7, opcode_color, "RFCOMM(s): ", "", COLOR_OFF, "%s %s",
+ type2str(type), CR_STR(mcc.type));
+
+ print_rfcomm_hdr(&rfcomm_frame, hdr);
+ packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
+
return true;
}
--
1.9.1
Changes made to decode UIH frame in btmon.
---
monitor/rfcomm.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
index 395a7b8..6994ffd 100644
--- a/monitor/rfcomm.c
+++ b/monitor/rfcomm.c
@@ -46,6 +46,7 @@
#define GET_LEN8(length) ((length & 0xfe) >> 1)
#define GET_LEN16(length) ((length & 0xfffe) >> 1)
+#define GET_PF(ctr) (((ctr) >> 4) & 0x1)
struct rfcomm_lhdr {
uint8_t address;
@@ -60,8 +61,36 @@ static void print_rfcomm_hdr(const struct l2cap_frame *frame,
{
}
+static inline bool mcc_frame(const struct l2cap_frame *frame,
+ struct rfcomm_lhdr hdr)
+{
+ packet_hexdump(frame->data, frame->size);
+ return true;
+}
+
static bool uih_frame(const struct l2cap_frame *frame, struct rfcomm_lhdr hdr)
{
+ uint8_t credits;
+
+ struct l2cap_frame rfcomm_frame;
+
+ l2cap_frame_pull(&rfcomm_frame, frame, 0);
+
+ if (!RFCOMM_GET_CHANNEL(hdr.address)) {
+ return mcc_frame(&rfcomm_frame, hdr);
+ } else {
+ print_indent(7, opcode_color, "RFCOMM(d): UIH ", "",
+ COLOR_OFF, "");
+ print_rfcomm_hdr(&rfcomm_frame, hdr);
+ if (GET_PF(hdr.control)) {
+ if (!l2cap_frame_get_u8(&rfcomm_frame, &credits))
+ return false;
+ print_field("Credits %d", credits);
+ return true;
+ }
+ }
+
+ packet_hexdump(rfcomm_frame.data, rfcomm_frame.size);
return true;
}
--
1.9.1
Changes made to decode RFCOMM specific commands in btmon.
---
monitor/rfcomm.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 71 insertions(+), 2 deletions(-)
diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
index 7d38a28..395a7b8 100644
--- a/monitor/rfcomm.c
+++ b/monitor/rfcomm.c
@@ -44,18 +44,87 @@
#include "sdp.h"
#include "rfcomm.h"
+#define GET_LEN8(length) ((length & 0xfe) >> 1)
+#define GET_LEN16(length) ((length & 0xfffe) >> 1)
+
+struct rfcomm_lhdr {
+ uint8_t address;
+ uint8_t control;
+ uint16_t length;
+} __attribute__((packed));
+
const char *opcode_color;
+static void print_rfcomm_hdr(const struct l2cap_frame *frame,
+ struct rfcomm_lhdr hdr)
+{
+}
+
+static bool uih_frame(const struct l2cap_frame *frame, struct rfcomm_lhdr hdr)
+{
+ return true;
+}
+
void rfcomm_packet(const struct l2cap_frame *frame)
{
+ uint8_t ctr_type, length, ex_length;
+ const char *opcode_str;
+ struct rfcomm_lhdr hdr;
+ struct l2cap_frame rfcomm_frame;
+
+ l2cap_frame_pull(&rfcomm_frame, frame, 0);
+
+ if (!l2cap_frame_get_u8(&rfcomm_frame, &hdr.address) ||
+ !l2cap_frame_get_u8(&rfcomm_frame, &hdr.control) ||
+ !l2cap_frame_get_u8(&rfcomm_frame, &length))
+ goto fail;
+
+ if (RFCOMM_TEST_EA(length))
+ hdr.length = (uint16_t) GET_LEN8(length);
+ else {
+ if (!l2cap_frame_get_u8(&rfcomm_frame, &ex_length))
+ goto fail;
+ hdr.length = ((uint16_t)length << 8) | ex_length;
+ hdr.length = GET_LEN16(hdr.length);
+ }
+
if (frame->in)
opcode_color = COLOR_MAGENTA;
else
opcode_color = COLOR_BLUE;
- print_indent(7, opcode_color, "RFCOMM: ", "",
- COLOR_OFF, "");
+ ctr_type = RFCOMM_GET_TYPE(hdr.control);
+
+ if (ctr_type == RFCOMM_UIH) {
+ if (uih_frame(&rfcomm_frame, hdr))
+ return;
+ goto fail;
+ } else {
+ switch (ctr_type) {
+ case RFCOMM_SABM:
+ opcode_str = "SABM";
+ break;
+ case RFCOMM_UA:
+ opcode_str = "UA";
+ break;
+ case RFCOMM_DM:
+ opcode_str = "DM";
+ break;
+ case RFCOMM_DISC:
+ opcode_str = "DISC";
+ break;
+ default:
+ opcode_str = "ERR";
+ }
+
+ print_indent(7, opcode_color, "RFCOMM(s): ", opcode_str,
+ COLOR_OFF, "");
+ print_rfcomm_hdr(&rfcomm_frame, hdr);
+ return;
+ }
+fail:
+ print_text(COLOR_ERROR, "Frame too short");
packet_hexdump(frame->data, frame->size);
return;
}
--
1.9.1
Changes made to add initial code to support RFCOMM frame in btmon.
---
Makefile.tools | 1 +
monitor/l2cap.c | 4 ++++
monitor/l2cap.h | 1 +
monitor/rfcomm.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 67 insertions(+)
create mode 100644 monitor/rfcomm.c
diff --git a/Makefile.tools b/Makefile.tools
index 42cccc6..75a6faa 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -26,6 +26,7 @@ monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \
monitor/l2cap.h monitor/l2cap.c \
monitor/sdp.h monitor/sdp.c \
monitor/avctp.h monitor/avctp.c \
+ monitor/rfcomm.h monitor/rfcomm.c \
monitor/uuid.h monitor/uuid.c \
monitor/hwdb.h monitor/hwdb.c \
monitor/keys.h monitor/keys.c \
diff --git a/monitor/l2cap.c b/monitor/l2cap.c
index c004d6b..ebdd20f 100644
--- a/monitor/l2cap.c
+++ b/monitor/l2cap.c
@@ -42,6 +42,7 @@
#include "keys.h"
#include "sdp.h"
#include "avctp.h"
+#include "rfcomm.h"
#define MAX_CHAN 64
@@ -2643,6 +2644,9 @@ static void l2cap_frame(uint16_t index, bool in, uint16_t handle,
case 0x0001:
sdp_packet(&frame);
break;
+ case 0x0003:
+ rfcomm_packet(&frame);
+ break;
case 0x001f:
att_packet(index, in, handle, cid, data, size);
break;
diff --git a/monitor/l2cap.h b/monitor/l2cap.h
index 5faaea6..1f70b68 100644
--- a/monitor/l2cap.h
+++ b/monitor/l2cap.h
@@ -153,3 +153,4 @@ static inline bool l2cap_frame_get_le64(struct l2cap_frame *frame,
void l2cap_packet(uint16_t index, bool in, uint16_t handle, uint8_t flags,
const void *data, uint16_t size);
+void rfcomm_packet(const struct l2cap_frame *frame);
diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
new file mode 100644
index 0000000..7d38a28
--- /dev/null
+++ b/monitor/rfcomm.c
@@ -0,0 +1,61 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2011-2014 Intel Corporation
+ * Copyright (C) 2002-2010 Marcel Holtmann <[email protected]>
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <inttypes.h>
+
+#include <bluetooth/bluetooth.h>
+
+#include "src/shared/util.h"
+#include "bt.h"
+#include "packet.h"
+#include "display.h"
+#include "l2cap.h"
+#include "uuid.h"
+#include "keys.h"
+#include "sdp.h"
+#include "rfcomm.h"
+
+const char *opcode_color;
+
+void rfcomm_packet(const struct l2cap_frame *frame)
+{
+ if (frame->in)
+ opcode_color = COLOR_MAGENTA;
+ else
+ opcode_color = COLOR_BLUE;
+
+ print_indent(7, opcode_color, "RFCOMM: ", "",
+ COLOR_OFF, "");
+
+ packet_hexdump(frame->data, frame->size);
+ return;
+}
--
1.9.1