/usr/include/usbip/usbip_common.h is in libusbip-dev 0.1.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /*
* Copyright (C) 2005-2007 Takahiro Hirofuchi
*/
#ifndef _USBIP_COMMON_H
#define _USBIP_COMMON_H
#include <unistd.h>
#include <stdint.h>
#include <syslog.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <strings.h>
#include <sysfs/libsysfs.h>
#include <netdb.h>
#include <sys/socket.h>
#ifndef USBIDS_FILE
#define USBIDS_FILE "/usr/share/hwdata/usb.ids"
#endif
#ifndef VHCI_STATE_PATH
#define VHCI_STATE_PATH "/var/run/vhci_hcd"
#endif
//#include <linux/usb_ch9.h>
enum usb_device_speed {
USB_SPEED_UNKNOWN = 0, /* enumerating */
USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
USB_SPEED_HIGH, /* usb 2.0 */
USB_SPEED_VARIABLE /* wireless (usb 2.5) */
};
/* FIXME: how to sync with drivers/usbip_common.h ? */
enum usbip_device_status{
/* sdev is available. */
SDEV_ST_AVAILABLE = 0x01,
/* sdev is now used. */
SDEV_ST_USED,
/* sdev is unusable because of a fatal error. */
SDEV_ST_ERROR,
/* vdev does not connect a remote device. */
VDEV_ST_NULL,
/* vdev is used, but the USB address is not assigned yet */
VDEV_ST_NOTASSIGNED,
VDEV_ST_USED,
VDEV_ST_ERROR
};
extern int usbip_use_syslog;
extern int usbip_use_stderr;
extern int usbip_use_debug ;
#define err(fmt, args...) do { \
if (usbip_use_syslog) { \
syslog(LOG_ERR, "usbip err: %13s:%4d (%-12s) " fmt "\n", \
__FILE__, __LINE__, __FUNCTION__, ##args); \
} \
if (usbip_use_stderr) { \
fprintf(stderr, "usbip err: %13s:%4d (%-12s) " fmt "\n", \
__FILE__, __LINE__, __FUNCTION__, ##args); \
} \
} while (0)
#define notice(fmt, args...) do { \
if (usbip_use_syslog) { \
syslog(LOG_DEBUG, "usbip: " fmt, ##args); \
} \
if (usbip_use_stderr) { \
fprintf(stderr, "usbip: " fmt "\n", ##args); \
} \
} while (0)
#define info(fmt, args...) do { \
if (usbip_use_syslog) { \
syslog(LOG_DEBUG, fmt, ##args); \
} \
if (usbip_use_stderr) { \
fprintf(stderr, fmt "\n", ##args); \
} \
} while (0)
#define dbg(fmt, args...) do { \
if (usbip_use_debug) { \
if (usbip_use_syslog) { \
syslog(LOG_DEBUG, "usbip dbg: %13s:%4d (%-12s) " fmt, \
__FILE__, __LINE__, __FUNCTION__, ##args); \
} \
if (usbip_use_stderr) { \
fprintf(stderr, "usbip dbg: %13s:%4d (%-12s) " fmt "\n", \
__FILE__, __LINE__, __FUNCTION__, ##args); \
} \
} \
} while (0)
#define BUG() do { err("sorry, it's a bug"); abort(); } while (0)
struct usb_interface {
uint8_t bInterfaceClass;
uint8_t bInterfaceSubClass;
uint8_t bInterfaceProtocol;
uint8_t padding; /* alignment */
} __attribute__((packed));
struct usb_device {
char path[SYSFS_PATH_MAX];
char busid[SYSFS_BUS_ID_SIZE];
uint32_t busnum;
uint32_t devnum;
uint32_t speed;
uint16_t idVendor;
uint16_t idProduct;
uint16_t bcdDevice;
uint8_t bDeviceClass;
uint8_t bDeviceSubClass;
uint8_t bDeviceProtocol;
uint8_t bConfigurationValue;
uint8_t bNumConfigurations;
uint8_t bNumInterfaces;
} __attribute__((packed));
#define to_string(s) #s
void dump_usb_interface(struct usb_interface *);
void dump_usb_device(struct usb_device *);
int read_usb_device(struct sysfs_device *sdev, struct usb_device *udev);
int read_attr_value(struct sysfs_device *dev, const char *name, const char *format);
int read_usb_interface(struct usb_device *udev, int i, struct usb_interface *uinf);
const char *usbip_speed_string(int num);
const char *usbip_status_string(int32_t status);
int usbip_names_init(char *);
void usbip_names_free(void);
void usbip_names_get_product(char *buff, size_t size, uint16_t vendor, uint16_t product);
void usbip_names_get_class(char *buff, size_t size, uint8_t class, uint8_t subclass, uint8_t protocol);
#endif
|