serial: ability to setup the server serial driver thanks to a third parameter on the command line

This commit is contained in:
Emmanuel Ledoux 2014-06-18 18:20:21 +02:00 committed by Emmanuel Ledoux
parent 62298fcd95
commit e6c82f99d5
7 changed files with 65 additions and 22 deletions

View File

@ -64,6 +64,7 @@ typedef struct _SERIAL_DEVICE SERIAL_DEVICE;
struct _SERIAL_DEVICE
{
DEVICE device;
SERIAL_DRIVER_ID ServerSerialDriverId;
HANDLE* hComm;
/* TODO: use of log (prefered the old fashion DEBUG_SVC and
@ -193,6 +194,8 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
goto error_handle;
}
_comm_setServerSerialDriver(serial->hComm, serial->ServerSerialDriverId);
/* FIXME: Appeared to be useful to setup some devices. Guess
* the device driver asked to setup some unsupported feature
* that were not eventually used. TODO: collecting more
@ -744,12 +747,14 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
int i, len;
char* name;
char* path;
char* driver;
RDPDR_SERIAL* device;
SERIAL_DEVICE* serial;
device = (RDPDR_SERIAL*) pEntryPoints->device;
name = device->Name;
path = device->Path;
driver = device->Driver;
if (!name || (name[0] == '*'))
{
@ -782,6 +787,31 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
for (i = 0; i <= len; i++)
Stream_Write_UINT8(serial->device.data, name[i] < 0 ? '_' : name[i]);
if (driver != NULL)
{
if (_stricmp(driver, "Serial") == 0)
serial->ServerSerialDriverId = SerialDriverSerialSys;
else if (_stricmp(driver, "SerCx") == 0)
serial->ServerSerialDriverId = SerialDriverSerCxSys;
else if (_stricmp(driver, "SerCx2") == 0)
serial->ServerSerialDriverId = SerialDriverSerCx2Sys;
else
{
assert(FALSE);
DEBUG_SVC("Unknown server's serial driver: %s. SerCx2 will be used", driver);
serial->ServerSerialDriverId = SerialDriverSerCx2Sys;
}
}
else
{
/* default driver */
serial->ServerSerialDriverId = SerialDriverSerCx2Sys;
}
DEBUG_SVC("Server's serial driver: %s (id: %d)", driver, serial->ServerSerialDriverId);
/* TODO: implement auto detection of the server's serial driver */
serial->MainIrpQueue = MessageQueue_New(NULL);
/* IrpThreads content only modified by create_irp_thread() */

View File

@ -385,6 +385,9 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
if (count > 2)
serial->Path = _strdup(params[2]);
if (count > 3)
serial->Driver = _strdup(params[3]);
freerdp_device_collection_add(settings, (RDPDR_DEVICE*) serial);
settings->DeviceRedirection = TRUE;

View File

@ -466,6 +466,7 @@ struct _RDPDR_SERIAL
UINT32 Type;
char* Name;
char* Path;
char* Driver;
};
typedef struct _RDPDR_SERIAL RDPDR_SERIAL;

View File

@ -287,8 +287,17 @@ out_smartc_name_error:
goto out_serial_path_error;
}
if (serial->Driver)
{
_serial->Driver = _strdup(serial->Driver);
if (!_serial->Driver)
goto out_serial_driver_error;
}
return (RDPDR_DEVICE*) _serial;
out_serial_driver_error:
free(_serial->Path);
out_serial_path_error:
free(_serial->Name);
out_serial_name_error:
@ -360,6 +369,7 @@ void freerdp_device_collection_free(rdpSettings* settings)
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_SERIAL)
{
free(((RDPDR_SERIAL*) device)->Path);
free(((RDPDR_SERIAL*) device)->Driver);
}
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_PARALLEL)
{

View File

@ -383,6 +383,20 @@ WINPR_API BOOL WaitCommEvent(HANDLE hFile, PDWORD lpEvtMask, LPOVERLAPPED lpOver
#define MAXULONG (4294967295UL)
#endif
/**
* IOCTLs table according the server's serial driver:
* http://msdn.microsoft.com/en-us/library/windows/hardware/dn265347%28v=vs.85%29.aspx
*/
typedef enum _SERIAL_DRIVER_ID
{
SerialDriverUnknown = 0,
SerialDriverSerialSys,
SerialDriverSerCxSys,
SerialDriverSerCx2Sys /* default fallback, see also CommDeviceIoControl() */
} SERIAL_DRIVER_ID;
/*
* About DefineCommDevice() / QueryDosDevice()
*
@ -534,6 +548,11 @@ static const _SERIAL_IOCTL_NAME _SERIAL_IOCTL_NAMES[] =
*/
const char* _comm_serial_ioctl_name(ULONG number);
/**
* FIXME: got a proper function name and place
*/
void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID);
/**
* FIXME: got a proper function name and place
*

View File

@ -347,7 +347,7 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
WINPR_COMM* pComm = (WINPR_COMM*) hFile;
DWORD bytesReturned;
// TMP: FIXME: validate changes according GetCommProperties
/* FIXME: validate changes according GetCommProperties? */
if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd )
{
@ -538,8 +538,6 @@ BOOL SetCommState(HANDLE hFile, LPDCB lpDCB)
upcomingTermios.c_iflag &= ~INPCK;
}
// TMP: TODO:
// (...)
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa363423%28v=vs.85%29.aspx
*
@ -1160,11 +1158,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
InitializeCriticalSection(&pComm->WriteLock);
/* TMP: TODO: FIXME: this information is at least needed for
* get/set baud functions. Is it possible to pull this
* information? Could be a command line argument.
*/
/* can also be setup later on with _comm_setServerSerialDriver() */
pComm->serverSerialDriverId = SerialDriverUnknown;
InitializeCriticalSection(&pComm->EventsLock);

View File

@ -30,18 +30,6 @@
#include "../handle/handle.h"
/**
* IOCTLs table according the remote serial driver:
* http://msdn.microsoft.com/en-us/library/windows/hardware/dn265347%28v=vs.85%29.aspx
*/
typedef enum _SERIAL_DRIVER_ID
{
SerialDriverUnknown = 0,
SerialDriverSerialSys,
SerialDriverSerCxSys,
SerialDriverSerCx2Sys /* default fallback, see also CommDeviceIoControl() */
} SERIAL_DRIVER_ID;
struct winpr_comm
{
WINPR_HANDLE_DEF();
@ -79,8 +67,6 @@ struct winpr_comm
typedef struct winpr_comm WINPR_COMM;
void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID);
/* TMP: TODO: move all specific defines and types here? at least SERIAL_EV_* */
#define SERIAL_EV_FREERDP_WAITING 0x4000 /* bit unused by SERIAL_EV_* */
#define SERIAL_EV_FREERDP_STOP 0x8000 /* bit unused by SERIAL_EV_* */