2 * Copyright (C) 2005-2007 Takahiro Hirofuchi
5 #ifndef __USBIP_COMMON_H
6 #define __USBIP_COMMON_H
8 #include <sysfs/libsysfs.h>
19 #define USBIDS_FILE "/usr/share/hwdata/usb.ids"
22 #ifndef VHCI_STATE_PATH
23 #define VHCI_STATE_PATH "/var/run/vhci_hcd"
26 /* kernel module names */
27 #define USBIP_CORE_MOD_NAME "usbip-core"
28 #define USBIP_HOST_DRV_NAME "usbip-host"
29 #define USBIP_VHCI_DRV_NAME "vhci_hcd"
31 extern int usbip_use_syslog
;
32 extern int usbip_use_stderr
;
33 extern int usbip_use_debug
;
35 #define PROGNAME "usbip"
37 #define pr_fmt(fmt) "%s: %s: " fmt "\n", PROGNAME
38 #define dbg_fmt(fmt) pr_fmt("%s:%d:[%s] " fmt), "debug", \
39 __FILE__, __LINE__, __FUNCTION__
41 #define err(fmt, args...) \
43 if (usbip_use_syslog) { \
44 syslog(LOG_ERR, pr_fmt(fmt), "error", ##args); \
46 if (usbip_use_stderr) { \
47 fprintf(stderr, pr_fmt(fmt), "error", ##args); \
51 #define info(fmt, args...) \
53 if (usbip_use_syslog) { \
54 syslog(LOG_INFO, pr_fmt(fmt), "info", ##args); \
56 if (usbip_use_stderr) { \
57 fprintf(stderr, pr_fmt(fmt), "info", ##args); \
61 #define dbg(fmt, args...) \
63 if (usbip_use_debug) { \
64 if (usbip_use_syslog) { \
65 syslog(LOG_DEBUG, dbg_fmt(fmt), ##args); \
67 if (usbip_use_stderr) { \
68 fprintf(stderr, dbg_fmt(fmt), ##args); \
75 err("sorry, it's a bug!"); \
79 enum usb_device_speed
{
80 USB_SPEED_UNKNOWN
= 0, /* enumerating */
81 USB_SPEED_LOW
, USB_SPEED_FULL
, /* usb 1.1 */
82 USB_SPEED_HIGH
, /* usb 2.0 */
83 USB_SPEED_VARIABLE
/* wireless (usb 2.5) */
86 /* FIXME: how to sync with drivers/usbip_common.h ? */
87 enum usbip_device_status
{
88 /* sdev is available. */
89 SDEV_ST_AVAILABLE
= 0x01,
90 /* sdev is now used. */
92 /* sdev is unusable because of a fatal error. */
95 /* vdev does not connect a remote device. */
97 /* vdev is used, but the USB address is not assigned yet */
103 struct usbip_usb_interface
{
104 uint8_t bInterfaceClass
;
105 uint8_t bInterfaceSubClass
;
106 uint8_t bInterfaceProtocol
;
107 uint8_t padding
; /* alignment */
108 } __attribute__((packed
));
110 struct usbip_usb_device
{
111 char path
[SYSFS_PATH_MAX
];
112 char busid
[SYSFS_BUS_ID_SIZE
];
122 uint8_t bDeviceClass
;
123 uint8_t bDeviceSubClass
;
124 uint8_t bDeviceProtocol
;
125 uint8_t bConfigurationValue
;
126 uint8_t bNumConfigurations
;
127 uint8_t bNumInterfaces
;
128 } __attribute__((packed
));
130 #define to_string(s) #s
132 void dump_usb_interface(struct usbip_usb_interface
*);
133 void dump_usb_device(struct usbip_usb_device
*);
134 int read_usb_device(struct sysfs_device
*sdev
, struct usbip_usb_device
*udev
);
135 int read_attr_value(struct sysfs_device
*dev
, const char *name
,
137 int read_usb_interface(struct usbip_usb_device
*udev
, int i
,
138 struct usbip_usb_interface
*uinf
);
140 const char *usbip_speed_string(int num
);
141 const char *usbip_status_string(int32_t status
);
143 int usbip_names_init(char *);
144 void usbip_names_free(void);
145 void usbip_names_get_product(char *buff
, size_t size
, uint16_t vendor
,
147 void usbip_names_get_class(char *buff
, size_t size
, uint8_t class,
148 uint8_t subclass
, uint8_t protocol
);
150 #endif /* __USBIP_COMMON_H */
This page took 0.04395 seconds and 5 git commands to generate.