/libusbip

USB over IP

Primary LanguageC

Libusbip - C library to support USB over IP

Introducing

libusbip was originally designed to communicate with remote iDevices via USB over IP. It provides
a layer on top of libusb-1.0. libusbip allows you to work with remote USB devices over a local
network or Internet as if they were connected directly to your local Mac/PC.

It is realized as a library so you can write your own individual client-server programs.

How to build

To build libusbip you first need to install libusb-1.0 (http://www.libusb.org/wiki/libusb-1.0) and
tpl (http://tpl.sourceforge.net/).

After that just run make to compile libusbip or make all to compile libusbip and
all example programs.

Supported libusb functions

Currently, libusbip provides support for the following functions:

  • libusb_init
  • libusb_exit
  • libusb_get_device_list
  • libusb_get_device_descriptor
  • libusb_open_device_with_vid_pid
  • libusb_close
  • libusb_open
  • libusb_claim_interface
  • libusb_release_interface
  • libusb_get_configuration
  • libusb_set_configuration
  • libusb_set_interface_alt_setting
  • libusb_reset_device
  • libusb_control_transfer
  • libusb_bulk_transfer
  • libusb_clear_halt
  • libusb_get_string_descriptor_ascii

For a general overview, please refer to the libusb-1.0 API Reference http://libusb.sourceforge.net/api-1.0/

Data structures

libusbip consists of the following structures:

  • struct libusbip_device
    Reflection of struct libusb_device

  • struct libusbip_device_list
    Reflection of libusb_device **

  • struct libusbip_device_descriptor
    Reflection of libusb_device_descriptor

  • struct libusbip_device_handle
    Reflection of libusb_device_handle

  • struct libusbip_connection_info
    Holds information about the client or server, respectively. And
    if libusbip is used in client or server context.

  • struct libusbip_rpc_info
    Holds all information about the structures mentioned above. You
    require that structure if you use libusbip through the
    libusbip_rpc_call convenience function.

Typedefs

  • libusbip_error_t
    libusbip error identifier. Can be LIBUSBIP_E_SUCCESS or LIBUSBIP_E_FAILURE.

  • libusbip_rpc_t
    Identifies the Remote Procedure Call. For example, LIBUSBIP_RPC_USB_INIT
    stands for libusb_init

  • libusbip_ctx_t
    ibusbip context identifier. Can be LIBUSBIP_CTX_CLIENT or LIBUSBIP_CTX_SERVER.

Functions

  • libusbip_error_t libusbip_init(struct libusbip_connection_info *ci)

    Initialize libusbip.

    This function must be called before calling any other libusbip function.

    Parameters:
    ci connection info pointer.

    Returns:
    LIBUSBIP_E_SUCCESS on success, or LIBUSBIP_E_FAILURE on failure.

  • void libusbip_exit(struct libusbip_connection_info *ci)

    Deinitialize libusbip.

    Should be called after closing all open devices and before your application terminates.

    Parameters:
    ci connection info pointer.

  • void libusbip_get_device_list(struct libusbip_connection_info *ci, struct libusbip_device_list *dl)

    Returns a list of USB devices currently attached to the system.

    This is your entry point into finding a USB device to operate.

    Parameters:
    ci connection info pointer.
    dl pointer as output location for a list of devices.

  • libusbip_get_device_descriptor(struct libusbip_connection_info *ci, struct libusbip_device *dev,
    struct libusbip_device_descriptor *dd)


    Get the USB configuration descriptor for the currently active configuration.

    Parameters:
    ci connection info pointer.
    dev The device.
    dd pointer as output location for the descriptor data.

    Returns:
    LIBUSBIP_E_SUCCESS on success, or LIBUSBIP_E_FAILURE on failure.

  • libusbip_error_t libusbip_open(struct libusbip_connection_info *ci, struct libusbip_device *dev,
    struct libusbip_device_handle *dh)


    Open a device and obtain a device handle.

    Parameters:
    ci connection info pointer.
    dev The device.
    dh pointer as output location for the returned device handle pointer.

    Returns:
    LIBUSBIP_E_SUCCESS on success, or LIBUSBIP_E_FAILURE on failure.

  • libusbip_error_t libusbip_claim_interface(struct libusbip_connection_info *ci,
    struct libusbip_device_handle *dh, int intf)


    Claim an interface on a given device handle.

    Parameters:
    ci connection info pointer.
    dh The device handle.
    intf the number of the interface you wish to claim

    Returns:
    LIBUSBIP_E_SUCCESS on success, or LIBUSBIP_E_FAILURE on failure.