2011-08-01 15:43:51

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH hcidump 01/13 v2] Don't parse response AVRCP pdu if ctype is NOT_IMPLETED

From: Luiz Augusto von Dentz <[email protected]>

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

diff --git a/parser/avrcp.c b/parser/avrcp.c
index ff6862d..1b3afad 100644
--- a/parser/avrcp.c
+++ b/parser/avrcp.c
@@ -473,6 +473,12 @@ void avrcp_dump(int level, struct frame *frm)
return;
}

+ /* Not implemented should not contain any operand */
+ if (ctype == AVC_CTYPE_NOT_IMPLEMENTED) {
+ raw_dump(level, frm);
+ return;
+ }
+
switch (opcode) {
case AVC_OP_PASSTHROUGH:
avrcp_passthrough_dump(level + 1, frm);
--
1.7.6



2011-08-03 11:01:48

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH hcidump 01/13 v2] Don't parse response AVRCP pdu if ctype is NOT_IMPLETED

Hi Luiz,

On Mon, Aug 01, 2011, Luiz Augusto von Dentz wrote:
> ---
> parser/avrcp.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)

All of these patches have been applied. Thanks.

Johan

2011-08-01 15:45:02

by Lucas De Marchi

[permalink] [raw]
Subject: Re: [PATCH hcidump 01/13 v2] Don't parse response AVRCP pdu if ctype is NOT_IMPLETED

On Mon, Aug 1, 2011 at 12:43 PM, Luiz Augusto von Dentz
<[email protected]> wrote:
> From: Luiz Augusto von Dentz <[email protected]>
>
> ---
> ?parser/avrcp.c | ? ?6 ++++++
> ?1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/parser/avrcp.c b/parser/avrcp.c
> index ff6862d..1b3afad 100644
> --- a/parser/avrcp.c
> +++ b/parser/avrcp.c
> @@ -473,6 +473,12 @@ void avrcp_dump(int level, struct frame *frm)
> ? ? ? ? ? ? ? ?return;
> ? ? ? ?}
>
> + ? ? ? /* Not implemented should not contain any operand */
> + ? ? ? if (ctype == AVC_CTYPE_NOT_IMPLEMENTED) {
> + ? ? ? ? ? ? ? raw_dump(level, frm);
> + ? ? ? ? ? ? ? return;
> + ? ? ? }
> +

Now it seems good.


thanks,
Lucas De Marchi

2011-08-01 15:43:52

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH hcidump 02/13 v2] Add parsing for command type rejected AVRCP responses

From: Luiz Augusto von Dentz <[email protected]>

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

diff --git a/parser/avrcp.c b/parser/avrcp.c
index 1b3afad..2b1cb40 100644
--- a/parser/avrcp.c
+++ b/parser/avrcp.c
@@ -126,6 +126,30 @@
#define AVRCP_EVENT_UIDS_CHANGED 0x0c
#define AVRCP_EVENT_VOLUME_CHANGED 0x0d

+/* error statuses */
+#define AVRCP_STATUS_INVALID_COMMAND 0x00
+#define AVRCP_STATUS_INVALID_PARAMETER 0x01
+#define AVRCP_STATUS_NOT_FOUND 0x02
+#define AVRCP_STATUS_INTERNAL_ERROR 0x03
+#define AVRCP_STATUS_SUCCESS 0x04
+#define AVRCP_STATUS_UID_CHANGED 0x05
+#define AVRCP_STATUS_INVALID_DIRECTION 0x07
+#define AVRCP_STATUS_NOT_DIRECTORY 0x08
+#define AVRCP_STATUS_DOES_NOT_EXIST 0x09
+#define AVRCP_STATUS_INVALID_SCOPE 0x0a
+#define AVRCP_STATUS_OUT_OF_BOUNDS 0x0b
+#define AVRCP_STATUS_IS_DIRECTORY 0x0c
+#define AVRCP_STATUS_MEDIA_IN_USE 0x0d
+#define AVRCP_STATUS_NOW_PLAYING_LIST_FULL 0x0e
+#define AVRCP_STATUS_SEARCH_NOT_SUPPORTED 0x0f
+#define AVRCP_STATUS_SEARCH_IN_PROGRESS 0x10
+#define AVRCP_STATUS_INVALID_PLAYER_ID 0x11
+#define AVRCP_STATUS_PLAYER_NOT_BROWSABLE 0x12
+#define AVRCP_STATUS_PLAYER_NOT_ADDRESSED 0x13
+#define AVRCP_STATUS_NO_VALID_SEARCH_RESULTS 0x14
+#define AVRCP_STATUS_NO_AVAILABLE_PLAYERS 0x15
+#define AVRCP_STATUS_ADDRESSED_PLAYER_CHANGED 0x16
+
static const char *ctype2str(uint8_t ctype)
{
switch (ctype & 0x0f) {
@@ -274,6 +298,74 @@ static char *event2str(uint8_t event)
}
}

+static const char *error2str(uint8_t status)
+{
+ switch (status) {
+ case AVRCP_STATUS_INVALID_COMMAND:
+ return "Invalid Command";
+ case AVRCP_STATUS_INVALID_PARAMETER:
+ return "Invalid Parameter";
+ case AVRCP_STATUS_NOT_FOUND:
+ return "Not Found";
+ case AVRCP_STATUS_INTERNAL_ERROR:
+ return "Internal Error";
+ case AVRCP_STATUS_SUCCESS:
+ return "Success";
+ case AVRCP_STATUS_UID_CHANGED:
+ return "UID Changed";
+ case AVRCP_STATUS_INVALID_DIRECTION:
+ return "Invalid Direction";
+ case AVRCP_STATUS_NOT_DIRECTORY:
+ return "Not a Directory";
+ case AVRCP_STATUS_DOES_NOT_EXIST:
+ return "Does Not Exist";
+ case AVRCP_STATUS_INVALID_SCOPE:
+ return "Invalid Scope";
+ case AVRCP_STATUS_OUT_OF_BOUNDS:
+ return "Range Out of Bonds";
+ case AVRCP_STATUS_MEDIA_IN_USE:
+ return "Media in Use";
+ case AVRCP_STATUS_IS_DIRECTORY:
+ return "UID is a Directory";
+ case AVRCP_STATUS_NOW_PLAYING_LIST_FULL:
+ return "Now Playing List Full";
+ case AVRCP_STATUS_SEARCH_NOT_SUPPORTED:
+ return "Seach Not Supported";
+ case AVRCP_STATUS_SEARCH_IN_PROGRESS:
+ return "Search in Progress";
+ case AVRCP_STATUS_INVALID_PLAYER_ID:
+ return "Invalid Player ID";
+ case AVRCP_STATUS_PLAYER_NOT_BROWSABLE:
+ return "Player Not Browsable";
+ case AVRCP_STATUS_PLAYER_NOT_ADDRESSED:
+ return "Player Not Addressed";
+ case AVRCP_STATUS_NO_VALID_SEARCH_RESULTS:
+ return "No Valid Search Result";
+ case AVRCP_STATUS_NO_AVAILABLE_PLAYERS:
+ return "No Available Players";
+ case AVRCP_STATUS_ADDRESSED_PLAYER_CHANGED:
+ return "Addressed Player Changed";
+ default:
+ return "Unknown";
+ }
+}
+
+static void avrcp_rejected_dump(int level, struct frame *frm, uint16_t len)
+{
+ uint8_t status;
+
+ p_indent(level, frm);
+
+ if (len < 1) {
+ printf("PDU Malformed\n");
+ raw_dump(level, frm);
+ return;
+ }
+
+ status = get_u8(frm);
+ printf("Error: 0x%02x (%s)\n", status, error2str(status));
+}
+
static void avrcp_get_capabilities_dump(int level, struct frame *frm, uint16_t len)
{
uint8_t cap;
@@ -347,6 +439,11 @@ static void avrcp_pdu_dump(int level, struct frame *frm, uint8_t ctype)
return;
}

+ if (ctype == AVC_CTYPE_REJECTED) {
+ avrcp_rejected_dump(level + 1, frm, len);
+ return;
+ }
+
switch (pduid) {
case AVRCP_GET_CAPABILITIES:
avrcp_get_capabilities_dump(level + 1, frm, len);
--
1.7.6