File: modules_api.h

package info (click to toggle)
freerdp2 2.3.0%2Bdfsg1-2%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 27,060 kB
  • sloc: ansic: 330,648; xml: 1,676; cpp: 821; sh: 748; python: 638; perl: 231; lisp: 120; makefile: 86
file content (125 lines) | stat: -rw-r--r-- 3,377 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
 * FreeRDP: A Remote Desktop Protocol Implementation
 * FreeRDP Proxy Server
 *
 * Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
 * Copyright 2019 Idan Freiberg <speidy@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FREERDP_SERVER_PROXY_MODULES_API_H
#define FREERDP_SERVER_PROXY_MODULES_API_H

#include <freerdp/freerdp.h>
#include <winpr/winpr.h>

#include "../pf_context.h"

#define MODULE_TAG(module) "proxy.modules." module

/* hook callback. should return TRUE on success or FALSE on error. */
typedef BOOL (*proxyHookFn)(proxyData*);

/*
 * Filter callback:
 * 	It MUST return TRUE if the related event should be proxied,
 * 	or FALSE if it should be ignored.
 */
typedef BOOL (*proxyFilterFn)(proxyData*, void*);

/* describes a plugin: name, description and callbacks to execute. */
typedef struct proxy_plugin
{
	const char* name;        /* unique module name */
	const char* description; /* module description */

	BOOL (*PluginUnload)();

	/* proxy hooks. a module can set these function pointers to register hooks */
	proxyHookFn ClientPreConnect;
	proxyHookFn ClientLoginFailure;
	proxyHookFn ServerPostConnect;
	proxyHookFn ServerChannelsInit;
	proxyHookFn ServerChannelsFree;

	/* proxy filters. a module can set these function pointers to register filters */
	proxyFilterFn KeyboardEvent;
	proxyFilterFn MouseEvent;
	proxyFilterFn ClientChannelData; /* passthrough channels data */
	proxyFilterFn ServerChannelData; /* passthrough channels data */
} proxyPlugin;

/*
 * Main API for use by external modules.
 * Supports:
 *  - Registering a plugin.
 *  - Setting/getting plugin's per-session specific data.
 *  - Aborting a session.
 */
typedef struct proxy_plugins_manager
{
	/* used for registering a fresh new proxy plugin. */
	BOOL (*RegisterPlugin)(proxyPlugin* plugin);

	/* used for setting plugin's per-session info. */
	BOOL (*SetPluginData)(const char*, proxyData*, void*);

	/* used for getting plugin's per-session info. */
	void* (*GetPluginData)(const char*, proxyData*);

	/* used for aborting a session. */
	void (*AbortConnect)(proxyData*);
} proxyPluginsManager;

/* filter events parameters */
#define WINPR_PACK_PUSH
#include <winpr/pack.h>
typedef struct proxy_keyboard_event_info
{
	UINT16 flags;
	UINT16 rdp_scan_code;
} proxyKeyboardEventInfo;

typedef struct proxy_mouse_event_info
{
	UINT16 flags;
	UINT16 x;
	UINT16 y;
} proxyMouseEventInfo;

typedef struct channel_data_event_info
{
	/* channel metadata */
	const char* channel_name;
	UINT16 channel_id;

	/* actual data */
	const BYTE* data;
	int data_len;
} proxyChannelDataEventInfo;
#define WINPR_PACK_POP
#include <winpr/pack.h>

#ifdef __cplusplus
extern "C"
{
#endif

	FREERDP_API BOOL proxy_module_entry_point(proxyPluginsManager* plugins_manager);

#ifdef __cplusplus
};
#endif

#endif /* FREERDP_SERVER_PROXY_MODULES_API_H */