MAUSB dissector uses USB addresses
The MAUSB dissector now prints the USB address for MAUSB data packets in the Source & Destination columns. Before, the IP address was printed. All MAUSB data packets are now part of USB Conversations. Like the USB dissector, all data to & from one endpoint are part of the same conversation. Issues that need to be resolved: - In the case where multiple MAUSB packets exist in one TCP packet, only one USB address can be printed. - The USB conversations do not appear in the conversations window. They should appear under the USB conversations tab. Change-Id: I042daf7889cf70b3bbc450f9ccd974a0f93f4798 Reviewed-on: https://code.wireshark.org/review/1943 Reviewed-by: Evan Huus <eapache@gmail.com>
This commit is contained in:
parent
c6d175ef67
commit
c94d2e6848
|
@ -326,6 +326,11 @@ static const value_string mausb_type_string[] = {
|
|||
#define MAUSB_EP_HANDLE_DEV_ADDR 0x0fe0
|
||||
#define MAUSB_EP_HANDLE_BUS_NUM 0xf000
|
||||
|
||||
#define MAUSB_EP_HANDLE_D_OFFSET 0
|
||||
#define MAUSB_EP_HANDLE_EP_NUM_OFFSET 1
|
||||
#define MAUSB_EP_HANDLE_DEV_ADDR_OFFSET 5
|
||||
#define MAUSB_EP_HANDLE_BUS_NUM_OFFSET 12
|
||||
|
||||
static const value_string mausb_status_string[] = {
|
||||
{ 0, "SUCCESS (NO_ERROR)" },
|
||||
{ 128, "UNSUCCESSFUL" },
|
||||
|
@ -515,6 +520,16 @@ static gboolean mausb_is_data_pkt(struct mausb_header *header)
|
|||
return MAUSB_PKT_TYPE_DATA == (header->type & MAUSB_PKT_TYPE_MASK);
|
||||
}
|
||||
|
||||
/*** EP Handle parsing helper functions */
|
||||
|
||||
static guint8 mausb_ep_handle_ep_num(guint16 handle) {
|
||||
return (handle & MAUSB_EP_HANDLE_EP_NUM) >> MAUSB_EP_HANDLE_EP_NUM_OFFSET;
|
||||
}
|
||||
|
||||
static guint8 mausb_ep_handle_dev_addr(guint16 handle) {
|
||||
return (handle & MAUSB_EP_HANDLE_DEV_ADDR) >> MAUSB_EP_HANDLE_DEV_ADDR_OFFSET;
|
||||
}
|
||||
|
||||
/* returns the length field of the MAUSB packet */
|
||||
static guint mausb_get_pkt_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
|
||||
{
|
||||
|
@ -876,6 +891,30 @@ static guint16 dissect_mausb_mgmt_pkt_flds(struct mausb_header *header,
|
|||
return offset;
|
||||
}
|
||||
|
||||
static conversation_t
|
||||
*get_mausb_conversation(packet_info *pinfo, guint16 handle,
|
||||
gboolean is_data, gboolean req)
|
||||
{
|
||||
conversation_t *conversation;
|
||||
static usb_address_t src_addr, dst_addr; /* has to be static due to SET_ADDRESS */
|
||||
guint16 device_address;
|
||||
int endpoint;
|
||||
|
||||
/* Treat data packets the same as URBs */
|
||||
if (is_data) {
|
||||
device_address = mausb_ep_handle_dev_addr(handle);
|
||||
endpoint = mausb_ep_handle_ep_num(handle);
|
||||
|
||||
usb_set_addr(pinfo, &src_addr, &dst_addr, device_address, endpoint,
|
||||
req);
|
||||
conversation = get_usb_conversation(pinfo, &pinfo->src, &pinfo->dst,
|
||||
pinfo->srcport, pinfo->destport);
|
||||
}
|
||||
/* TODO: track control & managment packet conversations */
|
||||
|
||||
return conversation;
|
||||
}
|
||||
|
||||
/* Used to detect multiple MA Packets in a single TCP packet */
|
||||
/* Not used for MA Packets in SNAP Packets */
|
||||
static gint mausb_num_pdus = 0;
|
||||
|
@ -961,6 +1000,8 @@ 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));
|
||||
|
||||
if (mausb_is_mgmt_pkt(&header)) {
|
||||
|
||||
|
|
|
@ -1055,7 +1055,7 @@ get_usb_conv_info(conversation_t *conversation)
|
|||
return usb_conv_info;
|
||||
}
|
||||
|
||||
static conversation_t *
|
||||
conversation_t *
|
||||
get_usb_conversation(packet_info *pinfo,
|
||||
address *src_addr, address *dst_addr,
|
||||
guint32 src_endpoint, guint32 dst_endpoint)
|
||||
|
@ -2654,7 +2654,7 @@ dissect_win32_usb_pseudo_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t
|
|||
}
|
||||
|
||||
/* Set the usb_address_t fields based on the direction of the urb */
|
||||
static void
|
||||
void
|
||||
usb_set_addr(packet_info *pinfo, usb_address_t *src_addr,
|
||||
usb_address_t *dst_addr, guint16 device_address, int endpoint,
|
||||
gboolean req)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <epan/value_string.h>
|
||||
#include <epan/wmem/wmem.h>
|
||||
#include <epan/conversation.h>
|
||||
|
||||
typedef struct _usb_address_t {
|
||||
guint32 device;
|
||||
|
@ -194,6 +195,11 @@ typedef struct _usb_tap_data_t {
|
|||
#define ENDPOINT_TYPE_BULK 2
|
||||
#define ENDPOINT_TYPE_INTERRUPT 3
|
||||
|
||||
conversation_t *
|
||||
get_usb_conversation(packet_info *pinfo,
|
||||
address *src_addr, address *dst_addr,
|
||||
guint32 src_endpoint, guint32 dst_endpoint);
|
||||
|
||||
usb_conv_info_t *get_usb_iface_conv_info(packet_info *pinfo, guint8 interface_num);
|
||||
|
||||
proto_item * dissect_usb_descriptor_header(proto_tree *tree,
|
||||
|
@ -212,4 +218,10 @@ dissect_usb_unknown_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree,
|
|||
tvbuff_t *tvb, int offset,
|
||||
usb_trans_info_t *usb_trans_info _U_,
|
||||
usb_conv_info_t *usb_conv_info _U_);
|
||||
|
||||
void
|
||||
usb_set_addr(packet_info *pinfo, usb_address_t *src_addr,
|
||||
usb_address_t *dst_addr, guint16 device_address, int endpoint,
|
||||
gboolean req);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue