aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorSean O. Stalley <sean.stalley@intel.com>2014-06-05 17:01:46 -0700
committerEvan Huus <eapache@gmail.com>2014-06-09 20:08:49 +0000
commit3c37630c77154c50802ca4cdcfd8ea7b8f34af86 (patch)
tree2b8982bb7906d9d5097bdf12edc81dc5a3d3cf63 /epan
parentc9621e2befaba0543b5351f4fece3f7ef5c52c6b (diff)
downloadwireshark-3c37630c77154c50802ca4cdcfd8ea7b8f34af86.tar.gz
wireshark-3c37630c77154c50802ca4cdcfd8ea7b8f34af86.tar.bz2
wireshark-3c37630c77154c50802ca4cdcfd8ea7b8f34af86.zip
Dissection of USB setup data in MA USB data packets
This patch adds support for dissection of USB setup data contained inside of MA USB data packets. The MAUSB Dissector calls the same function used by the USB dissector to dissect the setup data. This patch also (and a bit unintentionally) adds transfer following. TransferReq & TransferAck packets now show a link & a time delta to their TransferReq (ie [Request in: XXX] & [Time from request: XXX]. TransferReq packets have a [Response in: XXX] tag, but it erronously points to the TransferAck, not the TransferResponse. Change-Id: I01041de3c38ea6248e9d34506b0b012518a1e6d8 Reviewed-on: https://code.wireshark.org/review/1548 Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-mausb.c57
-rw-r--r--epan/dissectors/packet-usb.c6
-rw-r--r--epan/dissectors/packet-usb.h12
3 files changed, 70 insertions, 5 deletions
diff --git a/epan/dissectors/packet-mausb.c b/epan/dissectors/packet-mausb.c
index 97e0e87570..b79e251784 100644
--- a/epan/dissectors/packet-mausb.c
+++ b/epan/dissectors/packet-mausb.c
@@ -519,6 +519,28 @@ static gboolean mausb_is_data_pkt(struct mausb_header *header)
return MAUSB_PKT_TYPE_DATA == (header->type & MAUSB_PKT_TYPE_MASK);
}
+static gboolean mausb_is_transfer_req(struct mausb_header *header)
+{
+ return TransferReq == header->type;
+}
+
+static gint8 mausb_tx_type(struct mausb_header *header)
+{
+ return (header->u.s.eps_tflags >> MAUSB_TFLAG_OFFSET) & MAUSB_TFLAG_TRANSFER_TYPE;
+}
+
+static gboolean mausb_has_setup_data(struct mausb_header *header)
+{
+ if ((TransferReq == header->type ) &&
+ (mausb_is_from_host(header)) &&
+ (0 == header->u.s.seq_num) &&
+ (MAUSB_TX_TYPE_CTRL == mausb_tx_type(header))) {
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
/*** EP Handle parsing helper functions */
static guint8 mausb_ep_handle_ep_num(guint16 handle) {
@@ -929,11 +951,18 @@ dissect_mausb_pkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree *mausb_tree;
proto_tree *flags_tree;
proto_tree *tflags_tree;
+ proto_tree *setup_tree;
/* Other misc. local variables. */
struct mausb_header header;
gint offset = 0;
gint payload_len;
+ /* Variables needed to follow the conversation */
+ usb_conv_info_t *usb_conv_info = NULL;
+ usb_trans_info_t *usb_trans_info = NULL;
+ conversation_t *conversation;
+
+
memset(&header, 0, sizeof(struct mausb_header));
/* Set the Protocol column to the constant string of mausb */
@@ -942,6 +971,7 @@ dissect_mausb_pkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
mausb_num_pdus++;
col_add_str(pinfo->cinfo, COL_INFO, "[");
+ col_set_fence(pinfo->cinfo, COL_INFO);
/*** PROTOCOL TREE ***/
@@ -996,8 +1026,25 @@ dissect_mausb_pkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* Is the next field a device handle or an endpoint handle */
header.handle = tvb_get_letohs(tvb, offset);
- get_mausb_conversation(pinfo, header.handle, mausb_is_data_pkt(&header),
- mausb_is_from_host(&header));
+
+ /* Once we have the endpoint/device handle,
+ * we can find the right conversation */
+ conversation = get_mausb_conversation(pinfo, header.handle,
+ mausb_is_data_pkt(&header),
+ mausb_is_from_host(&header));
+
+ /* If there is a usb conversation, find it */
+ if (mausb_is_data_pkt(&header)) {
+
+ usb_conv_info = get_usb_conv_info(conversation);
+
+ /* TODO: set all the usb_conv_info values */
+ usb_conv_info->is_request = mausb_is_transfer_req(&header);
+
+ usb_trans_info = usb_get_trans_info(tvb, pinfo, tree, 0, usb_conv_info);
+ usb_conv_info->usb_trans_info = usb_trans_info;
+ }
+
if (mausb_is_mgmt_pkt(&header)) {
@@ -1116,6 +1163,12 @@ dissect_mausb_pkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* Presentation Time (iso) */
/* Number of Segments (iso) */
+ /* If this packet contains USB Setup Data */
+ if (mausb_has_setup_data(&header)) {
+ offset = dissect_usb_setup_request(pinfo, mausb_tree, tvb, offset,
+ usb_conv_info, &setup_tree);
+ }
+
/*
* TODO: dissect MA USB Payload with USB class dissectors
* (ex: MBIM, USB Audio, etc.)
diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c
index a59b5860ce..272dce70ff 100644
--- a/epan/dissectors/packet-usb.c
+++ b/epan/dissectors/packet-usb.c
@@ -1032,7 +1032,7 @@ static decode_as_t usb_protocol_da = {
decode_as_default_change, NULL};
-static usb_conv_info_t *
+usb_conv_info_t *
get_usb_conv_info(conversation_t *conversation)
{
usb_conv_info_t *usb_conv_info;
@@ -2618,7 +2618,7 @@ dissect_usb_bmrequesttype(proto_tree *parent_tree, tvbuff_t *tvb, int offset, in
}
/* Dissector used for usb setup requests */
-static int
+int
dissect_usb_setup_request(packet_info *pinfo, proto_tree *parent, tvbuff_t *tvb,
int offset, usb_conv_info_t *usb_conv_info, proto_tree **setup_tree)
{
@@ -2842,7 +2842,7 @@ usb_set_addr(packet_info *pinfo, usb_address_t *src_addr,
/* Gets the transfer info for a given packet
* Generates transfer info if none exists yet
* Also adds request/response info to the tree for the given packet */
-static usb_trans_info_t
+usb_trans_info_t
*usb_get_trans_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint8 header_info, usb_conv_info_t *usb_conv_info)
{
diff --git a/epan/dissectors/packet-usb.h b/epan/dissectors/packet-usb.h
index 3ec9e520c0..ed9658dac2 100644
--- a/epan/dissectors/packet-usb.h
+++ b/epan/dissectors/packet-usb.h
@@ -195,6 +195,9 @@ typedef struct _usb_tap_data_t {
#define ENDPOINT_TYPE_BULK 2
#define ENDPOINT_TYPE_INTERRUPT 3
+usb_conv_info_t *
+get_usb_conv_info(conversation_t *conversation);
+
conversation_t *
get_usb_conversation(packet_info *pinfo,
address *src_addr, address *dst_addr,
@@ -219,9 +222,18 @@ dissect_usb_unknown_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree,
usb_trans_info_t *usb_trans_info _U_,
usb_conv_info_t *usb_conv_info _U_);
+int
+dissect_usb_setup_request(packet_info *pinfo, proto_tree *parent, tvbuff_t *tvb,
+ int offset, usb_conv_info_t *usb_conv_info, proto_tree **setup_tree);
+
void
usb_set_addr(packet_info *pinfo, usb_address_t *src_addr,
usb_address_t *dst_addr, guint16 device_address, int endpoint,
gboolean req);
+usb_trans_info_t
+*usb_get_trans_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
+ guint8 header_info, usb_conv_info_t *usb_conv_info);
+
+
#endif