Blame winpr/libwinpr/comm/comm_ioctl.h

Packit 1fb8d4
/**
Packit 1fb8d4
 * WinPR: Windows Portable Runtime
Packit 1fb8d4
 * Serial Communication API
Packit 1fb8d4
 *
Packit 1fb8d4
 * Copyright 2011 O.S. Systems Software Ltda.
Packit 1fb8d4
 * Copyright 2011 Eduardo Fiss Beloni <beloni@ossystems.com.br>
Packit 1fb8d4
 * Copyright 2014 Hewlett-Packard Development Company, L.P.
Packit 1fb8d4
 *
Packit 1fb8d4
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 1fb8d4
 * you may not use this file except in compliance with the License.
Packit 1fb8d4
 * You may obtain a copy of the License at
Packit 1fb8d4
 *
Packit 1fb8d4
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 1fb8d4
 *
Packit 1fb8d4
 * Unless required by applicable law or agreed to in writing, software
Packit 1fb8d4
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 1fb8d4
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 1fb8d4
 * See the License for the specific language governing permissions and
Packit 1fb8d4
 * limitations under the License.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#ifndef WINPR_COMM_IOCTL_H_
Packit 1fb8d4
#define WINPR_COMM_IOCTL_H_
Packit 1fb8d4
Packit 1fb8d4
#if defined __linux__ && !defined ANDROID
Packit 1fb8d4
Packit 1fb8d4
#include <termios.h>
Packit 1fb8d4
Packit 1fb8d4
#include <winpr/io.h>
Packit 1fb8d4
#include <winpr/tchar.h>
Packit 1fb8d4
#include <winpr/wtypes.h>
Packit 1fb8d4
Packit 1fb8d4
#include "comm.h"
Packit 1fb8d4
Packit 1fb8d4
/* Serial I/O Request Interface: http://msdn.microsoft.com/en-us/library/dn265347%28v=vs.85%29.aspx
Packit 1fb8d4
 * Ntddser.h http://msdn.microsoft.com/en-us/cc308432.aspx
Packit 1fb8d4
 * Ntddpar.h http://msdn.microsoft.com/en-us/cc308431.aspx
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#ifdef __cplusplus
Packit Service 5a9772
extern "C"
Packit 1fb8d4
{
Packit Service 5a9772
#endif
Packit 1fb8d4
Packit Service 5a9772
	/* TODO: defines and types below are very similar to those in comm.h, keep only
Packit Service 5a9772
	 * those that differ more than the names */
Packit Service 5a9772
Packit Service 5a9772
#define STOP_BIT_1 0
Packit Service 5a9772
#define STOP_BITS_1_5 1
Packit Service 5a9772
#define STOP_BITS_2 2
Packit Service 5a9772
Packit Service 5a9772
#define NO_PARITY 0
Packit Service 5a9772
#define ODD_PARITY 1
Packit Service 5a9772
#define EVEN_PARITY 2
Packit Service 5a9772
#define MARK_PARITY 3
Packit Service 5a9772
#define SPACE_PARITY 4
Packit Service 5a9772
Packit Service 5a9772
	typedef struct _SERIAL_BAUD_RATE
Packit Service 5a9772
	{
Packit Service 5a9772
		ULONG BaudRate;
Packit Service 5a9772
	} SERIAL_BAUD_RATE, *PSERIAL_BAUD_RATE;
Packit Service 5a9772
Packit Service 5a9772
	typedef struct _SERIAL_CHARS
Packit Service 5a9772
	{
Packit Service 5a9772
		UCHAR EofChar;
Packit Service 5a9772
		UCHAR ErrorChar;
Packit Service 5a9772
		UCHAR BreakChar;
Packit Service 5a9772
		UCHAR EventChar;
Packit Service 5a9772
		UCHAR XonChar;
Packit Service 5a9772
		UCHAR XoffChar;
Packit Service 5a9772
	} SERIAL_CHARS, *PSERIAL_CHARS;
Packit Service 5a9772
Packit Service 5a9772
	typedef struct _SERIAL_LINE_CONTROL
Packit Service 5a9772
	{
Packit Service 5a9772
		UCHAR StopBits;
Packit Service 5a9772
		UCHAR Parity;
Packit Service 5a9772
		UCHAR WordLength;
Packit Service 5a9772
	} SERIAL_LINE_CONTROL, *PSERIAL_LINE_CONTROL;
Packit Service 5a9772
Packit Service 5a9772
	typedef struct _SERIAL_HANDFLOW
Packit Service 5a9772
	{
Packit Service 5a9772
		ULONG ControlHandShake;
Packit Service 5a9772
		ULONG FlowReplace;
Packit Service 5a9772
		LONG XonLimit;
Packit Service 5a9772
		LONG XoffLimit;
Packit Service 5a9772
	} SERIAL_HANDFLOW, *PSERIAL_HANDFLOW;
Packit Service 5a9772
Packit Service 5a9772
#define SERIAL_DTR_MASK ((ULONG)0x03)
Packit Service 5a9772
#define SERIAL_DTR_CONTROL ((ULONG)0x01)
Packit Service 5a9772
#define SERIAL_DTR_HANDSHAKE ((ULONG)0x02)
Packit Service 5a9772
#define SERIAL_CTS_HANDSHAKE ((ULONG)0x08)
Packit Service 5a9772
#define SERIAL_DSR_HANDSHAKE ((ULONG)0x10)
Packit Service 5a9772
#define SERIAL_DCD_HANDSHAKE ((ULONG)0x20)
Packit Service 5a9772
#define SERIAL_OUT_HANDSHAKEMASK ((ULONG)0x38)
Packit Service 5a9772
#define SERIAL_DSR_SENSITIVITY ((ULONG)0x40)
Packit Service 5a9772
#define SERIAL_ERROR_ABORT ((ULONG)0x80000000)
Packit Service 5a9772
#define SERIAL_CONTROL_INVALID ((ULONG)0x7fffff84)
Packit Service 5a9772
#define SERIAL_AUTO_TRANSMIT ((ULONG)0x01)
Packit Service 5a9772
#define SERIAL_AUTO_RECEIVE ((ULONG)0x02)
Packit Service 5a9772
#define SERIAL_ERROR_CHAR ((ULONG)0x04)
Packit Service 5a9772
#define SERIAL_NULL_STRIPPING ((ULONG)0x08)
Packit Service 5a9772
#define SERIAL_BREAK_CHAR ((ULONG)0x10)
Packit Service 5a9772
#define SERIAL_RTS_MASK ((ULONG)0xc0)
Packit Service 5a9772
#define SERIAL_RTS_CONTROL ((ULONG)0x40)
Packit Service 5a9772
#define SERIAL_RTS_HANDSHAKE ((ULONG)0x80)
Packit Service 5a9772
#define SERIAL_TRANSMIT_TOGGLE ((ULONG)0xc0)
Packit Service 5a9772
#define SERIAL_XOFF_CONTINUE ((ULONG)0x80000000)
Packit Service 5a9772
#define SERIAL_FLOW_INVALID ((ULONG)0x7fffff20)
Packit Service 5a9772
Packit Service 5a9772
#define SERIAL_SP_SERIALCOMM ((ULONG)0x00000001)
Packit Service 5a9772
Packit Service 5a9772
#define SERIAL_SP_UNSPECIFIED ((ULONG)0x00000000)
Packit Service 5a9772
#define SERIAL_SP_RS232 ((ULONG)0x00000001)
Packit Service 5a9772
#define SERIAL_SP_PARALLEL ((ULONG)0x00000002)
Packit Service 5a9772
#define SERIAL_SP_RS422 ((ULONG)0x00000003)
Packit Service 5a9772
#define SERIAL_SP_RS423 ((ULONG)0x00000004)
Packit Service 5a9772
#define SERIAL_SP_RS449 ((ULONG)0x00000005)
Packit Service 5a9772
#define SERIAL_SP_MODEM ((ULONG)0x00000006)
Packit Service 5a9772
#define SERIAL_SP_FAX ((ULONG)0x00000021)
Packit Service 5a9772
#define SERIAL_SP_SCANNER ((ULONG)0x00000022)
Packit Service 5a9772
#define SERIAL_SP_BRIDGE ((ULONG)0x00000100)
Packit Service 5a9772
#define SERIAL_SP_LAT ((ULONG)0x00000101)
Packit Service 5a9772
#define SERIAL_SP_TELNET ((ULONG)0x00000102)
Packit Service 5a9772
#define SERIAL_SP_X25 ((ULONG)0x00000103)
Packit Service 5a9772
Packit Service 5a9772
	typedef struct _SERIAL_TIMEOUTS
Packit Service 5a9772
	{
Packit Service 5a9772
		ULONG ReadIntervalTimeout;
Packit Service 5a9772
		ULONG ReadTotalTimeoutMultiplier;
Packit Service 5a9772
		ULONG ReadTotalTimeoutConstant;
Packit Service 5a9772
		ULONG WriteTotalTimeoutMultiplier;
Packit Service 5a9772
		ULONG WriteTotalTimeoutConstant;
Packit Service 5a9772
	} SERIAL_TIMEOUTS, *PSERIAL_TIMEOUTS;
Packit Service 5a9772
Packit Service 5a9772
#define SERIAL_MSR_DCTS 0x01
Packit Service 5a9772
#define SERIAL_MSR_DDSR 0x02
Packit Service 5a9772
#define SERIAL_MSR_TERI 0x04
Packit Service 5a9772
#define SERIAL_MSR_DDCD 0x08
Packit Service 5a9772
#define SERIAL_MSR_CTS 0x10
Packit Service 5a9772
#define SERIAL_MSR_DSR 0x20
Packit Service 5a9772
#define SERIAL_MSR_RI 0x40
Packit Service 5a9772
#define SERIAL_MSR_DCD 0x80
Packit Service 5a9772
Packit Service 5a9772
	typedef struct _SERIAL_QUEUE_SIZE
Packit Service 5a9772
	{
Packit Service 5a9772
		ULONG InSize;
Packit Service 5a9772
		ULONG OutSize;
Packit Service 5a9772
	} SERIAL_QUEUE_SIZE, *PSERIAL_QUEUE_SIZE;
Packit 1fb8d4
Packit 1fb8d4
#define SERIAL_PURGE_TXABORT 0x00000001
Packit 1fb8d4
#define SERIAL_PURGE_RXABORT 0x00000002
Packit 1fb8d4
#define SERIAL_PURGE_TXCLEAR 0x00000004
Packit 1fb8d4
#define SERIAL_PURGE_RXCLEAR 0x00000008
Packit 1fb8d4
Packit Service 5a9772
	typedef struct _SERIAL_STATUS
Packit Service 5a9772
	{
Packit Service 5a9772
		ULONG Errors;
Packit Service 5a9772
		ULONG HoldReasons;
Packit Service 5a9772
		ULONG AmountInInQueue;
Packit Service 5a9772
		ULONG AmountInOutQueue;
Packit Service 5a9772
		BOOLEAN EofReceived;
Packit Service 5a9772
		BOOLEAN WaitForImmediate;
Packit Service 5a9772
	} SERIAL_STATUS, *PSERIAL_STATUS;
Packit Service 5a9772
Packit Service 5a9772
#define SERIAL_TX_WAITING_FOR_CTS ((ULONG)0x00000001)
Packit Service 5a9772
#define SERIAL_TX_WAITING_FOR_DSR ((ULONG)0x00000002)
Packit Service 5a9772
#define SERIAL_TX_WAITING_FOR_DCD ((ULONG)0x00000004)
Packit Service 5a9772
#define SERIAL_TX_WAITING_FOR_XON ((ULONG)0x00000008)
Packit Service 5a9772
#define SERIAL_TX_WAITING_XOFF_SENT ((ULONG)0x00000010)
Packit Service 5a9772
#define SERIAL_TX_WAITING_ON_BREAK ((ULONG)0x00000020)
Packit Service 5a9772
#define SERIAL_RX_WAITING_FOR_DSR ((ULONG)0x00000040)
Packit Service 5a9772
Packit Service 5a9772
#define SERIAL_ERROR_BREAK ((ULONG)0x00000001)
Packit Service 5a9772
#define SERIAL_ERROR_FRAMING ((ULONG)0x00000002)
Packit Service 5a9772
#define SERIAL_ERROR_OVERRUN ((ULONG)0x00000004)
Packit Service 5a9772
#define SERIAL_ERROR_QUEUEOVERRUN ((ULONG)0x00000008)
Packit Service 5a9772
#define SERIAL_ERROR_PARITY ((ULONG)0x00000010)
Packit Service 5a9772
Packit Service 5a9772
#define SERIAL_DTR_STATE ((ULONG)0x00000001)
Packit Service 5a9772
#define SERIAL_RTS_STATE ((ULONG)0x00000002)
Packit Service 5a9772
#define SERIAL_CTS_STATE ((ULONG)0x00000010)
Packit Service 5a9772
#define SERIAL_DSR_STATE ((ULONG)0x00000020)
Packit Service 5a9772
#define SERIAL_RI_STATE ((ULONG)0x00000040)
Packit Service 5a9772
#define SERIAL_DCD_STATE ((ULONG)0x00000080)
Packit Service 5a9772
Packit Service 5a9772
	/**
Packit Service 5a9772
	 * A function might be NULL if not supported by the underlying driver.
Packit Service 5a9772
	 *
Packit Service 5a9772
	 * FIXME: better have to use input and output buffers for all functions?
Packit Service 5a9772
	 */
Packit Service 5a9772
	typedef struct _SERIAL_DRIVER
Packit Service 5a9772
	{
Packit Service 5a9772
		SERIAL_DRIVER_ID id;
Packit Service 5a9772
		TCHAR* name;
Packit Service 5a9772
		BOOL (*set_baud_rate)(WINPR_COMM* pComm, const SERIAL_BAUD_RATE* pBaudRate);
Packit Service 5a9772
		BOOL (*get_baud_rate)(WINPR_COMM* pComm, SERIAL_BAUD_RATE* pBaudRate);
Packit Service 5a9772
		BOOL (*get_properties)(WINPR_COMM* pComm, COMMPROP* pProperties);
Packit Service 5a9772
		BOOL (*set_serial_chars)(WINPR_COMM* pComm, const SERIAL_CHARS* pSerialChars);
Packit Service 5a9772
		BOOL (*get_serial_chars)(WINPR_COMM* pComm, SERIAL_CHARS* pSerialChars);
Packit Service 5a9772
		BOOL (*set_line_control)(WINPR_COMM* pComm, const SERIAL_LINE_CONTROL* pLineControl);
Packit Service 5a9772
		BOOL (*get_line_control)(WINPR_COMM* pComm, SERIAL_LINE_CONTROL* pLineControl);
Packit Service 5a9772
		BOOL (*set_handflow)(WINPR_COMM* pComm, const SERIAL_HANDFLOW* pHandflow);
Packit Service 5a9772
		BOOL (*get_handflow)(WINPR_COMM* pComm, SERIAL_HANDFLOW* pHandflow);
Packit Service 5a9772
		BOOL (*set_timeouts)(WINPR_COMM* pComm, const SERIAL_TIMEOUTS* pTimeouts);
Packit Service 5a9772
		BOOL (*get_timeouts)(WINPR_COMM* pComm, SERIAL_TIMEOUTS* pTimeouts);
Packit Service 5a9772
		BOOL (*set_dtr)(WINPR_COMM* pComm);
Packit Service 5a9772
		BOOL (*clear_dtr)(WINPR_COMM* pComm);
Packit Service 5a9772
		BOOL (*set_rts)(WINPR_COMM* pComm);
Packit Service 5a9772
		BOOL (*clear_rts)(WINPR_COMM* pComm);
Packit Service 5a9772
		BOOL (*get_modemstatus)(WINPR_COMM* pComm, ULONG* pRegister);
Packit Service 5a9772
		BOOL (*set_wait_mask)(WINPR_COMM* pComm, const ULONG* pWaitMask);
Packit Service 5a9772
		BOOL (*get_wait_mask)(WINPR_COMM* pComm, ULONG* pWaitMask);
Packit Service 5a9772
		BOOL (*wait_on_mask)(WINPR_COMM* pComm, ULONG* pOutputMask);
Packit Service 5a9772
		BOOL (*set_queue_size)(WINPR_COMM* pComm, const SERIAL_QUEUE_SIZE* pQueueSize);
Packit Service 5a9772
		BOOL (*purge)(WINPR_COMM* pComm, const ULONG* pPurgeMask);
Packit Service 5a9772
		BOOL (*get_commstatus)(WINPR_COMM* pComm, SERIAL_STATUS* pCommstatus);
Packit Service 5a9772
		BOOL (*set_break_on)(WINPR_COMM* pComm);
Packit Service 5a9772
		BOOL (*set_break_off)(WINPR_COMM* pComm);
Packit Service 5a9772
		BOOL (*set_xoff)(WINPR_COMM* pComm);
Packit Service 5a9772
		BOOL (*set_xon)(WINPR_COMM* pComm);
Packit Service 5a9772
		BOOL (*get_dtrrts)(WINPR_COMM* pComm, ULONG* pMask);
Packit Service 5a9772
		BOOL (*config_size)(WINPR_COMM* pComm, ULONG* pSize);
Packit Service 5a9772
		BOOL (*immediate_char)(WINPR_COMM* pComm, const UCHAR* pChar);
Packit Service 5a9772
		BOOL (*reset_device)(WINPR_COMM* pComm);
Packit Service 5a9772
Packit Service 5a9772
	} SERIAL_DRIVER;
Packit Service 5a9772
Packit Service 5a9772
	int _comm_ioctl_tcsetattr(int fd, int optional_actions, const struct termios* termios_p);
Packit 1fb8d4
Packit 1fb8d4
#ifdef __cplusplus
Packit 1fb8d4
}
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
#endif /* __linux__ */
Packit 1fb8d4
Packit 1fb8d4
#endif /* WINPR_COMM_IOCTL_H_ */