From 6fcc1b44789b1a54881185da5c4577465a8d8f1f Mon Sep 17 00:00:00 2001 From: Emmanuel Ledoux Date: Fri, 25 Apr 2014 00:20:48 +0200 Subject: [PATCH] winpr-comm: first import of comm_ioctl.h and the REMOTE_SERIAL_DRIVER type. --- channels/serial/client/serial_tty.c | 18 +++ winpr/include/winpr/comm.h | 8 ++ winpr/libwinpr/comm/CMakeLists.txt | 10 +- winpr/libwinpr/comm/comm.c | 16 ++- winpr/libwinpr/comm/comm.h | 17 ++- winpr/libwinpr/comm/comm_ioctl.c | 182 ++++++++++++++++++++++++++ winpr/libwinpr/comm/comm_ioctl.h | 73 +++++++++++ winpr/libwinpr/comm/comm_sercx2_sys.c | 45 +++++++ winpr/libwinpr/comm/comm_sercx2_sys.h | 39 ++++++ winpr/libwinpr/comm/comm_sercx_sys.c | 44 +++++++ winpr/libwinpr/comm/comm_sercx_sys.h | 41 ++++++ winpr/libwinpr/comm/comm_serial_sys.c | 43 ++++++ winpr/libwinpr/comm/comm_serial_sys.h | 40 ++++++ 13 files changed, 570 insertions(+), 6 deletions(-) create mode 100644 winpr/libwinpr/comm/comm_ioctl.c create mode 100644 winpr/libwinpr/comm/comm_ioctl.h create mode 100644 winpr/libwinpr/comm/comm_sercx2_sys.c create mode 100644 winpr/libwinpr/comm/comm_sercx2_sys.h create mode 100644 winpr/libwinpr/comm/comm_sercx_sys.c create mode 100644 winpr/libwinpr/comm/comm_sercx_sys.h create mode 100644 winpr/libwinpr/comm/comm_serial_sys.c create mode 100644 winpr/libwinpr/comm/comm_serial_sys.h diff --git a/channels/serial/client/serial_tty.c b/channels/serial/client/serial_tty.c index 8e051e930..f4a5b5178 100644 --- a/channels/serial/client/serial_tty.c +++ b/channels/serial/client/serial_tty.c @@ -101,6 +101,24 @@ UINT32 serial_tty_control(SERIAL_TTY* tty, UINT32 IoControlCode, wStream* input, IoCtlAccess = ((IoControlCode >> 14) & 0x3); IoCtlDeviceType = ((IoControlCode >> 16) & 0xFFFF); + /* NB: MS-RDPESP's recommendation: + * + * <2> Section 3.2.5.1.6: Windows Implementations use IOCTL + * constants for IoControlCode values. The content and values + * of the IOCTLs are opaque to the protocol. On the server + * side, the data contained in an IOCTL is simply packaged and + * sent to the client side. For maximum compatibility between + * the different versions of the Windows operating system, the + * client implementation only singles out critical IOCTLs and + * invokes the applicable Win32 port API. The other IOCTLS are + * passed directly to the client-side driver, and the + * processing of this value depends on the drivers installed + * on the client side. The values and parameters for these + * IOCTLS can be found in [MSFT-W2KDDK] Volume 2, Part + * 2—Serial and Parallel Drivers, and in [MSDN-PORTS]. + */ + + /** * FILE_DEVICE_SERIAL_PORT 0x0000001B * FILE_DEVICE_UNKNOWN 0x00000022 diff --git a/winpr/include/winpr/comm.h b/winpr/include/winpr/comm.h index 5ad90a885..8b87743dc 100644 --- a/winpr/include/winpr/comm.h +++ b/winpr/include/winpr/comm.h @@ -372,6 +372,14 @@ WINPR_API BOOL IsCommDevice(LPCTSTR lpDeviceName); WINPR_API HANDLE CommCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); + +/** + * FIXME: to be moved in comm_ioctl.h + */ +BOOL CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, + LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped); + + #ifdef __cplusplus } #endif diff --git a/winpr/libwinpr/comm/CMakeLists.txt b/winpr/libwinpr/comm/CMakeLists.txt index 873025f94..70f0c6d48 100644 --- a/winpr/libwinpr/comm/CMakeLists.txt +++ b/winpr/libwinpr/comm/CMakeLists.txt @@ -20,7 +20,15 @@ set(MODULE_PREFIX "WINPR_COMM") set(${MODULE_PREFIX}_SRCS comm.c - comm.h) + comm.h + comm_ioctl.c + comm_ioctl.h + comm_serial_sys.c + comm_serial_sys.h + comm_sercx_sys.c + comm_sercx_sys.h + comm_sercx2_sys.c + comm_sercx2_sys.h) if(MSVC AND (NOT MONOLITHIC_BUILD)) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} module.def) diff --git a/winpr/libwinpr/comm/comm.c b/winpr/libwinpr/comm/comm.c index 9fc551796..7a20b1ab7 100644 --- a/winpr/libwinpr/comm/comm.c +++ b/winpr/libwinpr/comm/comm.c @@ -26,11 +26,12 @@ #ifndef _WIN32 -#include -#include #include -#include +#include +#include #include +#include + #include #include @@ -348,11 +349,12 @@ BOOL GetCommState(HANDLE hFile, LPDCB lpDCB) goto error_handle; } - lpLocalDcb->fBinary = TRUE; /* TMP: should the raw mode be tested? */ + lpLocalDcb->fBinary = TRUE; /* TMP: TODO: seems equivalent to the raw mode */ lpLocalDcb->fParity = (currentState.c_iflag & INPCK) != 0; + memcpy(lpDCB, lpLocalDcb, lpDCB->DCBlength); return TRUE; @@ -943,6 +945,12 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare } + /* TMP: TODO: FIXME: this information is at least need for + * get/set baud. Is possible to pull this information? to be + * forced with a comand line argument. + */ + pComm->remoteSerialDriverId = RemoteSerialDriverUnknown; + return (HANDLE)pComm; diff --git a/winpr/libwinpr/comm/comm.h b/winpr/libwinpr/comm/comm.h index a912b21cd..1b3d41580 100644 --- a/winpr/libwinpr/comm/comm.h +++ b/winpr/libwinpr/comm/comm.h @@ -3,6 +3,7 @@ * Serial Communication API * * Copyright 2014 Marc-Andre Moreau + * Copyright 2014 Hewlett-Packard Development Company, L.P. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,14 +27,28 @@ #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 _REMOTE_SERIAL_DRIVER_ID +{ + RemoteSerialDriverUnknown = 0, + RemoteSerialDriverSerialSys, + RemoteSerialDriverSerCxSys, + RemoteSerialDriverSerCx2Sys /* default fallback */ +} REMOTE_SERIAL_DRIVER_ID; + struct winpr_comm { WINPR_HANDLE_DEF(); int fd; + REMOTE_SERIAL_DRIVER_ID remoteSerialDriverId; }; typedef struct winpr_comm WINPR_COMM; -#endif + +#endif /* _WIN32 */ #endif /* WINPR_COMM_PRIVATE_H */ diff --git a/winpr/libwinpr/comm/comm_ioctl.c b/winpr/libwinpr/comm/comm_ioctl.c new file mode 100644 index 000000000..f3e4fac2b --- /dev/null +++ b/winpr/libwinpr/comm/comm_ioctl.c @@ -0,0 +1,182 @@ +/** + * WinPR: Windows Portable Runtime + * Serial Communication API + * + * Copyright 2011 O.S. Systems Software Ltda. + * Copyright 2011 Eduardo Fiss Beloni + * Copyright 2014 Marc-Andre Moreau + * Copyright 2014 Hewlett-Packard Development Company, L.P. + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef _WIN32 + +#include + +#include + +#include "comm.h" +#include "comm_ioctl.h" +#include "comm_serial_sys.h" +#include "comm_sercx_sys.h" +#include "comm_sercx2_sys.h" + + +/** + * FIXME: to be used through winpr-io's DeviceIoControl + * + * ERRORS: + * ERROR_INVALID_HANDLE + * ERROR_NOT_SUPPORTED lpOverlapped is not supported + */ +BOOL CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, + LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped) +{ + + WINPR_COMM* pComm = (WINPR_COMM*) hDevice; + PREMOTE_SERIAL_DRIVER pRemoteSerialDriver = NULL; + + if (!pComm || pComm->Type != HANDLE_TYPE_COMM || !pComm->fd ) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + if (lpOverlapped != NULL) + { + SetLastError(ERROR_NOT_SUPPORTED); + return FALSE; + } + + if (lpBytesReturned == NULL) + { + SetLastError(ERROR_INVALID_DATA); /* since we doesn't suppport lpOverlapped != NULL */ + return FALSE; + } + + *lpBytesReturned = 0; /* will be ajusted otherwise */ + + /* remoteSerialDriver to be use ... */ + switch (pComm->remoteSerialDriverId) + { + case RemoteSerialDriverSerialSys: + pRemoteSerialDriver = SerialSys(); + break; + + case RemoteSerialDriverSerCxSys: + pRemoteSerialDriver = SerCxSys(); + break; + + case RemoteSerialDriverSerCx2Sys: + pRemoteSerialDriver = SerCx2Sys(); + break; + + case RemoteSerialDriverUnknown: + default: + DEBUG_WARN("Unknown remote serial driver (%d), using SerCx2.sys", pComm->remoteSerialDriverId); + pRemoteSerialDriver = SerCx2Sys(); + break; + } + + assert(pRemoteSerialDriver != NULL); + + switch (dwIoControlCode) + { + case IOCTL_SERIAL_SET_BAUD_RATE: + { + PSERIAL_BAUD_RATE pBaudRate = (PSERIAL_BAUD_RATE)lpInBuffer; + + assert(nInBufferSize == sizeof(SERIAL_BAUD_RATE)); + if (nInBufferSize < sizeof(SERIAL_BAUD_RATE)) + { + SetLastError(ERROR_INVALID_DATA); + return FALSE; + } + + if (pRemoteSerialDriver->set_baud_rate) + { + return pRemoteSerialDriver->set_baud_rate(pBaudRate); + } + else + { + DEBUG_WARN(_T("unsupported IoControlCode: Ox%x (remote serial driver: %s)"), dwIoControlCode, pRemoteSerialDriver->name); + return FALSE; + } + } + default: + DEBUG_WARN("unsupported IoControlCode: Ox%x", dwIoControlCode); + return FALSE; + } + + + +/* IOCTL_SERIAL_GET_BAUD_RATE 0x001B0050 */ +/* IOCTL_SERIAL_SET_LINE_CONTROL 0x001B000C */ +/* IOCTL_SERIAL_GET_LINE_CONTROL 0x001B0054 */ +/* IOCTL_SERIAL_SET_TIMEOUTS 0x001B001C */ +/* IOCTL_SERIAL_GET_TIMEOUTS 0x001B0020 */ +/* IOCTL_SERIAL_SET_CHARS 0x001B0058 */ +/* IOCTL_SERIAL_GET_CHARS 0x001B005C */ +/* IOCTL_SERIAL_SET_DTR 0x001B0024 */ +/* IOCTL_SERIAL_CLR_DTR 0x001B0028 */ +/* IOCTL_SERIAL_RESET_DEVICE 0x001B002C */ +/* IOCTL_SERIAL_SET_RTS 0x001B0030 */ +/* IOCTL_SERIAL_CLR_RTS 0x001B0034 */ +/* IOCTL_SERIAL_SET_XOFF 0x001B0038 */ +/* IOCTL_SERIAL_SET_XON 0x001B003C */ +/* IOCTL_SERIAL_SET_BREAK_ON 0x001B0010 */ +/* IOCTL_SERIAL_SET_BREAK_OFF 0x001B0014 */ +/* IOCTL_SERIAL_SET_QUEUE_SIZE 0x001B0008 */ +/* IOCTL_SERIAL_GET_WAIT_MASK 0x001B0040 */ +/* IOCTL_SERIAL_SET_WAIT_MASK 0x001B0044 */ +/* IOCTL_SERIAL_WAIT_ON_MASK 0x001B0048 */ +/* IOCTL_SERIAL_IMMEDIATE_CHAR 0x001B0018 */ +/* IOCTL_SERIAL_PURGE 0x001B004C */ +/* IOCTL_SERIAL_GET_HANDFLOW 0x001B0060 */ +/* IOCTL_SERIAL_SET_HANDFLOW 0x001B0064 */ +/* IOCTL_SERIAL_GET_MODEMSTATUS 0x001B0068 */ +/* IOCTL_SERIAL_GET_DTRRTS 0x001B0078 */ +/* IOCTL_SERIAL_GET_COMMSTATUS 0x001B0084 */ +/* IOCTL_SERIAL_GET_PROPERTIES 0x001B0074 */ +/* IOCTL_SERIAL_XOFF_COUNTER 0x001B0070 */ +/* IOCTL_SERIAL_LSRMST_INSERT 0x001B007C */ +/* IOCTL_SERIAL_CONFIG_SIZE 0x001B0080 */ +/* IOCTL_SERIAL_GET_STATS 0x001B008C */ +/* IOCTL_SERIAL_CLEAR_STATS 0x001B0090 */ +/* IOCTL_SERIAL_GET_MODEM_CONTROL 0x001B0094 */ +/* IOCTL_SERIAL_SET_MODEM_CONTROL 0x001B0098 */ +/* IOCTL_SERIAL_SET_FIFO_CONTROL 0x001B009C */ + +/* IOCTL_PAR_QUERY_INFORMATION 0x00160004 */ +/* IOCTL_PAR_SET_INFORMATION 0x00160008 */ +/* IOCTL_PAR_QUERY_DEVICE_ID 0x0016000C */ +/* IOCTL_PAR_QUERY_DEVICE_ID_SIZE 0x00160010 */ +/* IOCTL_IEEE1284_GET_MODE 0x00160014 */ +/* IOCTL_IEEE1284_NEGOTIATE 0x00160018 */ +/* IOCTL_PAR_SET_WRITE_ADDRESS 0x0016001C */ +/* IOCTL_PAR_SET_READ_ADDRESS 0x00160020 */ +/* IOCTL_PAR_GET_DEVICE_CAPS 0x00160024 */ +/* IOCTL_PAR_GET_DEFAULT_MODES 0x00160028 */ +/* IOCTL_PAR_QUERY_RAW_DEVICE_ID 0x00160030 */ +/* IOCTL_PAR_IS_PORT_FREE 0x00160054 */ + + + return TRUE; + } + +#endif /* _WIN32 */ diff --git a/winpr/libwinpr/comm/comm_ioctl.h b/winpr/libwinpr/comm/comm_ioctl.h new file mode 100644 index 000000000..0c6a85ea9 --- /dev/null +++ b/winpr/libwinpr/comm/comm_ioctl.h @@ -0,0 +1,73 @@ +/** + * WinPR: Windows Portable Runtime + * Serial Communication API + * + * Copyright 2011 O.S. Systems Software Ltda. + * Copyright 2011 Eduardo Fiss Beloni + * Copyright 2014 Hewlett-Packard Development Company, L.P. + * + * 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. + */ + +#ifndef WINPR_COMM_IOCTL_H_ +#define WINPR_COMM_IOCTL_H_ + +#ifndef _WIN32 + +#include +#include +#include + +#include "comm.h" + +/* Ntddser.h http://msdn.microsoft.com/en-us/cc308432.aspx + * Ntddpar.h http://msdn.microsoft.com/en-us/cc308431.aspx + */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#define IOCTL_SERIAL_SET_BAUD_RATE 0x001B0004 + + + +typedef struct _SERIAL_BAUD_RATE +{ + ULONG BaudRate; +} SERIAL_BAUD_RATE, *PSERIAL_BAUD_RATE; + + +/** + * A function might be NULL if not supported by the underlying remote driver. + * + * FIXME: better have to use input and output buffers for all functions? + */ +typedef struct _REMOTE_SERIAL_DRIVER +{ + REMOTE_SERIAL_DRIVER_ID id; + TCHAR *name; + BOOL (*set_baud_rate)(PSERIAL_BAUD_RATE pBaudRate); + +} REMOTE_SERIAL_DRIVER, *PREMOTE_SERIAL_DRIVER; + + + +#ifdef __cplusplus +} +#endif + +#endif /* _WIN32 */ + +#endif /* WINPR_COMM_IOCTL_H_ */ diff --git a/winpr/libwinpr/comm/comm_sercx2_sys.c b/winpr/libwinpr/comm/comm_sercx2_sys.c new file mode 100644 index 000000000..90f8ba5f0 --- /dev/null +++ b/winpr/libwinpr/comm/comm_sercx2_sys.c @@ -0,0 +1,45 @@ +/** + * WinPR: Windows Portable Runtime + * Serial Communication API + * + * Copyright 2011 O.S. Systems Software Ltda. + * Copyright 2011 Eduardo Fiss Beloni + * Copyright 2014 Marc-Andre Moreau + * Copyright 2014 Hewlett-Packard Development Company, L.P. + * + * 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. + */ + + +#include "comm_sercx2_sys.h" +#include "comm_serial_sys.h" + + +/* specific functions only */ +static REMOTE_SERIAL_DRIVER _SerCx2Sys = +{ + .id = RemoteSerialDriverSerCx2Sys, + .name = _T("SerCx2.sys"), + .set_baud_rate = NULL, +}; + + +PREMOTE_SERIAL_DRIVER SerCx2Sys() +{ + /* _SerCxSys completed with default SerialSys functions */ + PREMOTE_SERIAL_DRIVER serialSys = SerialSys(); + + _SerCx2Sys.set_baud_rate = serialSys->set_baud_rate; + + return &_SerCx2Sys; +} diff --git a/winpr/libwinpr/comm/comm_sercx2_sys.h b/winpr/libwinpr/comm/comm_sercx2_sys.h new file mode 100644 index 000000000..c3aa53397 --- /dev/null +++ b/winpr/libwinpr/comm/comm_sercx2_sys.h @@ -0,0 +1,39 @@ +/** + * WinPR: Windows Portable Runtime + * Serial Communication API + * + * Copyright 2014 Hewlett-Packard Development Company, L.P. + * + * 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. + */ + +#ifndef COMM_SERCX2_SYS_H +#define COMM_SERCX2_SYS_H + +#ifndef _WIN32 + +#include "comm_ioctl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +WINPR_API PREMOTE_SERIAL_DRIVER SerCx2Sys(); + +#ifdef __cplusplus +} +#endif + +#endif /* _WIN32 */ + +#endif /* COMM_SERCX2_SYS_H */ diff --git a/winpr/libwinpr/comm/comm_sercx_sys.c b/winpr/libwinpr/comm/comm_sercx_sys.c new file mode 100644 index 000000000..d8072c604 --- /dev/null +++ b/winpr/libwinpr/comm/comm_sercx_sys.c @@ -0,0 +1,44 @@ +/** + * WinPR: Windows Portable Runtime + * Serial Communication API + * + * Copyright 2011 O.S. Systems Software Ltda. + * Copyright 2011 Eduardo Fiss Beloni + * Copyright 2014 Marc-Andre Moreau + * Copyright 2014 Hewlett-Packard Development Company, L.P. + * + * 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. + */ + + +#include "comm_serial_sys.h" + +/* specific functions only */ +static REMOTE_SERIAL_DRIVER _SerCxSys = +{ + .id = RemoteSerialDriverSerCxSys, + .name = _T("SerCx.sys"), + .set_baud_rate = NULL, +}; + + + +PREMOTE_SERIAL_DRIVER SerCxSys() +{ + /* _SerCxSys completed with default SerialSys functions */ + PREMOTE_SERIAL_DRIVER serialSys = SerialSys(); + + _SerCxSys.set_baud_rate = serialSys->set_baud_rate; + + return &_SerCxSys; +} diff --git a/winpr/libwinpr/comm/comm_sercx_sys.h b/winpr/libwinpr/comm/comm_sercx_sys.h new file mode 100644 index 000000000..1cceb29c8 --- /dev/null +++ b/winpr/libwinpr/comm/comm_sercx_sys.h @@ -0,0 +1,41 @@ +/** + * WinPR: Windows Portable Runtime + * Serial Communication API + * + * Copyright 2014 Hewlett-Packard Development Company, L.P. + * + * 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. + */ + +#ifndef COMM_SERCX_SYS_H +#define COMM_SERCX_SYS_H + +#ifndef _WIN32 + +#include "comm_ioctl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +WINPR_API PREMOTE_SERIAL_DRIVER SerCxSys(); + +#ifdef __cplusplus +} +#endif + + +#endif /* _WIN32 */ + + +#endif /* COMM_SERCX_SYS_H */ diff --git a/winpr/libwinpr/comm/comm_serial_sys.c b/winpr/libwinpr/comm/comm_serial_sys.c new file mode 100644 index 000000000..3b55e1024 --- /dev/null +++ b/winpr/libwinpr/comm/comm_serial_sys.c @@ -0,0 +1,43 @@ +/** + * WinPR: Windows Portable Runtime + * Serial Communication API + * + * Copyright 2011 O.S. Systems Software Ltda. + * Copyright 2011 Eduardo Fiss Beloni + * Copyright 2014 Marc-Andre Moreau + * Copyright 2014 Hewlett-Packard Development Company, L.P. + * + * 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. + */ + +#include "comm_serial_sys.h" + +static BOOL _set_baud_rate(PSERIAL_BAUD_RATE pBaudRate) +{ + + return FALSE; +} + + +static REMOTE_SERIAL_DRIVER _SerialSys = +{ + .id = RemoteSerialDriverSerialSys, + .name = _T("Serial.sys"), + .set_baud_rate = _set_baud_rate, +}; + + +PREMOTE_SERIAL_DRIVER SerialSys() +{ + return &_SerialSys; +} diff --git a/winpr/libwinpr/comm/comm_serial_sys.h b/winpr/libwinpr/comm/comm_serial_sys.h new file mode 100644 index 000000000..a23238df5 --- /dev/null +++ b/winpr/libwinpr/comm/comm_serial_sys.h @@ -0,0 +1,40 @@ +/** + * WinPR: Windows Portable Runtime + * Serial Communication API + * + * Copyright 2014 Hewlett-Packard Development Company, L.P. + * + * 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. + */ + +#ifndef COMM_SERIAL_SYS_H +#define COMM_SERIAL_SYS_H + +#ifndef _WIN32 + +#include "comm_ioctl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +WINPR_API PREMOTE_SERIAL_DRIVER SerialSys(); + +#ifdef __cplusplus +} +#endif + + +#endif /* _WIN32 */ + +#endif /* COMM_SERIAL_SYS_H */