aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-mausb.c
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/dissectors/packet-mausb.c
parentc9621e2befaba0543b5351f4fece3f7ef5c52c6b (diff)
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/dissectors/packet-mausb.c')
-rw-r--r--epan/dissectors/packet-mausb.c57
1 files changed, 55 insertions, 2 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.)