int rts_send_OUT_R2_C1_pdu(rdpRpc* rpc) { int status; BYTE* buffer; rpcconn_rts_hdr_t header; RpcOutChannel* nextOutChannel = rpc->VirtualConnection->NonDefaultOutChannel; 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_channel_write(nextOutChannel, buffer, header.frag_length); free(buffer); return (status > 0) ? 1 : -1; }
int rts_send_ping_pdu(rdpRpc* rpc) { int status; BYTE* buffer; UINT32 length; rpcconn_rts_hdr_t header; RpcInChannel* inChannel = rpc->VirtualConnection->DefaultInChannel; rts_pdu_header_init(&header); header.frag_length = 20; header.Flags = RTS_FLAG_PING; header.NumberOfCommands = 0; WLog_DBG(TAG, "Sending Ping RTS PDU"); buffer = (BYTE*) malloc(header.frag_length); if (!buffer) return -1; CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */ length = header.frag_length; status = rpc_in_channel_write(inChannel, buffer, length); free(buffer); return (status > 0) ? 1 : -1; }
int rts_send_OUT_R2_A7_pdu(rdpRpc* rpc) { int status; BYTE* buffer; rpcconn_rts_hdr_t header; BYTE* SuccessorChannelCookie; RpcInChannel* inChannel = rpc->VirtualConnection->DefaultInChannel; RpcOutChannel* nextOutChannel = rpc->VirtualConnection->NonDefaultOutChannel; 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*) &(nextOutChannel->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_in_channel_write(inChannel, buffer, header.frag_length); free(buffer); return (status > 0) ? 1 : -1; }
int rts_send_CONN_A1_pdu(rdpRpc* rpc) { int status; BYTE* buffer; rpcconn_rts_hdr_t header; UINT32 ReceiveWindowSize; BYTE* OUTChannelCookie; BYTE* VirtualConnectionCookie; RpcVirtualConnection* connection = rpc->VirtualConnection; RpcOutChannel* outChannel = connection->DefaultOutChannel; rts_pdu_header_init(&header); header.frag_length = 76; header.Flags = RTS_FLAG_NONE; header.NumberOfCommands = 4; WLog_DBG(TAG, "Sending CONN/A1 RTS PDU"); VirtualConnectionCookie = (BYTE*) &(connection->Cookie); OUTChannelCookie = (BYTE*) &(outChannel->Cookie); ReceiveWindowSize = outChannel->ReceiveWindow; buffer = (BYTE*) malloc(header.frag_length); if (!buffer) return -1; CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */ rts_version_command_write(&buffer[20]); /* Version (8 bytes) */ rts_cookie_command_write(&buffer[28], VirtualConnectionCookie); /* VirtualConnectionCookie (20 bytes) */ rts_cookie_command_write(&buffer[48], OUTChannelCookie); /* OUTChannelCookie (20 bytes) */ rts_receive_window_size_command_write(&buffer[68], ReceiveWindowSize); /* ReceiveWindowSize (8 bytes) */ status = rpc_out_channel_write(outChannel, buffer, header.frag_length); free(buffer); return (status > 0) ? 1 : -1; }
int rts_send_keep_alive_pdu(rdpRpc* rpc) { int status; BYTE* buffer; UINT32 length; rpcconn_rts_hdr_t header; RpcInChannel* inChannel = rpc->VirtualConnection->DefaultInChannel; rts_pdu_header_init(&header); header.frag_length = 28; header.Flags = RTS_FLAG_OTHER_CMD; header.NumberOfCommands = 1; WLog_DBG(TAG, "Sending Keep-Alive RTS PDU"); buffer = (BYTE*) malloc(header.frag_length); if (!buffer) return -1; CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */ rts_client_keepalive_command_write(&buffer[20], rpc->CurrentKeepAliveInterval); /* ClientKeepAlive (8 bytes) */ length = header.frag_length; status = rpc_in_channel_write(inChannel, buffer, length); free(buffer); return (status > 0) ? 1 : -1; }
int rts_send_flow_control_ack_pdu(rdpRpc* rpc) { int status; BYTE* buffer; UINT32 length; rpcconn_rts_hdr_t header; UINT32 BytesReceived; UINT32 AvailableWindow; BYTE* ChannelCookie; RpcVirtualConnection* connection = rpc->VirtualConnection; RpcInChannel* inChannel = connection->DefaultInChannel; RpcOutChannel* outChannel = connection->DefaultOutChannel; rts_pdu_header_init(&header); header.frag_length = 56; header.Flags = RTS_FLAG_OTHER_CMD; header.NumberOfCommands = 2; WLog_DBG(TAG, "Sending FlowControlAck RTS PDU"); BytesReceived = outChannel->BytesReceived; AvailableWindow = outChannel->AvailableWindowAdvertised; ChannelCookie = (BYTE*) &(outChannel->Cookie); outChannel->ReceiverAvailableWindow = outChannel->AvailableWindowAdvertised; 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], FDOutProxy); /* Destination Command (8 bytes) */ /* FlowControlAck Command (28 bytes) */ rts_flow_control_ack_command_write(&buffer[28], BytesReceived, AvailableWindow, ChannelCookie); length = header.frag_length; status = rpc_in_channel_write(inChannel, buffer, length); free(buffer); return (status > 0) ? 1 : -1; }
int rts_send_ping_pdu(rdpRpc* rpc) { BYTE* buffer; UINT32 length; rpcconn_rts_hdr_t header; rts_pdu_header_init(&header); header.frag_length = 20; header.Flags = RTS_FLAG_PING; header.NumberOfCommands = 0; WLog_DBG(TAG, "Sending Ping RTS PDU"); buffer = (BYTE*) malloc(header.frag_length); if (!buffer) return -1; CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */ length = header.frag_length; if (rpc_in_write(rpc, buffer, length) < 0) { free (buffer); return -1; } free(buffer); return length; }
int rts_send_keep_alive_pdu(rdpRpc* rpc) { BYTE* buffer; UINT32 length; rpcconn_rts_hdr_t header; rts_pdu_header_init(&header); header.frag_length = 28; header.Flags = RTS_FLAG_OTHER_CMD; header.NumberOfCommands = 1; WLog_DBG(TAG, "Sending Keep-Alive RTS PDU"); buffer = (BYTE*) malloc(header.frag_length); if (!buffer) return -1; CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */ rts_client_keepalive_command_write(&buffer[20], rpc->CurrentKeepAliveInterval); /* ClientKeepAlive (8 bytes) */ length = header.frag_length; if (rpc_in_write(rpc, buffer, length) < 0) { free (buffer); return -1; } free(buffer); return length; }
int rts_send_CONN_B1_pdu(rdpRpc* rpc) { int status; BYTE* buffer; UINT32 length; rpcconn_rts_hdr_t header; BYTE* INChannelCookie; BYTE* AssociationGroupId; BYTE* VirtualConnectionCookie; RpcVirtualConnection* connection = rpc->VirtualConnection; RpcInChannel* inChannel = connection->DefaultInChannel; rts_pdu_header_init(&header); header.frag_length = 104; header.Flags = RTS_FLAG_NONE; header.NumberOfCommands = 6; WLog_DBG(TAG, "Sending CONN/B1 RTS PDU"); VirtualConnectionCookie = (BYTE*) &(connection->Cookie); INChannelCookie = (BYTE*) &(inChannel->Cookie); AssociationGroupId = (BYTE*) &(connection->AssociationGroupId); buffer = (BYTE*) malloc(header.frag_length); if (!buffer) return -1; CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */ rts_version_command_write(&buffer[20]); /* Version (8 bytes) */ rts_cookie_command_write(&buffer[28], VirtualConnectionCookie); /* VirtualConnectionCookie (20 bytes) */ rts_cookie_command_write(&buffer[48], INChannelCookie); /* INChannelCookie (20 bytes) */ rts_channel_lifetime_command_write(&buffer[68], rpc->ChannelLifetime); /* ChannelLifetime (8 bytes) */ rts_client_keepalive_command_write(&buffer[76], rpc->KeepAliveInterval); /* ClientKeepalive (8 bytes) */ rts_association_group_id_command_write(&buffer[84], AssociationGroupId); /* AssociationGroupId (20 bytes) */ length = header.frag_length; status = rpc_in_channel_write(inChannel, buffer, length); free(buffer); return (status > 0) ? 1 : -1; }
int rts_send_OUT_R1_A3_pdu(rdpRpc* rpc) { int status; BYTE* buffer; rpcconn_rts_hdr_t header; UINT32 ReceiveWindowSize; BYTE* VirtualConnectionCookie; BYTE* PredecessorChannelCookie; BYTE* SuccessorChannelCookie; RpcVirtualConnection* connection = rpc->VirtualConnection; RpcOutChannel* outChannel = connection->DefaultOutChannel; RpcOutChannel* nextOutChannel = connection->NonDefaultOutChannel; rts_pdu_header_init(&header); header.frag_length = 96; header.Flags = RTS_FLAG_RECYCLE_CHANNEL; header.NumberOfCommands = 5; WLog_DBG(TAG, "Sending OUT_R1/A3 RTS PDU"); VirtualConnectionCookie = (BYTE*) &(connection->Cookie); PredecessorChannelCookie = (BYTE*) &(outChannel->Cookie); SuccessorChannelCookie = (BYTE*) &(nextOutChannel->Cookie); ReceiveWindowSize = outChannel->ReceiveWindow; buffer = (BYTE*) malloc(header.frag_length); if (!buffer) return -1; CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */ rts_version_command_write(&buffer[20]); /* Version (8 bytes) */ rts_cookie_command_write(&buffer[28], VirtualConnectionCookie); /* VirtualConnectionCookie (20 bytes) */ rts_cookie_command_write(&buffer[48], PredecessorChannelCookie); /* PredecessorChannelCookie (20 bytes) */ rts_cookie_command_write(&buffer[68], SuccessorChannelCookie); /* SuccessorChannelCookie (20 bytes) */ rts_receive_window_size_command_write(&buffer[88], ReceiveWindowSize); /* ReceiveWindowSize (8 bytes) */ status = rpc_out_channel_write(nextOutChannel, buffer, header.frag_length); free(buffer); return (status > 0) ? 1 : -1; }
int rts_send_CONN_B1_pdu(rdpRpc* rpc) { BYTE* buffer; UINT32 length; rpcconn_rts_hdr_t header; BYTE* INChannelCookie; BYTE* AssociationGroupId; BYTE* VirtualConnectionCookie; rts_pdu_header_init(&header); header.frag_length = 104; header.Flags = RTS_FLAG_NONE; header.NumberOfCommands = 6; DEBUG_RPC("Sending CONN_B1 RTS PDU"); rts_generate_cookie((BYTE*) &(rpc->VirtualConnection->DefaultInChannelCookie)); rts_generate_cookie((BYTE*) &(rpc->VirtualConnection->AssociationGroupId)); VirtualConnectionCookie = (BYTE*) &(rpc->VirtualConnection->Cookie); INChannelCookie = (BYTE*) &(rpc->VirtualConnection->DefaultInChannelCookie); AssociationGroupId = (BYTE*) &(rpc->VirtualConnection->AssociationGroupId); buffer = (BYTE*) malloc(header.frag_length); CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */ rts_version_command_write(&buffer[20]); /* Version (8 bytes) */ rts_cookie_command_write(&buffer[28], VirtualConnectionCookie); /* VirtualConnectionCookie (20 bytes) */ rts_cookie_command_write(&buffer[48], INChannelCookie); /* INChannelCookie (20 bytes) */ rts_channel_lifetime_command_write(&buffer[68], rpc->ChannelLifetime); /* ChannelLifetime (8 bytes) */ rts_client_keepalive_command_write(&buffer[76], rpc->KeepAliveInterval); /* ClientKeepalive (8 bytes) */ rts_association_group_id_command_write(&buffer[84], AssociationGroupId); /* AssociationGroupId (20 bytes) */ length = header.frag_length; rpc_in_write(rpc, buffer, length); free(buffer); return 0; }
int rts_send_flow_control_ack_pdu(rdpRpc* rpc) { BYTE* buffer; UINT32 length; rpcconn_rts_hdr_t header; UINT32 BytesReceived; UINT32 AvailableWindow; BYTE* ChannelCookie; rts_pdu_header_init(&header); header.frag_length = 56; header.Flags = RTS_FLAG_OTHER_CMD; header.NumberOfCommands = 2; DEBUG_RPC("Sending FlowControlAck RTS PDU"); BytesReceived = rpc->VirtualConnection->DefaultOutChannel->BytesReceived; AvailableWindow = rpc->VirtualConnection->DefaultOutChannel->AvailableWindowAdvertised; ChannelCookie = (BYTE*) &(rpc->VirtualConnection->DefaultOutChannelCookie); rpc->VirtualConnection->DefaultOutChannel->ReceiverAvailableWindow = rpc->VirtualConnection->DefaultOutChannel->AvailableWindowAdvertised; buffer = (BYTE*) malloc(header.frag_length); CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */ rts_destination_command_write(&buffer[20], FDOutProxy); /* Destination Command (8 bytes) */ /* FlowControlAck Command (28 bytes) */ rts_flow_control_ack_command_write(&buffer[28], BytesReceived, AvailableWindow, ChannelCookie); length = header.frag_length; rpc_in_write(rpc, buffer, length); free(buffer); return 0; }
int rts_send_CONN_A1_pdu(rdpRpc* rpc) { BYTE* buffer; rpcconn_rts_hdr_t header; UINT32 ReceiveWindowSize; BYTE* OUTChannelCookie; BYTE* VirtualConnectionCookie; rts_pdu_header_init(&header); header.frag_length = 76; header.Flags = RTS_FLAG_NONE; header.NumberOfCommands = 4; DEBUG_RPC("Sending CONN_A1 RTS PDU"); rts_generate_cookie((BYTE*) &(rpc->VirtualConnection->Cookie)); rts_generate_cookie((BYTE*) &(rpc->VirtualConnection->DefaultOutChannelCookie)); VirtualConnectionCookie = (BYTE*) &(rpc->VirtualConnection->Cookie); OUTChannelCookie = (BYTE*) &(rpc->VirtualConnection->DefaultOutChannelCookie); ReceiveWindowSize = rpc->VirtualConnection->DefaultOutChannel->ReceiveWindow; buffer = (BYTE*) malloc(header.frag_length); CopyMemory(buffer, ((BYTE*) &header), 20); /* RTS Header (20 bytes) */ rts_version_command_write(&buffer[20]); /* Version (8 bytes) */ rts_cookie_command_write(&buffer[28], VirtualConnectionCookie); /* VirtualConnectionCookie (20 bytes) */ rts_cookie_command_write(&buffer[48], OUTChannelCookie); /* OUTChannelCookie (20 bytes) */ rts_receive_window_size_command_write(&buffer[68], ReceiveWindowSize); /* ReceiveWindowSize (8 bytes) */ rpc_out_write(rpc, buffer, header.frag_length); free(buffer); return 0; }