FreeRDP
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
37 extern "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  pServerStaticChannelContext* StaticChannelContext_new(pServerContext* ps, const char* name,
94  UINT32 id);
95 
99  typedef struct p_client_context pClientContext;
100 
102  {
103  rdpContext context;
104 
105  proxyData* pdata;
106 
107  /*
108  * In a case when freerdp_connect fails,
109  * Used for NLA fallback feature, to check if the server should close the connection.
110  * When it is set to TRUE, proxy's client knows it shouldn't signal the server thread to
111  * closed the connection when pf_client_post_disconnect is called, because it is trying to
112  * connect reconnect without NLA. It must be set to TRUE before the first try, and to FALSE
113  * after the connection fully established, to ensure graceful shutdown of the connection
114  * when it will be closed.
115  */
116  BOOL allow_next_conn_failure;
117 
118  BOOL connected; /* Set after client post_connect. */
119 
120  pReceiveChannelData client_receive_channel_data_original;
121  wQueue* cached_server_channel_data;
122  BOOL (*sendChannelData)(pClientContext* pc, const proxyChannelDataEventInfo* ev);
123 
124  /* X509 specific */
125  char* remote_hostname;
126  wStream* remote_pem;
127  UINT16 remote_port;
128  UINT32 remote_flags;
129 
130  BOOL input_state_sync_pending;
131  UINT32 input_state;
132 
133  wHashTable* interceptContextMap;
134  UINT32 computerNameLen;
135  BOOL computerNameUnicode;
136  union
137  {
138  WCHAR* wc;
139  char* c;
140  void* v;
141  } computerName;
142  };
143 
147  struct proxy_data
148  {
149  proxyModule* module;
150  const proxyConfig* config;
151 
152  pServerContext* ps;
153  pClientContext* pc;
154 
155  HANDLE abort_event;
156  HANDLE client_thread;
157  HANDLE gfx_server_ready;
158 
159  char session_id[PROXY_SESSION_ID_LENGTH + 1];
160 
161  /* used to external modules to store per-session info */
162  wHashTable* modules_info;
163  psPeerReceiveChannelData server_receive_channel_data_original;
164  };
165 
166  FREERDP_API BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src);
167  FREERDP_API BOOL pf_context_init_server_context(freerdp_peer* client);
168 
169  WINPR_ATTR_MALLOC(freerdp_client_context_free, 1)
170  FREERDP_API pClientContext* pf_context_create_client_context(const rdpSettings* clientSettings);
171 
172  FREERDP_API void proxy_data_free(proxyData* pdata);
173 
174  WINPR_ATTR_MALLOC(proxy_data_free, 1)
175  FREERDP_API proxyData* proxy_data_new(void);
176  FREERDP_API void proxy_data_set_client_context(proxyData* pdata, pClientContext* context);
177  FREERDP_API void proxy_data_set_server_context(proxyData* pdata, pServerContext* context);
178 
179  FREERDP_API BOOL proxy_data_shall_disconnect(proxyData* pdata);
180  FREERDP_API void proxy_data_abort_connect(proxyData* pdata);
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif /* FREERDP_SERVER_PROXY_PFCONTEXT_H */
per channel configuration
Definition: proxy_context.h:61