FreeRDP
comm_ioctl.h
1 
22 #ifndef WINPR_COMM_IOCTL_H_
23 #define WINPR_COMM_IOCTL_H_
24 
25 #include <termios.h>
26 
27 #include <winpr/io.h>
28 #include <winpr/tchar.h>
29 #include <winpr/wtypes.h>
30 
31 #include "comm.h"
32 
33 /* Serial I/O Request Interface: http://msdn.microsoft.com/en-us/library/dn265347%28v=vs.85%29.aspx
34  * Ntddser.h http://msdn.microsoft.com/en-us/cc308432.aspx
35  * Ntddpar.h http://msdn.microsoft.com/en-us/cc308431.aspx
36  */
37 
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #endif
42 
43  /* TODO: defines and types below are very similar to those in comm.h, keep only
44  * those that differ more than the names */
45 
46 #define STOP_BIT_1 0
47 #define STOP_BITS_1_5 1
48 #define STOP_BITS_2 2
49 
50 #define NO_PARITY 0
51 #define ODD_PARITY 1
52 #define EVEN_PARITY 2
53 #define MARK_PARITY 3
54 #define SPACE_PARITY 4
55 
56  typedef struct
57  {
58  ULONG BaudRate;
60 
61  typedef struct
62  {
63  UCHAR EofChar;
64  UCHAR ErrorChar;
65  UCHAR BreakChar;
66  UCHAR EventChar;
67  UCHAR XonChar;
68  UCHAR XoffChar;
70 
71  typedef struct
72  {
73  UCHAR StopBits;
74  UCHAR Parity;
75  UCHAR WordLength;
77 
78  typedef struct
79  {
80  ULONG ControlHandShake;
81  ULONG FlowReplace;
82  WORD XonLimit;
83  WORD XoffLimit;
85 
86 #define SERIAL_DTR_MASK ((ULONG)0x03)
87 #define SERIAL_DTR_CONTROL ((ULONG)0x01)
88 #define SERIAL_DTR_HANDSHAKE ((ULONG)0x02)
89 #define SERIAL_CTS_HANDSHAKE ((ULONG)0x08)
90 #define SERIAL_DSR_HANDSHAKE ((ULONG)0x10)
91 #define SERIAL_DCD_HANDSHAKE ((ULONG)0x20)
92 #define SERIAL_OUT_HANDSHAKEMASK ((ULONG)0x38)
93 #define SERIAL_DSR_SENSITIVITY ((ULONG)0x40)
94 #define SERIAL_ERROR_ABORT ((ULONG)0x80000000)
95 #define SERIAL_CONTROL_INVALID ((ULONG)0x7fffff84)
96 #define SERIAL_AUTO_TRANSMIT ((ULONG)0x01)
97 #define SERIAL_AUTO_RECEIVE ((ULONG)0x02)
98 #define SERIAL_ERROR_CHAR ((ULONG)0x04)
99 #define SERIAL_NULL_STRIPPING ((ULONG)0x08)
100 #define SERIAL_BREAK_CHAR ((ULONG)0x10)
101 #define SERIAL_RTS_MASK ((ULONG)0xc0)
102 #define SERIAL_RTS_CONTROL ((ULONG)0x40)
103 #define SERIAL_RTS_HANDSHAKE ((ULONG)0x80)
104 #define SERIAL_TRANSMIT_TOGGLE ((ULONG)0xc0)
105 #define SERIAL_XOFF_CONTINUE ((ULONG)0x80000000)
106 #define SERIAL_FLOW_INVALID ((ULONG)0x7fffff20)
107 
108 #define SERIAL_SP_SERIALCOMM ((ULONG)0x00000001)
109 
110 #define SERIAL_SP_UNSPECIFIED ((ULONG)0x00000000)
111 #define SERIAL_SP_RS232 ((ULONG)0x00000001)
112 #define SERIAL_SP_PARALLEL ((ULONG)0x00000002)
113 #define SERIAL_SP_RS422 ((ULONG)0x00000003)
114 #define SERIAL_SP_RS423 ((ULONG)0x00000004)
115 #define SERIAL_SP_RS449 ((ULONG)0x00000005)
116 #define SERIAL_SP_MODEM ((ULONG)0x00000006)
117 #define SERIAL_SP_FAX ((ULONG)0x00000021)
118 #define SERIAL_SP_SCANNER ((ULONG)0x00000022)
119 #define SERIAL_SP_BRIDGE ((ULONG)0x00000100)
120 #define SERIAL_SP_LAT ((ULONG)0x00000101)
121 #define SERIAL_SP_TELNET ((ULONG)0x00000102)
122 #define SERIAL_SP_X25 ((ULONG)0x00000103)
123 
124  typedef struct
125  {
126  ULONG ReadIntervalTimeout;
127  ULONG ReadTotalTimeoutMultiplier;
128  ULONG ReadTotalTimeoutConstant;
129  ULONG WriteTotalTimeoutMultiplier;
130  ULONG WriteTotalTimeoutConstant;
132 
133 #define SERIAL_MSR_DCTS 0x01
134 #define SERIAL_MSR_DDSR 0x02
135 #define SERIAL_MSR_TERI 0x04
136 #define SERIAL_MSR_DDCD 0x08
137 #define SERIAL_MSR_CTS 0x10
138 #define SERIAL_MSR_DSR 0x20
139 #define SERIAL_MSR_RI 0x40
140 #define SERIAL_MSR_DCD 0x80
141 
142  typedef struct
143  {
144  ULONG InSize;
145  ULONG OutSize;
147 
148 #define SERIAL_PURGE_TXABORT 0x00000001
149 #define SERIAL_PURGE_RXABORT 0x00000002
150 #define SERIAL_PURGE_TXCLEAR 0x00000004
151 #define SERIAL_PURGE_RXCLEAR 0x00000008
152 
153  typedef struct
154  {
155  ULONG Errors;
156  ULONG HoldReasons;
157  ULONG AmountInInQueue;
158  ULONG AmountInOutQueue;
159  BOOLEAN EofReceived;
160  BOOLEAN WaitForImmediate;
162 
163 #define SERIAL_TX_WAITING_FOR_CTS ((ULONG)0x00000001)
164 #define SERIAL_TX_WAITING_FOR_DSR ((ULONG)0x00000002)
165 #define SERIAL_TX_WAITING_FOR_DCD ((ULONG)0x00000004)
166 #define SERIAL_TX_WAITING_FOR_XON ((ULONG)0x00000008)
167 #define SERIAL_TX_WAITING_XOFF_SENT ((ULONG)0x00000010)
168 #define SERIAL_TX_WAITING_ON_BREAK ((ULONG)0x00000020)
169 #define SERIAL_RX_WAITING_FOR_DSR ((ULONG)0x00000040)
170 
171 #define SERIAL_ERROR_BREAK ((ULONG)0x00000001)
172 #define SERIAL_ERROR_FRAMING ((ULONG)0x00000002)
173 #define SERIAL_ERROR_OVERRUN ((ULONG)0x00000004)
174 #define SERIAL_ERROR_QUEUEOVERRUN ((ULONG)0x00000008)
175 #define SERIAL_ERROR_PARITY ((ULONG)0x00000010)
176 
177 #define SERIAL_DTR_STATE ((ULONG)0x00000001)
178 #define SERIAL_RTS_STATE ((ULONG)0x00000002)
179 #define SERIAL_CTS_STATE ((ULONG)0x00000010)
180 #define SERIAL_DSR_STATE ((ULONG)0x00000020)
181 #define SERIAL_RI_STATE ((ULONG)0x00000040)
182 #define SERIAL_DCD_STATE ((ULONG)0x00000080)
183 
189  typedef struct
190  {
191  SERIAL_DRIVER_ID id;
192  TCHAR* name;
193  BOOL (*set_baud_rate)(WINPR_COMM* pComm, const SERIAL_BAUD_RATE* pBaudRate);
194  BOOL (*get_baud_rate)(WINPR_COMM* pComm, SERIAL_BAUD_RATE* pBaudRate);
195  BOOL (*get_properties)(WINPR_COMM* pComm, COMMPROP* pProperties);
196  BOOL (*set_serial_chars)(WINPR_COMM* pComm, const SERIAL_CHARS* pSerialChars);
197  BOOL (*get_serial_chars)(WINPR_COMM* pComm, SERIAL_CHARS* pSerialChars);
198  BOOL (*set_line_control)(WINPR_COMM* pComm, const SERIAL_LINE_CONTROL* pLineControl);
199  BOOL (*get_line_control)(WINPR_COMM* pComm, SERIAL_LINE_CONTROL* pLineControl);
200  BOOL (*set_handflow)(WINPR_COMM* pComm, const SERIAL_HANDFLOW* pHandflow);
201  BOOL (*get_handflow)(WINPR_COMM* pComm, SERIAL_HANDFLOW* pHandflow);
202  BOOL (*set_timeouts)(WINPR_COMM* pComm, const SERIAL_TIMEOUTS* pTimeouts);
203  BOOL (*get_timeouts)(WINPR_COMM* pComm, SERIAL_TIMEOUTS* pTimeouts);
204  BOOL (*set_dtr)(WINPR_COMM* pComm);
205  BOOL (*clear_dtr)(WINPR_COMM* pComm);
206  BOOL (*set_rts)(WINPR_COMM* pComm);
207  BOOL (*clear_rts)(WINPR_COMM* pComm);
208  BOOL (*get_modemstatus)(WINPR_COMM* pComm, ULONG* pRegister);
209  BOOL (*set_wait_mask)(WINPR_COMM* pComm, const ULONG* pWaitMask);
210  BOOL (*get_wait_mask)(WINPR_COMM* pComm, ULONG* pWaitMask);
211  BOOL (*wait_on_mask)(WINPR_COMM* pComm, ULONG* pOutputMask);
212  BOOL (*set_queue_size)(WINPR_COMM* pComm, const SERIAL_QUEUE_SIZE* pQueueSize);
213  BOOL (*purge)(WINPR_COMM* pComm, const ULONG* pPurgeMask);
214  BOOL (*get_commstatus)(WINPR_COMM* pComm, SERIAL_STATUS* pCommstatus);
215  BOOL (*set_break_on)(WINPR_COMM* pComm);
216  BOOL (*set_break_off)(WINPR_COMM* pComm);
217  BOOL (*set_xoff)(WINPR_COMM* pComm);
218  BOOL (*set_xon)(WINPR_COMM* pComm);
219  BOOL (*get_dtrrts)(WINPR_COMM* pComm, ULONG* pMask);
220  BOOL (*config_size)(WINPR_COMM* pComm, ULONG* pSize);
221  BOOL (*immediate_char)(WINPR_COMM* pComm, const UCHAR* pChar);
222  BOOL (*reset_device)(WINPR_COMM* pComm);
223 
224  } SERIAL_DRIVER;
225 
226  int _comm_ioctl_tcsetattr(int fd, int optional_actions, const struct termios* termios_p);
227 
228 #ifdef __cplusplus
229 }
230 #endif
231 
232 #endif /* WINPR_COMM_IOCTL_H_ */