FreeRDP
Loading...
Searching...
No Matches
proxy_modules_api.h
1
25#ifndef FREERDP_SERVER_PROXY_MODULES_API_H
26#define FREERDP_SERVER_PROXY_MODULES_API_H
27
28#include <winpr/winpr.h>
29#include <winpr/stream.h>
30#include <winpr/sspi.h>
31
32#include <freerdp/server/proxy/proxy_types.h>
33
34#define MODULE_TAG(module) "proxy.modules." module
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 proxy_plugin proxyPlugin;
44 typedef struct proxy_plugins_manager proxyPluginsManager;
45
46 /* hook callback. should return TRUE on success or FALSE on error. */
47 typedef BOOL (*proxyHookFn)(proxyPlugin*, proxyData*, void*);
48
49 /*
50 * Filter callback:
51 * It MUST return TRUE if the related event should be proxied,
52 * or FALSE if it should be ignored.
53 */
54 typedef BOOL (*proxyFilterFn)(proxyPlugin*, proxyData*, void*);
55
56 /* describes a plugin: name, description and callbacks to execute.
57 *
58 * This is public API, so always add new fields at the end of the struct to keep
59 * some backward compatibility.
60 */
62 {
63 const char* name; /* 0: unique module name */
64 const char* description; /* 1: module description */
65
66 UINT64 reserved1[32 - 2]; /* 2-32 */
67
68 WINPR_ATTR_NODISCARD BOOL (*PluginUnload)(proxyPlugin* plugin); /* 33 */
69 UINT64 reserved2[66 - 34]; /* 34 - 65 */
70
71 /* proxy hooks. a module can set these function pointers to register hooks */
72 WINPR_ATTR_NODISCARD proxyHookFn ClientInitConnect; /* 66 custom=rdpContext* */
73 WINPR_ATTR_NODISCARD proxyHookFn ClientUninitConnect; /* 67 custom=rdpContext* */
74 WINPR_ATTR_NODISCARD proxyHookFn ClientPreConnect; /* 68 custom=rdpContext* */
75 WINPR_ATTR_NODISCARD proxyHookFn ClientPostConnect; /* 69 custom=rdpContext* */
76 WINPR_ATTR_NODISCARD proxyHookFn ClientPostDisconnect; /* 70 custom=rdpContext* */
77 WINPR_ATTR_NODISCARD proxyHookFn ClientX509Certificate; /* 71 custom=rdpContext* */
78 WINPR_ATTR_NODISCARD proxyHookFn ClientLoginFailure; /* 72 custom=rdpContext* */
79 WINPR_ATTR_NODISCARD proxyHookFn ClientEndPaint; /* 73 custom=rdpContext* */
80 WINPR_ATTR_NODISCARD proxyHookFn ClientRedirect; /* 74 custom=rdpContext* */
81 WINPR_ATTR_NODISCARD proxyHookFn ClientLoadChannels; /* 75 custom=rdpContext* */
82 UINT64 reserved3[96 - 76]; /* 76-95 */
83
84 WINPR_ATTR_NODISCARD proxyHookFn ServerPostConnect; /* 96 custom=freerdp_peer* */
85 WINPR_ATTR_NODISCARD proxyHookFn ServerPeerActivate; /* 97 custom=freerdp_peer* */
86 WINPR_ATTR_NODISCARD proxyHookFn ServerChannelsInit; /* 98 custom=freerdp_peer* */
87 WINPR_ATTR_NODISCARD proxyHookFn ServerChannelsFree; /* 99 custom=freerdp_peer* */
88 WINPR_ATTR_NODISCARD proxyHookFn ServerSessionEnd; /* 100 custom=freerdp_peer* */
89 WINPR_ATTR_NODISCARD proxyHookFn ServerSessionInitialize; /* 101 custom=freerdp_peer* */
90 WINPR_ATTR_NODISCARD proxyHookFn ServerSessionStarted; /* 102 custom=freerdp_peer* */
91
92 UINT64 reserved4[128 - 103]; /* 103 - 127 */
93
94 /* proxy filters. a module can set these function pointers to register filters */
95 WINPR_ATTR_NODISCARD proxyFilterFn KeyboardEvent; /* 128 */
96 WINPR_ATTR_NODISCARD proxyFilterFn MouseEvent; /* 129 */
97 WINPR_ATTR_NODISCARD proxyFilterFn ClientChannelData; /* 130 passthrough channels data */
98 WINPR_ATTR_NODISCARD proxyFilterFn ServerChannelData; /* 131 passthrough channels data */
99 WINPR_ATTR_NODISCARD proxyFilterFn
100 DynamicChannelCreate; /* 132 passthrough drdynvc channel create data */
101 WINPR_ATTR_NODISCARD proxyFilterFn ServerFetchTargetAddr; /* 133 */
102 WINPR_ATTR_NODISCARD proxyFilterFn ServerPeerLogon; /* 134 */
103 WINPR_ATTR_NODISCARD proxyFilterFn
104 ChannelCreate; /* 135 passthrough drdynvc channel create data */
105 WINPR_ATTR_NODISCARD proxyFilterFn UnicodeEvent; /* 136 */
106 WINPR_ATTR_NODISCARD proxyFilterFn MouseExEvent; /* 137 */
107
108 /* proxy dynamic channel filters:
109 *
110 * - a function that returns the list of channels to intercept
111 * - a function to call with the data received
112 */
113 WINPR_ATTR_NODISCARD proxyFilterFn DynChannelToIntercept; /* 138 */
114 WINPR_ATTR_NODISCARD proxyFilterFn DynChannelIntercept; /* 139 */
115 WINPR_ATTR_NODISCARD proxyFilterFn StaticChannelToIntercept; /* 140 */
116 UINT64 reserved5[160 - 141]; /* 141-159 */
117
118 /* Runtime data fields */
119 proxyPluginsManager* mgr; /* 160 */
120 void* userdata; /* 161 */
122 void* custom; /* 162 */
125 UINT64 reserved6[192 - 163]; /* 163-191 Add some filler data to allow for new callbacks or
126 * fields without breaking API */
127 };
128
129 /*
130 * Main API for use by external modules.
131 * Supports:
132 * - Registering a plugin.
133 * - Setting/getting plugin's per-session specific data.
134 * - Aborting a session.
135 */
137 {
138 /* 0 used for registering a fresh new proxy plugin. */
139 WINPR_ATTR_NODISCARD BOOL (*RegisterPlugin)(struct proxy_plugins_manager* mgr,
140 const proxyPlugin* plugin);
141
142 /* 1 used for setting plugin's per-session info. */
143 WINPR_ATTR_NODISCARD BOOL (*SetPluginData)(struct proxy_plugins_manager* mgr, const char*,
144 proxyData*, void*);
145
146 /* 2 used for getting plugin's per-session info. */
147 WINPR_ATTR_NODISCARD void* (*GetPluginData)(struct proxy_plugins_manager* mgr, const char*,
148 proxyData*);
149
150 /* 3 used for aborting a session. */
151 void (*AbortConnect)(struct proxy_plugins_manager* mgr, proxyData*);
152
153 UINT64 reserved[128 - 4]; /* 4-127 reserved fields */
154 };
155
156 typedef BOOL (*proxyModuleEntryPoint)(proxyPluginsManager* plugins_manager, void* userdata);
157
158/* filter events parameters */
159#define WINPR_PACK_PUSH
160#include <winpr/pack.h>
161typedef struct proxy_keyboard_event_info
162{
163 UINT16 flags;
164 UINT16 rdp_scan_code;
166
167typedef struct proxy_unicode_event_info
168{
169 UINT16 flags;
170 UINT16 code;
172
173typedef struct proxy_mouse_event_info
174{
175 UINT16 flags;
176 UINT16 x;
177 UINT16 y;
179
180typedef struct proxy_mouse_ex_event_info
181{
182 UINT16 flags;
183 UINT16 x;
184 UINT16 y;
186
187typedef struct
188{
189 /* channel metadata */
190 const char* channel_name;
191 UINT16 channel_id;
192
193 /* actual data */
194 const BYTE* data;
195 size_t data_len;
196 size_t total_size;
197 UINT32 flags;
199
200typedef struct
201{
202 /* out values */
203 char* target_address;
204 UINT16 target_port;
205
206 /*
207 * If this value is set to true by a plugin, target info will be fetched from config and proxy
208 * will connect any client to the same remote server.
209 */
210 ProxyFetchTargetMethod fetch_method;
212
213typedef struct server_peer_logon
214{
215 const SEC_WINNT_AUTH_IDENTITY* identity;
216 BOOL automatic;
218
219typedef struct dyn_channel_intercept_data
220{
221 const char* name;
222 UINT32 channelId;
223 wStream* data;
224 BOOL isBackData;
225 BOOL first;
226 BOOL last;
227 BOOL rewritten;
228 size_t packetSize;
229 PfChannelResult result;
231
232typedef struct dyn_channel_to_intercept_data
233{
234 const char* name;
235 UINT32 channelId;
236 BOOL intercept;
238
239#define WINPR_PACK_POP
240#include <winpr/pack.h>
241
242#ifdef __cplusplus
243}
244#endif
245
246#endif /* FREERDP_SERVER_PROXY_MODULES_API_H */
UINT64 reserved6[192 - 163]