FreeRDP
libusb_udevice.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <winpr/crt.h>
#include "libusb_udevice.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 int get_next_timeout (libusb_context *ctx, struct timeval *tv, struct timeval *out)
 
static int handle_events_completed (libusb_context *ctx, int *completed)
 
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 int func_set_usbd_status (UDEVICE *pdev, UINT32 *status, int err_result)
 
static void func_iso_data_init (ISO_USER_DATA *iso_user_data, UINT32 numPacket, UINT32 buffsize, UINT32 noAck, BYTE *isoPacket, BYTE *buffer)
 
static int func_config_release_all_interface (LIBUSB_DEVICE_HANDLE *libusb_handle, UINT32 NumInterfaces)
 
static int func_claim_all_interface (LIBUSB_DEVICE_HANDLE *libusb_handle, int NumInterfaces)
 
static LIBUSB_DEVICEudev_get_libusb_dev (int bus_number, int dev_number)
 
static LIBUSB_DEVICE_DESCRIPTORudev_new_descript (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 int libusb_udev_control_query_device_text (IUDEVICE *idev, UINT32 TextType, UINT32 LocaleId, UINT32 *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 void libusb_udev_detach_kernel_driver (IUDEVICE *idev)
 
static void libusb_udev_attach_kernel_driver (IUDEVICE *idev)
 
static int libusb_udev_is_composite_device (IUDEVICE *idev)
 
static int libusb_udev_is_signal_end (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_signal_end (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_wait_action_completion (IUDEVICE *idev)
 
static void libusb_udev_push_action (IUDEVICE *idev)
 
static void libusb_udev_complete_action (IUDEVICE *idev)
 
static int libusb_udev_wait_for_detach (IUDEVICE *idev)
 
static void libusb_udev_lock_fifo_isoch (IUDEVICE *idev)
 
static void libusb_udev_unlock_fifo_isoch (IUDEVICE *idev)
 
static int libusb_udev_query_device_port_status (IUDEVICE *idev, UINT32 *UsbdStatus, UINT32 *BufferSize, BYTE *Buffer)
 
static int libusb_udev_request_queue_is_none (IUDEVICE *idev)
 
static int libusb_udev_isoch_transfer (IUDEVICE *idev, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags, int NoAck, UINT32 *ErrorCount, UINT32 *UrbdStatus, UINT32 *StartFrame, UINT32 NumberOfPackets, BYTE *IsoPacket, UINT32 *BufferSize, BYTE *Buffer, int Timeout)
 
static int 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, UINT32 RequestId, UINT32 EndpointAddress, UINT32 TransferFlags, UINT32 *UsbdStatus, UINT32 *BufferSize, BYTE *Buffer, UINT32 Timeout)
 
static void libusb_udev_cancel_all_transfer_request (IUDEVICE *idev)
 
static int func_cancel_xact_request (TRANSFER_REQUEST *request)
 
static int libusb_udev_cancel_transfer_request (IUDEVICE *idev, UINT32 RequestId)
 
static void udev_load_interface (UDEVICE *pdev)
 
static IUDEVICE * udev_init (UDEVICE *pdev, UINT16 bus_number, UINT16 dev_number)
 
int udev_new_by_id (UINT16 idVendor, UINT16 idProduct, IUDEVICE ***devArray)
 
IUDEVICE * udev_new_by_addr (int bus_number, int dev_number)
 

Macro Definition Documentation

#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; \
}
return(void *)((char *) buffer-> buffer+buffer->tail)
#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; \
}
return(void *)((char *) buffer-> buffer+buffer->tail)

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.

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

Function Documentation

static void func_bulk_transfer_cb ( struct libusb_transfer *  transfer)
static

Here is the caller graph for this function:

static int func_cancel_xact_request ( TRANSFER_REQUEST *  request)
static

Here is the caller graph for this function:

static int func_claim_all_interface ( LIBUSB_DEVICE_HANDLE libusb_handle,
int  NumInterfaces 
)
static

Here is the caller graph for this function:

static int func_config_release_all_interface ( LIBUSB_DEVICE_HANDLE libusb_handle,
UINT32  NumInterfaces 
)
static

Here is the caller graph for this function:

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:

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:

static void func_iso_data_init ( ISO_USER_DATA *  iso_user_data,
UINT32  numPacket,
UINT32  buffsize,
UINT32  noAck,
BYTE isoPacket,
BYTE buffer 
)
static

Here is the caller graph for this function:

static int func_set_usbd_status ( UDEVICE *  pdev,
UINT32 status,
int  err_result 
)
static

Here is the caller graph for this function:

static int get_next_timeout ( libusb_context *  ctx,
struct timeval *  tv,
struct timeval *  out 
)
static

Here is the caller graph for this function:

static int handle_events_completed ( libusb_context *  ctx,
int *  completed 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static void libusb_udev_attach_kernel_driver ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_bulk_or_interrupt_transfer ( IUDEVICE *  idev,
UINT32  RequestId,
UINT32  EndpointAddress,
UINT32  TransferFlags,
UINT32 UsbdStatus,
UINT32 BufferSize,
BYTE Buffer,
UINT32  Timeout 
)
static

Bulk Transfer

Interrupt Transfer

Sometime, we may have receive a oversized transfer request, it make submit urb return error, so we set the length of request to wMaxPacketSize

Bug fixed in libusb-1.0-8 later: issue of memory crash

Here is the call graph for this function:

Here is the caller graph for this function:

static void libusb_udev_cancel_all_transfer_request ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_cancel_transfer_request ( IUDEVICE *  idev,
UINT32  RequestId 
)
static

END

Here is the call graph for this function:

Here is the caller graph for this function:

static void libusb_udev_channel_closed ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static void libusb_udev_complete_action ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

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:

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:

static int libusb_udev_control_query_device_text ( IUDEVICE *  idev,
UINT32  TextType,
UINT32  LocaleId,
UINT32 BufferSize,
BYTE Buffer 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static int 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:

static void libusb_udev_detach_kernel_driver ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static char* libusb_udev_get_path ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_is_already_send ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_is_channel_closed ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_is_composite_device ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_is_exist ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_is_signal_end ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_isoch_transfer ( IUDEVICE *  idev,
UINT32  RequestId,
UINT32  EndpointAddress,
UINT32  TransferFlags,
int  NoAck,
UINT32 ErrorCount,
UINT32 UrbdStatus,
UINT32 StartFrame,
UINT32  NumberOfPackets,
BYTE IsoPacket,
UINT32 BufferSize,
BYTE Buffer,
int  Timeout 
)
static

process URB_FUNCTION_IOSCH_TRANSFER

fill setting

Here is the call graph for this function:

Here is the caller graph for this function:

static void libusb_udev_lock_fifo_isoch ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

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 caller graph for this function:

static void libusb_udev_push_action ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_query_device_descriptor ( IUDEVICE *  idev,
int  offset 
)
static

Here is the caller graph for this function:

static int libusb_udev_query_device_port_status ( IUDEVICE *  idev,
UINT32 UsbdStatus,
UINT32 BufferSize,
BYTE Buffer 
)
static

Here is the caller graph for this function:

static int libusb_udev_request_queue_is_none ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

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:

static int libusb_udev_select_interface ( IUDEVICE *  idev,
BYTE  InterfaceNumber,
BYTE  AlternateSetting 
)
static

Here is the caller graph for this function:

static void libusb_udev_set_already_send ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static void libusb_udev_signal_end ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static void libusb_udev_unlock_fifo_isoch ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_wait_action_completion ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static int libusb_udev_wait_for_detach ( IUDEVICE *  idev)
static

Here is the caller graph for this function:

static LIBUSB_DEVICE* udev_get_libusb_dev ( int  bus_number,
int  dev_number 
)
static

Here is the caller graph for this function:

static IUDEVICE* udev_init ( 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:

static void udev_load_interface ( UDEVICE *  pdev)
static

Here is the call graph for this function:

Here is the caller graph for this function:

IUDEVICE* udev_new_by_addr ( int  bus_number,
int  dev_number 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int udev_new_by_id ( UINT16  idVendor,
UINT16  idProduct,
IUDEVICE ***  devArray 
)

Here is the call graph for this function:

Here is the caller graph for this function:

static LIBUSB_DEVICE_DESCRIPTOR* udev_new_descript ( LIBUSB_DEVICE libusb_dev)
static

Here is the call graph for this function:

Here is the caller graph for this function: