Permalink
Newer
Older
100644 180 lines (147 sloc) 4.82 KB
1
/*************************************************************************
2
** usbparse.h for USBView - a USB device viewer
@gregkh
Oct 23, 2007
3
** Copyright (c) 1999, 2000 by Greg Kroah-Hartman, greg@kroah.com
4
**
5
** This program is free software; you can redistribute it and/or modify
6
** it under the terms of the GNU General Public License as published by
7
** the Free Software Foundation; version 2 of the License.
8
**
9
** This program is distributed in the hope that it will be useful,
10
** but WITHOUT ANY WARRANTY; without even the implied warranty of
11
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
** GNU General Public License for more details.
13
**
14
** (See the included file COPYING)
15
*************************************************************************/
16
17
#ifndef __USB_PARSE_H
18
#define __USB_PARSE_H
19
20
/* should make these dynamic someday... */
21
#define MAX_ENDPOINTS 32
22
#define MAX_INTERFACES 32
23
#define MAX_CONFIGS 32
24
#define MAX_CHILDREN 32
25
26
#define DEVICE_VERSION_SIZE 6
27
#define DEVICE_CLASS_SIZE 10
28
#define DEVICE_SUBCLASS_SIZE 3
29
#define DEVICE_PROTOCOL_SIZE 3
30
#define DEVICE_VENDOR_ID_SIZE 5
31
#define DEVICE_PRODUCT_ID_SIZE 5
32
#define DEVICE_REVISION_NUMBER_SIZE 6
33
34
#define CONFIG_ATTRIBUTES_SIZE 3
35
#define CONFIG_MAXPOWER_SIZE 10
36
37
#define INTERFACE_CLASS_SIZE 10
38
39
#define ENDPOINT_TYPE_SIZE 5
40
#define ENDPOINT_MAXPACKETSIZE_SIZE 5
41
#define ENDPOINT_INTERVAL_SIZE 10
42
43
44
#define TOPOLOGY_BUS_STRING "Bus="
45
#define TOPOLOGY_LEVEL_STRING "Lev="
46
#define TOPOLOGY_PARENT_STRING "Prnt="
47
#define TOPOLOGY_PORT_STRING "Port="
48
#define TOPOLOGY_COUNT_STRING "Cnt="
49
#define TOPOLOGY_DEVICENUMBER_STRING "Dev#="
50
#define TOPOLOGY_SPEED_STRING "Spd="
51
#define TOPOLOGY_MAXCHILDREN_STRING "MxCh="
52
53
#define BANDWIDTH_ALOCATED "Alloc="
54
#define BANDWIDTH_TOTAL "/"
55
#define BANDWIDTH_PERCENT "us ("
56
#define BANDWIDTH_INTERRUPT_TOTAL "#Int="
57
#define BANDWIDTH_ISOC_TOTAL "#Iso="
58
59
#define DEVICE_VERSION_STRING "Ver="
60
#define DEVICE_CLASS_STRING "Cls="
61
#define DEVICE_SUBCLASS_STRING "Sub="
62
#define DEVICE_PROTOCOL_STRING "Prot="
63
#define DEVICE_MAXPACKETSIZE_STRING "MxPS="
64
#define DEVICE_NUMCONFIGS_STRING "#Cfgs="
65
#define DEVICE_VENDOR_STRING "Vendor="
66
#define DEVICE_PRODUCTID_STRING "ProdID="
67
#define DEVICE_REVISION_STRING "Rev="
68
#define DEVICE_MANUFACTURER_STRING "Manufacturer="
69
#define DEVICE_PRODUCT_STRING "Product="
70
#define DEVICE_SERIALNUMBER_STRING "SerialNumber="
71
#define DEVICE_STRING_MAXSIZE 255
72
73
#define CONFIG_NUMINTERFACES_STRING "#Ifs="
74
#define CONFIG_CONFIGNUMBER_STRING "Cfg#="
75
#define CONFIG_ATTRIBUTES_STRING "Atr="
76
#define CONFIG_MAXPOWER_STRING "MxPwr="
77
78
#define INTERFACE_NUMBER_STRING "If#="
79
#define INTERFACE_ALTERNATESETTING_STRING "Alt="
80
#define INTERFACE_NUMENDPOINTS_STRING "#EPs="
81
#define INTERFACE_CLASS_STRING "Cls="
82
#define INTERFACE_SUBCLASS_STRING "Sub="
83
#define INTERFACE_PROTOCOL_STRING "Prot="
84
#define INTERFACE_DRIVERNAME_STRING "Driver="
85
#define INTERFACE_DRIVERNAME_NODRIVER_STRING "(none)"
86
#define INTERFACE_DRIVERNAME_STRING_MAXLENGTH 50
87
88
#define ENDPOINT_ADDRESS_STRING "Ad="
89
#define ENDPOINT_ATTRIBUTES_STRING "Atr="
90
#define ENDPOINT_MAXPACKETSIZE_STRING "MxPS="
91
#define ENDPOINT_INTERVAL_STRING "Ivl="
92
93
94
95
typedef struct DeviceEndpoint {
96
gint address;
97
gboolean in; /* TRUE if in, FALSE if out */
98
gint attribute;
99
gchar *type;
100
gint maxPacketSize;
101
gchar *interval;
102
} DeviceEndpoint;
103
104
105
typedef struct DeviceInterface {
106
gchar *name;
107
gint interfaceNumber;
108
gint alternateNumber;
109
gint numEndpoints;
110
gint subClass;
111
gint protocol;
112
gchar *class;
113
DeviceEndpoint *endpoint[MAX_ENDPOINTS];
114
gboolean driverAttached; /* TRUE if driver is attached to this interface currently */
115
} DeviceInterface;
116
117
118
119
typedef struct DeviceConfig {
120
gint configNumber;
121
gint numInterfaces;
122
gint attributes;
123
gchar *maxPower;
124
DeviceInterface *interface[MAX_INTERFACES];
125
} DeviceConfig;
126
127
128
typedef struct DeviceBandwidth {
129
gint allocated;
130
gint total;
131
gint percent;
132
gint numInterruptRequests;
133
gint numIsocRequests;
134
} DeviceBandwidth;
135
136
137
typedef struct Device {
138
gchar *name;
139
gint busNumber;
140
gint level;
141
gint parentNumber;
142
gint portNumber;
143
gint connectorNumber;
144
gint count;
145
gint deviceNumber;
146
gint speed;
147
gint maxChildren;
148
gchar *version;
149
gchar *class;
150
gchar *subClass;
151
gchar *protocol;
152
gint maxPacketSize;
153
gint numConfigs;
154
gint vendorId;
155
gint productId;
156
gchar *revisionNumber;
157
gchar *manufacturer;
158
gchar *product;
159
gchar *serialNumber;
160
DeviceConfig *config[MAX_CONFIGS];
161
struct Device *parent;
162
struct Device *child[MAX_CHILDREN];
163
DeviceBandwidth *bandwidth;
164
GtkWidget *tree;
165
GtkTreeIter leaf;
166
} Device;
167
168
169
extern Device *rootDevice;
170
171
172
extern Device *usb_find_device (int deviceNumber, int busNumber);
173
extern void usb_initialize_list (void);
174
extern void usb_parse_line (char *line);
175
extern void usb_name_devices (void);
176
177
178
#endif /* __USB_PARSE_H */
179