Blame server/proxy/modules/modules_api.h

Packit Service 5a9772
/**
Packit Service 5a9772
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit Service 5a9772
 * FreeRDP Proxy Server
Packit Service 5a9772
 *
Packit Service 5a9772
 * Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
Packit Service 5a9772
 * Copyright 2019 Idan Freiberg <speidy@gmail.com>
Packit Service 5a9772
 *
Packit Service 5a9772
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit Service 5a9772
 * you may not use this file except in compliance with the License.
Packit Service 5a9772
 * You may obtain a copy of the License at
Packit Service 5a9772
 *
Packit Service 5a9772
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit Service 5a9772
 *
Packit Service 5a9772
 * Unless required by applicable law or agreed to in writing, software
Packit Service 5a9772
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit Service 5a9772
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit Service 5a9772
 * See the License for the specific language governing permissions and
Packit Service 5a9772
 * limitations under the License.
Packit Service 5a9772
 */
Packit Service 5a9772
Packit Service 5a9772
#ifndef FREERDP_SERVER_PROXY_MODULES_API_H
Packit Service 5a9772
#define FREERDP_SERVER_PROXY_MODULES_API_H
Packit Service 5a9772
Packit Service 5a9772
#include <freerdp/freerdp.h>
Packit Service 5a9772
#include <winpr/winpr.h>
Packit Service 5a9772
Packit Service 5a9772
#include "../pf_context.h"
Packit Service 5a9772
Packit Service 5a9772
#define MODULE_TAG(module) "proxy.modules." module
Packit Service 5a9772
Packit Service 5a9772
/* hook callback. should return TRUE on success or FALSE on error. */
Packit Service 5a9772
typedef BOOL (*proxyHookFn)(proxyData*);
Packit Service 5a9772
Packit Service 5a9772
/*
Packit Service 5a9772
 * Filter callback:
Packit Service 5a9772
 * 	It MUST return TRUE if the related event should be proxied,
Packit Service 5a9772
 * 	or FALSE if it should be ignored.
Packit Service 5a9772
 */
Packit Service 5a9772
typedef BOOL (*proxyFilterFn)(proxyData*, void*);
Packit Service 5a9772
Packit Service 5a9772
/* describes a plugin: name, description and callbacks to execute. */
Packit Service 5a9772
typedef struct proxy_plugin
Packit Service 5a9772
{
Packit Service 5a9772
	const char* name;        /* unique module name */
Packit Service 5a9772
	const char* description; /* module description */
Packit Service 5a9772
Packit Service 5a9772
	BOOL (*PluginUnload)();
Packit Service 5a9772
Packit Service 5a9772
	/* proxy hooks. a module can set these function pointers to register hooks */
Packit Service 5a9772
	proxyHookFn ClientPreConnect;
Packit Service 5a9772
	proxyHookFn ClientLoginFailure;
Packit Service 5a9772
	proxyHookFn ServerPostConnect;
Packit Service 5a9772
	proxyHookFn ServerChannelsInit;
Packit Service 5a9772
	proxyHookFn ServerChannelsFree;
Packit Service 5a9772
Packit Service 5a9772
	/* proxy filters. a module can set these function pointers to register filters */
Packit Service 5a9772
	proxyFilterFn KeyboardEvent;
Packit Service 5a9772
	proxyFilterFn MouseEvent;
Packit Service 5a9772
	proxyFilterFn ClientChannelData; /* passthrough channels data */
Packit Service 5a9772
	proxyFilterFn ServerChannelData; /* passthrough channels data */
Packit Service 5a9772
} proxyPlugin;
Packit Service 5a9772
Packit Service 5a9772
/*
Packit Service 5a9772
 * Main API for use by external modules.
Packit Service 5a9772
 * Supports:
Packit Service 5a9772
 *  - Registering a plugin.
Packit Service 5a9772
 *  - Setting/getting plugin's per-session specific data.
Packit Service 5a9772
 *  - Aborting a session.
Packit Service 5a9772
 */
Packit Service 5a9772
typedef struct proxy_plugins_manager
Packit Service 5a9772
{
Packit Service 5a9772
	/* used for registering a fresh new proxy plugin. */
Packit Service 5a9772
	BOOL (*RegisterPlugin)(proxyPlugin* plugin);
Packit Service 5a9772
Packit Service 5a9772
	/* used for setting plugin's per-session info. */
Packit Service 5a9772
	BOOL (*SetPluginData)(const char*, proxyData*, void*);
Packit Service 5a9772
Packit Service 5a9772
	/* used for getting plugin's per-session info. */
Packit Service 5a9772
	void* (*GetPluginData)(const char*, proxyData*);
Packit Service 5a9772
Packit Service 5a9772
	/* used for aborting a session. */
Packit Service 5a9772
	void (*AbortConnect)(proxyData*);
Packit Service 5a9772
} proxyPluginsManager;
Packit Service 5a9772
Packit Service 5a9772
/* filter events parameters */
Packit Service 5a9772
#define WINPR_PACK_PUSH
Packit Service 5a9772
#include <winpr/pack.h>
Packit Service 5a9772
typedef struct proxy_keyboard_event_info
Packit Service 5a9772
{
Packit Service 5a9772
	UINT16 flags;
Packit Service 5a9772
	UINT16 rdp_scan_code;
Packit Service 5a9772
} proxyKeyboardEventInfo;
Packit Service 5a9772
Packit Service 5a9772
typedef struct proxy_mouse_event_info
Packit Service 5a9772
{
Packit Service 5a9772
	UINT16 flags;
Packit Service 5a9772
	UINT16 x;
Packit Service 5a9772
	UINT16 y;
Packit Service 5a9772
} proxyMouseEventInfo;
Packit Service 5a9772
Packit Service 5a9772
typedef struct channel_data_event_info
Packit Service 5a9772
{
Packit Service 5a9772
	/* channel metadata */
Packit Service 5a9772
	const char* channel_name;
Packit Service 5a9772
	UINT16 channel_id;
Packit Service 5a9772
Packit Service 5a9772
	/* actual data */
Packit Service 5a9772
	const BYTE* data;
Packit Service 5a9772
	int data_len;
Packit Service 5a9772
} proxyChannelDataEventInfo;
Packit Service 5a9772
#define WINPR_PACK_POP
Packit Service 5a9772
#include <winpr/pack.h>
Packit Service 5a9772
Packit Service 5a9772
#ifdef __cplusplus
Packit Service 5a9772
extern "C"
Packit Service 5a9772
{
Packit Service 5a9772
#endif
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API BOOL proxy_module_entry_point(proxyPluginsManager* plugins_manager);
Packit Service 5a9772
Packit Service 5a9772
#ifdef __cplusplus
Packit Service 5a9772
};
Packit Service 5a9772
#endif
Packit Service 5a9772
Packit Service 5a9772
#endif /* FREERDP_SERVER_PROXY_MODULES_API_H */