FreeRDP
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
37 extern "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  */
61  struct proxy_plugin
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  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  proxyHookFn ClientInitConnect; /* 66 custom=rdpContext* */
73  proxyHookFn ClientUninitConnect; /* 67 custom=rdpContext* */
74  proxyHookFn ClientPreConnect; /* 68 custom=rdpContext* */
75  proxyHookFn ClientPostConnect; /* 69 custom=rdpContext* */
76  proxyHookFn ClientPostDisconnect; /* 70 custom=rdpContext* */
77  proxyHookFn ClientX509Certificate; /* 71 custom=rdpContext* */
78  proxyHookFn ClientLoginFailure; /* 72 custom=rdpContext* */
79  proxyHookFn ClientEndPaint; /* 73 custom=rdpContext* */
80  proxyHookFn ClientRedirect; /* 74 custom=rdpContext* */
81  proxyHookFn ClientLoadChannels; /* 75 custom=rdpContext* */
82  UINT64 reserved3[96 - 76]; /* 76-95 */
83 
84  proxyHookFn ServerPostConnect; /* 96 custom=freerdp_peer* */
85  proxyHookFn ServerPeerActivate; /* 97 custom=freerdp_peer* */
86  proxyHookFn ServerChannelsInit; /* 98 custom=freerdp_peer* */
87  proxyHookFn ServerChannelsFree; /* 99 custom=freerdp_peer* */
88  proxyHookFn ServerSessionEnd; /* 100 custom=freerdp_peer* */
89  proxyHookFn ServerSessionInitialize; /* 101 custom=freerdp_peer* */
90  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  proxyFilterFn KeyboardEvent; /* 128 */
96  proxyFilterFn MouseEvent; /* 129 */
97  proxyFilterFn ClientChannelData; /* 130 passthrough channels data */
98  proxyFilterFn ServerChannelData; /* 131 passthrough channels data */
99  proxyFilterFn DynamicChannelCreate; /* 132 passthrough drdynvc channel create data */
100  proxyFilterFn ServerFetchTargetAddr; /* 133 */
101  proxyFilterFn ServerPeerLogon; /* 134 */
102  proxyFilterFn ChannelCreate; /* 135 passthrough drdynvc channel create data */
103  proxyFilterFn UnicodeEvent; /* 136 */
104  proxyFilterFn MouseExEvent; /* 137 */
105 
106  /* proxy dynamic channel filters:
107  *
108  * - a function that returns the list of channels to intercept
109  * - a function to call with the data received
110  */
111  proxyFilterFn DynChannelToIntercept; /* 138 */
112  proxyFilterFn DynChannelIntercept; /* 139 */
113  proxyFilterFn StaticChannelToIntercept; /* 140 */
114  UINT64 reserved5[160 - 141]; /* 141-159 */
115 
116  /* Runtime data fields */
117  proxyPluginsManager* mgr; /* 160 */
118  void* userdata; /* 161 */
120  void* custom; /* 162 */
123  UINT64 reserved6[192 - 163]; /* 163-191 Add some filler data to allow for new callbacks or
124  * fields without breaking API */
125  };
126 
127  /*
128  * Main API for use by external modules.
129  * Supports:
130  * - Registering a plugin.
131  * - Setting/getting plugin's per-session specific data.
132  * - Aborting a session.
133  */
135  {
136  /* 0 used for registering a fresh new proxy plugin. */
137  BOOL (*RegisterPlugin)(struct proxy_plugins_manager* mgr, const proxyPlugin* plugin);
138 
139  /* 1 used for setting plugin's per-session info. */
140  BOOL (*SetPluginData)(struct proxy_plugins_manager* mgr, const char*, proxyData*, void*);
141 
142  /* 2 used for getting plugin's per-session info. */
143  void* (*GetPluginData)(struct proxy_plugins_manager* mgr, const char*, proxyData*);
144 
145  /* 3 used for aborting a session. */
146  void (*AbortConnect)(struct proxy_plugins_manager* mgr, proxyData*);
147 
148  UINT64 reserved[128 - 4]; /* 4-127 reserved fields */
149  };
150 
151  typedef BOOL (*proxyModuleEntryPoint)(proxyPluginsManager* plugins_manager, void* userdata);
152 
153 /* filter events parameters */
154 #define WINPR_PACK_PUSH
155 #include <winpr/pack.h>
156 typedef struct proxy_keyboard_event_info
157 {
158  UINT16 flags;
159  UINT16 rdp_scan_code;
161 
162 typedef struct proxy_unicode_event_info
163 {
164  UINT16 flags;
165  UINT16 code;
167 
168 typedef struct proxy_mouse_event_info
169 {
170  UINT16 flags;
171  UINT16 x;
172  UINT16 y;
174 
175 typedef struct proxy_mouse_ex_event_info
176 {
177  UINT16 flags;
178  UINT16 x;
179  UINT16 y;
181 
182 typedef struct
183 {
184  /* channel metadata */
185  const char* channel_name;
186  UINT16 channel_id;
187 
188  /* actual data */
189  const BYTE* data;
190  size_t data_len;
191  size_t total_size;
192  UINT32 flags;
194 
195 typedef struct
196 {
197  /* out values */
198  char* target_address;
199  UINT16 target_port;
200 
201  /*
202  * If this value is set to true by a plugin, target info will be fetched from config and proxy
203  * will connect any client to the same remote server.
204  */
205  ProxyFetchTargetMethod fetch_method;
207 
208 typedef struct server_peer_logon
209 {
210  const SEC_WINNT_AUTH_IDENTITY* identity;
211  BOOL automatic;
213 
214 typedef struct dyn_channel_intercept_data
215 {
216  const char* name;
217  UINT32 channelId;
218  wStream* data;
219  BOOL isBackData;
220  BOOL first;
221  BOOL last;
222  BOOL rewritten;
223  size_t packetSize;
224  PfChannelResult result;
226 
227 typedef struct dyn_channel_to_intercept_data
228 {
229  const char* name;
230  UINT32 channelId;
231  BOOL intercept;
233 
234 #define WINPR_PACK_POP
235 #include <winpr/pack.h>
236 
237 #ifdef __cplusplus
238 }
239 #endif
240 
241 #endif /* FREERDP_SERVER_PROXY_MODULES_API_H */
UINT64 reserved6[192 - 163]