FreeRDP
libwinpr/comm/comm.h
1 
21 #ifndef WINPR_COMM_PRIVATE_H
22 #define WINPR_COMM_PRIVATE_H
23 
24 #if defined(__linux__)
25 #define WINPR_HAVE_COMM_COUNTERS
26 #include <linux/serial.h>
27 #endif
28 
29 #include <winpr/comm.h>
30 
31 #include "../handle/handle.h"
32 #include <winpr/config.h>
33 
34 #if defined(WINPR_HAVE_SYS_EVENTFD_H)
35 #include <sys/eventfd.h>
36 #endif
37 
38 struct winpr_comm
39 {
40  WINPR_HANDLE common;
41 
42  int fd;
43 
44  int fd_read;
45  int fd_read_event; /* as of today, only used by _purge() */
46  CRITICAL_SECTION ReadLock;
47 
48  int fd_write;
49  int fd_write_event; /* as of today, only used by _purge() */
50  CRITICAL_SECTION WriteLock;
51 
52  /* permissive mode on errors. If TRUE (default is FALSE)
53  * CommDeviceIoControl always return TRUE.
54  *
55  * Not all features are supported yet and an error is then returned when
56  * an application turns them on (e.g: i/o buffers > 4096). It appeared
57  * though that devices and applications can be still functional on such
58  * errors.
59  *
60  * see also: comm_ioctl.c
61  *
62  * FIXME: getting rid of this flag once all features supported.
63  */
64  BOOL permissive;
65 
66  SERIAL_DRIVER_ID serverSerialDriverId;
67 
68  COMMTIMEOUTS timeouts;
69 
71  EventsLock; /* protects counters, WaitEventMask and PendingEvents */
72 #if defined(WINPR_HAVE_COMM_COUNTERS)
73  struct serial_icounter_struct counters;
74 #endif
75  ULONG WaitEventMask;
76  ULONG PendingEvents;
77 
78  BYTE eventChar;
79  /* NB: CloseHandle() has to free resources */
80 };
81 
82 typedef struct winpr_comm WINPR_COMM;
83 
84 #define SERIAL_EV_RXCHAR 0x0001
85 #define SERIAL_EV_RXFLAG 0x0002
86 #define SERIAL_EV_TXEMPTY 0x0004
87 #define SERIAL_EV_CTS 0x0008
88 #define SERIAL_EV_DSR 0x0010
89 #define SERIAL_EV_RLSD 0x0020
90 #define SERIAL_EV_BREAK 0x0040
91 #define SERIAL_EV_ERR 0x0080
92 #define SERIAL_EV_RING 0x0100
93 #define SERIAL_EV_PERR 0x0200
94 #define SERIAL_EV_RX80FULL 0x0400
95 #define SERIAL_EV_EVENT1 0x0800
96 #define SERIAL_EV_EVENT2 0x1000
97 #define SERIAL_EV_WINPR_WAITING 0x4000 /* bit today unused by other SERIAL_EV_* */
98 #define SERIAL_EV_WINPR_STOP 0x8000 /* bit today unused by other SERIAL_EV_* */
99 
100 #define WINPR_PURGE_TXABORT 0x00000001 /* abort pending transmission */
101 #define WINPR_PURGE_RXABORT 0x00000002 /* abort pending reception */
102 
103 void CommLog_Print(DWORD wlog_level, ...);
104 
105 BOOL CommIsHandled(HANDLE handle);
106 BOOL CommIsHandleValid(HANDLE handle);
107 BOOL CommCloseHandle(HANDLE handle);
108 const HANDLE_CREATOR* GetCommHandleCreator(void);
109 
110 #if defined(WINPR_HAVE_SYS_EVENTFD_H)
111 #ifndef WITH_EVENTFD_READ_WRITE
112 int eventfd_read(int fd, eventfd_t* value);
113 int eventfd_write(int fd, eventfd_t value);
114 #endif
115 #endif
116 
117 #endif /* WINPR_COMM_PRIVATE_H */