FreeRDP
transport_io.h
1 
22 #ifndef FREERDP_TRANSPORT_IO_H
23 #define FREERDP_TRANSPORT_IO_H
24 
25 #include <winpr/stream.h>
26 
27 #include <freerdp/api.h>
28 #include <freerdp/types.h>
29 #include <freerdp/settings.h>
30 
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35 
44  typedef int (*pTransportLayerRead)(void* userContext, void* data, int bytes);
45 
54  typedef int (*pTransportLayerWrite)(void* userContext, const void* data, int bytes);
55  typedef BOOL (*pTransportLayerFkt)(void* userContext);
56  typedef BOOL (*pTransportLayerWait)(void* userContext, BOOL waitWrite, DWORD timeout);
57  typedef HANDLE (*pTransportLayerGetEvent)(void* userContext);
58 
62  typedef struct
63  {
64  ALIGN64 void* userContext;
65  ALIGN64 pTransportLayerRead Read;
66  ALIGN64 pTransportLayerWrite Write;
67  ALIGN64 pTransportLayerFkt Close;
68  ALIGN64 pTransportLayerWait Wait;
69  ALIGN64 pTransportLayerGetEvent GetEvent;
70  UINT64 reserved[64 - 6]; /* Reserve some space for ABI compatibility */
72 
73  typedef int (*pTCPConnect)(rdpContext* context, rdpSettings* settings, const char* hostname,
74  int port, DWORD timeout);
75  typedef BOOL (*pTransportFkt)(rdpTransport* transport);
76  typedef BOOL (*pTransportAttach)(rdpTransport* transport, int sockfd);
77  typedef int (*pTransportRWFkt)(rdpTransport* transport, wStream* s);
78  typedef SSIZE_T (*pTransportRead)(rdpTransport* transport, BYTE* data, size_t bytes);
79  typedef BOOL (*pTransportGetPublicKey)(rdpTransport* transport, const BYTE** data,
80  DWORD* length);
90  typedef BOOL (*pTransportSetBlockingMode)(rdpTransport* transport, BOOL blocking);
91  typedef rdpTransportLayer* (*pTransportConnectLayer)(rdpTransport* transport,
92  const char* hostname, int port,
93  DWORD timeout);
94 
103  typedef BOOL (*pTransportAttachLayer)(rdpTransport* transport, rdpTransportLayer* layer);
104 
106  {
107  pTCPConnect TCPConnect;
108  pTransportFkt TLSConnect;
109  pTransportFkt TLSAccept;
110  pTransportAttach TransportAttach;
111  pTransportFkt TransportDisconnect;
112  pTransportRWFkt ReadPdu; /* Reads a whole PDU from the transport */
113  pTransportRWFkt WritePdu; /* Writes a whole PDU to the transport */
114  pTransportRead ReadBytes; /* Reads up to a requested amount of bytes */
115  pTransportGetPublicKey GetPublicKey;
116  pTransportSetBlockingMode SetBlockingMode;
117  pTransportConnectLayer ConnectLayer;
118  pTransportAttachLayer AttachLayer;
119  UINT64 reserved[64 - 12]; /* Reserve some space for ABI compatibility */
120  };
121  typedef struct rdp_transport_io rdpTransportIo;
122 
123  FREERDP_API BOOL freerdp_io_callback_set_event(rdpContext* context, BOOL set);
124 
125  FREERDP_API const rdpTransportIo* freerdp_get_io_callbacks(rdpContext* context);
126  FREERDP_API BOOL freerdp_set_io_callbacks(rdpContext* context,
127  const rdpTransportIo* io_callbacks);
128 
129  FREERDP_API BOOL freerdp_set_io_callback_context(rdpContext* context, void* usercontext);
130  FREERDP_API void* freerdp_get_io_callback_context(rdpContext* context);
131 
132  /* PDU parser.
133  * incomplete: FALSE if the whole PDU is available, TRUE otherwise
134  * Return: 0 -> PDU header incomplete
135  * >0 -> PDU header complete, length of PDU.
136  * <0 -> Abort, an error occurred
137  */
138  FREERDP_API SSIZE_T transport_parse_pdu(rdpTransport* transport, wStream* s, BOOL* incomplete);
139  FREERDP_API rdpContext* transport_get_context(rdpTransport* transport);
140  FREERDP_API rdpTransport* freerdp_get_transport(rdpContext* context);
141 
147  FREERDP_API void transport_layer_free(rdpTransportLayer* layer);
148 
156  WINPR_ATTR_MALLOC(transport_layer_free, 1)
157  FREERDP_API rdpTransportLayer* transport_layer_new(rdpTransport* transport, size_t contextSize);
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif /* FREERDP_TRANSPORT_IO_H */
pTransportSetBlockingMode SetBlockingMode
Definition: transport_io.h:116
UINT64 reserved[64 - 12]
Definition: transport_io.h:119
pTransportAttachLayer AttachLayer
Definition: transport_io.h:118
pTransportConnectLayer ConnectLayer
Definition: transport_io.h:117