1 /** 2 \file usbobex.h 3 USB OBEX, USB transport for OBEX. 4 OpenOBEX library - Free implementation of the Object Exchange protocol. 5 6 Copyright (c) 2005 Alex Kanavin, All Rights Reserved. 7 8 OpenOBEX is free software; you can redistribute it and/or modify 9 it under the terms of the GNU Lesser General Public License as 10 published by the Free Software Foundation; either version 2.1 of 11 the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with OpenOBEX. If not, see <http://www.gnu.org/>. 20 */ 21 22 #ifndef USBOBEX_H 23 #define USBOBEX_H 24 25 #include <openobex/obex_const.h> 26 27 #ifdef HAVE_USB1 28 #include <libusb.h> 29 #else 30 #include <usb.h> 31 #endif 32 33 /* Information about a USB OBEX interface present on the system */ 34 struct obex_usb_intf_transport_t { 35 struct obex_usb_intf_transport_t *next; /* Next interface in the list */ 36 int configuration; /* Device configuration */ 37 int configuration_description; /* Configuration string descriptor number */ 38 int control_interface; /* OBEX master interface */ 39 int control_setting; /* OBEX master interface setting */ 40 int control_interface_description; /* OBEX master interface string descriptor number 41 * If non-zero, use usb_get_string_simple() from 42 * libusb to retrieve human-readable description 43 */ 44 char *extra_descriptors; /* Extra master interface descriptors */ 45 int extra_descriptors_len; /* Length of extra descriptors */ 46 int data_interface; /* OBEX data/slave interface */ 47 int data_idle_setting; /* OBEX data/slave idle setting */ 48 int data_interface_idle_description; /* OBEX data/slave interface string descriptor number 49 * in idle setting */ 50 int data_active_setting; /* OBEX data/slave active setting */ 51 int data_interface_active_description; /* OBEX data/slave interface string descriptor number 52 * in active setting */ 53 int data_endpoint_read; /* OBEX data/slave interface read endpoint */ 54 int data_endpoint_write; /* OBEX data/slave interface write endpoint */ 55 #ifdef HAVE_USB1 56 struct libusb_device *device; /* libusb 1.x device */ 57 struct libusb_device_handle *dev; /* libusb 1.x device handle */ 58 #else 59 struct usb_device *device; /* libusb 0.x device */ 60 usb_dev_handle *dev; /* libusb 0.x device handle */ 61 #endif 62 }; 63 64 /* "Union Functional Descriptor" from CDC spec 5.2.3.X 65 * used to find data/slave OBEX interface */ 66 #pragma pack(1) 67 struct cdc_union_desc { 68 uint8_t bLength; 69 uint8_t bDescriptorType; 70 uint8_t bDescriptorSubType; 71 72 uint8_t bMasterInterface0; 73 uint8_t bSlaveInterface0; 74 }; 75 #pragma pack() 76 77 /* CDC class and subclass types */ 78 #define USB_CDC_CLASS 0x02 79 #define USB_CDC_OBEX_SUBCLASS 0x0b 80 81 /* class and subclass specific descriptor types */ 82 #define CDC_HEADER_TYPE 0x00 83 #define CDC_CALL_MANAGEMENT_TYPE 0x01 84 #define CDC_AC_MANAGEMENT_TYPE 0x02 85 #define CDC_UNION_TYPE 0x06 86 #define CDC_COUNTRY_TYPE 0x07 87 #define CDC_OBEX_TYPE 0x15 88 #define CDC_OBEX_SERVICE_ID_TYPE 0x19 89 90 /* Interface descriptor */ 91 #define USB_DT_CS_INTERFACE 0x24 92 #define CDC_DATA_INTERFACE_TYPE 0x0a 93 94 #define WMC_DEFAULT_OBEX_SERVER_UUID \ 95 { 0x02, 0xae, 0xb3, 0x20, \ 96 0xf6, 0x49, 0x11, 0xda, \ 97 0x97, 0x4d, 0x08, 0x00, \ 98 0x20, 0x0c, 0x9a, 0x66 } 99 100 #define USB_MAX_STRING_SIZE 256 101 102 struct obex_transport * usbobex_transport_create(void); 103 104 struct usbobex_data { 105 #ifdef HAVE_USB1 106 struct libusb_context *ctx; 107 int fd; 108 #endif 109 struct obex_usb_intf_transport_t self; 110 }; 111 #endif 112