Blame server/proxy/pf_context.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 Mati Shabtay <matishabtay@gmail.com>
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_PFCONTEXT_H
Packit Service 5a9772
#define FREERDP_SERVER_PROXY_PFCONTEXT_H
Packit Service 5a9772
Packit Service 5a9772
#include <freerdp/freerdp.h>
Packit Service 5a9772
#include <freerdp/channels/wtsvc.h>
Packit Service 5a9772
#include <freerdp/client/rdpei.h>
Packit Service 5a9772
#include <freerdp/client/rail.h>
Packit Service 5a9772
#include <freerdp/server/rail.h>
Packit Service 5a9772
#include <freerdp/client/rdpgfx.h>
Packit Service 5a9772
#include <freerdp/server/rdpgfx.h>
Packit Service 5a9772
#include <freerdp/client/disp.h>
Packit Service 5a9772
#include <freerdp/server/disp.h>
Packit Service 5a9772
#include <freerdp/server/cliprdr.h>
Packit Service 5a9772
#include <freerdp/server/rdpsnd.h>
Packit Service 5a9772
Packit Service 5a9772
#include "pf_config.h"
Packit Service 5a9772
#include "pf_server.h"
Packit Service 5a9772
Packit Service 5a9772
typedef struct proxy_data proxyData;
Packit Service 5a9772
Packit Service 5a9772
/**
Packit Service 5a9772
 * Wraps rdpContext and holds the state for the proxy's server.
Packit Service 5a9772
 */
Packit Service 5a9772
struct p_server_context
Packit Service 5a9772
{
Packit Service 5a9772
	rdpContext context;
Packit Service 5a9772
Packit Service 5a9772
	proxyData* pdata;
Packit Service 5a9772
Packit Service 5a9772
	HANDLE vcm;
Packit Service 5a9772
	HANDLE dynvcReady;
Packit Service 5a9772
Packit Service 5a9772
	RailServerContext* rail;
Packit Service 5a9772
	RdpgfxServerContext* gfx;
Packit Service 5a9772
	DispServerContext* disp;
Packit Service 5a9772
	CliprdrServerContext* cliprdr;
Packit Service 5a9772
	RdpsndServerContext* rdpsnd;
Packit Service 5a9772
Packit Service 5a9772
	HANDLE* vc_handles; /* static virtual channels open handles */
Packit Service 5a9772
	wHashTable* vc_ids; /* channel_name -> channel_id map */
Packit Service 5a9772
};
Packit Service 5a9772
typedef struct p_server_context pServerContext;
Packit Service 5a9772
Packit Service 5a9772
/**
Packit Service 5a9772
 * Wraps rdpContext and holds the state for the proxy's client.
Packit Service 5a9772
 */
Packit Service 5a9772
struct p_client_context
Packit Service 5a9772
{
Packit Service 5a9772
	rdpContext context;
Packit Service 5a9772
Packit Service 5a9772
	proxyData* pdata;
Packit Service 5a9772
Packit Service 5a9772
	RdpeiClientContext* rdpei;
Packit Service 5a9772
	RdpgfxClientContext* gfx_proxy;
Packit Service 5a9772
	RdpgfxClientContext* gfx_decoder;
Packit Service 5a9772
	DispClientContext* disp;
Packit Service 5a9772
	CliprdrClientContext* cliprdr;
Packit Service 5a9772
	RailClientContext* rail;
Packit Service 5a9772
Packit Service 5a9772
	/*
Packit Service 5a9772
	 * In a case when freerdp_connect fails,
Packit Service 5a9772
	 * Used for NLA fallback feature, to check if the server should close the connection.
Packit Service 5a9772
	 * When it is set to TRUE, proxy's client knows it shouldn't signal the server thread to
Packit Service 5a9772
	 * closed the connection when pf_client_post_disconnect is called, because it is trying to
Packit Service 5a9772
	 * connect reconnect without NLA. It must be set to TRUE before the first try, and to FALSE
Packit Service 5a9772
	 * after the connection fully established, to ensure graceful shutdown of the connection
Packit Service 5a9772
	 * when it will be closed.
Packit Service 5a9772
	 */
Packit Service 5a9772
	BOOL allow_next_conn_failure;
Packit Service 5a9772
Packit Service 5a9772
	/* session capture */
Packit Service 5a9772
	char* frames_dir;
Packit Service 5a9772
	UINT64 frames_count;
Packit Service 5a9772
Packit Service 5a9772
	wHashTable* vc_ids; /* channel_name -> channel_id map */
Packit Service 5a9772
};
Packit Service 5a9772
typedef struct p_client_context pClientContext;
Packit Service 5a9772
Packit Service 5a9772
/**
Packit Service 5a9772
 * Holds data common to both sides of a proxy's session.
Packit Service 5a9772
 */
Packit Service 5a9772
struct proxy_data
Packit Service 5a9772
{
Packit Service 5a9772
	proxyConfig* config;
Packit Service 5a9772
Packit Service 5a9772
	pServerContext* ps;
Packit Service 5a9772
	pClientContext* pc;
Packit Service 5a9772
Packit Service 5a9772
	HANDLE abort_event;
Packit Service 5a9772
	HANDLE client_thread;
Packit Service 5a9772
	HANDLE gfx_server_ready;
Packit Service 5a9772
Packit Service 5a9772
	char* session_id;
Packit Service 5a9772
Packit Service 5a9772
	/* used to external modules to store per-session info */
Packit Service 5a9772
	wHashTable* modules_info;
Packit Service 5a9772
};
Packit Service 5a9772
Packit Service 5a9772
BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src);
Packit Service 5a9772
BOOL pf_context_init_server_context(freerdp_peer* client);
Packit Service 5a9772
pClientContext* pf_context_create_client_context(rdpSettings* clientSettings);
Packit Service 5a9772
Packit Service 5a9772
proxyData* proxy_data_new(void);
Packit Service 5a9772
void proxy_data_set_client_context(proxyData* pdata, pClientContext* context);
Packit Service 5a9772
void proxy_data_set_server_context(proxyData* pdata, pServerContext* context);
Packit Service 5a9772
void proxy_data_free(proxyData* pdata);
Packit Service 5a9772
Packit Service 5a9772
BOOL proxy_data_shall_disconnect(proxyData* pdata);
Packit Service 5a9772
void proxy_data_abort_connect(proxyData* pdata);
Packit Service 5a9772
Packit Service 5a9772
#endif /* FREERDP_SERVER_PROXY_PFCONTEXT_H */