FreeRDP
Loading...
Searching...
No Matches
proxy_context.h
1
22#ifndef FREERDP_SERVER_PROXY_PFCONTEXT_H
23#define FREERDP_SERVER_PROXY_PFCONTEXT_H
24
25#include <freerdp/api.h>
26#include <freerdp/types.h>
27
28#include <freerdp/freerdp.h>
29#include <freerdp/channels/wtsvc.h>
30
31#include <freerdp/server/proxy/proxy_config.h>
32#include <freerdp/server/proxy/proxy_types.h>
33
34#define PROXY_SESSION_ID_LENGTH 32
35
36#ifdef __cplusplus
37extern "C"
38{
39#endif
40
41 typedef struct proxy_data proxyData;
42 typedef struct proxy_module proxyModule;
43 typedef struct p_server_static_channel_context pServerStaticChannelContext;
44
45 typedef struct s_InterceptContextMapEntry
46 {
47 void (*free)(struct s_InterceptContextMapEntry*);
49
50 /* All proxy interception channels derive from this base struct
51 * and set their cleanup function accordingly. */
52 FREERDP_API void intercept_context_entry_free(void* obj);
53 typedef PfChannelResult (*proxyChannelDataFn)(proxyData* pdata,
54 const pServerStaticChannelContext* channel,
55 const BYTE* xdata, size_t xsize, UINT32 flags,
56 size_t totalSizepServer);
57 typedef void (*proxyChannelContextDtor)(void* context);
58
61 {
62 char* channel_name;
63 UINT32 front_channel_id;
64 UINT32 back_channel_id;
65 pf_utils_channel_mode channelMode;
66 proxyChannelDataFn onFrontData;
67 proxyChannelDataFn onBackData;
68 proxyChannelContextDtor contextDtor;
69 void* context;
70 };
71
72 void StaticChannelContext_free(pServerStaticChannelContext* ctx);
73
78 {
79 rdpContext context;
80
81 proxyData* pdata;
82
83 HANDLE vcm;
84 HANDLE dynvcReady;
85
86 wHashTable* interceptContextMap;
87 wHashTable* channelsByFrontId;
88 wHashTable* channelsByBackId;
89 };
90 typedef struct p_server_context pServerContext;
91
92 WINPR_ATTR_MALLOC(StaticChannelContext_free, 1)
93 WINPR_ATTR_NODISCARD
94 pServerStaticChannelContext* StaticChannelContext_new(pServerContext* ps, const char* name,
95 UINT32 id);
96
100 typedef struct p_client_context pClientContext;
101
103 {
104 rdpContext context;
105
106 proxyData* pdata;
107
108 /*
109 * In a case when freerdp_connect fails,
110 * Used for NLA fallback feature, to check if the server should close the connection.
111 * When it is set to TRUE, proxy's client knows it shouldn't signal the server thread to
112 * closed the connection when pf_client_post_disconnect is called, because it is trying to
113 * connect reconnect without NLA. It must be set to TRUE before the first try, and to FALSE
114 * after the connection fully established, to ensure graceful shutdown of the connection
115 * when it will be closed.
116 */
117 BOOL allow_next_conn_failure;
118
119 BOOL connected; /* Set after client post_connect. */
120
121 pReceiveChannelData client_receive_channel_data_original;
122 wQueue* cached_server_channel_data;
123 BOOL (*sendChannelData)(pClientContext* pc, const proxyChannelDataEventInfo* ev);
124
125 /* X509 specific */
126 char* remote_hostname;
127 wStream* remote_pem;
128 UINT16 remote_port;
129 UINT32 remote_flags;
130
131 BOOL input_state_sync_pending;
132 UINT32 input_state;
133
134 wHashTable* interceptContextMap;
135 UINT32 computerNameLen;
136 BOOL computerNameUnicode;
137 union
138 {
139 WCHAR* wc;
140 char* c;
141 void* v;
142 } computerName;
143 };
144
149 {
150 proxyModule* module;
151 const proxyConfig* config;
152
153 pServerContext* ps;
154 pClientContext* pc;
155
156 HANDLE abort_event;
157 HANDLE client_thread;
158 HANDLE gfx_server_ready;
159
160 char session_id[PROXY_SESSION_ID_LENGTH + 1];
161
162 /* used to external modules to store per-session info */
163 wHashTable* modules_info;
164 psPeerReceiveChannelData server_receive_channel_data_original;
165 };
166
167 FREERDP_API BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src);
168 FREERDP_API BOOL pf_context_init_server_context(freerdp_peer* client);
169
170 WINPR_ATTR_MALLOC(freerdp_client_context_free, 1)
171 WINPR_ATTR_NODISCARD
172 FREERDP_API pClientContext* pf_context_create_client_context(const rdpSettings* clientSettings);
173
174 FREERDP_API void proxy_data_free(proxyData* pdata);
175
176 WINPR_ATTR_MALLOC(proxy_data_free, 1)
177 WINPR_ATTR_NODISCARD
178 FREERDP_API proxyData* proxy_data_new(void);
179 FREERDP_API void proxy_data_set_client_context(proxyData* pdata, pClientContext* context);
180 FREERDP_API void proxy_data_set_server_context(proxyData* pdata, pServerContext* context);
181
182 FREERDP_API BOOL proxy_data_shall_disconnect(proxyData* pdata);
183 FREERDP_API void proxy_data_abort_connect(proxyData* pdata);
184
185#ifdef __cplusplus
186}
187#endif
188
189#endif /* FREERDP_SERVER_PROXY_PFCONTEXT_H */
per channel configuration