From e9749c6b3fdfc09ac70193637d1d3665cdcb772f Mon Sep 17 00:00:00 2001 From: Emmanuel Ledoux Date: Tue, 16 Sep 2014 12:08:33 +0200 Subject: [PATCH] serial: ability to turn on the permissive mode from the command line --- channels/serial/client/serial_main.c | 22 +++++++++++++++++----- client/common/cmdline.c | 7 +++++-- include/freerdp/settings.h | 3 ++- winpr/libwinpr/comm/comm.h | 13 +++++++++---- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index 8990ad26a..17d5692d7 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -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 */ diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 345e11cde..203773a2f 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -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:\n"); - printf("Printer Redirection: /printer:,\n"); - printf("Serial Port Redirection: /serial:\n"); + printf("Serial Port Redirection: /serial:,,[SerCx2|SerCx|Serial],[permissive]\n"); + printf("Serial Port Redirection: /serial:COM1,/dev/ttyS0\n"); printf("Parallel Port Redirection: /parallel:\n"); printf("Printer Redirection: /printer:,\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; diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index f1002e1ce..f2556024e 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -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; diff --git a/winpr/libwinpr/comm/comm.h b/winpr/libwinpr/comm/comm.h index 7714f3b55..772e62803 100644 --- a/winpr/libwinpr/comm/comm.h +++ b/winpr/libwinpr/comm/comm.h @@ -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;