USBIP C library 0.7.0
Virtual USB devices & host drivers over USB/IP
Loading...
Searching...
No Matches
USB/IP transport

The wire under every host/device call. More...

Files

file  usbip.h
 Shared, role-neutral types and the transport seam.
 

Typedefs

typedef struct usb_transport usb_transport
 Opaque handle to a USB/IP transport (the wire under host/device calls).
 

Functions

usb_transportusbip_transport (const char *host, int port)
 Create a real USB/IP transport over TCP.
 
usb_transportusbip_loopback (void)
 Create an in-process transport for tests - no sockets, no kernel, no root.
 
void usbip_transport_free (usb_transport *transport)
 Release a transport created by usbip_transport() / usbip_loopback().
 

Detailed Description

The wire under every host/device call.

Only this module knows about USB/IP. Every host and device entry point takes an optional usb_transport *; NULL selects the default local transport, and usbip_transport() serves or connects over TCP. The device side listens on the handle and the host side connects to it (roles).

Typedef Documentation

◆ usb_transport

typedef struct usb_transport usb_transport

Opaque handle to a USB/IP transport (the wire under host/device calls).

Function Documentation

◆ usbip_transport()

usb_transport * usbip_transport ( const char *  host,
int  port 
)

Create a real USB/IP transport over TCP.

Hand the result to usbip_device_plug() (device side) or usbip_host_set_transport() (host side). Ownership stays with the caller: release it with usbip_transport_free() once the device is unplugged / the host context is exited.

Parameters
hostPeer/bind address. On the host side, the USB/IP server to connect to; on the device side, the local address to serve on. Pass NULL for the local default (connect to 127.0.0.1, serve on 0.0.0.0).
portTCP port; the USB/IP well-known port is 3240.
Returns
a transport handle, or NULL on allocation failure.

◆ usbip_loopback()

usb_transport * usbip_loopback ( void  )

Create an in-process transport for tests - no sockets, no kernel, no root.

A device plugged onto a loopback transport can be driven by a host built on the same handle, entirely within one process; the test suite uses this for cross-language verification.

Returns
a transport handle, or NULL on allocation failure.

◆ usbip_transport_free()

void usbip_transport_free ( usb_transport transport)

Release a transport created by usbip_transport() / usbip_loopback().

The transport must no longer be in use - unplug the device (usbip_device_unplug()) and exit any host context (usbip_host_exit()) first.

Parameters
transportthe transport to free.