b38396f618d116f0c83d8f88aec43b3f0c068125
2 * Copyright (C) 2005-2007 Takahiro Hirofuchi
5 #ifndef _USBIP_COMMON_H
6 #define _USBIP_COMMON_H
16 #include <sysfs/libsysfs.h>
18 #include <sys/socket.h>
21 #define USBIDS_FILE "/usr/share/hwdata/usb.ids"
24 #ifndef VHCI_STATE_PATH
25 #define VHCI_STATE_PATH "/var/run/vhci_hcd"
28 /* kernel module names */
29 #define USBIP_CORE_MOD_NAME "usbip-core"
30 #define USBIP_HOST_DRV_NAME "usbip-host"
31 #define USBIP_VHCI_DRV_NAME "vhci_hcd"
33 enum usb_device_speed
{
34 USB_SPEED_UNKNOWN
= 0, /* enumerating */
35 USB_SPEED_LOW
, USB_SPEED_FULL
, /* usb 1.1 */
36 USB_SPEED_HIGH
, /* usb 2.0 */
37 USB_SPEED_VARIABLE
/* wireless (usb 2.5) */
40 /* FIXME: how to sync with drivers/usbip_common.h ? */
41 enum usbip_device_status
{
42 /* sdev is available. */
43 SDEV_ST_AVAILABLE
= 0x01,
44 /* sdev is now used. */
46 /* sdev is unusable because of a fatal error. */
49 /* vdev does not connect a remote device. */
51 /* vdev is used, but the USB address is not assigned yet */
57 extern int usbip_use_syslog
;
58 extern int usbip_use_stderr
;
59 extern int usbip_use_debug
;
61 #define err(fmt, args...) do { \
62 if (usbip_use_syslog) { \
63 syslog(LOG_ERR, "usbip err: %13s:%4d (%-12s) " fmt "\n", \
64 __FILE__, __LINE__, __FUNCTION__, ##args); \
66 if (usbip_use_stderr) { \
67 fprintf(stderr, "usbip err: %13s:%4d (%-12s) " fmt "\n", \
68 __FILE__, __LINE__, __FUNCTION__, ##args); \
72 #define notice(fmt, args...) do { \
73 if (usbip_use_syslog) { \
74 syslog(LOG_DEBUG, "usbip: " fmt, ##args); \
76 if (usbip_use_stderr) { \
77 fprintf(stderr, "usbip: " fmt "\n", ##args); \
81 #define info(fmt, args...) do { \
82 if (usbip_use_syslog) { \
83 syslog(LOG_DEBUG, fmt, ##args); \
85 if (usbip_use_stderr) { \
86 fprintf(stderr, fmt "\n", ##args); \
90 #define dbg(fmt, args...) do { \
91 if (usbip_use_debug) { \
92 if (usbip_use_syslog) { \
93 syslog(LOG_DEBUG, "usbip dbg: %13s:%4d (%-12s) " fmt, \
94 __FILE__, __LINE__, __FUNCTION__, ##args); \
96 if (usbip_use_stderr) { \
97 fprintf(stderr, "usbip dbg: %13s:%4d (%-12s) " fmt "\n", \
98 __FILE__, __LINE__, __FUNCTION__, ##args); \
104 #define BUG() do { err("sorry, it's a bug"); abort(); } while (0)
107 struct usb_interface
{
108 uint8_t bInterfaceClass
;
109 uint8_t bInterfaceSubClass
;
110 uint8_t bInterfaceProtocol
;
111 uint8_t padding
; /* alignment */
112 } __attribute__((packed
));
117 char path
[SYSFS_PATH_MAX
];
118 char busid
[SYSFS_BUS_ID_SIZE
];
128 uint8_t bDeviceClass
;
129 uint8_t bDeviceSubClass
;
130 uint8_t bDeviceProtocol
;
131 uint8_t bConfigurationValue
;
132 uint8_t bNumConfigurations
;
133 uint8_t bNumInterfaces
;
134 } __attribute__((packed
));
136 #define to_string(s) #s
138 void dump_usb_interface(struct usb_interface
*);
139 void dump_usb_device(struct usb_device
*);
140 int read_usb_device(struct sysfs_device
*sdev
, struct usb_device
*udev
);
141 int read_attr_value(struct sysfs_device
*dev
, const char *name
, const char *format
);
142 int read_usb_interface(struct usb_device
*udev
, int i
, struct usb_interface
*uinf
);
144 const char *usbip_speed_string(int num
);
145 const char *usbip_status_string(int32_t status
);
147 int usbip_names_init(char *);
148 void usbip_names_free(void);
149 void usbip_names_get_product(char *buff
, size_t size
, uint16_t vendor
, uint16_t product
);
150 void usbip_names_get_class(char *buff
, size_t size
, uint8_t class, uint8_t subclass
, uint8_t protocol
);
This page took 0.034349 seconds and 4 git commands to generate.