All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH hcidump 1/2] Add check to verify AVRCP pdu length matches frame length
@ 2011-07-12  8:07 Luiz Augusto von Dentz
  2011-07-12  8:07 ` [PATCH hcidump 2/2] Add parsing for AVRCP GetCapabilities Luiz Augusto von Dentz
  0 siblings, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2011-07-12  8:07 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 parser/avrcp.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/parser/avrcp.c b/parser/avrcp.c
index 0fa38d1..43e8a8b 100644
--- a/parser/avrcp.c
+++ b/parser/avrcp.c
@@ -226,6 +226,11 @@ static void avrcp_pdu_dump(int level, struct frame *frm, uint8_t ctype)
 
 	printf("AVRCP: %s: pt 0x%02x len 0x%04x\n", pdu2str(pduid), pt, len);
 
+	if (len != frm->len) {
+		p_indent(level, frm);
+		printf("PDU Malformed\n");
+	}
+
 	raw_dump(level, frm);
 }
 
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH hcidump 2/2] Add parsing for AVRCP GetCapabilities
  2011-07-12  8:07 [PATCH hcidump 1/2] Add check to verify AVRCP pdu length matches frame length Luiz Augusto von Dentz
@ 2011-07-12  8:07 ` Luiz Augusto von Dentz
  2011-07-12 12:01   ` Lucas De Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2011-07-12  8:07 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 parser/avrcp.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 57 insertions(+), 1 deletions(-)

diff --git a/parser/avrcp.c b/parser/avrcp.c
index 43e8a8b..9529b33 100644
--- a/parser/avrcp.c
+++ b/parser/avrcp.c
@@ -213,6 +213,54 @@ static const char *pdu2str(uint8_t pduid)
 	}
 }
 
+static char *cap2str(uint8_t cap)
+{
+	switch (cap) {
+	case 0x2:
+		return "CompanyID";
+	case 0x3:
+		return "EventsID";
+	default:
+		return "Unknown";
+	}
+}
+
+static void avrcp_get_capabilities_dump(int level, struct frame *frm, uint16_t len)
+{
+	uint8_t cap;
+	uint8_t count;
+
+	p_indent(level, frm);
+
+	if (len < 1) {
+		printf("PDU Malformed\n");
+		raw_dump(level, frm);
+		return;
+	}
+
+	cap = get_u8(frm);
+	printf("Capability ID: 0x%02x (%s)\n", cap, cap2str(cap));
+
+	if (len == 1)
+		return;
+
+	p_indent(level, frm);
+
+	count = get_u8(frm);
+	printf("Capability Count: 0x%02x\n", count);
+
+	for (; count > 0; count--) {
+		int i;
+
+		p_indent(level, frm);
+
+		printf("%s: 0x", cap2str(cap));
+		for (i = 0; i < 3; i++)
+			printf("0x%02x", get_u8(frm));
+		printf("\n");
+	}
+}
+
 static void avrcp_pdu_dump(int level, struct frame *frm, uint8_t ctype)
 {
 	uint8_t pduid, pt;
@@ -229,9 +277,17 @@ static void avrcp_pdu_dump(int level, struct frame *frm, uint8_t ctype)
 	if (len != frm->len) {
 		p_indent(level, frm);
 		printf("PDU Malformed\n");
+		raw_dump(level, frm);
+		return;
 	}
 
-	raw_dump(level, frm);
+	switch (pduid) {
+	case AVRCP_GET_CAPABILITIES:
+		avrcp_get_capabilities_dump(level + 1, frm, len);
+		break;
+	default:
+		raw_dump(level, frm);
+	}
 }
 
 static char *op2str(uint8_t op)
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH hcidump 2/2] Add parsing for AVRCP GetCapabilities
  2011-07-12  8:07 ` [PATCH hcidump 2/2] Add parsing for AVRCP GetCapabilities Luiz Augusto von Dentz
@ 2011-07-12 12:01   ` Lucas De Marchi
  2011-07-12 12:32     ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 4+ messages in thread
From: Lucas De Marchi @ 2011-07-12 12:01 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

On Tue, Jul 12, 2011 at 5:07 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> ---
>  parser/avrcp.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 57 insertions(+), 1 deletions(-)
>
> diff --git a/parser/avrcp.c b/parser/avrcp.c
> index 43e8a8b..9529b33 100644
> --- a/parser/avrcp.c
> +++ b/parser/avrcp.c
> @@ -213,6 +213,54 @@ static const char *pdu2str(uint8_t pduid)
>        }
>  }
>
> +static char *cap2str(uint8_t cap)
> +{
> +       switch (cap) {
> +       case 0x2:
> +               return "CompanyID";
> +       case 0x3:
> +               return "EventsID";
> +       default:
> +               return "Unknown";
> +       }
> +}
> +
> +static void avrcp_get_capabilities_dump(int level, struct frame *frm, uint16_t len)
> +{
> +       uint8_t cap;
> +       uint8_t count;
> +
> +       p_indent(level, frm);
> +
> +       if (len < 1) {
> +               printf("PDU Malformed\n");
> +               raw_dump(level, frm);
> +               return;
> +       }
> +
> +       cap = get_u8(frm);
> +       printf("Capability ID: 0x%02x (%s)\n", cap, cap2str(cap));
> +
> +       if (len == 1)
> +               return;
> +
> +       p_indent(level, frm);
> +
> +       count = get_u8(frm);
> +       printf("Capability Count: 0x%02x\n", count);
> +
> +       for (; count > 0; count--) {
> +               int i;
> +
> +               p_indent(level, frm);
> +
> +               printf("%s: 0x", cap2str(cap));
> +               for (i = 0; i < 3; i++)
> +                       printf("0x%02x", get_u8(frm));

Whouldn't it be better to print the company id as a whole instead of split it?

Also, if it is a response to EVENTS_SUPPORTED, this field is not
3-byte long (table 5.5 of AVRCP 1.3).


Lucas De Marchi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH hcidump 2/2] Add parsing for AVRCP GetCapabilities
  2011-07-12 12:01   ` Lucas De Marchi
@ 2011-07-12 12:32     ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2011-07-12 12:32 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-bluetooth

Hi Lucas,

On Tue, Jul 12, 2011 at 3:01 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> On Tue, Jul 12, 2011 at 5:07 AM, Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> ---
>>  parser/avrcp.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>>  1 files changed, 57 insertions(+), 1 deletions(-)
>>
>> diff --git a/parser/avrcp.c b/parser/avrcp.c
>> index 43e8a8b..9529b33 100644
>> --- a/parser/avrcp.c
>> +++ b/parser/avrcp.c
>> @@ -213,6 +213,54 @@ static const char *pdu2str(uint8_t pduid)
>>        }
>>  }
>>
>> +static char *cap2str(uint8_t cap)
>> +{
>> +       switch (cap) {
>> +       case 0x2:
>> +               return "CompanyID";
>> +       case 0x3:
>> +               return "EventsID";
>> +       default:
>> +               return "Unknown";
>> +       }
>> +}
>> +
>> +static void avrcp_get_capabilities_dump(int level, struct frame *frm, uint16_t len)
>> +{
>> +       uint8_t cap;
>> +       uint8_t count;
>> +
>> +       p_indent(level, frm);
>> +
>> +       if (len < 1) {
>> +               printf("PDU Malformed\n");
>> +               raw_dump(level, frm);
>> +               return;
>> +       }
>> +
>> +       cap = get_u8(frm);
>> +       printf("Capability ID: 0x%02x (%s)\n", cap, cap2str(cap));
>> +
>> +       if (len == 1)
>> +               return;
>> +
>> +       p_indent(level, frm);
>> +
>> +       count = get_u8(frm);
>> +       printf("Capability Count: 0x%02x\n", count);
>> +
>> +       for (; count > 0; count--) {
>> +               int i;
>> +
>> +               p_indent(level, frm);
>> +
>> +               printf("%s: 0x", cap2str(cap));
>> +               for (i = 0; i < 3; i++)
>> +                       printf("0x%02x", get_u8(frm));
>
> Whouldn't it be better to print the company id as a whole instead of split it?

Its a bug, Im actually following the spec examples how to display the
company ids e.g 0xXXXXXX

> Also, if it is a response to EVENTS_SUPPORTED, this field is not
> 3-byte long (table 5.5 of AVRCP 1.3).

Yep, I was planning to add it latter but I guess it makes more to
sense add only complete pdu parsers, btw lets use the latest adopted
spec (1.4) as reference.



-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-07-12 12:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-12  8:07 [PATCH hcidump 1/2] Add check to verify AVRCP pdu length matches frame length Luiz Augusto von Dentz
2011-07-12  8:07 ` [PATCH hcidump 2/2] Add parsing for AVRCP GetCapabilities Luiz Augusto von Dentz
2011-07-12 12:01   ` Lucas De Marchi
2011-07-12 12:32     ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.