mirror of https://github.com/FreeRDP/FreeRDP
libfreerdp-core: move RTS pdu signature checking to separate file
This commit is contained in:
parent
4da0c0daa9
commit
536d7be180
|
@ -35,6 +35,8 @@ set(${MODULE_PREFIX}_GATEWAY_SRCS
|
|||
${${MODULE_PREFIX}_GATEWAY_DIR}/tsg.h
|
||||
${${MODULE_PREFIX}_GATEWAY_DIR}/rts.c
|
||||
${${MODULE_PREFIX}_GATEWAY_DIR}/rts.h
|
||||
${${MODULE_PREFIX}_GATEWAY_DIR}/rts_signature.c
|
||||
${${MODULE_PREFIX}_GATEWAY_DIR}/rts_signature.h
|
||||
${${MODULE_PREFIX}_GATEWAY_DIR}/ntlm.c
|
||||
${${MODULE_PREFIX}_GATEWAY_DIR}/ntlm.h
|
||||
${${MODULE_PREFIX}_GATEWAY_DIR}/http.c
|
||||
|
|
|
@ -227,3 +227,54 @@ BOOL rpc_ntlm_http_out_connect(rdpRpc* rpc)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void rpc_ntlm_http_init_channel(rdpRpc* rpc, rdpNtlmHttp* ntlm_http, TSG_CHANNEL channel)
|
||||
{
|
||||
if (channel == TSG_CHANNEL_IN)
|
||||
http_context_set_method(ntlm_http->context, "RPC_IN_DATA");
|
||||
else if (channel == TSG_CHANNEL_OUT)
|
||||
http_context_set_method(ntlm_http->context, "RPC_OUT_DATA");
|
||||
|
||||
http_context_set_uri(ntlm_http->context, "/rpc/rpcproxy.dll?localhost:3388");
|
||||
http_context_set_accept(ntlm_http->context, "application/rpc");
|
||||
http_context_set_cache_control(ntlm_http->context, "no-cache");
|
||||
http_context_set_connection(ntlm_http->context, "Keep-Alive");
|
||||
http_context_set_user_agent(ntlm_http->context, "MSRPC");
|
||||
http_context_set_host(ntlm_http->context, rpc->settings->GatewayHostname);
|
||||
|
||||
if (channel == TSG_CHANNEL_IN)
|
||||
{
|
||||
http_context_set_pragma(ntlm_http->context,
|
||||
"ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729");
|
||||
}
|
||||
else if (channel == TSG_CHANNEL_OUT)
|
||||
{
|
||||
http_context_set_pragma(ntlm_http->context,
|
||||
"ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729" ", "
|
||||
"SessionId=fbd9c34f-397d-471d-a109-1b08cc554624");
|
||||
}
|
||||
}
|
||||
|
||||
rdpNtlmHttp* ntlm_http_new()
|
||||
{
|
||||
rdpNtlmHttp* ntlm_http;
|
||||
|
||||
ntlm_http = (rdpNtlmHttp*) malloc(sizeof(rdpNtlmHttp));
|
||||
|
||||
if (ntlm_http != NULL)
|
||||
{
|
||||
ZeroMemory(ntlm_http, sizeof(rdpNtlmHttp));
|
||||
ntlm_http->ntlm = ntlm_new();
|
||||
ntlm_http->context = http_context_new();
|
||||
}
|
||||
|
||||
return ntlm_http;
|
||||
}
|
||||
|
||||
void ntlm_http_free(rdpNtlmHttp* ntlm_http)
|
||||
{
|
||||
if (ntlm_http != NULL)
|
||||
{
|
||||
ntlm_free(ntlm_http->ntlm);
|
||||
http_context_free(ntlm_http->context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,12 @@
|
|||
|
||||
#include "rpc.h"
|
||||
|
||||
STREAM* rpc_ntlm_http_request(rdpRpc* rpc, SecBuffer* ntlm_token, int content_length, TSG_CHANNEL channel);
|
||||
|
||||
BOOL rpc_ntlm_http_out_connect(rdpRpc* rpc);
|
||||
BOOL rpc_ntlm_http_in_connect(rdpRpc* rpc);
|
||||
|
||||
void rpc_ntlm_http_init_channel(rdpRpc* rpc, rdpNtlmHttp* ntlm_http, TSG_CHANNEL channel);
|
||||
|
||||
rdpNtlmHttp* ntlm_http_new();
|
||||
void ntlm_http_free(rdpNtlmHttp* ntlm_http);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1062,60 +1062,6 @@ void rpc_virtual_connection_cookie_table_free(RpcVirtualConnectionCookieTable* t
|
|||
}
|
||||
}
|
||||
|
||||
/* NTLM over HTTP */
|
||||
|
||||
rdpNtlmHttp* ntlm_http_new()
|
||||
{
|
||||
rdpNtlmHttp* ntlm_http;
|
||||
|
||||
ntlm_http = (rdpNtlmHttp*) malloc(sizeof(rdpNtlmHttp));
|
||||
|
||||
if (ntlm_http != NULL)
|
||||
{
|
||||
ZeroMemory(ntlm_http, sizeof(rdpNtlmHttp));
|
||||
ntlm_http->ntlm = ntlm_new();
|
||||
ntlm_http->context = http_context_new();
|
||||
}
|
||||
|
||||
return ntlm_http;
|
||||
}
|
||||
|
||||
void rpc_ntlm_http_init_channel(rdpRpc* rpc, rdpNtlmHttp* ntlm_http, TSG_CHANNEL channel)
|
||||
{
|
||||
if (channel == TSG_CHANNEL_IN)
|
||||
http_context_set_method(ntlm_http->context, "RPC_IN_DATA");
|
||||
else if (channel == TSG_CHANNEL_OUT)
|
||||
http_context_set_method(ntlm_http->context, "RPC_OUT_DATA");
|
||||
|
||||
http_context_set_uri(ntlm_http->context, "/rpc/rpcproxy.dll?localhost:3388");
|
||||
http_context_set_accept(ntlm_http->context, "application/rpc");
|
||||
http_context_set_cache_control(ntlm_http->context, "no-cache");
|
||||
http_context_set_connection(ntlm_http->context, "Keep-Alive");
|
||||
http_context_set_user_agent(ntlm_http->context, "MSRPC");
|
||||
http_context_set_host(ntlm_http->context, rpc->settings->GatewayHostname);
|
||||
|
||||
if (channel == TSG_CHANNEL_IN)
|
||||
{
|
||||
http_context_set_pragma(ntlm_http->context,
|
||||
"ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729");
|
||||
}
|
||||
else if (channel == TSG_CHANNEL_OUT)
|
||||
{
|
||||
http_context_set_pragma(ntlm_http->context,
|
||||
"ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729" ", "
|
||||
"SessionId=fbd9c34f-397d-471d-a109-1b08cc554624");
|
||||
}
|
||||
}
|
||||
|
||||
void ntlm_http_free(rdpNtlmHttp* ntlm_http)
|
||||
{
|
||||
if (ntlm_http != NULL)
|
||||
{
|
||||
ntlm_free(ntlm_http->ntlm);
|
||||
http_context_free(ntlm_http->context);
|
||||
}
|
||||
}
|
||||
|
||||
/* RPC Core Module */
|
||||
|
||||
rdpRpc* rpc_new(rdpTransport* transport)
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#ifndef FREERDP_CORE_RPC_H
|
||||
#define FREERDP_CORE_RPC_H
|
||||
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
typedef struct rdp_rpc rdpRpc;
|
||||
|
||||
#define DEFINE_RPC_COMMON_FIELDS() \
|
||||
|
@ -714,9 +716,6 @@ struct rdp_rpc
|
|||
|
||||
BOOL rpc_connect(rdpRpc* rpc);
|
||||
|
||||
BOOL rpc_ntlm_http_out_connect(rdpRpc* rpc);
|
||||
BOOL rpc_ntlm_http_in_connect(rdpRpc* rpc);
|
||||
|
||||
void rpc_pdu_header_init(rdpRpc* rpc, rpcconn_hdr_t* header);
|
||||
|
||||
UINT32 rpc_offset_align(UINT32* offset, UINT32 alignment);
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include <winpr/crt.h>
|
||||
|
||||
#include "ncacn_http.h"
|
||||
|
||||
#include "rts.h"
|
||||
|
||||
/**
|
||||
|
@ -30,67 +32,6 @@
|
|||
* http://msdn.microsoft.com/en-us/library/cc243950/
|
||||
*/
|
||||
|
||||
static RtsPduSignature RTS_PDU_CONN_A1_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_CONN_A2_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_CONN_A3_SIGNATURE;
|
||||
|
||||
static RtsPduSignature RTS_PDU_CONN_B1_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_CONN_B2_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_CONN_B3_SIGNATURE;
|
||||
|
||||
static RtsPduSignature RTS_PDU_CONN_C1_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_CONN_C2_SIGNATURE;
|
||||
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A1_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A2_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A3_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A4_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A5_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A6_SIGNATURE;
|
||||
|
||||
static RtsPduSignature RTS_PDU_IN_R1_B1_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_IN_R1_B2_SIGNATURE;
|
||||
|
||||
static RtsPduSignature RTS_PDU_IN_R2_A1_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_IN_R2_A2_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_IN_R2_A3_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_IN_R2_A4_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_IN_R2_A5_SIGNATURE;
|
||||
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A1_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A2_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A3_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A4_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A5_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A6_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A7_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A8_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A9_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A10_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A11_SIGNATURE;
|
||||
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A1_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A2_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A3_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A4_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A5_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A6_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A7_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A8_SIGNATURE;
|
||||
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_B1_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_B2_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_B3_SIGNATURE;
|
||||
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_C1_SIGNATURE;
|
||||
|
||||
static RtsPduSignature RTS_PDU_KEEP_ALIVE_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_PING_TRAFFIC_SENT_NOTIFY_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_ECHO_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_PING_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_FLOW_CONTROL_ACK_SIGNATURE;
|
||||
static RtsPduSignature RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION_SIGNATURE;
|
||||
|
||||
/**
|
||||
* Connection Establishment\n
|
||||
*
|
||||
|
@ -936,200 +877,6 @@ int rts_send_ping_pdu(rdpRpc* rpc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static RtsPduSignature RTS_PDU_CONN_A1_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_CONN_A2_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 5,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_CONN_A3_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
static RtsPduSignature RTS_PDU_CONN_B1_SIGNATURE = { RTS_FLAG_NONE, 6,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_CLIENT_KEEPALIVE, RTS_CMD_ASSOCIATION_GROUP_ID, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_CONN_B2_SIGNATURE = { RTS_FLAG_IN_CHANNEL, 7,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, RTS_CMD_ASSOCIATION_GROUP_ID, RTS_CMD_CLIENT_ADDRESS, 0 } };
|
||||
static RtsPduSignature RTS_PDU_CONN_B3_SIGNATURE = { RTS_FLAG_NONE, 2,
|
||||
{ RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_VERSION, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
static RtsPduSignature RTS_PDU_CONN_C1_SIGNATURE = { RTS_FLAG_NONE, 3,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_CONN_C2_SIGNATURE = { RTS_FLAG_NONE, 3,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A2_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A3_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A4_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A5_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_IN_R1_A6_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
static RtsPduSignature RTS_PDU_IN_R1_B1_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_EMPTY, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_IN_R1_B2_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
static RtsPduSignature RTS_PDU_IN_R2_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_IN_R2_A2_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_IN_R2_A3_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_IN_R2_A4_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_IN_R2_A5_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A2_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A3_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 5,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A4_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL | RTS_FLAG_OUT_CHANNEL, 7,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A5_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 3,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A6_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 3,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A7_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A8_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A9_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A10_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R1_A11_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A2_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A3_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 5,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A4_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A5_SIGNATURE = { RTS_FLAG_NONE, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A6_SIGNATURE = { RTS_FLAG_NONE, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A7_SIGNATURE = { RTS_FLAG_NONE, 3,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, RTS_CMD_VERSION, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_A8_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_B1_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_B2_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_NEGATIVE_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_B3_SIGNATURE = { RTS_FLAG_EOF, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
static RtsPduSignature RTS_PDU_OUT_R2_C1_SIGNATURE = { RTS_FLAG_PING, 1,
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
static RtsPduSignature RTS_PDU_KEEP_ALIVE_SIGNATURE = { RTS_FLAG_OTHER_CMD, 1,
|
||||
{ RTS_CMD_CLIENT_KEEPALIVE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_PING_TRAFFIC_SENT_NOTIFY_SIGNATURE = { RTS_FLAG_OTHER_CMD, 1,
|
||||
{ RTS_CMD_PING_TRAFFIC_SENT_NOTIFY, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_ECHO_SIGNATURE = { RTS_FLAG_ECHO, 0,
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_PING_SIGNATURE = { RTS_FLAG_PING, 0,
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_FLOW_CONTROL_ACK_SIGNATURE = { RTS_FLAG_OTHER_CMD, 1,
|
||||
{ RTS_CMD_FLOW_CONTROL_ACK, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
static RtsPduSignature RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION_SIGNATURE = { RTS_FLAG_OTHER_CMD, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_FLOW_CONTROL_ACK, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
struct _RTS_PDU_SIGNATURE_ENTRY
|
||||
{
|
||||
UINT32 SignatureId;
|
||||
RtsPduSignature* Signature;
|
||||
const char* PduName;
|
||||
};
|
||||
typedef struct _RTS_PDU_SIGNATURE_ENTRY RTS_PDU_SIGNATURE_ENTRY;
|
||||
|
||||
RTS_PDU_SIGNATURE_ENTRY RTS_PDU_SIGNATURE_TABLE[] =
|
||||
{
|
||||
{ RTS_PDU_CONN_A1, &RTS_PDU_CONN_A1_SIGNATURE, "CONN/A1" },
|
||||
{ RTS_PDU_CONN_A2, &RTS_PDU_CONN_A2_SIGNATURE, "CONN/A2" },
|
||||
{ RTS_PDU_CONN_A3, &RTS_PDU_CONN_A3_SIGNATURE, "CONN/A3" },
|
||||
|
||||
{ RTS_PDU_CONN_B1, &RTS_PDU_CONN_B1_SIGNATURE, "CONN/B1" },
|
||||
{ RTS_PDU_CONN_B2, &RTS_PDU_CONN_B2_SIGNATURE, "CONN/B2" },
|
||||
{ RTS_PDU_CONN_B3, &RTS_PDU_CONN_B3_SIGNATURE, "CONN/B3" },
|
||||
|
||||
{ RTS_PDU_CONN_C1, &RTS_PDU_CONN_C1_SIGNATURE, "CONN/C1" },
|
||||
{ RTS_PDU_CONN_C2, &RTS_PDU_CONN_C2_SIGNATURE, "CONN/C2" },
|
||||
|
||||
{ RTS_PDU_IN_R1_A1, &RTS_PDU_IN_R1_A1_SIGNATURE, "IN_R1/A1" },
|
||||
{ RTS_PDU_IN_R1_A2, &RTS_PDU_IN_R1_A2_SIGNATURE, "IN_R1/A2" },
|
||||
{ RTS_PDU_IN_R1_A3, &RTS_PDU_IN_R1_A3_SIGNATURE, "IN_R1/A3" },
|
||||
{ RTS_PDU_IN_R1_A4, &RTS_PDU_IN_R1_A4_SIGNATURE, "IN_R1/A4" },
|
||||
{ RTS_PDU_IN_R1_A5, &RTS_PDU_IN_R1_A5_SIGNATURE, "IN_R1/A5" },
|
||||
{ RTS_PDU_IN_R1_A6, &RTS_PDU_IN_R1_A6_SIGNATURE, "IN_R1/A6" },
|
||||
|
||||
{ RTS_PDU_IN_R1_B1, &RTS_PDU_IN_R1_B1_SIGNATURE, "IN_R1/B1" },
|
||||
{ RTS_PDU_IN_R1_B2, &RTS_PDU_IN_R1_B2_SIGNATURE, "IN_R1/B2" },
|
||||
|
||||
{ RTS_PDU_IN_R2_A1, &RTS_PDU_IN_R2_A1_SIGNATURE, "IN_R2/A1" },
|
||||
{ RTS_PDU_IN_R2_A2, &RTS_PDU_IN_R2_A2_SIGNATURE, "IN_R2/A2" },
|
||||
{ RTS_PDU_IN_R2_A3, &RTS_PDU_IN_R2_A3_SIGNATURE, "IN_R2/A3" },
|
||||
{ RTS_PDU_IN_R2_A4, &RTS_PDU_IN_R2_A4_SIGNATURE, "IN_R2/A4" },
|
||||
{ RTS_PDU_IN_R2_A5, &RTS_PDU_IN_R2_A5_SIGNATURE, "IN_R2/A5" },
|
||||
|
||||
{ RTS_PDU_OUT_R1_A1, &RTS_PDU_OUT_R1_A1_SIGNATURE, "OUT_R1/A1" },
|
||||
{ RTS_PDU_OUT_R1_A2, &RTS_PDU_OUT_R1_A2_SIGNATURE, "OUT_R1/A2" },
|
||||
{ RTS_PDU_OUT_R1_A3, &RTS_PDU_OUT_R1_A3_SIGNATURE, "OUT_R1/A3" },
|
||||
{ RTS_PDU_OUT_R1_A4, &RTS_PDU_OUT_R1_A4_SIGNATURE, "OUT_R1/A4" },
|
||||
{ RTS_PDU_OUT_R1_A5, &RTS_PDU_OUT_R1_A5_SIGNATURE, "OUT_R1/A5" },
|
||||
{ RTS_PDU_OUT_R1_A6, &RTS_PDU_OUT_R1_A6_SIGNATURE, "OUT_R1/A6" },
|
||||
{ RTS_PDU_OUT_R1_A7, &RTS_PDU_OUT_R1_A7_SIGNATURE, "OUT_R1/A7" },
|
||||
{ RTS_PDU_OUT_R1_A8, &RTS_PDU_OUT_R1_A8_SIGNATURE, "OUT_R1/A8" },
|
||||
{ RTS_PDU_OUT_R1_A9, &RTS_PDU_OUT_R1_A9_SIGNATURE, "OUT_R1/A9" },
|
||||
{ RTS_PDU_OUT_R1_A10, &RTS_PDU_OUT_R1_A10_SIGNATURE, "OUT_R1/A10" },
|
||||
{ RTS_PDU_OUT_R1_A11, &RTS_PDU_OUT_R1_A11_SIGNATURE, "OUT_R1/A11" },
|
||||
|
||||
{ RTS_PDU_OUT_R2_A1, &RTS_PDU_OUT_R2_A1_SIGNATURE, "OUT_R2/A1" },
|
||||
{ RTS_PDU_OUT_R2_A2, &RTS_PDU_OUT_R2_A2_SIGNATURE, "OUT_R2/A2" },
|
||||
{ RTS_PDU_OUT_R2_A3, &RTS_PDU_OUT_R2_A3_SIGNATURE, "OUT_R2/A3" },
|
||||
{ RTS_PDU_OUT_R2_A4, &RTS_PDU_OUT_R2_A4_SIGNATURE, "OUT_R2/A4" },
|
||||
{ RTS_PDU_OUT_R2_A5, &RTS_PDU_OUT_R2_A5_SIGNATURE, "OUT_R2/A5" },
|
||||
{ RTS_PDU_OUT_R2_A6, &RTS_PDU_OUT_R2_A6_SIGNATURE, "OUT_R2/A6" },
|
||||
{ RTS_PDU_OUT_R2_A7, &RTS_PDU_OUT_R2_A7_SIGNATURE, "OUT_R2/A7" },
|
||||
{ RTS_PDU_OUT_R2_A8, &RTS_PDU_OUT_R2_A8_SIGNATURE, "OUT_R2/A8" },
|
||||
|
||||
{ RTS_PDU_OUT_R2_B1, &RTS_PDU_OUT_R2_B1_SIGNATURE, "OUT_R2/B1" },
|
||||
{ RTS_PDU_OUT_R2_B2, &RTS_PDU_OUT_R2_B2_SIGNATURE, "OUT_R2/B2" },
|
||||
{ RTS_PDU_OUT_R2_B3, &RTS_PDU_OUT_R2_B3_SIGNATURE, "OUT_R2/B3" },
|
||||
|
||||
{ RTS_PDU_OUT_R2_C1, &RTS_PDU_OUT_R2_C1_SIGNATURE, "OUT_R2/C1" },
|
||||
|
||||
{ RTS_PDU_KEEP_ALIVE, &RTS_PDU_KEEP_ALIVE_SIGNATURE, "Keep-Alive" },
|
||||
{ RTS_PDU_PING_TRAFFIC_SENT_NOTIFY, &RTS_PDU_PING_TRAFFIC_SENT_NOTIFY_SIGNATURE, "Ping Traffic Sent Notify" },
|
||||
{ RTS_PDU_ECHO, &RTS_PDU_ECHO_SIGNATURE, "Echo" },
|
||||
{ RTS_PDU_PING, &RTS_PDU_PING_SIGNATURE, "Ping" },
|
||||
{ RTS_PDU_FLOW_CONTROL_ACK, &RTS_PDU_FLOW_CONTROL_ACK_SIGNATURE, "FlowControlAck" },
|
||||
{ RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION, &RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION_SIGNATURE, "FlowControlAckWithDestination" },
|
||||
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
int rts_command_length(rdpRpc* rpc, UINT32 CommandType, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
int CommandLength = 0;
|
||||
|
@ -1205,132 +952,6 @@ int rts_command_length(rdpRpc* rpc, UINT32 CommandType, BYTE* buffer, UINT32 len
|
|||
return CommandLength;
|
||||
}
|
||||
|
||||
BOOL rts_match_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, rpcconn_rts_hdr_t* rts)
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
BYTE* buffer;
|
||||
UINT32 length;
|
||||
UINT32 offset;
|
||||
UINT32 CommandType;
|
||||
UINT32 CommandLength;
|
||||
|
||||
if (rts->Flags != signature->Flags)
|
||||
return FALSE;
|
||||
|
||||
if (rts->NumberOfCommands != signature->NumberOfCommands)
|
||||
return FALSE;
|
||||
|
||||
buffer = (BYTE*) rts;
|
||||
offset = RTS_PDU_HEADER_LENGTH;
|
||||
length = rts->frag_length - offset;
|
||||
|
||||
for (i = 0; i < rts->NumberOfCommands; i++)
|
||||
{
|
||||
CommandType = *((UINT32*) &buffer[offset]); /* CommandType (4 bytes) */
|
||||
offset += 4;
|
||||
|
||||
if (CommandType != signature->CommandTypes[i])
|
||||
return FALSE;
|
||||
|
||||
status = rts_command_length(rpc, CommandType, &buffer[offset], length);
|
||||
|
||||
if (status < 0)
|
||||
return FALSE;
|
||||
|
||||
CommandLength = (UINT32) status;
|
||||
offset += CommandLength;
|
||||
|
||||
length = rts->frag_length - offset;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int rts_extract_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, rpcconn_rts_hdr_t* rts)
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
BYTE* buffer;
|
||||
UINT32 length;
|
||||
UINT32 offset;
|
||||
UINT32 CommandType;
|
||||
UINT32 CommandLength;
|
||||
|
||||
signature->Flags = rts->Flags;
|
||||
signature->NumberOfCommands = rts->NumberOfCommands;
|
||||
|
||||
buffer = (BYTE*) rts;
|
||||
offset = RTS_PDU_HEADER_LENGTH;
|
||||
length = rts->frag_length - offset;
|
||||
|
||||
for (i = 0; i < rts->NumberOfCommands; i++)
|
||||
{
|
||||
CommandType = *((UINT32*) &buffer[offset]); /* CommandType (4 bytes) */
|
||||
offset += 4;
|
||||
|
||||
signature->CommandTypes[i] = CommandType;
|
||||
|
||||
status = rts_command_length(rpc, CommandType, &buffer[offset], length);
|
||||
|
||||
if (status < 0)
|
||||
return FALSE;
|
||||
|
||||
CommandLength = (UINT32) status;
|
||||
offset += CommandLength;
|
||||
|
||||
length = rts->frag_length - offset;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 rts_identify_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, RTS_PDU_SIGNATURE_ENTRY** entry)
|
||||
{
|
||||
int i, j;
|
||||
RtsPduSignature* pSignature;
|
||||
|
||||
for (i = 0; RTS_PDU_SIGNATURE_TABLE[i].SignatureId != 0; i++)
|
||||
{
|
||||
pSignature = RTS_PDU_SIGNATURE_TABLE[i].Signature;
|
||||
|
||||
if (signature->Flags == pSignature->Flags)
|
||||
{
|
||||
if (signature->NumberOfCommands == pSignature->NumberOfCommands)
|
||||
{
|
||||
for (j = 0; j < signature->NumberOfCommands; j++)
|
||||
{
|
||||
if (signature->CommandTypes[j] != pSignature->CommandTypes[j])
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry)
|
||||
*entry = &RTS_PDU_SIGNATURE_TABLE[i];
|
||||
|
||||
return RTS_PDU_SIGNATURE_TABLE[i].SignatureId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rts_print_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature)
|
||||
{
|
||||
UINT32 SignatureId;
|
||||
RTS_PDU_SIGNATURE_ENTRY* entry;
|
||||
|
||||
printf("RTS PDU Signature: Flags: 0x%04X NumberOfCommands: %d\n",
|
||||
signature->Flags, signature->NumberOfCommands);
|
||||
|
||||
SignatureId = rts_identify_pdu_signature(rpc, signature, &entry);
|
||||
|
||||
if (SignatureId)
|
||||
printf("Identified %s RTS PDU\n", entry->PduName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rts_recv_pdu(rdpRpc* rpc)
|
||||
{
|
||||
int status;
|
||||
|
|
|
@ -77,94 +77,11 @@
|
|||
#define FDServer 0x00000002
|
||||
#define FDOutProxy 0x00000003
|
||||
|
||||
struct rts_pdu_signature
|
||||
{
|
||||
UINT16 Flags;
|
||||
UINT16 NumberOfCommands;
|
||||
UINT32 CommandTypes[8];
|
||||
};
|
||||
typedef struct rts_pdu_signature RtsPduSignature;
|
||||
|
||||
/* RTS PDU Signature IDs */
|
||||
|
||||
#define RTS_PDU_CONN_A 0x10000000
|
||||
#define RTS_PDU_CONN_A1 (RTS_PDU_CONN_A | 0x00000001)
|
||||
#define RTS_PDU_CONN_A2 (RTS_PDU_CONN_A | 0x00000002)
|
||||
#define RTS_PDU_CONN_A3 (RTS_PDU_CONN_A | 0x00000003)
|
||||
|
||||
#define RTS_PDU_CONN_B 0x20000000
|
||||
#define RTS_PDU_CONN_B1 (RTS_PDU_CONN_B | 0x00000001)
|
||||
#define RTS_PDU_CONN_B2 (RTS_PDU_CONN_B | 0x00000002)
|
||||
#define RTS_PDU_CONN_B3 (RTS_PDU_CONN_B | 0x00000003)
|
||||
|
||||
#define RTS_PDU_CONN_C 0x40000000
|
||||
#define RTS_PDU_CONN_C1 (RTS_PDU_CONN_C | 0x00000001)
|
||||
#define RTS_PDU_CONN_C2 (RTS_PDU_CONN_C | 0x00000002)
|
||||
|
||||
#define RTS_PDU_IN_R1_A 0x01000000
|
||||
#define RTS_PDU_IN_R1_A1 (RTS_PDU_IN_R1_A | 0x00000001)
|
||||
#define RTS_PDU_IN_R1_A2 (RTS_PDU_IN_R1_A | 0x00000002)
|
||||
#define RTS_PDU_IN_R1_A3 (RTS_PDU_IN_R1_A | 0x00000003)
|
||||
#define RTS_PDU_IN_R1_A4 (RTS_PDU_IN_R1_A | 0x00000004)
|
||||
#define RTS_PDU_IN_R1_A5 (RTS_PDU_IN_R1_A | 0x00000005)
|
||||
#define RTS_PDU_IN_R1_A6 (RTS_PDU_IN_R1_A | 0x00000006)
|
||||
|
||||
#define RTS_PDU_IN_R1_B 0x02000000
|
||||
#define RTS_PDU_IN_R1_B1 (RTS_PDU_IN_R1_B | 0x00000001)
|
||||
#define RTS_PDU_IN_R1_B2 (RTS_PDU_IN_R1_B | 0x00000002)
|
||||
|
||||
#define RTS_PDU_IN_R2_A 0x04000000
|
||||
#define RTS_PDU_IN_R2_A1 (RTS_PDU_IN_R2_A | 0x00000001)
|
||||
#define RTS_PDU_IN_R2_A2 (RTS_PDU_IN_R2_A | 0x00000002)
|
||||
#define RTS_PDU_IN_R2_A3 (RTS_PDU_IN_R2_A | 0x00000003)
|
||||
#define RTS_PDU_IN_R2_A4 (RTS_PDU_IN_R2_A | 0x00000004)
|
||||
#define RTS_PDU_IN_R2_A5 (RTS_PDU_IN_R2_A | 0x00000005)
|
||||
|
||||
#define RTS_PDU_OUT_R1_A 0x00100000
|
||||
#define RTS_PDU_OUT_R1_A1 (RTS_PDU_OUT_R1_A | 0x00000001)
|
||||
#define RTS_PDU_OUT_R1_A2 (RTS_PDU_OUT_R1_A | 0x00000002)
|
||||
#define RTS_PDU_OUT_R1_A3 (RTS_PDU_OUT_R1_A | 0x00000003)
|
||||
#define RTS_PDU_OUT_R1_A4 (RTS_PDU_OUT_R1_A | 0x00000004)
|
||||
#define RTS_PDU_OUT_R1_A5 (RTS_PDU_OUT_R1_A | 0x00000005)
|
||||
#define RTS_PDU_OUT_R1_A6 (RTS_PDU_OUT_R1_A | 0x00000006)
|
||||
#define RTS_PDU_OUT_R1_A7 (RTS_PDU_OUT_R1_A | 0x00000007)
|
||||
#define RTS_PDU_OUT_R1_A8 (RTS_PDU_OUT_R1_A | 0x00000008)
|
||||
#define RTS_PDU_OUT_R1_A9 (RTS_PDU_OUT_R1_A | 0x00000009)
|
||||
#define RTS_PDU_OUT_R1_A10 (RTS_PDU_OUT_R1_A | 0x0000000A)
|
||||
#define RTS_PDU_OUT_R1_A11 (RTS_PDU_OUT_R1_A | 0x0000000B)
|
||||
|
||||
#define RTS_PDU_OUT_R2_A 0x00200000
|
||||
#define RTS_PDU_OUT_R2_A1 (RTS_PDU_OUT_R2_A | 0x00000001)
|
||||
#define RTS_PDU_OUT_R2_A2 (RTS_PDU_OUT_R2_A | 0x00000002)
|
||||
#define RTS_PDU_OUT_R2_A3 (RTS_PDU_OUT_R2_A | 0x00000003)
|
||||
#define RTS_PDU_OUT_R2_A4 (RTS_PDU_OUT_R2_A | 0x00000004)
|
||||
#define RTS_PDU_OUT_R2_A5 (RTS_PDU_OUT_R2_A | 0x00000005)
|
||||
#define RTS_PDU_OUT_R2_A6 (RTS_PDU_OUT_R2_A | 0x00000006)
|
||||
#define RTS_PDU_OUT_R2_A7 (RTS_PDU_OUT_R2_A | 0x00000007)
|
||||
#define RTS_PDU_OUT_R2_A8 (RTS_PDU_OUT_R2_A | 0x00000008)
|
||||
|
||||
#define RTS_PDU_OUT_R2_B 0x00400000
|
||||
#define RTS_PDU_OUT_R2_B1 (RTS_PDU_OUT_R2_B | 0x00000001)
|
||||
#define RTS_PDU_OUT_R2_B2 (RTS_PDU_OUT_R2_B | 0x00000002)
|
||||
#define RTS_PDU_OUT_R2_B3 (RTS_PDU_OUT_R2_B | 0x00000003)
|
||||
|
||||
#define RTS_PDU_OUT_R2_C 0x00800000
|
||||
#define RTS_PDU_OUT_R2_C1 (RTS_PDU_OUT_R2_C | 0x00000001)
|
||||
|
||||
#define RTS_PDU_OUT_OF_SEQUENCE 0x00010000
|
||||
#define RTS_PDU_KEEP_ALIVE (RTS_PDU_OUT_OF_SEQUENCE | 0x00000001)
|
||||
#define RTS_PDU_PING_TRAFFIC_SENT_NOTIFY (RTS_PDU_OUT_OF_SEQUENCE | 0x00000002)
|
||||
#define RTS_PDU_ECHO (RTS_PDU_OUT_OF_SEQUENCE | 0x00000003)
|
||||
#define RTS_PDU_PING (RTS_PDU_OUT_OF_SEQUENCE | 0x00000004)
|
||||
#define RTS_PDU_FLOW_CONTROL_ACK (RTS_PDU_OUT_OF_SEQUENCE | 0x00000005)
|
||||
#define RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION (RTS_PDU_OUT_OF_SEQUENCE | 0x00000006)
|
||||
BOOL rts_connect(rdpRpc* rpc);
|
||||
|
||||
int rts_command_length(rdpRpc* rpc, UINT32 CommandType, BYTE* buffer, UINT32 length);
|
||||
BOOL rts_match_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, rpcconn_rts_hdr_t* rts);
|
||||
int rts_recv_pdu_commands(rdpRpc* rpc, rpcconn_rts_hdr_t* rts);
|
||||
|
||||
BOOL rts_connect(rdpRpc* rpc);
|
||||
|
||||
int rts_receive_window_size_command_read(rdpRpc* rpc, BYTE* buffer, UINT32 length, UINT32* ReceiveWindowSize);
|
||||
int rts_receive_window_size_command_write(BYTE* buffer, UINT32 ReceiveWindowSize);
|
||||
|
||||
|
@ -225,6 +142,8 @@ int rts_send_ping_pdu(rdpRpc* rpc);
|
|||
int rts_recv_pdu(rdpRpc* rpc);
|
||||
int rts_recv_out_of_sequence_pdu(rdpRpc* rpc);
|
||||
|
||||
#include "rts_signature.h"
|
||||
|
||||
#ifdef WITH_DEBUG_TSG
|
||||
#define WITH_DEBUG_RTS
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,332 @@
|
|||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Request To Send (RTS) PDU Signatures
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@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.
|
||||
*/
|
||||
|
||||
#include "rts_signature.h"
|
||||
|
||||
RtsPduSignature RTS_PDU_CONN_A1_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_CONN_A2_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 5,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_CONN_A3_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RtsPduSignature RTS_PDU_CONN_B1_SIGNATURE = { RTS_FLAG_NONE, 6,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_CLIENT_KEEPALIVE, RTS_CMD_ASSOCIATION_GROUP_ID, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_CONN_B2_SIGNATURE = { RTS_FLAG_IN_CHANNEL, 7,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, RTS_CMD_ASSOCIATION_GROUP_ID, RTS_CMD_CLIENT_ADDRESS, 0 } };
|
||||
RtsPduSignature RTS_PDU_CONN_B3_SIGNATURE = { RTS_FLAG_NONE, 2,
|
||||
{ RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_VERSION, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RtsPduSignature RTS_PDU_CONN_C1_SIGNATURE = { RTS_FLAG_NONE, 3,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_CONN_C2_SIGNATURE = { RTS_FLAG_NONE, 3,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RtsPduSignature RTS_PDU_IN_R1_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_IN_R1_A2_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_IN_R1_A3_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_IN_R1_A4_SIGNATURE = { RTS_FLAG_NONE, 4,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_RECEIVE_WINDOW_SIZE,
|
||||
RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_IN_R1_A5_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_IN_R1_A6_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RtsPduSignature RTS_PDU_IN_R1_B1_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_EMPTY, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_IN_R1_B2_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RtsPduSignature RTS_PDU_IN_R2_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 4,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_IN_R2_A2_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_IN_R2_A3_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_IN_R2_A4_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_IN_R2_A5_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A2_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A3_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 5,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A4_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL | RTS_FLAG_OUT_CHANNEL, 7,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_CHANNEL_LIFETIME,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, RTS_CMD_CONNECTION_TIMEOUT, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A5_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 3,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A6_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 3,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_VERSION, RTS_CMD_CONNECTION_TIMEOUT, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A7_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A8_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A9_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A10_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R1_A11_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A1_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A2_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 1,
|
||||
{ RTS_CMD_DESTINATION, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A3_SIGNATURE = { RTS_FLAG_RECYCLE_CHANNEL, 5,
|
||||
{ RTS_CMD_VERSION, RTS_CMD_COOKIE, RTS_CMD_COOKIE, RTS_CMD_COOKIE,
|
||||
RTS_CMD_RECEIVE_WINDOW_SIZE, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A4_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A5_SIGNATURE = { RTS_FLAG_NONE, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A6_SIGNATURE = { RTS_FLAG_NONE, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A7_SIGNATURE = { RTS_FLAG_NONE, 3,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, RTS_CMD_VERSION, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R2_A8_SIGNATURE = { RTS_FLAG_OUT_CHANNEL, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_COOKIE, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RtsPduSignature RTS_PDU_OUT_R2_B1_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R2_B2_SIGNATURE = { RTS_FLAG_NONE, 1,
|
||||
{ RTS_CMD_NEGATIVE_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_OUT_R2_B3_SIGNATURE = { RTS_FLAG_EOF, 1,
|
||||
{ RTS_CMD_ANCE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RtsPduSignature RTS_PDU_OUT_R2_C1_SIGNATURE = { RTS_FLAG_PING, 1,
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RtsPduSignature RTS_PDU_KEEP_ALIVE_SIGNATURE = { RTS_FLAG_OTHER_CMD, 1,
|
||||
{ RTS_CMD_CLIENT_KEEPALIVE, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_PING_TRAFFIC_SENT_NOTIFY_SIGNATURE = { RTS_FLAG_OTHER_CMD, 1,
|
||||
{ RTS_CMD_PING_TRAFFIC_SENT_NOTIFY, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_ECHO_SIGNATURE = { RTS_FLAG_ECHO, 0,
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_PING_SIGNATURE = { RTS_FLAG_PING, 0,
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_FLOW_CONTROL_ACK_SIGNATURE = { RTS_FLAG_OTHER_CMD, 1,
|
||||
{ RTS_CMD_FLOW_CONTROL_ACK, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
RtsPduSignature RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION_SIGNATURE = { RTS_FLAG_OTHER_CMD, 2,
|
||||
{ RTS_CMD_DESTINATION, RTS_CMD_FLOW_CONTROL_ACK, 0, 0, 0, 0, 0, 0 } };
|
||||
|
||||
RTS_PDU_SIGNATURE_ENTRY RTS_PDU_SIGNATURE_TABLE[] =
|
||||
{
|
||||
{ RTS_PDU_CONN_A1, &RTS_PDU_CONN_A1_SIGNATURE, "CONN/A1" },
|
||||
{ RTS_PDU_CONN_A2, &RTS_PDU_CONN_A2_SIGNATURE, "CONN/A2" },
|
||||
{ RTS_PDU_CONN_A3, &RTS_PDU_CONN_A3_SIGNATURE, "CONN/A3" },
|
||||
|
||||
{ RTS_PDU_CONN_B1, &RTS_PDU_CONN_B1_SIGNATURE, "CONN/B1" },
|
||||
{ RTS_PDU_CONN_B2, &RTS_PDU_CONN_B2_SIGNATURE, "CONN/B2" },
|
||||
{ RTS_PDU_CONN_B3, &RTS_PDU_CONN_B3_SIGNATURE, "CONN/B3" },
|
||||
|
||||
{ RTS_PDU_CONN_C1, &RTS_PDU_CONN_C1_SIGNATURE, "CONN/C1" },
|
||||
{ RTS_PDU_CONN_C2, &RTS_PDU_CONN_C2_SIGNATURE, "CONN/C2" },
|
||||
|
||||
{ RTS_PDU_IN_R1_A1, &RTS_PDU_IN_R1_A1_SIGNATURE, "IN_R1/A1" },
|
||||
{ RTS_PDU_IN_R1_A2, &RTS_PDU_IN_R1_A2_SIGNATURE, "IN_R1/A2" },
|
||||
{ RTS_PDU_IN_R1_A3, &RTS_PDU_IN_R1_A3_SIGNATURE, "IN_R1/A3" },
|
||||
{ RTS_PDU_IN_R1_A4, &RTS_PDU_IN_R1_A4_SIGNATURE, "IN_R1/A4" },
|
||||
{ RTS_PDU_IN_R1_A5, &RTS_PDU_IN_R1_A5_SIGNATURE, "IN_R1/A5" },
|
||||
{ RTS_PDU_IN_R1_A6, &RTS_PDU_IN_R1_A6_SIGNATURE, "IN_R1/A6" },
|
||||
|
||||
{ RTS_PDU_IN_R1_B1, &RTS_PDU_IN_R1_B1_SIGNATURE, "IN_R1/B1" },
|
||||
{ RTS_PDU_IN_R1_B2, &RTS_PDU_IN_R1_B2_SIGNATURE, "IN_R1/B2" },
|
||||
|
||||
{ RTS_PDU_IN_R2_A1, &RTS_PDU_IN_R2_A1_SIGNATURE, "IN_R2/A1" },
|
||||
{ RTS_PDU_IN_R2_A2, &RTS_PDU_IN_R2_A2_SIGNATURE, "IN_R2/A2" },
|
||||
{ RTS_PDU_IN_R2_A3, &RTS_PDU_IN_R2_A3_SIGNATURE, "IN_R2/A3" },
|
||||
{ RTS_PDU_IN_R2_A4, &RTS_PDU_IN_R2_A4_SIGNATURE, "IN_R2/A4" },
|
||||
{ RTS_PDU_IN_R2_A5, &RTS_PDU_IN_R2_A5_SIGNATURE, "IN_R2/A5" },
|
||||
|
||||
{ RTS_PDU_OUT_R1_A1, &RTS_PDU_OUT_R1_A1_SIGNATURE, "OUT_R1/A1" },
|
||||
{ RTS_PDU_OUT_R1_A2, &RTS_PDU_OUT_R1_A2_SIGNATURE, "OUT_R1/A2" },
|
||||
{ RTS_PDU_OUT_R1_A3, &RTS_PDU_OUT_R1_A3_SIGNATURE, "OUT_R1/A3" },
|
||||
{ RTS_PDU_OUT_R1_A4, &RTS_PDU_OUT_R1_A4_SIGNATURE, "OUT_R1/A4" },
|
||||
{ RTS_PDU_OUT_R1_A5, &RTS_PDU_OUT_R1_A5_SIGNATURE, "OUT_R1/A5" },
|
||||
{ RTS_PDU_OUT_R1_A6, &RTS_PDU_OUT_R1_A6_SIGNATURE, "OUT_R1/A6" },
|
||||
{ RTS_PDU_OUT_R1_A7, &RTS_PDU_OUT_R1_A7_SIGNATURE, "OUT_R1/A7" },
|
||||
{ RTS_PDU_OUT_R1_A8, &RTS_PDU_OUT_R1_A8_SIGNATURE, "OUT_R1/A8" },
|
||||
{ RTS_PDU_OUT_R1_A9, &RTS_PDU_OUT_R1_A9_SIGNATURE, "OUT_R1/A9" },
|
||||
{ RTS_PDU_OUT_R1_A10, &RTS_PDU_OUT_R1_A10_SIGNATURE, "OUT_R1/A10" },
|
||||
{ RTS_PDU_OUT_R1_A11, &RTS_PDU_OUT_R1_A11_SIGNATURE, "OUT_R1/A11" },
|
||||
|
||||
{ RTS_PDU_OUT_R2_A1, &RTS_PDU_OUT_R2_A1_SIGNATURE, "OUT_R2/A1" },
|
||||
{ RTS_PDU_OUT_R2_A2, &RTS_PDU_OUT_R2_A2_SIGNATURE, "OUT_R2/A2" },
|
||||
{ RTS_PDU_OUT_R2_A3, &RTS_PDU_OUT_R2_A3_SIGNATURE, "OUT_R2/A3" },
|
||||
{ RTS_PDU_OUT_R2_A4, &RTS_PDU_OUT_R2_A4_SIGNATURE, "OUT_R2/A4" },
|
||||
{ RTS_PDU_OUT_R2_A5, &RTS_PDU_OUT_R2_A5_SIGNATURE, "OUT_R2/A5" },
|
||||
{ RTS_PDU_OUT_R2_A6, &RTS_PDU_OUT_R2_A6_SIGNATURE, "OUT_R2/A6" },
|
||||
{ RTS_PDU_OUT_R2_A7, &RTS_PDU_OUT_R2_A7_SIGNATURE, "OUT_R2/A7" },
|
||||
{ RTS_PDU_OUT_R2_A8, &RTS_PDU_OUT_R2_A8_SIGNATURE, "OUT_R2/A8" },
|
||||
|
||||
{ RTS_PDU_OUT_R2_B1, &RTS_PDU_OUT_R2_B1_SIGNATURE, "OUT_R2/B1" },
|
||||
{ RTS_PDU_OUT_R2_B2, &RTS_PDU_OUT_R2_B2_SIGNATURE, "OUT_R2/B2" },
|
||||
{ RTS_PDU_OUT_R2_B3, &RTS_PDU_OUT_R2_B3_SIGNATURE, "OUT_R2/B3" },
|
||||
|
||||
{ RTS_PDU_OUT_R2_C1, &RTS_PDU_OUT_R2_C1_SIGNATURE, "OUT_R2/C1" },
|
||||
|
||||
{ RTS_PDU_KEEP_ALIVE, &RTS_PDU_KEEP_ALIVE_SIGNATURE, "Keep-Alive" },
|
||||
{ RTS_PDU_PING_TRAFFIC_SENT_NOTIFY, &RTS_PDU_PING_TRAFFIC_SENT_NOTIFY_SIGNATURE, "Ping Traffic Sent Notify" },
|
||||
{ RTS_PDU_ECHO, &RTS_PDU_ECHO_SIGNATURE, "Echo" },
|
||||
{ RTS_PDU_PING, &RTS_PDU_PING_SIGNATURE, "Ping" },
|
||||
{ RTS_PDU_FLOW_CONTROL_ACK, &RTS_PDU_FLOW_CONTROL_ACK_SIGNATURE, "FlowControlAck" },
|
||||
{ RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION, &RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION_SIGNATURE, "FlowControlAckWithDestination" },
|
||||
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
BOOL rts_match_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, rpcconn_rts_hdr_t* rts)
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
BYTE* buffer;
|
||||
UINT32 length;
|
||||
UINT32 offset;
|
||||
UINT32 CommandType;
|
||||
UINT32 CommandLength;
|
||||
|
||||
if (rts->Flags != signature->Flags)
|
||||
return FALSE;
|
||||
|
||||
if (rts->NumberOfCommands != signature->NumberOfCommands)
|
||||
return FALSE;
|
||||
|
||||
buffer = (BYTE*) rts;
|
||||
offset = RTS_PDU_HEADER_LENGTH;
|
||||
length = rts->frag_length - offset;
|
||||
|
||||
for (i = 0; i < rts->NumberOfCommands; i++)
|
||||
{
|
||||
CommandType = *((UINT32*) &buffer[offset]); /* CommandType (4 bytes) */
|
||||
offset += 4;
|
||||
|
||||
if (CommandType != signature->CommandTypes[i])
|
||||
return FALSE;
|
||||
|
||||
status = rts_command_length(rpc, CommandType, &buffer[offset], length);
|
||||
|
||||
if (status < 0)
|
||||
return FALSE;
|
||||
|
||||
CommandLength = (UINT32) status;
|
||||
offset += CommandLength;
|
||||
|
||||
length = rts->frag_length - offset;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int rts_extract_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, rpcconn_rts_hdr_t* rts)
|
||||
{
|
||||
int i;
|
||||
int status;
|
||||
BYTE* buffer;
|
||||
UINT32 length;
|
||||
UINT32 offset;
|
||||
UINT32 CommandType;
|
||||
UINT32 CommandLength;
|
||||
|
||||
signature->Flags = rts->Flags;
|
||||
signature->NumberOfCommands = rts->NumberOfCommands;
|
||||
|
||||
buffer = (BYTE*) rts;
|
||||
offset = RTS_PDU_HEADER_LENGTH;
|
||||
length = rts->frag_length - offset;
|
||||
|
||||
for (i = 0; i < rts->NumberOfCommands; i++)
|
||||
{
|
||||
CommandType = *((UINT32*) &buffer[offset]); /* CommandType (4 bytes) */
|
||||
offset += 4;
|
||||
|
||||
signature->CommandTypes[i] = CommandType;
|
||||
|
||||
status = rts_command_length(rpc, CommandType, &buffer[offset], length);
|
||||
|
||||
if (status < 0)
|
||||
return FALSE;
|
||||
|
||||
CommandLength = (UINT32) status;
|
||||
offset += CommandLength;
|
||||
|
||||
length = rts->frag_length - offset;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 rts_identify_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, RTS_PDU_SIGNATURE_ENTRY** entry)
|
||||
{
|
||||
int i, j;
|
||||
RtsPduSignature* pSignature;
|
||||
|
||||
for (i = 0; RTS_PDU_SIGNATURE_TABLE[i].SignatureId != 0; i++)
|
||||
{
|
||||
pSignature = RTS_PDU_SIGNATURE_TABLE[i].Signature;
|
||||
|
||||
if (signature->Flags == pSignature->Flags)
|
||||
{
|
||||
if (signature->NumberOfCommands == pSignature->NumberOfCommands)
|
||||
{
|
||||
for (j = 0; j < signature->NumberOfCommands; j++)
|
||||
{
|
||||
if (signature->CommandTypes[j] != pSignature->CommandTypes[j])
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry)
|
||||
*entry = &RTS_PDU_SIGNATURE_TABLE[i];
|
||||
|
||||
return RTS_PDU_SIGNATURE_TABLE[i].SignatureId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rts_print_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature)
|
||||
{
|
||||
UINT32 SignatureId;
|
||||
RTS_PDU_SIGNATURE_ENTRY* entry;
|
||||
|
||||
printf("RTS PDU Signature: Flags: 0x%04X NumberOfCommands: %d\n",
|
||||
signature->Flags, signature->NumberOfCommands);
|
||||
|
||||
SignatureId = rts_identify_pdu_signature(rpc, signature, &entry);
|
||||
|
||||
if (SignatureId)
|
||||
printf("Identified %s RTS PDU\n", entry->PduName);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* Request To Send (RTS) PDU Signatures
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@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_CORE_RTS_SIGNATURE_H
|
||||
#define FREERDP_CORE_RTS_SIGNATURE_H
|
||||
|
||||
typedef struct rts_pdu_signature RtsPduSignature;
|
||||
typedef struct _RTS_PDU_SIGNATURE_ENTRY RTS_PDU_SIGNATURE_ENTRY;
|
||||
|
||||
#include "rts.h"
|
||||
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
struct rts_pdu_signature
|
||||
{
|
||||
UINT16 Flags;
|
||||
UINT16 NumberOfCommands;
|
||||
UINT32 CommandTypes[8];
|
||||
};
|
||||
|
||||
struct _RTS_PDU_SIGNATURE_ENTRY
|
||||
{
|
||||
UINT32 SignatureId;
|
||||
RtsPduSignature* Signature;
|
||||
const char* PduName;
|
||||
};
|
||||
|
||||
/* RTS PDU Signature IDs */
|
||||
|
||||
#define RTS_PDU_CONN_A 0x10000000
|
||||
#define RTS_PDU_CONN_A1 (RTS_PDU_CONN_A | 0x00000001)
|
||||
#define RTS_PDU_CONN_A2 (RTS_PDU_CONN_A | 0x00000002)
|
||||
#define RTS_PDU_CONN_A3 (RTS_PDU_CONN_A | 0x00000003)
|
||||
|
||||
#define RTS_PDU_CONN_B 0x20000000
|
||||
#define RTS_PDU_CONN_B1 (RTS_PDU_CONN_B | 0x00000001)
|
||||
#define RTS_PDU_CONN_B2 (RTS_PDU_CONN_B | 0x00000002)
|
||||
#define RTS_PDU_CONN_B3 (RTS_PDU_CONN_B | 0x00000003)
|
||||
|
||||
#define RTS_PDU_CONN_C 0x40000000
|
||||
#define RTS_PDU_CONN_C1 (RTS_PDU_CONN_C | 0x00000001)
|
||||
#define RTS_PDU_CONN_C2 (RTS_PDU_CONN_C | 0x00000002)
|
||||
|
||||
#define RTS_PDU_IN_R1_A 0x01000000
|
||||
#define RTS_PDU_IN_R1_A1 (RTS_PDU_IN_R1_A | 0x00000001)
|
||||
#define RTS_PDU_IN_R1_A2 (RTS_PDU_IN_R1_A | 0x00000002)
|
||||
#define RTS_PDU_IN_R1_A3 (RTS_PDU_IN_R1_A | 0x00000003)
|
||||
#define RTS_PDU_IN_R1_A4 (RTS_PDU_IN_R1_A | 0x00000004)
|
||||
#define RTS_PDU_IN_R1_A5 (RTS_PDU_IN_R1_A | 0x00000005)
|
||||
#define RTS_PDU_IN_R1_A6 (RTS_PDU_IN_R1_A | 0x00000006)
|
||||
|
||||
#define RTS_PDU_IN_R1_B 0x02000000
|
||||
#define RTS_PDU_IN_R1_B1 (RTS_PDU_IN_R1_B | 0x00000001)
|
||||
#define RTS_PDU_IN_R1_B2 (RTS_PDU_IN_R1_B | 0x00000002)
|
||||
|
||||
#define RTS_PDU_IN_R2_A 0x04000000
|
||||
#define RTS_PDU_IN_R2_A1 (RTS_PDU_IN_R2_A | 0x00000001)
|
||||
#define RTS_PDU_IN_R2_A2 (RTS_PDU_IN_R2_A | 0x00000002)
|
||||
#define RTS_PDU_IN_R2_A3 (RTS_PDU_IN_R2_A | 0x00000003)
|
||||
#define RTS_PDU_IN_R2_A4 (RTS_PDU_IN_R2_A | 0x00000004)
|
||||
#define RTS_PDU_IN_R2_A5 (RTS_PDU_IN_R2_A | 0x00000005)
|
||||
|
||||
#define RTS_PDU_OUT_R1_A 0x00100000
|
||||
#define RTS_PDU_OUT_R1_A1 (RTS_PDU_OUT_R1_A | 0x00000001)
|
||||
#define RTS_PDU_OUT_R1_A2 (RTS_PDU_OUT_R1_A | 0x00000002)
|
||||
#define RTS_PDU_OUT_R1_A3 (RTS_PDU_OUT_R1_A | 0x00000003)
|
||||
#define RTS_PDU_OUT_R1_A4 (RTS_PDU_OUT_R1_A | 0x00000004)
|
||||
#define RTS_PDU_OUT_R1_A5 (RTS_PDU_OUT_R1_A | 0x00000005)
|
||||
#define RTS_PDU_OUT_R1_A6 (RTS_PDU_OUT_R1_A | 0x00000006)
|
||||
#define RTS_PDU_OUT_R1_A7 (RTS_PDU_OUT_R1_A | 0x00000007)
|
||||
#define RTS_PDU_OUT_R1_A8 (RTS_PDU_OUT_R1_A | 0x00000008)
|
||||
#define RTS_PDU_OUT_R1_A9 (RTS_PDU_OUT_R1_A | 0x00000009)
|
||||
#define RTS_PDU_OUT_R1_A10 (RTS_PDU_OUT_R1_A | 0x0000000A)
|
||||
#define RTS_PDU_OUT_R1_A11 (RTS_PDU_OUT_R1_A | 0x0000000B)
|
||||
|
||||
#define RTS_PDU_OUT_R2_A 0x00200000
|
||||
#define RTS_PDU_OUT_R2_A1 (RTS_PDU_OUT_R2_A | 0x00000001)
|
||||
#define RTS_PDU_OUT_R2_A2 (RTS_PDU_OUT_R2_A | 0x00000002)
|
||||
#define RTS_PDU_OUT_R2_A3 (RTS_PDU_OUT_R2_A | 0x00000003)
|
||||
#define RTS_PDU_OUT_R2_A4 (RTS_PDU_OUT_R2_A | 0x00000004)
|
||||
#define RTS_PDU_OUT_R2_A5 (RTS_PDU_OUT_R2_A | 0x00000005)
|
||||
#define RTS_PDU_OUT_R2_A6 (RTS_PDU_OUT_R2_A | 0x00000006)
|
||||
#define RTS_PDU_OUT_R2_A7 (RTS_PDU_OUT_R2_A | 0x00000007)
|
||||
#define RTS_PDU_OUT_R2_A8 (RTS_PDU_OUT_R2_A | 0x00000008)
|
||||
|
||||
#define RTS_PDU_OUT_R2_B 0x00400000
|
||||
#define RTS_PDU_OUT_R2_B1 (RTS_PDU_OUT_R2_B | 0x00000001)
|
||||
#define RTS_PDU_OUT_R2_B2 (RTS_PDU_OUT_R2_B | 0x00000002)
|
||||
#define RTS_PDU_OUT_R2_B3 (RTS_PDU_OUT_R2_B | 0x00000003)
|
||||
|
||||
#define RTS_PDU_OUT_R2_C 0x00800000
|
||||
#define RTS_PDU_OUT_R2_C1 (RTS_PDU_OUT_R2_C | 0x00000001)
|
||||
|
||||
#define RTS_PDU_OUT_OF_SEQUENCE 0x00010000
|
||||
#define RTS_PDU_KEEP_ALIVE (RTS_PDU_OUT_OF_SEQUENCE | 0x00000001)
|
||||
#define RTS_PDU_PING_TRAFFIC_SENT_NOTIFY (RTS_PDU_OUT_OF_SEQUENCE | 0x00000002)
|
||||
#define RTS_PDU_ECHO (RTS_PDU_OUT_OF_SEQUENCE | 0x00000003)
|
||||
#define RTS_PDU_PING (RTS_PDU_OUT_OF_SEQUENCE | 0x00000004)
|
||||
#define RTS_PDU_FLOW_CONTROL_ACK (RTS_PDU_OUT_OF_SEQUENCE | 0x00000005)
|
||||
#define RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION (RTS_PDU_OUT_OF_SEQUENCE | 0x00000006)
|
||||
|
||||
extern RtsPduSignature RTS_PDU_CONN_A1_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_CONN_A2_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_CONN_A3_SIGNATURE;
|
||||
|
||||
extern RtsPduSignature RTS_PDU_CONN_B1_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_CONN_B2_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_CONN_B3_SIGNATURE;
|
||||
|
||||
extern RtsPduSignature RTS_PDU_CONN_C1_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_CONN_C2_SIGNATURE;
|
||||
|
||||
extern RtsPduSignature RTS_PDU_IN_R1_A1_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_IN_R1_A2_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_IN_R1_A3_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_IN_R1_A4_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_IN_R1_A5_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_IN_R1_A6_SIGNATURE;
|
||||
|
||||
extern RtsPduSignature RTS_PDU_IN_R1_B1_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_IN_R1_B2_SIGNATURE;
|
||||
|
||||
extern RtsPduSignature RTS_PDU_IN_R2_A1_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_IN_R2_A2_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_IN_R2_A3_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_IN_R2_A4_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_IN_R2_A5_SIGNATURE;
|
||||
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A1_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A2_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A3_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A4_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A5_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A6_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A7_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A8_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A9_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A10_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R1_A11_SIGNATURE;
|
||||
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_A1_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_A2_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_A3_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_A4_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_A5_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_A6_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_A7_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_A8_SIGNATURE;
|
||||
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_B1_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_B2_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_B3_SIGNATURE;
|
||||
|
||||
extern RtsPduSignature RTS_PDU_OUT_R2_C1_SIGNATURE;
|
||||
|
||||
extern RtsPduSignature RTS_PDU_KEEP_ALIVE_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_PING_TRAFFIC_SENT_NOTIFY_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_ECHO_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_PING_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_FLOW_CONTROL_ACK_SIGNATURE;
|
||||
extern RtsPduSignature RTS_PDU_FLOW_CONTROL_ACK_WITH_DESTINATION_SIGNATURE;
|
||||
|
||||
BOOL rts_match_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, rpcconn_rts_hdr_t* rts);
|
||||
int rts_extract_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, rpcconn_rts_hdr_t* rts);
|
||||
UINT32 rts_identify_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature, RTS_PDU_SIGNATURE_ENTRY** entry);
|
||||
int rts_print_pdu_signature(rdpRpc* rpc, RtsPduSignature* signature);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue