HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-usb.h
blob19d0afbeabc4578a8497b84461597489d1fc5351
1 /* packet-usb.h
3 * $Id$
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #ifndef __PACKET_USB_H__
25 #define __PACKET_USB_H__
27 #include <epan/value_string.h>
28 #include <epan/wmem/wmem.h>
30 typedef struct _usb_address_t {
31 guint32 device;
32 guint32 endpoint;
33 } usb_address_t;
34 #define USB_ADDR_LEN (sizeof(usb_address_t))
36 /* Flag used to mark usb_address_t.endpoint as an interface
37 * address instead of the normal endpoint address.
39 #define INTERFACE_PORT 0x80000000
42 typedef struct _usb_conv_info_t usb_conv_info_t;
44 /* there is one such structure for each request/response */
45 typedef struct _usb_trans_info_t {
46 guint32 request_in;
47 guint32 response_in;
48 nstime_t req_time;
49 gboolean header_len_64;
51 /* Valid only for SETUP transactions */
52 struct _usb_setup {
53 guint8 requesttype;
54 guint8 request;
55 guint16 wValue;
56 guint16 wIndex;
57 guint16 wLength;
58 } setup;
60 /* Valid only during GET DESCRIPTOR transactions */
61 union {
62 struct {
63 guint8 type;
64 guint8 index;
65 } get_descriptor;
66 } u;
69 /* used to pass the interface class from the
70 * interface descriptor onto the endpoint
71 * descriptors so that we can create a
72 * conversation with the appropriate class
73 * once we know the endpoint.
74 * Valid only during GET CONFIGURATION response.
76 usb_conv_info_t *interface_info;
77 } usb_trans_info_t;
79 /* Conversation Structure
80 * there is one such structure for each device/endpoint conversation */
81 struct _usb_conv_info_t {
82 guint16 bus_id;
83 guint8 device_address;
84 guint8 endpoint;
85 gint direction;
87 guint16 interfaceClass; /* Interface Descriptor - class */
88 guint16 interfaceSubclass; /* Interface Descriptor - subclass */
89 guint16 interfaceProtocol; /* Interface Descriptor - protocol */
90 guint8 interfaceNum; /* Most recent interface number */
92 guint16 deviceVendor; /* Device Descriptor - USB Vendor ID */
93 guint32 deviceProduct; /* Device Descriptor - USB Product ID - MSBs only for encoding unknown */
94 wmem_tree_t *transactions;
95 usb_trans_info_t *usb_trans_info; /* pointer to the current transaction */
97 void *class_data; /* private class/id decode data */
100 /* This is what a tap will tap */
101 typedef struct _usb_tap_data_t {
102 guint8 urb_type;
103 guint8 transfer_type;
104 usb_conv_info_t *conv_info;
105 usb_trans_info_t *trans_info;
106 } usb_tap_data_t;
109 /* This is the endpoint number used for "no endpoint" or the fake endpoint
110 * for the host side since we need two endpoints to manage conversations
111 * properly.
113 #define NO_ENDPOINT 0xffffffff
116 * Values from the Linux USB pseudo-header.
120 * event_type values
122 #define URB_SUBMIT 'S'
123 #define URB_COMPLETE 'C'
124 #define URB_ERROR 'E'
127 * transfer_type values
129 #define URB_ISOCHRONOUS 0x0
130 #define URB_INTERRUPT 0x1
131 #define URB_CONTROL 0x2
132 #define URB_BULK 0x3
134 #define URB_TRANSFER_IN 0x80 /* to host */
137 /* http://www.usb.org/developers/defined_class */
138 #define IF_CLASS_DEVICE 0x00
139 #define IF_CLASS_AUDIO 0x01
140 #define IF_CLASS_COMMUNICATIONS 0x02
141 #define IF_CLASS_HID 0x03
142 #define IF_CLASS_PHYSICAL 0x05
143 #define IF_CLASS_IMAGE 0x06
144 #define IF_CLASS_PRINTER 0x07
145 #define IF_CLASS_MASS_STORAGE 0x08
146 #define IF_CLASS_HUB 0x09
147 #define IF_CLASS_CDC_DATA 0x0a
148 #define IF_CLASS_SMART_CARD 0x0b
149 #define IF_CLASS_CONTENT_SECURITY 0x0d
150 #define IF_CLASS_VIDEO 0x0e
151 #define IF_CLASS_PERSONAL_HEALTHCARE 0x0f
152 #define IF_CLASS_AUDIO_VIDEO 0x10
153 #define IF_CLASS_DIAGNOSTIC_DEVICE 0xdc
154 #define IF_CLASS_WIRELESS_CONTROLLER 0xe0
155 #define IF_CLASS_MISCELLANEOUS 0xef
156 #define IF_CLASS_APPLICATION_SPECIFIC 0xfe
157 #define IF_CLASS_VENDOR_SPECIFIC 0xff
159 #define IF_CLASS_UNKNOWN 0xffff
160 #define IF_SUBCLASS_UNKNOWN 0xffff
161 #define IF_PROTOCOL_UNKNOWN 0xffff
162 #define DEV_VENDOR_UNKNOWN 0x0000 /* this id is unassigned */
163 #define DEV_PRODUCT_UNKNOWN 0xfffffff /* 0x0000 and 0xffff are used values by vendors, so MSBs encode unknown */
165 /* bmRequestType values */
166 #define USB_DIR_OUT 0 /* to device */
167 #define USB_DIR_IN 0x80 /* to host */
169 #define USB_TYPE_MASK (0x03 << 5)
170 #define USB_TYPE(type) (((type) & USB_TYPE_MASK) >> 5)
171 #define RQT_SETUP_TYPE_STANDARD 0
172 #define RQT_SETUP_TYPE_CLASS 1
173 #define RQT_SETUP_TYPE_VENDOR 2
175 #define USB_RECIPIENT_MASK 0x1F
176 #define USB_RECIPIENT(type) ((type) & USB_RECIPIENT_MASK)
177 #define RQT_SETUP_RECIPIENT_DEVICE 0
178 #define RQT_SETUP_RECIPIENT_INTERFACE 1
179 #define RQT_SETUP_RECIPIENT_ENDPOINT 2
180 #define RQT_SETUP_RECIPIENT_OTHER 3
182 /* Endpoint descriptor bmAttributes */
183 #define ENDPOINT_TYPE(ep_attrib) ((ep_attrib) & 0x03)
184 #define ENDPOINT_TYPE_CONTROL 0
185 #define ENDPOINT_TYPE_ISOCHRONOUS 1
186 #define ENDPOINT_TYPE_BULK 2
187 #define ENDPOINT_TYPE_INTERRUPT 3
189 usb_conv_info_t *get_usb_iface_conv_info(packet_info *pinfo, guint8 interface_num);
191 void dissect_usb_descriptor_header(proto_tree *tree,
192 tvbuff_t *tvb, int offset,
193 value_string_ext *type_val_str);
194 void dissect_usb_endpoint_address(proto_tree *tree, tvbuff_t *tvb, int offset);
196 #endif