FreeRDP
tsg.c File Reference
#include <winpr/crt.h>
#include <winpr/ndr.h>
#include <winpr/error.h>
#include <winpr/print.h>
#include <winpr/stream.h>
#include <freerdp/log.h>
#include "rpc_bind.h"
#include "rpc_client.h"
#include "tsg.h"
#include "../../crypto/opensslcompat.h"

Macros

#define TAG   FREERDP_TAG("core.gateway.tsg")
 

Typedefs

typedef WCHAR * RESOURCENAME
 
typedef union TSG_CAPABILITIES_UNION * PTSG_CAPABILITIES_UNION
 
typedef union TSG_PACKET_TYPE_MESSAGE_UNION * PTSG_PACKET_TYPE_MESSAGE_UNION
 
typedef union TSG_INITIAL_PACKET_TYPE_UNION * PTSG_INITIAL_PACKET_TYPE_UNION
 

Functions

static BOOL tsg_stream_align (wStream *s, size_t align)
 
static BIO_METHOD * BIO_s_tsg (void)
 
static int TsProxySendToServer (handle_t IDL_handle, const byte pRpcMessage[], UINT32 count, UINT32 *lengths)
 
static BOOL TsProxyCreateTunnelWriteRequest (rdpTsg *tsg, PTSG_PACKET tsgPacket)
 
static BOOL TsProxyCreateTunnelReadResponse (rdpTsg *tsg, RPC_PDU *pdu, CONTEXT_HANDLE *tunnelContext, UINT32 *tunnelId)
 
static BOOL TsProxyAuthorizeTunnelWriteRequest (rdpTsg *tsg, CONTEXT_HANDLE *tunnelContext)
 
static BOOL TsProxyAuthorizeTunnelReadResponse (rdpTsg *tsg, RPC_PDU *pdu)
 
static BOOL TsProxyMakeTunnelCallWriteRequest (rdpTsg *tsg, CONTEXT_HANDLE *tunnelContext, UINT32 procId)
 
static BOOL TsProxyMakeTunnelCallReadResponse (rdpTsg *tsg, RPC_PDU *pdu)
 
static BOOL TsProxyCreateChannelWriteRequest (rdpTsg *tsg, CONTEXT_HANDLE *tunnelContext)
 
static BOOL TsProxyCreateChannelReadResponse (rdpTsg *tsg, RPC_PDU *pdu, CONTEXT_HANDLE *channelContext, UINT32 *channelId)
 
static BOOL TsProxyCloseChannelWriteRequest (rdpTsg *tsg, CONTEXT_HANDLE *context)
 
static BOOL TsProxyCloseChannelReadResponse (rdpTsg *tsg, RPC_PDU *pdu, CONTEXT_HANDLE *context)
 
static BOOL TsProxyCloseTunnelWriteRequest (rdpTsg *tsg, CONTEXT_HANDLE *context)
 
static BOOL TsProxyCloseTunnelReadResponse (rdpTsg *tsg, RPC_PDU *pdu, CONTEXT_HANDLE *context)
 
static BOOL TsProxySetupReceivePipeWriteRequest (rdpTsg *tsg, CONTEXT_HANDLE *channelContext)
 
static BOOL tsg_transition_to_state (rdpTsg *tsg, TSG_STATE state)
 
BOOL tsg_proxy_begin (rdpTsg *tsg)
 
static BOOL tsg_proxy_reauth (rdpTsg *tsg)
 
BOOL tsg_recv_pdu (rdpTsg *tsg, RPC_PDU *pdu)
 
BOOL tsg_check_event_handles (rdpTsg *tsg)
 
DWORD tsg_get_event_handles (rdpTsg *tsg, HANDLE *events, DWORD count)
 
static BOOL tsg_set_hostname (rdpTsg *tsg, const char *hostname)
 
static BOOL tsg_set_machine_name (rdpTsg *tsg, const char *machineName)
 
BOOL tsg_connect (rdpTsg *tsg, const char *hostname, UINT16 port, int timeout)
 
BOOL tsg_disconnect (rdpTsg *tsg)
 
static int tsg_read (rdpTsg *tsg, BYTE *data, UINT32 length)
 
static int tsg_write (rdpTsg *tsg, const BYTE *data, UINT32 length)
 
rdpTsg * tsg_new (rdpTransport *transport)
 
void tsg_free (rdpTsg *tsg)
 
static int transport_bio_tsg_write (BIO *bio, const char *buf, int num)
 
static int transport_bio_tsg_read (BIO *bio, char *buf, int size)
 
static int transport_bio_tsg_puts (BIO *bio, const char *str)
 
static int transport_bio_tsg_gets (BIO *bio, char *str, int size)
 
static long transport_bio_tsg_ctrl (BIO *bio, int cmd, long arg1, void *arg2)
 
static int transport_bio_tsg_new (BIO *bio)
 
static int transport_bio_tsg_free (BIO *bio)
 
TSG_STATE tsg_get_state (rdpTsg *tsg)
 
BIO * tsg_get_bio (rdpTsg *tsg)
 
BOOL tsg_set_state (rdpTsg *tsg, TSG_STATE state)
 

Macro Definition Documentation

#define TAG   FREERDP_TAG("core.gateway.tsg")

FreeRDP: A Remote Desktop Protocol Implementation Terminal Server Gateway (TSG)

Copyright 2012 Fujitsu Technology Solutions GmbH Copyright 2012 Dmitrij Jasnov dmitr.nosp@m.ij.j.nosp@m.asnov.nosp@m.@ts..nosp@m.fujit.nosp@m.su.c.nosp@m.om Copyright 2015 Thincast Technologies GmbH Copyright 2015 DI (FH) Martin Haimberger marti.nosp@m.n.ha.nosp@m.imber.nosp@m.ger@.nosp@m.thinc.nosp@m.ast..nosp@m.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.

Typedef Documentation

typedef union TSG_CAPABILITIES_UNION * PTSG_CAPABILITIES_UNION
typedef union TSG_INITIAL_PACKET_TYPE_UNION * PTSG_INITIAL_PACKET_TYPE_UNION
typedef union TSG_PACKET_TYPE_MESSAGE_UNION * PTSG_PACKET_TYPE_MESSAGE_UNION
typedef WCHAR* RESOURCENAME

Function Documentation

BIO_METHOD * BIO_s_tsg ( void  )
static

Here is the call graph for this function:

Here is the caller graph for this function:

static long transport_bio_tsg_ctrl ( BIO *  bio,
int  cmd,
long  arg1,
void arg2 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static int transport_bio_tsg_free ( BIO *  bio)
static

Here is the caller graph for this function:

static int transport_bio_tsg_gets ( BIO *  bio,
char *  str,
int  size 
)
static

Here is the caller graph for this function:

static int transport_bio_tsg_new ( BIO *  bio)
static

Here is the caller graph for this function:

static int transport_bio_tsg_puts ( BIO *  bio,
const char *  str 
)
static

Here is the caller graph for this function:

static int transport_bio_tsg_read ( BIO *  bio,
char *  buf,
int  size 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static int transport_bio_tsg_write ( BIO *  bio,
const char *  buf,
int  num 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL tsg_check_event_handles ( rdpTsg *  tsg)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL tsg_connect ( rdpTsg *  tsg,
const char *  hostname,
UINT16  port,
int  timeout 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL tsg_disconnect ( rdpTsg *  tsg)
               Gateway Shutdown Phase

Client Server | |

----------—TsProxyCloseChannel Request-------—>
<----—TsProxySetupReceivePipe Final Response--—
<--------—TsProxyCloseChannel Response--------—
-—TsProxyMakeTunnelCall Request (cancel async)–>
<—TsProxyMakeTunnelCall Response (call async)-—
<—TsProxyMakeTunnelCall Response (cancel async)–
-----------—TsProxyCloseTunnel Request-------—>
<----------—TsProxyCloseTunnel Response-------—

Here is the call graph for this function:

void tsg_free ( rdpTsg *  tsg)

Here is the call graph for this function:

Here is the caller graph for this function:

BIO* tsg_get_bio ( rdpTsg *  tsg)

Here is the caller graph for this function:

DWORD tsg_get_event_handles ( rdpTsg *  tsg,
HANDLE *  events,
DWORD  count 
)

Here is the caller graph for this function:

TSG_STATE tsg_get_state ( rdpTsg *  tsg)

Here is the caller graph for this function:

rdpTsg* tsg_new ( rdpTransport *  transport)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL tsg_proxy_begin ( rdpTsg *  tsg)

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL tsg_proxy_reauth ( rdpTsg *  tsg)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static int tsg_read ( rdpTsg *  tsg,
BYTE data,
UINT32  length 
)
static
Parameters
[in]tsg
[in]data
[in]length
Returns
< 0 on error; 0 if not enough data is available (non blocking mode); > 0 bytes to read

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL tsg_recv_pdu ( rdpTsg *  tsg,
RPC_PDU pdu 
)

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL tsg_set_hostname ( rdpTsg *  tsg,
const char *  hostname 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL tsg_set_machine_name ( rdpTsg *  tsg,
const char *  machineName 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL tsg_set_state ( rdpTsg *  tsg,
TSG_STATE  state 
)

Here is the caller graph for this function:

static BOOL tsg_stream_align ( wStream *  s,
size_t  align 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL tsg_transition_to_state ( rdpTsg *  tsg,
TSG_STATE  state 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static int tsg_write ( rdpTsg *  tsg,
const BYTE data,
UINT32  length 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyAuthorizeTunnelReadResponse ( rdpTsg *  tsg,
RPC_PDU pdu 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyAuthorizeTunnelWriteRequest ( rdpTsg *  tsg,
CONTEXT_HANDLE tunnelContext 
)
static

OpNum = 2

HRESULT TsProxyAuthorizeTunnel( [in] PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext, [in, ref] PTSG_PACKET tsgPacket, [out, ref] PTSG_PACKET* tsgPacketResponse );

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyCloseChannelReadResponse ( rdpTsg *  tsg,
RPC_PDU pdu,
CONTEXT_HANDLE context 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyCloseChannelWriteRequest ( rdpTsg *  tsg,
CONTEXT_HANDLE context 
)
static

HRESULT TsProxyCloseChannel( [in, out] PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE* context );

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyCloseTunnelReadResponse ( rdpTsg *  tsg,
RPC_PDU pdu,
CONTEXT_HANDLE context 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyCloseTunnelWriteRequest ( rdpTsg *  tsg,
CONTEXT_HANDLE context 
)
static

HRESULT TsProxyCloseTunnel( [in, out] PTUNNEL_CONTEXT_HANDLE_SERIALIZE* context );

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyCreateChannelReadResponse ( rdpTsg *  tsg,
RPC_PDU pdu,
CONTEXT_HANDLE channelContext,
UINT32 channelId 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyCreateChannelWriteRequest ( rdpTsg *  tsg,
CONTEXT_HANDLE tunnelContext 
)
static

OpNum = 4

HRESULT TsProxyCreateChannel( [in] PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext, [in, ref] PTSENDPOINTINFO tsEndPointInfo, [out] PCHANNEL_CONTEXT_HANDLE_SERIALIZE* channelContext, [out] unsigned long* channelId );

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyCreateTunnelReadResponse ( rdpTsg *  tsg,
RPC_PDU pdu,
CONTEXT_HANDLE tunnelContext,
UINT32 tunnelId 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyCreateTunnelWriteRequest ( rdpTsg *  tsg,
PTSG_PACKET  tsgPacket 
)
static

OpNum = 1

HRESULT TsProxyCreateTunnel( [in, ref] PTSG_PACKET tsgPacket, [out, ref] PTSG_PACKET* tsgPacketResponse, [out] PTUNNEL_CONTEXT_HANDLE_SERIALIZE* tunnelContext, [out] unsigned long* tunnelId );

The following 60-byte structure is apparently undocumented, but parts of it can be matched to known C706 data structures.

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyMakeTunnelCallReadResponse ( rdpTsg *  tsg,
RPC_PDU pdu 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxyMakeTunnelCallWriteRequest ( rdpTsg *  tsg,
CONTEXT_HANDLE tunnelContext,
UINT32  procId 
)
static

OpNum = 3

HRESULT TsProxyMakeTunnelCall( [in] PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE tunnelContext, [in] unsigned long procId, [in, ref] PTSG_PACKET tsgPacket, [out, ref] PTSG_PACKET* tsgPacketResponse );

Here is the call graph for this function:

Here is the caller graph for this function:

static int TsProxySendToServer ( handle_t  IDL_handle,
const byte  pRpcMessage[],
UINT32  count,
UINT32 lengths 
)
static

RPC Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa378623/ Remote Procedure Call: http://msdn.microsoft.com/en-us/library/windows/desktop/aa378651/ RPC NDR Interface Reference: http://msdn.microsoft.com/en-us/library/windows/desktop/hh802752/ call sequence with silent reauth:

TsProxyCreateTunnelRequest() TsProxyCreateTunnelResponse(TunnelContext) TsProxyAuthorizeTunnelRequest(TunnelContext) TsProxyAuthorizeTunnelResponse() TsProxyMakeTunnelCallRequest(TunnelContext) TsProxyCreateChannelRequest(TunnelContext) TsProxyCreateChannelResponse(ChannelContext) TsProxySetupReceivePipeRequest(ChannelContext) TsProxySendToServerRequest(ChannelContext)

...

TsProxyMakeTunnelCallResponse(reauth) TsProxyCreateTunnelRequest() TsProxyMakeTunnelCallRequest(TunnelContext) TsProxyCreateTunnelResponse(NewTunnelContext) TsProxyAuthorizeTunnelRequest(NewTunnelContext) TsProxyAuthorizeTunnelResponse() TsProxyCreateChannelRequest(NewTunnelContext) TsProxyCreateChannelResponse(NewChannelContext) TsProxyCloseChannelRequest(NewChannelContext) TsProxyCloseTunnelRequest(NewTunnelContext) TsProxyCloseChannelResponse(NullChannelContext) TsProxyCloseTunnelResponse(NullTunnelContext) TsProxySendToServerRequest(ChannelContext)

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL TsProxySetupReceivePipeWriteRequest ( rdpTsg *  tsg,
CONTEXT_HANDLE channelContext 
)
static

OpNum = 8

DWORD TsProxySetupReceivePipe( [in, max_is(32767)] byte pRpcMessage[] );

Here is the call graph for this function:

Here is the caller graph for this function: