summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Labedzki <michal.labedzki@tieto.com>2014-12-17 16:12:41 +0100
committerMichal Labedzki <michal.labedzki@tieto.com>2015-01-10 15:34:24 +0000
commit7177cedc269ed9fa03fd5f6abfc5b7a2df39e38c (patch)
tree3776fabd550cbafd89626aa8a6ef84a2c6d5e17f
parentc93d0ab880263ec9a829e763b7fc38fc555db8ad (diff)
downloadwireshark-7177cedc269ed9fa03fd5f6abfc5b7a2df39e38c.tar.gz
USB: Fix Conversation/Endpoint filters
There were not fields for that, so simple add them. Change-Id: I489bae24ac96ea0baf395add731f4d62ccf19352 Reviewed-on: https://code.wireshark.org/review/6401 Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com> Tested-by: Michal Labedzki <michal.labedzki@tieto.com> Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
-rw-r--r--epan/conversation_table.c6
-rw-r--r--epan/dissectors/packet-mausb.c8
-rw-r--r--epan/dissectors/packet-usb.c54
-rw-r--r--epan/dissectors/packet-usb.h2
4 files changed, 52 insertions, 18 deletions
diff --git a/epan/conversation_table.c b/epan/conversation_table.c
index cc77cd1745..ad6f5acedc 100644
--- a/epan/conversation_table.c
+++ b/epan/conversation_table.c
@@ -414,14 +414,14 @@ const char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e dir
src_addr = address_to_str(NULL, &conv_item->src_address);
dst_addr = address_to_str(NULL, &conv_item->dst_address);
- if (conv_item->src_address.type == AT_STRINGZ) {
+ if (conv_item->src_address.type == AT_STRINGZ || conv_item->src_address.type == AT_USB) {
char *new_addr;
new_addr = wmem_strdup_printf(NULL, "\"%s\"", src_addr);
wmem_free(NULL, src_addr);
src_addr = new_addr;
}
- if (conv_item->dst_address.type == AT_STRINGZ) {
+ if (conv_item->dst_address.type == AT_STRINGZ || conv_item->src_address.type == AT_USB) {
char *new_addr;
new_addr = wmem_strdup_printf(NULL, "\"%s\"", dst_addr);
@@ -564,7 +564,7 @@ const char *get_hostlist_filter(hostlist_talker_t *host)
sport=ct_port_to_str(host->ptype, host->port);
src_addr = address_to_str(NULL, &host->myaddress);
- if (host->myaddress.type == AT_STRINGZ) {
+ if (host->myaddress.type == AT_STRINGZ || host->myaddress.type == AT_USB) {
char *new_addr;
new_addr = wmem_strdup_printf(NULL, "\"%s\"", src_addr);
diff --git a/epan/dissectors/packet-mausb.c b/epan/dissectors/packet-mausb.c
index 35fd890149..d0f72b9c82 100644
--- a/epan/dissectors/packet-mausb.c
+++ b/epan/dissectors/packet-mausb.c
@@ -1113,8 +1113,8 @@ static guint16 dissect_mausb_mgmt_pkt_flds(struct mausb_header *header,
}
static conversation_t
-*get_mausb_conversation(packet_info *pinfo, guint16 handle,
- gboolean is_data, gboolean req)
+*get_mausb_conversation(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo,
+ guint16 handle, gboolean is_data, gboolean req)
{
conversation_t *conversation = NULL;
guint16 device_address;
@@ -1127,7 +1127,7 @@ static conversation_t
endpoint = mausb_ep_handle_ep_num(handle);
bus_num = mausb_ep_handle_bus_num(handle);
- usb_set_addr(pinfo, bus_num, device_address, endpoint, req);
+ usb_set_addr(tree, tvb, pinfo, bus_num, device_address, endpoint, req);
conversation = get_usb_conversation(pinfo, &pinfo->src, &pinfo->dst,
pinfo->srcport, pinfo->destport);
}
@@ -1228,7 +1228,7 @@ dissect_mausb_pkt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* Once we have the endpoint/device handle,
* we can find the right conversation */
- conversation = get_mausb_conversation(pinfo, header.handle,
+ conversation = get_mausb_conversation(mausb_tree, tvb, pinfo, header.handle,
mausb_is_data_pkt(&header),
mausb_is_from_host(&header));
diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c
index 44988c0aba..9e60b13ef3 100644
--- a/epan/dissectors/packet-usb.c
+++ b/epan/dissectors/packet-usb.c
@@ -172,6 +172,9 @@ static int hf_usb_bFunctionSubClass = -1;
static int hf_usb_bFunctionProtocol = -1;
static int hf_usb_iFunction = -1;
static int hf_usb_data_fragment = -1;
+static int hf_usb_src = -1;
+static int hf_usb_dst = -1;
+static int hf_usb_addr = -1;
static gint usb_hdr = -1;
static gint usb_setup_hdr = -1;
@@ -1124,7 +1127,6 @@ static void clear_usb_conv_tmp_data(usb_conv_info_t *usb_conv_info)
}
}
-
conversation_t *
get_usb_conversation(packet_info *pinfo,
address *src_addr, address *dst_addr,
@@ -1172,10 +1174,10 @@ get_usb_iface_conv_info(packet_info *pinfo, guint8 interface_num)
static const char* usb_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter)
{
if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == AT_USB))
- return "usb.sa";
+ return "usb.src";
if ((filter == CONV_FT_DST_ADDRESS) && (conv->dst_address.type == AT_USB))
- return "usb.da";
+ return "usb.dst";
if ((filter == CONV_FT_ANY_ADDRESS) && (conv->src_address.type == AT_USB))
return "usb.addr";
@@ -2770,7 +2772,6 @@ try_dissect_next_protocol(proto_tree *tree, tvbuff_t *next_tvb, packet_info *pin
usb_conv_info = get_usb_conv_info(conversation);
usb_conv_info->usb_trans_info = usb_trans_info;
-
}
else {
/* the recipient is "other" or "reserved"
@@ -3106,11 +3107,14 @@ dissect_usbpcap_buffer_packet_header(tvbuff_t *tvb, packet_info *pinfo, proto_tr
/* Set the usb_address_t fields based on the direction of the urb */
void
-usb_set_addr(packet_info *pinfo, guint16 bus_id, guint16 device_address,
+usb_set_addr(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, guint16 bus_id, guint16 device_address,
int endpoint, gboolean req)
{
+ proto_item *sub_item;
usb_address_t *src_addr = wmem_new(pinfo->pool, usb_address_t),
*dst_addr = wmem_new(pinfo->pool, usb_address_t);
+ guint8 *str_src_addr;
+ guint8 *str_dst_addr;
if (req) {
/* request */
@@ -3135,6 +3139,21 @@ usb_set_addr(packet_info *pinfo, guint16 bus_id, guint16 device_address,
pinfo->ptype = PT_USB;
pinfo->srcport = src_addr->endpoint;
pinfo->destport = dst_addr->endpoint;
+
+ str_src_addr = address_to_str(wmem_packet_scope(), &pinfo->src);
+ str_dst_addr = address_to_str(wmem_packet_scope(), &pinfo->dst);
+
+ sub_item = proto_tree_add_string(tree, hf_usb_src, tvb, 0, 0, str_src_addr);
+ PROTO_ITEM_SET_GENERATED(sub_item);
+
+ sub_item = proto_tree_add_string(tree, hf_usb_addr, tvb, 0, 0, str_src_addr);
+ PROTO_ITEM_SET_HIDDEN(sub_item);
+
+ sub_item = proto_tree_add_string(tree, hf_usb_dst, tvb, 0, 0, str_dst_addr);
+ PROTO_ITEM_SET_GENERATED(sub_item);
+
+ sub_item = proto_tree_add_string(tree, hf_usb_addr, tvb, 0, 0, str_dst_addr);
+ PROTO_ITEM_SET_HIDDEN(sub_item);
}
@@ -3439,7 +3458,11 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
else
return; /* invalid USB pseudo header */
- usb_set_addr(pinfo, bus_id, device_address, endpoint,
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "USB");
+ urb_tree_ti = proto_tree_add_protocol_format(parent, proto_usb, tvb, 0, -1, "USB URB");
+ tree = proto_item_add_subtree(urb_tree_ti, usb_hdr);
+
+ usb_set_addr(tree, tvb, pinfo, bus_id, device_address, endpoint,
(urb_type == URB_SUBMIT));
conversation = get_usb_conversation(pinfo, &pinfo->src, &pinfo->dst, pinfo->srcport, pinfo->destport);
@@ -3447,10 +3470,6 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
clear_usb_conv_tmp_data(usb_conv_info);
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "USB");
- urb_tree_ti = proto_tree_add_protocol_format(parent, proto_usb, tvb, 0, -1, "USB URB");
- tree = proto_item_add_subtree(urb_tree_ti, usb_hdr);
-
if (header_info & USB_HEADER_IS_LINUX) {
proto_item_set_len(urb_tree_ti, (header_info&USB_HEADER_IS_64_BYTES) ? 64 : 48);
offset = dissect_linux_usb_pseudo_header(tvb, pinfo, tree, usb_conv_info);
@@ -4255,6 +4274,21 @@ proto_register_usb(void)
{ "Data Fragment",
"usb.data_fragment", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
+ { &hf_usb_src,
+ { "Source", "usb.src",
+ FT_STRING, STR_ASCII, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_usb_dst,
+ { "Destination", "usb.dst",
+ FT_STRING, STR_ASCII, NULL, 0x0,
+ NULL, HFILL }
+ },
+ { &hf_usb_addr,
+ { "Source or Destination", "usb.addr",
+ FT_STRING, STR_ASCII, NULL, 0x0,
+ NULL, HFILL }
+ }
};
static gint *usb_subtrees[] = {
diff --git a/epan/dissectors/packet-usb.h b/epan/dissectors/packet-usb.h
index 1e07dfce14..b499132aad 100644
--- a/epan/dissectors/packet-usb.h
+++ b/epan/dissectors/packet-usb.h
@@ -239,7 +239,7 @@ dissect_usb_setup_request(packet_info *pinfo, proto_tree *tree,
void
-usb_set_addr(packet_info *pinfo, guint16 bus_id, guint16 device_address,
+usb_set_addr(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, guint16 bus_id, guint16 device_address,
int endpoint, gboolean req);
usb_trans_info_t