| usbip_common.h | | usbip_common.h | |
| /* | | /* | |
|
| * Copyright (C) 2005-2006 Takahiro Hirofuchi | | * Copyright (C) 2005-2007 Takahiro Hirofuchi | |
| */ | | */ | |
| | | | |
| #ifndef _USBIP_COMMON_H | | #ifndef _USBIP_COMMON_H | |
| #define _USBIP_COMMON_H | | #define _USBIP_COMMON_H | |
| | | | |
| #include <unistd.h> | | #include <unistd.h> | |
| #include <stdint.h> | | #include <stdint.h> | |
| #include <syslog.h> | | #include <syslog.h> | |
| #include <errno.h> | | #include <errno.h> | |
| #include <stdio.h> | | #include <stdio.h> | |
| #include <string.h> | | #include <string.h> | |
| #include <stdlib.h> | | #include <stdlib.h> | |
| #include <strings.h> | | #include <strings.h> | |
| | | | |
| #include <sysfs/libsysfs.h> | | #include <sysfs/libsysfs.h> | |
| #include <netdb.h> | | #include <netdb.h> | |
| #include <sys/socket.h> | | #include <sys/socket.h> | |
| | | | |
|
| #define USBIDS_FILE "/usr/share/hwdata/usb.ids" | | /* | |
| | | * logging has moved to this file | |
| | | */ | |
| | | #include "log_util.h" | |
| | | | |
|
| extern int usbip_use_syslog; | | #ifndef USBIDS_FILE | |
| extern int usbip_use_stderr; | | #define USBIDS_FILE "/usr/share/hwdata/usb.ids" | |
| extern int usbip_use_debug ; | | #endif | |
| | | | |
| //#include <linux/usb_ch9.h> | | //#include <linux/usb_ch9.h> | |
| enum usb_device_speed { | | enum usb_device_speed { | |
| USB_SPEED_UNKNOWN = 0, /* enumerating */ | | USB_SPEED_UNKNOWN = 0, /* enumerating */ | |
| USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ | | USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ | |
| USB_SPEED_HIGH, /* usb 2.0 */ | | USB_SPEED_HIGH, /* usb 2.0 */ | |
| USB_SPEED_VARIABLE /* wireless (usb 2.5) */ | | USB_SPEED_VARIABLE /* wireless (usb 2.5) */ | |
| }; | | }; | |
| | | | |
| /* FIXME: how to sync with drivers/usbip_common.h ? */ | | /* FIXME: how to sync with drivers/usbip_common.h ? */ | |
| | | | |
| skipping to change at line 52 | | skipping to change at line 55 | |
| SDEV_ST_ERROR, | | SDEV_ST_ERROR, | |
| | | | |
| /* vdev does not connect a remote device. */ | | /* vdev does not connect a remote device. */ | |
| VDEV_ST_NULL, | | VDEV_ST_NULL, | |
| /* vdev is used, but the USB address is not assigned yet */ | | /* vdev is used, but the USB address is not assigned yet */ | |
| VDEV_ST_NOTASSIGNED, | | VDEV_ST_NOTASSIGNED, | |
| VDEV_ST_USED, | | VDEV_ST_USED, | |
| VDEV_ST_ERROR | | VDEV_ST_ERROR | |
| }; | | }; | |
| | | | |
|
| | | /* | |
| | | extern int usbip_use_syslog; | |
| | | extern int usbip_use_stderr; | |
| | | extern int usbip_use_debug ; | |
| | | | |
| #define err(fmt, args...) do { \ | | #define err(fmt, args...) do { \ | |
|
| if(usbip_use_syslog) { \ | | if (usbip_use_syslog) { \ | |
| syslog(LOG_ERR, "usbip err: %13s:%4d (%-12s) " fmt " [%s]", | | syslog(LOG_ERR, "usbip err: %13s:%4d (%-12s) " fmt "\n", \ | |
| \ | | __FILE__, __LINE__, __FUNCTION__, ##args); \ | |
| __FILE__, __LINE__, __FUNCTION__, ##args, strerror( | | | |
| errno)); \ | | | |
| } \ | | } \ | |
|
| if(usbip_use_stderr) { \ | | if (usbip_use_stderr) { \ | |
| fprintf(stderr, "usbip err: %13s:%4d (%-12s) " fmt " [%s]\n | | fprintf(stderr, "usbip err: %13s:%4d (%-12s) " fmt "\n", \ | |
| ", \ | | __FILE__, __LINE__, __FUNCTION__, ##args); \ | |
| __FILE__, __LINE__, __FUNCTION__, ##args, strerror( | | | |
| errno)); \ | | | |
| } \ | | } \ | |
| } while (0) | | } while (0) | |
| | | | |
| #define notice(fmt, args...) do { \ | | #define notice(fmt, args...) do { \ | |
|
| if(usbip_use_syslog) { \ | | if (usbip_use_syslog) { \ | |
| syslog(LOG_DEBUG, "usbip: " fmt, ##args); \ | | syslog(LOG_DEBUG, "usbip: " fmt, ##args); \ | |
| } \ | | } \ | |
|
| if(usbip_use_stderr) { \ | | if (usbip_use_stderr) { \ | |
| fprintf(stderr, "usbip: " fmt "\n", ##args); \ | | fprintf(stderr, "usbip: " fmt "\n", ##args); \ | |
| } \ | | } \ | |
| } while (0) | | } while (0) | |
| | | | |
| #define info(fmt, args...) do { \ | | #define info(fmt, args...) do { \ | |
|
| if(usbip_use_syslog) { \ | | if (usbip_use_syslog) { \ | |
| syslog(LOG_DEBUG, fmt, ##args); \ | | syslog(LOG_DEBUG, fmt, ##args); \ | |
| } \ | | } \ | |
|
| if(usbip_use_stderr) { \ | | if (usbip_use_stderr) { \ | |
| fprintf(stderr, fmt "\n", ##args); \ | | fprintf(stderr, fmt "\n", ##args); \ | |
| } \ | | } \ | |
| } while (0) | | } while (0) | |
| | | | |
| #define dbg(fmt, args...) do { \ | | #define dbg(fmt, args...) do { \ | |
|
| if(usbip_use_debug) { \ | | if (usbip_use_debug) { \ | |
| if(usbip_use_syslog) { \ | | if (usbip_use_syslog) { \ | |
| syslog(LOG_DEBUG, "usbip dbg: %13s:%4d (%-12s) " fmt
, \ | | syslog(LOG_DEBUG, "usbip dbg: %13s:%4d (%-12s) " fmt
, \ | |
| __FILE__, __LINE__, __FUNCTION__, ##args);
\ | | __FILE__, __LINE__, __FUNCTION__, ##args);
\ | |
| } \ | | } \ | |
|
| if(usbip_use_stderr) { \ | | if (usbip_use_stderr) { \ | |
| fprintf(stderr, "usbip dbg: %13s:%4d (%-12s) " fmt "
\n", \ | | fprintf(stderr, "usbip dbg: %13s:%4d (%-12s) " fmt "
\n", \ | |
| __FILE__, __LINE__, __FUNCTION__, ##args);
\ | | __FILE__, __LINE__, __FUNCTION__, ##args);
\ | |
| } \ | | } \ | |
| } \ | | } \ | |
| } while (0) | | } while (0) | |
| | | | |
|
| #define BUG() do { err("sorry, it's a bug"); abort(); } while(0) | | #define BUG() do { err("sorry, it's a bug"); abort(); } while (0) | |
| | | */ | |
| | | | |
| struct usb_interface { | | struct usb_interface { | |
| uint8_t bInterfaceClass; | | uint8_t bInterfaceClass; | |
| uint8_t bInterfaceSubClass; | | uint8_t bInterfaceSubClass; | |
| uint8_t bInterfaceProtocol; | | uint8_t bInterfaceProtocol; | |
|
| | | uint8_t padding; /* alignment */ | |
| } __attribute__((packed)); | | } __attribute__((packed)); | |
| | | | |
| struct usb_device { | | struct usb_device { | |
| char path[SYSFS_PATH_MAX]; | | char path[SYSFS_PATH_MAX]; | |
| char busid[SYSFS_BUS_ID_SIZE]; | | char busid[SYSFS_BUS_ID_SIZE]; | |
| | | | |
| uint32_t busnum; | | uint32_t busnum; | |
| uint32_t devnum; | | uint32_t devnum; | |
| uint32_t speed; | | uint32_t speed; | |
| | | | |
| | | | |
| skipping to change at line 133 | | skipping to change at line 143 | |
| | | | |
| void dump_usb_interface(struct usb_interface *); | | void dump_usb_interface(struct usb_interface *); | |
| void dump_usb_device(struct usb_device *); | | void dump_usb_device(struct usb_device *); | |
| int read_usb_device(struct sysfs_device *sdev, struct usb_device *udev); | | 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_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); | | int read_usb_interface(struct usb_device *udev, int i, struct usb_interface
*uinf); | |
| | | | |
| const char *usbip_speed_string(int num); | | const char *usbip_speed_string(int num); | |
| const char *usbip_status_string(int32_t status); | | const char *usbip_status_string(int32_t status); | |
| | | | |
|
| void usbip_product_name(char *buff, size_t size, uint16_t vendor, uint16_t | | int usbip_names_init(char *); | |
| product); | | void usbip_names_free(void); | |
| void usbip_class_name(char *buff, size_t size, uint8_t class, uint8_t subcl | | void usbip_names_get_product(char *buff, size_t size, uint16_t vendor, uint | |
| ass, uint8_t protocol); | | 16_t product); | |
| | | void usbip_names_get_class(char *buff, size_t size, uint8_t class, uint8_t | |
| void pack_uint32_t(int pack, uint32_t *num); | | subclass, uint8_t protocol); | |
| void pack_uint16_t(int pack, uint16_t *num); | | | |
| void pack_usb_device(int pack, struct usb_device *udev); | | | |
| void pack_usb_interface(int pack, struct usb_interface *uinf); | | | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 15 change blocks. |
| 32 lines changed or deleted | | 35 lines changed or added | |
|
| vhci_driver.h | | vhci_driver.h | |
| /* | | /* | |
|
| * Copyright (C) 2005-2006 Takahiro Hirofuchi | | * Copyright (C) 2005-2007 Takahiro Hirofuchi | |
| */ | | */ | |
| | | | |
| #ifndef _VHCI_DRIVER_H | | #ifndef _VHCI_DRIVER_H | |
| #define _VHCI_DRIVER_H | | #define _VHCI_DRIVER_H | |
| | | | |
| #include "usbip.h" | | #include "usbip.h" | |
| | | | |
|
| extern const char *portst_str[]; | | | |
| | | | |
| #define MAXNPORT 128 | | #define MAXNPORT 128 | |
| | | | |
| struct class_device { | | struct class_device { | |
| char clspath[SYSFS_PATH_MAX]; | | char clspath[SYSFS_PATH_MAX]; | |
| char devpath[SYSFS_PATH_MAX]; | | char devpath[SYSFS_PATH_MAX]; | |
| }; | | }; | |
| | | | |
| struct usbip_imported_device { | | struct usbip_imported_device { | |
| uint8_t port; | | uint8_t port; | |
| uint32_t status; | | uint32_t status; | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 38 | |
| struct usbip_vhci_driver { | | struct usbip_vhci_driver { | |
| char sysfs_mntpath[SYSFS_PATH_MAX]; | | char sysfs_mntpath[SYSFS_PATH_MAX]; | |
| struct sysfs_device *hc_device; /* /sys/devices/platform/vhci_hcd */ | | struct sysfs_device *hc_device; /* /sys/devices/platform/vhci_hcd */ | |
| | | | |
| struct dlist *cdev_list; /* list of class device */ | | struct dlist *cdev_list; /* list of class device */ | |
| | | | |
| int nports; | | int nports; | |
| struct usbip_imported_device idev[MAXNPORT]; | | struct usbip_imported_device idev[MAXNPORT]; | |
| }; | | }; | |
| | | | |
|
| struct usbip_vhci_driver *usbip_vhci_driver_open(void); | | extern struct usbip_vhci_driver *vhci_driver; | |
| void usbip_vhci_driver_close(struct usbip_vhci_driver *driver); | | | |
| int usbip_vhci_refresh_device_list(struct usbip_vhci_driver *driver); | | | |
| | | | |
|
| int usbip_vhci_get_free_port(struct usbip_vhci_driver *driver); | | int usbip_vhci_driver_open(void); | |
| int usbip_vhci_import_device(struct usbip_vhci_driver *driver, | | void usbip_vhci_driver_close(void); | |
| uint8_t port, int sockfd, struct usb_device *udev); | | | |
| int usbip_vhci_import_device2(struct usbip_vhci_driver *driver, | | int usbip_vhci_refresh_device_list(void); | |
| uint8_t port, int sockfd, uint8_t busnum, | | | |
| | | int usbip_vhci_get_free_port(void); | |
| | | int usbip_vhci_attach_device(uint8_t port, int sockfd, uint8_t busnum, | |
| uint8_t devnum, uint32_t speed); | | uint8_t devnum, uint32_t speed); | |
|
| int usbip_vhci_detach_device(struct usbip_vhci_driver *driver, uint8_t port
); | | int usbip_vhci_detach_device(uint8_t port); | |
| #endif | | #endif | |
| | | | |
End of changes. 5 change blocks. |
| 12 lines changed or deleted | | 10 lines changed or added | |
|