Convert the USB dissectors to wmem.
svn path=/trunk/; revision=51042
This commit is contained in:
parent
9bb17b7b2b
commit
bc7c14a2a1
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <epan/conversation.h>
|
||||
#include <epan/emem.h>
|
||||
#include <epan/expert.h>
|
||||
#include <epan/packet.h>
|
||||
#include <epan/reassemble.h>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <epan/packet.h>
|
||||
#include <epan/emem.h>
|
||||
#include <epan/wmem/wmem.h>
|
||||
#include <epan/conversation.h>
|
||||
#include "packet-usb.h"
|
||||
#include "packet-scsi.h"
|
||||
|
@ -52,8 +52,8 @@ static gint ett_usb_ms = -1;
|
|||
|
||||
/* there is one such structure for each masstorage conversation */
|
||||
typedef struct _usb_ms_conv_info_t {
|
||||
emem_tree_t *itl; /* indexed by LUN */
|
||||
emem_tree_t *itlq; /* pinfo->fd->num */
|
||||
wmem_tree_t *itl; /* indexed by LUN */
|
||||
wmem_tree_t *itlq; /* pinfo->fd->num */
|
||||
} usb_ms_conv_info_t;
|
||||
|
||||
|
||||
|
@ -192,9 +192,9 @@ dissect_usb_ms_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
/* verify that we do have a usb_ms_conv_info */
|
||||
usb_ms_conv_info=(usb_ms_conv_info_t *)usb_conv_info->class_data;
|
||||
if(!usb_ms_conv_info){
|
||||
usb_ms_conv_info=se_new(usb_ms_conv_info_t);
|
||||
usb_ms_conv_info->itl=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "USB ITL");
|
||||
usb_ms_conv_info->itlq=se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "USB ITLQ");
|
||||
usb_ms_conv_info=wmem_new(wmem_file_scope(), usb_ms_conv_info_t);
|
||||
usb_ms_conv_info->itl=wmem_tree_new(wmem_file_scope());
|
||||
usb_ms_conv_info->itlq=wmem_tree_new(wmem_file_scope());
|
||||
usb_conv_info->class_data=usb_ms_conv_info;
|
||||
}
|
||||
|
||||
|
@ -249,18 +249,18 @@ dissect_usb_ms_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
offset+=1;
|
||||
|
||||
/* make sure we have a ITL structure for this LUN */
|
||||
itl=(itl_nexus_t *)se_tree_lookup32(usb_ms_conv_info->itl, lun);
|
||||
itl=(itl_nexus_t *)wmem_tree_lookup32(usb_ms_conv_info->itl, lun);
|
||||
if(!itl){
|
||||
itl=se_new(itl_nexus_t);
|
||||
itl=wmem_new(wmem_file_scope(), itl_nexus_t);
|
||||
itl->cmdset=0xff;
|
||||
itl->conversation=NULL;
|
||||
se_tree_insert32(usb_ms_conv_info->itl, lun, itl);
|
||||
wmem_tree_insert32(usb_ms_conv_info->itl, lun, itl);
|
||||
}
|
||||
|
||||
/* make sure we have an ITLQ structure for this LUN/transaction */
|
||||
itlq=(itlq_nexus_t *)se_tree_lookup32(usb_ms_conv_info->itlq, pinfo->fd->num);
|
||||
itlq=(itlq_nexus_t *)wmem_tree_lookup32(usb_ms_conv_info->itlq, pinfo->fd->num);
|
||||
if(!itlq){
|
||||
itlq=se_new(itlq_nexus_t);
|
||||
itlq=wmem_new(wmem_file_scope(), itlq_nexus_t);
|
||||
itlq->lun=lun;
|
||||
itlq->scsi_opcode=0xffff;
|
||||
itlq->task_flags=0;
|
||||
|
@ -279,7 +279,7 @@ dissect_usb_ms_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
itlq->flags=0;
|
||||
itlq->alloc_len=0;
|
||||
itlq->extra_data=NULL;
|
||||
se_tree_insert32(usb_ms_conv_info->itlq, pinfo->fd->num, itlq);
|
||||
wmem_tree_insert32(usb_ms_conv_info->itlq, pinfo->fd->num, itlq);
|
||||
}
|
||||
|
||||
/* dCBWCBLength */
|
||||
|
@ -322,13 +322,13 @@ dissect_usb_ms_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
status=tvb_get_guint8(tvb, offset);
|
||||
/*offset+=1;*/
|
||||
|
||||
itlq=(itlq_nexus_t *)se_tree_lookup32_le(usb_ms_conv_info->itlq, pinfo->fd->num);
|
||||
itlq=(itlq_nexus_t *)wmem_tree_lookup32_le(usb_ms_conv_info->itlq, pinfo->fd->num);
|
||||
if(!itlq){
|
||||
return;
|
||||
}
|
||||
itlq->last_exchange_frame=pinfo->fd->num;
|
||||
|
||||
itl=(itl_nexus_t *)se_tree_lookup32(usb_ms_conv_info->itl, itlq->lun);
|
||||
itl=(itl_nexus_t *)wmem_tree_lookup32(usb_ms_conv_info->itl, itlq->lun);
|
||||
if(!itl){
|
||||
return;
|
||||
}
|
||||
|
@ -345,12 +345,12 @@ dissect_usb_ms_bulk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|||
/*
|
||||
* Ok it was neither CDB not STATUS so just assume it is either data in/out
|
||||
*/
|
||||
itlq=(itlq_nexus_t *)se_tree_lookup32_le(usb_ms_conv_info->itlq, pinfo->fd->num);
|
||||
itlq=(itlq_nexus_t *)wmem_tree_lookup32_le(usb_ms_conv_info->itlq, pinfo->fd->num);
|
||||
if(!itlq){
|
||||
return;
|
||||
}
|
||||
|
||||
itl=(itl_nexus_t *)se_tree_lookup32(usb_ms_conv_info->itl, itlq->lun);
|
||||
itl=(itl_nexus_t *)wmem_tree_lookup32(usb_ms_conv_info->itl, itlq->lun);
|
||||
if(!itl){
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <glib.h>
|
||||
#include <epan/expert.h>
|
||||
#include <epan/packet.h>
|
||||
#include <epan/emem.h>
|
||||
#include <epan/wmem/wmem.h>
|
||||
#include <epan/conversation.h>
|
||||
#include "packet-usb.h"
|
||||
|
||||
|
@ -648,7 +648,7 @@ typedef struct
|
|||
/* video_entity_t's (units/terminals) associated with each video interface */
|
||||
/* There is one such structure for each video conversation (interface) */
|
||||
typedef struct _video_conv_info_t {
|
||||
emem_tree_t* entities; /* indexed by entity ID */
|
||||
wmem_tree_t* entities; /* indexed by entity ID */
|
||||
} video_conv_info_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1025,21 +1025,20 @@ dissect_usb_video_control_interface_descriptor(proto_tree *parent_tree, tvbuff_t
|
|||
|
||||
if (!video_conv_info)
|
||||
{
|
||||
video_conv_info = se_new(video_conv_info_t);
|
||||
video_conv_info->entities = se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK,
|
||||
"USBVIDEO Entities");
|
||||
video_conv_info = wmem_new(wmem_file_scope(), video_conv_info_t);
|
||||
video_conv_info->entities = wmem_tree_new(wmem_file_scope());
|
||||
usb_conv_info->class_data = video_conv_info;
|
||||
}
|
||||
|
||||
entity = (video_entity_t*) se_tree_lookup32(video_conv_info->entities, entity_id);
|
||||
entity = (video_entity_t*) wmem_tree_lookup32(video_conv_info->entities, entity_id);
|
||||
if (!entity)
|
||||
{
|
||||
entity = se_new(video_entity_t);
|
||||
entity = wmem_new(wmem_file_scope(), video_entity_t);
|
||||
entity->entityID = entity_id;
|
||||
entity->subtype = subtype;
|
||||
entity->terminalType = terminal_type;
|
||||
|
||||
se_tree_insert32(video_conv_info->entities, entity_id, entity);
|
||||
wmem_tree_insert32(video_conv_info->entities, entity_id, entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1606,7 +1605,7 @@ get_control_selector_values(guint8 entity_id, usb_conv_info_t *usb_conv_info)
|
|||
|
||||
video_conv_info = (video_conv_info_t *)usb_conv_info->class_data;
|
||||
if (video_conv_info)
|
||||
entity = (video_entity_t*) se_tree_lookup32(video_conv_info->entities, entity_id);
|
||||
entity = (video_entity_t*) wmem_tree_lookup32(video_conv_info->entities, entity_id);
|
||||
|
||||
if (entity_id == 0)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <epan/packet.h>
|
||||
#include <epan/etypes.h>
|
||||
#include <epan/addr_resolv.h>
|
||||
#include <epan/emem.h>
|
||||
#include <epan/wmem/wmem.h>
|
||||
#include <epan/tap.h>
|
||||
#include <epan/conversation.h>
|
||||
#include <epan/expert.h>
|
||||
|
@ -207,8 +207,8 @@ static heur_dissector_list_t heur_bulk_subdissector_list;
|
|||
static heur_dissector_list_t heur_control_subdissector_list;
|
||||
static heur_dissector_list_t heur_interrupt_subdissector_list;
|
||||
|
||||
static emem_tree_t *device_to_protocol_table = NULL;
|
||||
static emem_tree_t *device_to_product_table = NULL;
|
||||
static wmem_tree_t *device_to_protocol_table = NULL;
|
||||
static wmem_tree_t *device_to_product_table = NULL;
|
||||
|
||||
static dissector_table_t device_to_dissector;
|
||||
static dissector_table_t protocol_to_dissector;
|
||||
|
@ -1002,13 +1002,13 @@ get_usb_conv_info(conversation_t *conversation)
|
|||
usb_conv_info = (usb_conv_info_t *)conversation_get_proto_data(conversation, proto_usb);
|
||||
if (!usb_conv_info) {
|
||||
/* no not yet so create some */
|
||||
usb_conv_info = se_new0(usb_conv_info_t);
|
||||
usb_conv_info = wmem_new0(wmem_file_scope(), usb_conv_info_t);
|
||||
usb_conv_info->interfaceClass = IF_CLASS_UNKNOWN;
|
||||
usb_conv_info->interfaceSubclass = IF_SUBCLASS_UNKNOWN;
|
||||
usb_conv_info->interfaceProtocol = IF_PROTOCOL_UNKNOWN;
|
||||
usb_conv_info->deviceVendor = DEV_VENDOR_UNKNOWN;
|
||||
usb_conv_info->deviceProduct = DEV_PRODUCT_UNKNOWN;
|
||||
usb_conv_info->transactions = se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "usb transactions");
|
||||
usb_conv_info->transactions = wmem_tree_new(wmem_file_scope());
|
||||
|
||||
conversation_add_proto_data(conversation, proto_usb, usb_conv_info);
|
||||
}
|
||||
|
@ -1191,7 +1191,7 @@ dissect_usb_device_qualifier_descriptor(packet_info *pinfo _U_, proto_tree *pare
|
|||
guint k_bus_id;
|
||||
guint k_device_address;
|
||||
guint k_frame_number;
|
||||
emem_tree_key_t key[4];
|
||||
wmem_tree_key_t key[4];
|
||||
device_protocol_data_t *device_protocol_data;
|
||||
|
||||
k_frame_number = pinfo->fd->num;
|
||||
|
@ -1207,11 +1207,11 @@ dissect_usb_device_qualifier_descriptor(packet_info *pinfo _U_, proto_tree *pare
|
|||
key[3].length = 0;
|
||||
key[3].key = NULL;
|
||||
|
||||
device_protocol_data = se_new(device_protocol_data_t);
|
||||
device_protocol_data = wmem_new(wmem_file_scope(), device_protocol_data_t);
|
||||
device_protocol_data->protocol = protocol;
|
||||
device_protocol_data->bus_id = bus_id;
|
||||
device_protocol_data->device_address = device_address;
|
||||
se_tree_insert32_array(device_to_protocol_table, key, device_protocol_data);
|
||||
wmem_tree_insert32_array(device_to_protocol_table, key, device_protocol_data);
|
||||
}
|
||||
|
||||
/* bMaxPacketSize0 */
|
||||
|
@ -1302,7 +1302,7 @@ dissect_usb_device_descriptor(packet_info *pinfo, proto_tree *parent_tree,
|
|||
|
||||
hfi = proto_registrar_get_nth(hf_usb_idProduct);
|
||||
field_description_length = (gint)strlen(hfi->name) + 14;
|
||||
field_description = (guint8 *)ep_alloc(field_description_length);
|
||||
field_description = (guint8 *)wmem_alloc(wmem_packet_scope(), field_description_length);
|
||||
g_strlcpy(field_description, hfi->name, field_description_length);
|
||||
g_strlcat(field_description, ": %s (0x%04x)", field_description_length);
|
||||
|
||||
|
@ -1315,7 +1315,7 @@ dissect_usb_device_descriptor(packet_info *pinfo, proto_tree *parent_tree,
|
|||
guint k_bus_id;
|
||||
guint k_device_address;
|
||||
guint k_frame_number;
|
||||
emem_tree_key_t key[4];
|
||||
wmem_tree_key_t key[4];
|
||||
device_product_data_t *device_product_data;
|
||||
device_protocol_data_t *device_protocol_data;
|
||||
|
||||
|
@ -1332,19 +1332,19 @@ dissect_usb_device_descriptor(packet_info *pinfo, proto_tree *parent_tree,
|
|||
key[3].length = 0;
|
||||
key[3].key = NULL;
|
||||
|
||||
device_product_data = se_new(device_product_data_t);
|
||||
device_product_data = wmem_new(wmem_file_scope(), device_product_data_t);
|
||||
device_product_data->vendor = vendor_id;
|
||||
device_product_data->product = product_id;
|
||||
device_product_data->bus_id = bus_id;
|
||||
device_product_data->device_address = device_address;
|
||||
se_tree_insert32_array(device_to_product_table, key, device_product_data);
|
||||
wmem_tree_insert32_array(device_to_product_table, key, device_product_data);
|
||||
|
||||
device_protocol_data = se_new(device_protocol_data_t);
|
||||
device_protocol_data = wmem_new(wmem_file_scope(), device_protocol_data_t);
|
||||
device_protocol_data->protocol = protocol;
|
||||
device_protocol_data->bus_id = bus_id;
|
||||
device_protocol_data->device_address = device_address;
|
||||
|
||||
se_tree_insert32_array(device_to_protocol_table, key, device_protocol_data);
|
||||
wmem_tree_insert32_array(device_to_protocol_table, key, device_protocol_data);
|
||||
}
|
||||
|
||||
/* bcdDevice */
|
||||
|
@ -2613,7 +2613,7 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
|
|||
return;
|
||||
}
|
||||
|
||||
usb_data = se_new(usb_data_t);
|
||||
usb_data = wmem_new(wmem_file_scope(), usb_data_t);
|
||||
usb_data->bus_id = bus_id;
|
||||
usb_data->device_address = device_address;
|
||||
usb_data->endpoint = endpoint;
|
||||
|
@ -2659,14 +2659,14 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
|
|||
*/
|
||||
if (is_request) {
|
||||
/* this is a request */
|
||||
usb_trans_info = (usb_trans_info_t *)se_tree_lookup32(usb_conv_info->transactions, pinfo->fd->num);
|
||||
usb_trans_info = (usb_trans_info_t *)wmem_tree_lookup32(usb_conv_info->transactions, pinfo->fd->num);
|
||||
if (!usb_trans_info) {
|
||||
usb_trans_info = se_new0(usb_trans_info_t);
|
||||
usb_trans_info = wmem_new0(wmem_file_scope(), usb_trans_info_t);
|
||||
usb_trans_info->request_in = pinfo->fd->num;
|
||||
usb_trans_info->req_time = pinfo->fd->abs_ts;
|
||||
usb_trans_info->header_len_64 = (header_info & USB_HEADER_IS_64_BYTES) ? TRUE : FALSE;
|
||||
|
||||
se_tree_insert32(usb_conv_info->transactions, pinfo->fd->num, usb_trans_info);
|
||||
wmem_tree_insert32(usb_conv_info->transactions, pinfo->fd->num, usb_trans_info);
|
||||
}
|
||||
usb_conv_info->usb_trans_info = usb_trans_info;
|
||||
|
||||
|
@ -2679,12 +2679,12 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
|
|||
} else {
|
||||
/* this is a response */
|
||||
if (pinfo->fd->flags.visited) {
|
||||
usb_trans_info = (usb_trans_info_t *)se_tree_lookup32(usb_conv_info->transactions, pinfo->fd->num);
|
||||
usb_trans_info = (usb_trans_info_t *)wmem_tree_lookup32(usb_conv_info->transactions, pinfo->fd->num);
|
||||
} else {
|
||||
usb_trans_info = (usb_trans_info_t *)se_tree_lookup32_le(usb_conv_info->transactions, pinfo->fd->num);
|
||||
usb_trans_info = (usb_trans_info_t *)wmem_tree_lookup32_le(usb_conv_info->transactions, pinfo->fd->num);
|
||||
if (usb_trans_info) {
|
||||
usb_trans_info->response_in = pinfo->fd->num;
|
||||
se_tree_insert32(usb_conv_info->transactions, pinfo->fd->num, usb_trans_info);
|
||||
wmem_tree_insert32(usb_conv_info->transactions, pinfo->fd->num, usb_trans_info);
|
||||
}
|
||||
}
|
||||
usb_conv_info->usb_trans_info = usb_trans_info;
|
||||
|
@ -2703,7 +2703,7 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
|
|||
}
|
||||
}
|
||||
|
||||
tap_data = ep_new(usb_tap_data_t);
|
||||
tap_data = wmem_new(wmem_packet_scope(), usb_tap_data_t);
|
||||
tap_data->urb_type = urb_type;
|
||||
tap_data->transfer_type = (guint8)type;
|
||||
tap_data->conv_info = usb_conv_info;
|
||||
|
@ -3295,7 +3295,7 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
|
|||
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
||||
|
||||
if (!dissector_try_uint(device_to_dissector, (guint32) (bus_id << 8 | device_address), next_tvb, pinfo, parent)) {
|
||||
emem_tree_key_t key[4];
|
||||
wmem_tree_key_t key[4];
|
||||
guint32 k_frame_number;
|
||||
guint32 k_device_address;
|
||||
guint32 k_bus_id;
|
||||
|
@ -3314,7 +3314,7 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
|
|||
key[3].length = 0;
|
||||
key[3].key = NULL;
|
||||
|
||||
device_protocol_data = (device_protocol_data_t *)se_tree_lookup32_array_le(device_to_protocol_table, key);
|
||||
device_protocol_data = (device_protocol_data_t *)wmem_tree_lookup32_array_le(device_to_protocol_table, key);
|
||||
if (device_protocol_data && device_protocol_data->bus_id == bus_id &&
|
||||
device_protocol_data->device_address == device_address &&
|
||||
dissector_try_uint(protocol_to_dissector, (guint32) device_protocol_data->protocol, next_tvb, pinfo, parent)) {
|
||||
|
@ -3322,7 +3322,7 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
|
|||
} else {
|
||||
device_product_data_t *device_product_data;
|
||||
|
||||
device_product_data = (device_product_data_t *)se_tree_lookup32_array_le(device_to_product_table, key);
|
||||
device_product_data = (device_product_data_t *)wmem_tree_lookup32_array_le(device_to_product_table, key);
|
||||
if (device_product_data && device_product_data->bus_id == bus_id &&
|
||||
device_product_data->device_address == device_address &&
|
||||
dissector_try_uint(product_to_dissector, (guint32) (device_product_data->vendor << 16 | device_product_data->product), next_tvb, pinfo, parent)) {
|
||||
|
@ -3932,8 +3932,8 @@ proto_register_usb(void)
|
|||
expert_usb = expert_register_protocol(proto_usb);
|
||||
expert_register_field_array(expert_usb, ei, array_length(ei));
|
||||
|
||||
device_to_product_table = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "usb device_address, bus_id and frame number to vendor_product");
|
||||
device_to_protocol_table = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "usb device_address, bus_id and frame number to class_subclass_protocol");
|
||||
device_to_product_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
|
||||
device_to_protocol_table = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
|
||||
device_to_dissector = register_dissector_table("usb.device", "USB device", FT_UINT32, BASE_HEX);
|
||||
protocol_to_dissector = register_dissector_table("usb.protocol", "USB protocol", FT_UINT32, BASE_HEX);
|
||||
product_to_dissector = register_dissector_table("usb.product", "USB product", FT_UINT32, BASE_HEX);
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#ifndef __PACKET_USB_H__
|
||||
#define __PACKET_USB_H__
|
||||
|
||||
#include <epan/wmem/wmem.h>
|
||||
|
||||
typedef struct _usb_address_t {
|
||||
guint32 device;
|
||||
guint32 endpoint;
|
||||
|
@ -82,7 +84,7 @@ struct _usb_conv_info_t {
|
|||
guint8 interfaceNum; /* Most recent interface number */
|
||||
guint16 deviceVendor; /* Device Descriptor - USB Vendor ID */
|
||||
guint32 deviceProduct; /* Device Descriptor - USB Product ID - MSBs only for encoding unknown */
|
||||
emem_tree_t *transactions;
|
||||
wmem_tree_t *transactions;
|
||||
usb_trans_info_t *usb_trans_info; /* pointer to the current transaction */
|
||||
void *class_data; /* private class/id decode data */
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue