serial: ability to turn on the permissive mode from the command line

This commit is contained in:
Emmanuel Ledoux 2014-09-16 12:08:33 +02:00 committed by eledoux
parent 275a1b9bc4
commit e9749c6b3f
4 changed files with 33 additions and 12 deletions

View File

@ -53,6 +53,7 @@ typedef struct _SERIAL_DEVICE SERIAL_DEVICE;
struct _SERIAL_DEVICE
{
DEVICE device;
BOOL permissive;
SERIAL_DRIVER_ID ServerSerialDriverId;
HANDLE* hComm;
@ -182,11 +183,7 @@ static void serial_process_irp_create(SERIAL_DEVICE* serial, IRP* irp)
_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
* details, a command line argument? */
/* _comm_set_permissive(serial->hComm, TRUE); */
_comm_set_permissive(serial->hComm, serial->permissive);
/* NOTE: binary mode/raw mode required for the redirection. On
* Linux, CommCreateFileA forces this setting.
@ -817,6 +814,21 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
serial->ServerSerialDriverId = SerialDriverSerCx2Sys;
}
if (device->Permissive != NULL)
{
if (_stricmp(device->Permissive, "permissive") == 0)
{
serial->permissive = TRUE;
}
else
{
WLog_Print(serial->log, WLOG_DEBUG, "Unknown flag: %s", device->Permissive);
assert(FALSE);
}
}
WLog_Print(serial->log, WLOG_DEBUG, "Server's serial driver: %s (id: %d)", driver, serial->ServerSerialDriverId);
/* TODO: implement auto detection of the server's serial driver */

View File

@ -253,8 +253,8 @@ int freerdp_client_print_command_line_help(int argc, char** argv)
printf("Drive Redirection: /drive:home,/home/user\n");
printf("Smartcard Redirection: /smartcard:<device>\n");
printf("Printer Redirection: /printer:<device>,<driver>\n");
printf("Serial Port Redirection: /serial:<device>\n");
printf("Serial Port Redirection: /serial:<name>,<device>,[SerCx2|SerCx|Serial],[permissive]\n");
printf("Serial Port Redirection: /serial:COM1,/dev/ttyS0\n");
printf("Parallel Port Redirection: /parallel:<device>\n");
printf("Printer Redirection: /printer:<device>,<driver>\n");
printf("\n");
@ -422,6 +422,9 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
if (count > 3)
serial->Driver = _strdup(params[3]);
if (count > 4)
serial->Permissive = _strdup(params[4]);
freerdp_device_collection_add(settings, (RDPDR_DEVICE*) serial);
return 1;

View File

@ -471,7 +471,8 @@ struct _RDPDR_SERIAL
UINT32 Type;
char* Name;
char* Path;
char* Driver;
char* Driver;
char* Permissive;
};
typedef struct _RDPDR_SERIAL RDPDR_SERIAL;

View File

@ -44,12 +44,17 @@ struct winpr_comm
int fd_write_event; /* as of today, only used by _purge() */
CRITICAL_SECTION WriteLock;
/* permissive mode on errors if TRUE (default is FALSE).
/* permissive mode on errors. If TRUE (default is FALSE)
* CommDeviceIoControl always return TRUE.
*
* Since not all features are supported, some devices and applications
* can still be functional on such errors.
* Not all features are supported yet and an error is then returned when
* an application turns them on (e.g: i/o buffers > 4096). It appeared
* though that devices and applications can be still functional on such
* errors.
*
* TODO: command line switch or getting rid of it.
* see also: comm_ioctl.c
*
* FIXME: getting rid of this flag once all features supported.
*/
BOOL permissive;