~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/usb/usbip/libsrc/usbip_common.h

Version: ~ [ linux-5.5-rc2 ] ~ [ linux-5.4.3 ] ~ [ linux-5.3.16 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.89 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.158 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.206 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.206 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.79 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * Copyright (C) 2005-2007 Takahiro Hirofuchi
  4  */
  5 
  6 #ifndef __USBIP_COMMON_H
  7 #define __USBIP_COMMON_H
  8 
  9 #include <libudev.h>
 10 
 11 #include <stdint.h>
 12 #include <stdio.h>
 13 #include <stdlib.h>
 14 #include <string.h>
 15 
 16 #include <syslog.h>
 17 #include <unistd.h>
 18 #include <linux/usb/ch9.h>
 19 #include <linux/usbip.h>
 20 
 21 #ifndef USBIDS_FILE
 22 #define USBIDS_FILE "/usr/share/hwdata/usb.ids"
 23 #endif
 24 
 25 #ifndef VHCI_STATE_PATH
 26 #define VHCI_STATE_PATH "/var/run/vhci_hcd"
 27 #endif
 28 
 29 #define VUDC_DEVICE_DESCR_FILE "dev_desc"
 30 
 31 /* kernel module names */
 32 #define USBIP_CORE_MOD_NAME     "usbip-core"
 33 #define USBIP_HOST_DRV_NAME     "usbip-host"
 34 #define USBIP_DEVICE_DRV_NAME   "usbip-vudc"
 35 #define USBIP_VHCI_DRV_NAME     "vhci_hcd"
 36 
 37 /* sysfs constants */
 38 #define SYSFS_MNT_PATH         "/sys"
 39 #define SYSFS_BUS_NAME         "bus"
 40 #define SYSFS_BUS_TYPE         "usb"
 41 #define SYSFS_DRIVERS_NAME     "drivers"
 42 
 43 #define SYSFS_PATH_MAX          256
 44 #define SYSFS_BUS_ID_SIZE       32
 45 
 46 extern int usbip_use_syslog;
 47 extern int usbip_use_stderr;
 48 extern int usbip_use_debug ;
 49 
 50 #define PROGNAME "usbip"
 51 
 52 #define pr_fmt(fmt)     "%s: %s: " fmt "\n", PROGNAME
 53 #define dbg_fmt(fmt)    pr_fmt("%s:%d:[%s] " fmt), "debug",     \
 54                         __FILE__, __LINE__, __func__
 55 
 56 #define err(fmt, args...)                                               \
 57         do {                                                            \
 58                 if (usbip_use_syslog) {                                 \
 59                         syslog(LOG_ERR, pr_fmt(fmt), "error", ##args);  \
 60                 }                                                       \
 61                 if (usbip_use_stderr) {                                 \
 62                         fprintf(stderr, pr_fmt(fmt), "error", ##args);  \
 63                 }                                                       \
 64         } while (0)
 65 
 66 #define info(fmt, args...)                                              \
 67         do {                                                            \
 68                 if (usbip_use_syslog) {                                 \
 69                         syslog(LOG_INFO, pr_fmt(fmt), "info", ##args);  \
 70                 }                                                       \
 71                 if (usbip_use_stderr) {                                 \
 72                         fprintf(stderr, pr_fmt(fmt), "info", ##args);   \
 73                 }                                                       \
 74         } while (0)
 75 
 76 #define dbg(fmt, args...)                                               \
 77         do {                                                            \
 78         if (usbip_use_debug) {                                          \
 79                 if (usbip_use_syslog) {                                 \
 80                         syslog(LOG_DEBUG, dbg_fmt(fmt), ##args);        \
 81                 }                                                       \
 82                 if (usbip_use_stderr) {                                 \
 83                         fprintf(stderr, dbg_fmt(fmt), ##args);          \
 84                 }                                                       \
 85         }                                                               \
 86         } while (0)
 87 
 88 #define BUG()                                           \
 89         do {                                            \
 90                 err("sorry, it's a bug!");              \
 91                 abort();                                \
 92         } while (0)
 93 
 94 struct usbip_usb_interface {
 95         uint8_t bInterfaceClass;
 96         uint8_t bInterfaceSubClass;
 97         uint8_t bInterfaceProtocol;
 98         uint8_t padding;        /* alignment */
 99 } __attribute__((packed));
100 
101 struct usbip_usb_device {
102         char path[SYSFS_PATH_MAX];
103         char busid[SYSFS_BUS_ID_SIZE];
104 
105         uint32_t busnum;
106         uint32_t devnum;
107         uint32_t speed;
108 
109         uint16_t idVendor;
110         uint16_t idProduct;
111         uint16_t bcdDevice;
112 
113         uint8_t bDeviceClass;
114         uint8_t bDeviceSubClass;
115         uint8_t bDeviceProtocol;
116         uint8_t bConfigurationValue;
117         uint8_t bNumConfigurations;
118         uint8_t bNumInterfaces;
119 } __attribute__((packed));
120 
121 #define to_string(s)    #s
122 
123 void dump_usb_interface(struct usbip_usb_interface *);
124 void dump_usb_device(struct usbip_usb_device *);
125 int read_usb_device(struct udev_device *sdev, struct usbip_usb_device *udev);
126 int read_attr_value(struct udev_device *dev, const char *name,
127                     const char *format);
128 int read_usb_interface(struct usbip_usb_device *udev, int i,
129                        struct usbip_usb_interface *uinf);
130 
131 const char *usbip_speed_string(int num);
132 const char *usbip_status_string(int32_t status);
133 
134 int usbip_names_init(char *);
135 void usbip_names_free(void);
136 void usbip_names_get_product(char *buff, size_t size, uint16_t vendor,
137                              uint16_t product);
138 void usbip_names_get_class(char *buff, size_t size, uint8_t class,
139                            uint8_t subclass, uint8_t protocol);
140 
141 #endif /* __USBIP_COMMON_H */
142 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp