libfreerdp-core: integrate new RTS pdu functions from denis
This commit is contained in:
parent
c92e82b3dc
commit
8f2b2be9f2
@ -661,7 +661,7 @@ RpcInChannel* rpc_client_in_channel_new(rdpRpc* rpc)
|
||||
|
||||
if (inChannel)
|
||||
{
|
||||
|
||||
rpc_client_in_channel_init(rpc, inChannel);
|
||||
}
|
||||
|
||||
return inChannel;
|
||||
@ -799,7 +799,7 @@ RpcOutChannel* rpc_client_out_channel_new(rdpRpc* rpc)
|
||||
|
||||
if (outChannel)
|
||||
{
|
||||
|
||||
rpc_client_out_channel_init(rpc, outChannel);
|
||||
}
|
||||
|
||||
return outChannel;
|
||||
@ -854,18 +854,6 @@ int rpc_client_virtual_connection_transition_to_state(rdpRpc* rpc,
|
||||
return status;
|
||||
}
|
||||
|
||||
void rpc_client_virtual_connection_init(rdpRpc* rpc, RpcVirtualConnection* connection)
|
||||
{
|
||||
rts_generate_cookie((BYTE*) &(connection->Cookie));
|
||||
rts_generate_cookie((BYTE*) &(connection->AssociationGroupId));
|
||||
|
||||
rpc_client_in_channel_init(rpc, connection->DefaultInChannel);
|
||||
rpc_client_out_channel_init(rpc, connection->DefaultOutChannel);
|
||||
|
||||
rts_generate_cookie((BYTE*) &(connection->NonDefaultInChannelCookie));
|
||||
rts_generate_cookie((BYTE*) &(connection->NonDefaultOutChannelCookie));
|
||||
}
|
||||
|
||||
RpcVirtualConnection* rpc_client_virtual_connection_new(rdpRpc* rpc)
|
||||
{
|
||||
RpcVirtualConnection* connection;
|
||||
@ -875,6 +863,9 @@ RpcVirtualConnection* rpc_client_virtual_connection_new(rdpRpc* rpc)
|
||||
if (!connection)
|
||||
return NULL;
|
||||
|
||||
rts_generate_cookie((BYTE*) &(connection->Cookie));
|
||||
rts_generate_cookie((BYTE*) &(connection->AssociationGroupId));
|
||||
|
||||
connection->State = VIRTUAL_CONNECTION_STATE_INITIAL;
|
||||
|
||||
connection->DefaultInChannel = rpc_client_in_channel_new(rpc);
|
||||
@ -887,8 +878,6 @@ RpcVirtualConnection* rpc_client_virtual_connection_new(rdpRpc* rpc)
|
||||
if (!connection->DefaultOutChannel)
|
||||
goto out_default_in;
|
||||
|
||||
rpc_client_virtual_connection_init(rpc, connection);
|
||||
|
||||
return connection;
|
||||
out_default_in:
|
||||
free(connection->DefaultInChannel);
|
||||
@ -897,15 +886,18 @@ out_free:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void rpc_client_virtual_connection_free(RpcVirtualConnection* virtualConnection)
|
||||
void rpc_client_virtual_connection_free(RpcVirtualConnection* connection)
|
||||
{
|
||||
if (!virtualConnection)
|
||||
if (!connection)
|
||||
return;
|
||||
|
||||
rpc_client_in_channel_free(virtualConnection->DefaultInChannel);
|
||||
rpc_client_out_channel_free(virtualConnection->DefaultOutChannel);
|
||||
rpc_client_in_channel_free(connection->DefaultInChannel);
|
||||
rpc_client_in_channel_free(connection->NonDefaultInChannel);
|
||||
|
||||
free(virtualConnection);
|
||||
rpc_client_out_channel_free(connection->DefaultOutChannel);
|
||||
rpc_client_out_channel_free(connection->NonDefaultOutChannel);
|
||||
|
||||
free(connection);
|
||||
}
|
||||
|
||||
rdpRpc* rpc_new(rdpTransport* transport)
|
||||
|
@ -688,15 +688,13 @@ typedef enum _VIRTUAL_CONNECTION_STATE VIRTUAL_CONNECTION_STATE;
|
||||
|
||||
struct rpc_virtual_connection
|
||||
{
|
||||
BYTE Cookie[16]; /* Virtual Connection Cookie */
|
||||
BYTE AssociationGroupId[16]; /* AssociationGroupId */
|
||||
VIRTUAL_CONNECTION_STATE State; /* Virtual Connection State */
|
||||
RpcInChannel* DefaultInChannel; /* Default IN Channel */
|
||||
RpcInChannel* NonDefaultInChannel; /* Non-Default IN Channel */
|
||||
BYTE NonDefaultInChannelCookie[16]; /* Non-Default Default IN Channel Cookie */
|
||||
RpcOutChannel* DefaultOutChannel; /* Default OUT Channel */
|
||||
RpcOutChannel* NonDefaultOutChannel; /* Non-Default OUT Channel */
|
||||
BYTE NonDefaultOutChannelCookie[16]; /* Non-Default Default OUT Channel Cookie */
|
||||
BYTE Cookie[16];
|
||||
BYTE AssociationGroupId[16];
|
||||
VIRTUAL_CONNECTION_STATE State;
|
||||
RpcInChannel* DefaultInChannel;
|
||||
RpcInChannel* NonDefaultInChannel;
|
||||
RpcOutChannel* DefaultOutChannel;
|
||||
RpcOutChannel* NonDefaultOutChannel;
|
||||
};
|
||||
typedef struct rpc_virtual_connection RpcVirtualConnection;
|
||||
|
||||
@ -776,6 +774,12 @@ int rpc_in_write(rdpRpc* rpc, const BYTE* data, int length);
|
||||
|
||||
BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* header, UINT32* offset, UINT32* length);
|
||||
|
||||
RpcInChannel* rpc_client_in_channel_new(rdpRpc* rpc);
|
||||
void rpc_client_in_channel_free(RpcInChannel* inChannel);
|
||||
|
||||
RpcOutChannel* rpc_client_out_channel_new(rdpRpc* rpc);
|
||||
void rpc_client_out_channel_free(RpcOutChannel* outChannel);
|
||||
|
||||
int rpc_client_in_channel_transition_to_state(RpcInChannel* inChannel, CLIENT_IN_CHANNEL_STATE state);
|
||||
int rpc_client_out_channel_transition_to_state(RpcOutChannel* outChannel, CLIENT_OUT_CHANNEL_STATE state);
|
||||
|
||||
|
@ -539,14 +539,9 @@ int rts_recv_CONN_C2_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
WLog_DBG(TAG, "ConnectionTimeout: %d", ConnectionTimeout);
|
||||
WLog_DBG(TAG, "ReceiveWindowSize: %d", ReceiveWindowSize);
|
||||
|
||||
/* TODO: verify if this is the correct protocol variable */
|
||||
rpc->VirtualConnection->DefaultInChannel->PingOriginator.ConnectionTimeout = ConnectionTimeout;
|
||||
|
||||
rpc->VirtualConnection->DefaultInChannel->PeerReceiveWindow = ReceiveWindowSize;
|
||||
|
||||
rpc->VirtualConnection->DefaultInChannel->State = CLIENT_IN_CHANNEL_STATE_OPENED;
|
||||
rpc->VirtualConnection->DefaultOutChannel->State = CLIENT_OUT_CHANNEL_STATE_OPENED;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -796,6 +791,67 @@ int rts_command_length(rdpRpc* rpc, UINT32 CommandType, BYTE* buffer, UINT32 len
|
||||
return CommandLength;
|
||||
}
|
||||
|
||||
int rts_send_OUT_R2_A7_pdu(rdpRpc* rpc)
|
||||
{
|
||||
int status;
|
||||
BYTE* buffer;
|
||||
rpcconn_rts_hdr_t header;
|
||||
BYTE* SuccessorChannelCookie;
|
||||
|
||||
rts_pdu_header_init(&header);
|
||||
header.frag_length = 56;
|
||||
header.Flags = RTS_FLAG_OUT_CHANNEL;
|
||||
header.NumberOfCommands = 3;
|
||||
|
||||
WLog_DBG(TAG, "Sending OUT R2/A7 RTS PDU");
|
||||
|
||||
SuccessorChannelCookie = (BYTE*) &(rpc->VirtualConnection->NonDefaultOutChannel->Cookie);
|
||||
|
||||
buffer = (BYTE*) malloc(header.frag_length);
|
||||
|
||||
if (!buffer)
|
||||
return -1;
|
||||
|
||||
CopyMemory(buffer, ((BYTE*)&header), 20); /* RTS Header (20 bytes) */
|
||||
rts_destination_command_write(&buffer[20], FDServer); /* Destination (8 bytes)*/
|
||||
rts_cookie_command_write(&buffer[28], SuccessorChannelCookie); /* SuccessorChannelCookie (20 bytes) */
|
||||
rts_version_command_write(&buffer[48]); /* Version (8 bytes) */
|
||||
|
||||
status = rpc_out_write(rpc, buffer, header.frag_length);
|
||||
|
||||
free(buffer);
|
||||
|
||||
return (status > 0) ? 1 : -1;
|
||||
}
|
||||
|
||||
int rts_send_OUT_R2_C1_pdu(rdpRpc* rpc)
|
||||
{
|
||||
int status;
|
||||
BYTE* buffer;
|
||||
rpcconn_rts_hdr_t header;
|
||||
|
||||
rts_pdu_header_init(&header);
|
||||
header.frag_length = 24;
|
||||
header.Flags = RTS_FLAG_PING;
|
||||
header.NumberOfCommands = 1;
|
||||
|
||||
WLog_DBG(TAG, "Sending OUT R2/C1 RTS PDU");
|
||||
|
||||
buffer = (BYTE*) malloc(header.frag_length);
|
||||
|
||||
if (!buffer)
|
||||
return -1;
|
||||
|
||||
CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */
|
||||
rts_empty_command_write(&buffer[20]); /* Empty command (4 bytes) */
|
||||
|
||||
status = rpc_out_write(rpc, buffer, header.frag_length);
|
||||
|
||||
free(buffer);
|
||||
|
||||
return (status > 0) ? 1 : -1;
|
||||
}
|
||||
|
||||
int rts_send_OUT_R1_A3_pdu(rdpRpc* rpc)
|
||||
{
|
||||
int status;
|
||||
@ -815,7 +871,7 @@ int rts_send_OUT_R1_A3_pdu(rdpRpc* rpc)
|
||||
|
||||
VirtualConnectionCookie = (BYTE*) &(rpc->VirtualConnection->Cookie);
|
||||
PredecessorChannelCookie = (BYTE*) &(rpc->VirtualConnection->DefaultOutChannel->Cookie);
|
||||
SuccessorChannelCookie = (BYTE*) &(rpc->VirtualConnection->NonDefaultOutChannelCookie);
|
||||
SuccessorChannelCookie = (BYTE*) &(rpc->VirtualConnection->NonDefaultOutChannel->Cookie);
|
||||
ReceiveWindowSize = rpc->VirtualConnection->DefaultOutChannel->ReceiveWindow;
|
||||
|
||||
buffer = (BYTE*) malloc(header.frag_length);
|
||||
@ -841,6 +897,7 @@ int rts_recv_OUT_R1_A2_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
UINT32 offset;
|
||||
UINT32 Destination = 0;
|
||||
RpcVirtualConnection* connection = rpc->VirtualConnection;
|
||||
|
||||
offset = 24;
|
||||
offset += rts_destination_command_read(rpc, &buffer[offset], length - offset, &Destination) + 4;
|
||||
@ -849,6 +906,38 @@ int rts_recv_OUT_R1_A2_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
|
||||
WLog_ERR(TAG, "TS Gateway channel recycling is incomplete");
|
||||
|
||||
connection->NonDefaultOutChannel = rpc_client_out_channel_new(rpc);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rts_recv_OUT_R2_A6_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
int status;
|
||||
UINT32 offset;
|
||||
UINT32 Destination = 0;
|
||||
|
||||
offset = 24;
|
||||
offset += rts_destination_command_read(rpc, &buffer[offset], length - offset, &Destination) + 4;
|
||||
offset += rts_empty_command_read(rpc, &buffer[offset], length - offset) + 4;
|
||||
|
||||
WLog_DBG(TAG, "Destination: %d", Destination);
|
||||
|
||||
status = rts_send_OUT_R2_C1_pdu(rpc);
|
||||
|
||||
if (status < 0)
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rts_recv_OUT_R2_B3_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length)
|
||||
{
|
||||
UINT32 offset;
|
||||
|
||||
offset = 24;
|
||||
offset += rts_ance_command_read(rpc, &buffer[offset], length - offset) + 4;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user