FreeRDP
libusb_udevice.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/sysinfo.h>
#include <winpr/collections.h>
#include <errno.h>
#include "libusb_udevice.h"
#include "../common/urbdrc_types.h"

Macros

#define BASIC_STATE_FUNC_DEFINED(_arg, _type)
 
#define BASIC_POINT_FUNC_DEFINED(_arg, _type)
 
#define BASIC_STATE_FUNC_REGISTER(_arg, _dev)
 

Functions

static BOOL log_libusb_result (wLog *log, DWORD lvl, const char *fmt, int error,...)
 
const char * usb_interface_class_to_string (uint8_t class)
 
static ASYNC_TRANSFER_USER_DATA * async_transfer_user_data_new (IUDEVICE *idev, UINT32 MessageId, size_t offset, size_t BufferSize, size_t packetSize, BOOL NoAck, t_isoch_transfer_cb cb, URBDRC_CHANNEL_CALLBACK *callback)
 
static void async_transfer_user_data_free (ASYNC_TRANSFER_USER_DATA *user_data)
 
static void func_iso_callback (struct libusb_transfer *transfer)
 
static const LIBUSB_ENDPOINT_DESCEIPTORfunc_get_ep_desc (LIBUSB_CONFIG_DESCRIPTOR *LibusbConfig, MSUSB_CONFIG_DESCRIPTOR *MsConfig, UINT32 EndpointAddress)
 
static void func_bulk_transfer_cb (struct libusb_transfer *transfer)
 
static BOOL func_set_usbd_status (URBDRC_PLUGIN *urbdrc, UDEVICE *pdev, UINT32 *status, int err_result)
 
static int func_config_release_all_interface (URBDRC_PLUGIN *urbdrc, LIBUSB_DEVICE_HANDLE *libusb_handle, UINT32 NumInterfaces)
 
static int func_claim_all_interface (URBDRC_PLUGIN *urbdrc, LIBUSB_DEVICE_HANDLE *libusb_handle, int NumInterfaces)
 
static LIBUSB_DEVICEudev_get_libusb_dev (libusb_context *context, uint8_t bus_number, uint8_t dev_number)
 
static LIBUSB_DEVICE_DESCRIPTORudev_new_descript (URBDRC_PLUGIN *urbdrc, LIBUSB_DEVICE *libusb_dev)
 
static int libusb_udev_select_interface (IUDEVICE *idev, BYTE InterfaceNumber, BYTE AlternateSetting)
 
static MSUSB_CONFIG_DESCRIPTOR * libusb_udev_complete_msconfig_setup (IUDEVICE *idev, MSUSB_CONFIG_DESCRIPTOR *MsConfig)
 
static int libusb_udev_select_configuration (IUDEVICE *idev, UINT32 bConfigurationValue)
 
static int libusb_udev_control_pipe_request (IUDEVICE *idev, UINT32 RequestId, UINT32 EndpointAddress, UINT32 *UsbdStatus, int command)
 
static UINT32 libusb_udev_control_query_device_text (IUDEVICE *idev, UINT32 TextType, UINT16 LocaleId, UINT8 *BufferSize, BYTE *Buffer)
 
static int libusb_udev_os_feature_descriptor_request (IUDEVICE *idev, UINT32 RequestId, BYTE Recipient, BYTE InterfaceNumber, BYTE Ms_PageIndex, UINT16 Ms_featureDescIndex, UINT32 *UsbdStatus, UINT32 *BufferSize, BYTE *Buffer, int Timeout)
 
static int libusb_udev_query_device_descriptor (IUDEVICE *idev, int offset)
 
static BOOL libusb_udev_detach_kernel_driver (IUDEVICE *idev)
 
static BOOL libusb_udev_attach_kernel_driver (IUDEVICE *idev)
 
static int libusb_udev_is_composite_device (IUDEVICE *idev)
 
static int libusb_udev_is_exist (IUDEVICE *idev)
 
static int libusb_udev_is_channel_closed (IUDEVICE *idev)
 
static int libusb_udev_is_already_send (IUDEVICE *idev)
 
static void libusb_udev_channel_closed (IUDEVICE *idev)
 
static void libusb_udev_set_already_send (IUDEVICE *idev)
 
static char * libusb_udev_get_path (IUDEVICE *idev)
 
static int libusb_udev_query_device_port_status (IUDEVICE *idev, UINT32 *UsbdStatus, UINT32 *BufferSize, BYTE *Buffer)
 
static int libusb_udev_isoch_transfer (IUDEVICE *idev, URBDRC_CHANNEL_CALLBACK *callback, UINT32 MessageId, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags, UINT32 StartFrame, UINT32 ErrorCount, BOOL NoAck, const BYTE *packetDescriptorData, UINT32 NumberOfPackets, UINT32 BufferSize, const BYTE *Buffer, t_isoch_transfer_cb cb, UINT32 Timeout)
 
static BOOL libusb_udev_control_transfer (IUDEVICE *idev, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags, BYTE bmRequestType, BYTE Request, UINT16 Value, UINT16 Index, UINT32 *UrbdStatus, UINT32 *BufferSize, BYTE *Buffer, UINT32 Timeout)
 
static int libusb_udev_bulk_or_interrupt_transfer (IUDEVICE *idev, URBDRC_CHANNEL_CALLBACK *callback, UINT32 MessageId, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags, BOOL NoAck, UINT32 BufferSize, t_isoch_transfer_cb cb, UINT32 Timeout)
 
static int func_cancel_xact_request (URBDRC_PLUGIN *urbdrc, wHashTable *queue, uint32_t streamID, struct libusb_transfer *transfer)
 
static void libusb_udev_cancel_all_transfer_request (IUDEVICE *idev)
 
static int libusb_udev_cancel_transfer_request (IUDEVICE *idev, UINT32 RequestId)
 
static UINT32 udev_get_UsbDevice (IUDEVICE *idev)
 
static void udev_set_UsbDevice (IUDEVICE *idev, UINT32 val)
 
static void udev_free (IUDEVICE *idev)
 
static void udev_load_interface (UDEVICE *pdev)
 
static int udev_get_hub_handle (URBDRC_PLUGIN *urbdrc, libusb_context *ctx, UDEVICE *pdev, UINT16 bus_number, UINT16 dev_number)
 
static void request_free (void *value)
 
static IUDEVICE * udev_init (URBDRC_PLUGIN *urbdrc, libusb_context *context, LIBUSB_DEVICE *device, BYTE bus_number, BYTE dev_number)
 
size_t udev_new_by_id (URBDRC_PLUGIN *urbdrc, libusb_context *ctx, UINT16 idVendor, UINT16 idProduct, IUDEVICE ***devArray)
 
IUDEVICE * udev_new_by_addr (URBDRC_PLUGIN *urbdrc, libusb_context *context, BYTE bus_number, BYTE dev_number)
 

Macro Definition Documentation

◆ BASIC_POINT_FUNC_DEFINED

#define BASIC_POINT_FUNC_DEFINED (   _arg,
  _type 
)
Value:
static _type udev_get_p_##_arg(IUDEVICE* idev) \
{ \
UDEVICE* pdev = (UDEVICE*)idev; \
return pdev->_arg; \
} \
static void udev_set_p_##_arg(IUDEVICE* idev, _type _t) \
{ \
UDEVICE* pdev = (UDEVICE*)idev; \
pdev->_arg = _t; \
}

◆ BASIC_STATE_FUNC_DEFINED

#define BASIC_STATE_FUNC_DEFINED (   _arg,
  _type 
)
Value:
static _type udev_get_##_arg(IUDEVICE* idev) \
{ \
UDEVICE* pdev = (UDEVICE*)idev; \
return pdev->_arg; \
} \
static void udev_set_##_arg(IUDEVICE* idev, _type _t) \
{ \
UDEVICE* pdev = (UDEVICE*)idev; \
pdev->_arg = _t; \
}

FreeRDP: A Remote Desktop Protocol Implementation RemoteFX USB Redirection

Copyright 2012 Atrust corp. Copyright 2012 Alfred Liu alfre.nosp@m.d.li.nosp@m.u@atr.nosp@m.usco.nosp@m.rp.co.nosp@m.m

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

◆ BASIC_STATE_FUNC_REGISTER

#define BASIC_STATE_FUNC_REGISTER (   _arg,
  _dev 
)
Value:
_dev->iface.get_##_arg = udev_get_##_arg; \
_dev->iface.set_##_arg = udev_set_##_arg

Function Documentation

◆ async_transfer_user_data_free()

static void async_transfer_user_data_free ( ASYNC_TRANSFER_USER_DATA *  user_data)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ async_transfer_user_data_new()

static ASYNC_TRANSFER_USER_DATA* async_transfer_user_data_new ( IUDEVICE *  idev,
UINT32  MessageId,
size_t  offset,
size_t  BufferSize,
size_t  packetSize,
BOOL  NoAck,
t_isoch_transfer_cb  cb,
URBDRC_CHANNEL_CALLBACK *  callback 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_bulk_transfer_cb()

static void func_bulk_transfer_cb ( struct libusb_transfer *  transfer)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_cancel_xact_request()

static int func_cancel_xact_request ( URBDRC_PLUGIN *  urbdrc,
wHashTable *  queue,
uint32_t  streamID,
struct libusb_transfer *  transfer 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_claim_all_interface()

static int func_claim_all_interface ( URBDRC_PLUGIN *  urbdrc,
LIBUSB_DEVICE_HANDLE libusb_handle,
int  NumInterfaces 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_config_release_all_interface()

static int func_config_release_all_interface ( URBDRC_PLUGIN *  urbdrc,
LIBUSB_DEVICE_HANDLE libusb_handle,
UINT32  NumInterfaces 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_get_ep_desc()

static const LIBUSB_ENDPOINT_DESCEIPTOR* func_get_ep_desc ( LIBUSB_CONFIG_DESCRIPTOR LibusbConfig,
MSUSB_CONFIG_DESCRIPTOR *  MsConfig,
UINT32  EndpointAddress 
)
static
Here is the caller graph for this function:

◆ func_iso_callback()

static void func_iso_callback ( struct libusb_transfer *  transfer)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ func_set_usbd_status()

static BOOL func_set_usbd_status ( URBDRC_PLUGIN *  urbdrc,
UDEVICE *  pdev,
UINT32 *  status,
int  err_result 
)
static
Here is the caller graph for this function:

◆ libusb_udev_attach_kernel_driver()

static BOOL libusb_udev_attach_kernel_driver ( IUDEVICE *  idev)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_bulk_or_interrupt_transfer()

static int libusb_udev_bulk_or_interrupt_transfer ( IUDEVICE *  idev,
URBDRC_CHANNEL_CALLBACK *  callback,
UINT32  MessageId,
UINT32  RequestId,
UINT32  EndpointAddress,
UINT32  TransferFlags,
BOOL  NoAck,
UINT32  BufferSize,
t_isoch_transfer_cb  cb,
UINT32  Timeout 
)
static

Bulk Transfer

Interrupt Transfer

Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_cancel_all_transfer_request()

static void libusb_udev_cancel_all_transfer_request ( IUDEVICE *  idev)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_cancel_transfer_request()

static int libusb_udev_cancel_transfer_request ( IUDEVICE *  idev,
UINT32  RequestId 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_channel_closed()

static void libusb_udev_channel_closed ( IUDEVICE *  idev)
static
Here is the caller graph for this function:

◆ libusb_udev_complete_msconfig_setup()

static MSUSB_CONFIG_DESCRIPTOR* libusb_udev_complete_msconfig_setup ( IUDEVICE *  idev,
MSUSB_CONFIG_DESCRIPTOR *  MsConfig 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_control_pipe_request()

static int libusb_udev_control_pipe_request ( IUDEVICE *  idev,
UINT32  RequestId,
UINT32  EndpointAddress,
UINT32 *  UsbdStatus,
int  command 
)
static

cancel bulk or int transfer

set feature to ep (set halt)

Here is the caller graph for this function:

◆ libusb_udev_control_query_device_text()

static UINT32 libusb_udev_control_query_device_text ( IUDEVICE *  idev,
UINT32  TextType,
UINT16  LocaleId,
UINT8 *  BufferSize,
BYTE Buffer 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_control_transfer()

static BOOL libusb_udev_control_transfer ( IUDEVICE *  idev,
UINT32  RequestId,
UINT32  EndpointAddress,
UINT32  TransferFlags,
BYTE  bmRequestType,
BYTE  Request,
UINT16  Value,
UINT16  Index,
UINT32 *  UrbdStatus,
UINT32 *  BufferSize,
BYTE Buffer,
UINT32  Timeout 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_detach_kernel_driver()

static BOOL libusb_udev_detach_kernel_driver ( IUDEVICE *  idev)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_get_path()

static char* libusb_udev_get_path ( IUDEVICE *  idev)
static
Here is the caller graph for this function:

◆ libusb_udev_is_already_send()

static int libusb_udev_is_already_send ( IUDEVICE *  idev)
static
Here is the caller graph for this function:

◆ libusb_udev_is_channel_closed()

static int libusb_udev_is_channel_closed ( IUDEVICE *  idev)
static
Here is the caller graph for this function:

◆ libusb_udev_is_composite_device()

static int libusb_udev_is_composite_device ( IUDEVICE *  idev)
static
Here is the caller graph for this function:

◆ libusb_udev_is_exist()

static int libusb_udev_is_exist ( IUDEVICE *  idev)
static
Here is the caller graph for this function:

◆ libusb_udev_isoch_transfer()

static int libusb_udev_isoch_transfer ( IUDEVICE *  idev,
URBDRC_CHANNEL_CALLBACK *  callback,
UINT32  MessageId,
UINT32  RequestId,
UINT32  EndpointAddress,
UINT32  TransferFlags,
UINT32  StartFrame,
UINT32  ErrorCount,
BOOL  NoAck,
const BYTE packetDescriptorData,
UINT32  NumberOfPackets,
UINT32  BufferSize,
const BYTE Buffer,
t_isoch_transfer_cb  cb,
UINT32  Timeout 
)
static

process URB_FUNCTION_IOSCH_TRANSFER

Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_os_feature_descriptor_request()

static int libusb_udev_os_feature_descriptor_request ( IUDEVICE *  idev,
UINT32  RequestId,
BYTE  Recipient,
BYTE  InterfaceNumber,
BYTE  Ms_PageIndex,
UINT16  Ms_featureDescIndex,
UINT32 *  UsbdStatus,
UINT32 *  BufferSize,
BYTE Buffer,
int  Timeout 
)
static

get os descriptor

Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_query_device_descriptor()

static int libusb_udev_query_device_descriptor ( IUDEVICE *  idev,
int  offset 
)
static
Here is the caller graph for this function:

◆ libusb_udev_query_device_port_status()

static int libusb_udev_query_device_port_status ( IUDEVICE *  idev,
UINT32 *  UsbdStatus,
UINT32 *  BufferSize,
BYTE Buffer 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_select_configuration()

static int libusb_udev_select_configuration ( IUDEVICE *  idev,
UINT32  bConfigurationValue 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_select_interface()

static int libusb_udev_select_interface ( IUDEVICE *  idev,
BYTE  InterfaceNumber,
BYTE  AlternateSetting 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libusb_udev_set_already_send()

static void libusb_udev_set_already_send ( IUDEVICE *  idev)
static
Here is the caller graph for this function:

◆ log_libusb_result()

static BOOL log_libusb_result ( wLog *  log,
DWORD  lvl,
const char *  fmt,
int  error,
  ... 
)
static
Here is the caller graph for this function:

◆ request_free()

static void request_free ( void *  value)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ udev_free()

static void udev_free ( IUDEVICE *  idev)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ udev_get_hub_handle()

static int udev_get_hub_handle ( URBDRC_PLUGIN *  urbdrc,
libusb_context *  ctx,
UDEVICE *  pdev,
UINT16  bus_number,
UINT16  dev_number 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ udev_get_libusb_dev()

static LIBUSB_DEVICE* udev_get_libusb_dev ( libusb_context *  context,
uint8_t  bus_number,
uint8_t  dev_number 
)
static
Here is the caller graph for this function:

◆ udev_get_UsbDevice()

static UINT32 udev_get_UsbDevice ( IUDEVICE *  idev)
static

◆ udev_init()

static IUDEVICE* udev_init ( URBDRC_PLUGIN *  urbdrc,
libusb_context *  context,
LIBUSB_DEVICE device,
BYTE  bus_number,
BYTE  dev_number 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ udev_load_interface()

static void udev_load_interface ( UDEVICE *  pdev)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ udev_new_by_addr()

IUDEVICE* udev_new_by_addr ( URBDRC_PLUGIN *  urbdrc,
libusb_context *  context,
BYTE  bus_number,
BYTE  dev_number 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ udev_new_by_id()

size_t udev_new_by_id ( URBDRC_PLUGIN *  urbdrc,
libusb_context *  ctx,
UINT16  idVendor,
UINT16  idProduct,
IUDEVICE ***  devArray 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ udev_new_descript()

static LIBUSB_DEVICE_DESCRIPTOR* udev_new_descript ( URBDRC_PLUGIN *  urbdrc,
LIBUSB_DEVICE libusb_dev 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ udev_set_UsbDevice()

static void udev_set_UsbDevice ( IUDEVICE *  idev,
UINT32  val 
)
static

◆ usb_interface_class_to_string()

const char* usb_interface_class_to_string ( uint8_t  class)
Here is the caller graph for this function: