[core,gateway] add rts_recv_ping_pdu

This commit is contained in:
Armin Novak 2023-10-25 16:53:22 +02:00 committed by akallabeth
parent f367465485
commit 99f3a9c0e6
3 changed files with 35 additions and 5 deletions

View File

@ -195,15 +195,13 @@ static int rpc_client_recv_pdu_int(rdpRpc* rpc, RPC_PDU* pdu)
WLog_VRB(TAG, "client state %s, vc state %s", rpc_client_state_str(rpc->State),
rpc_vc_state_str(rpc->VirtualConnection->State));
if (!rts_extract_pdu_signature(&found, pdu->s, NULL))
return FALSE;
const BOOL rc = rts_match_pdu_signature_ex(&RTS_PDU_PING_SIGNATURE, pdu->s, NULL, &found);
rts_print_pdu_signature(rpc->log, WLOG_TRACE, &found);
if (rc)
return rts_recv_ping_pdu(rpc, pdu->s);
if (rpc->VirtualConnection->State < VIRTUAL_CONNECTION_STATE_OPENED)
{
if (rts_match_pdu_signature_ex(&RTS_PDU_PING_SIGNATURE, pdu->s, NULL, &found))
return 1;
switch (rpc->VirtualConnection->State)
{
case VIRTUAL_CONNECTION_STATE_INITIAL:

View File

@ -1862,6 +1862,36 @@ static int rts_recv_flow_control_ack_with_destination_pdu(rdpRpc* rpc, wStream*
return 1;
}
BOOL rts_recv_ping_pdu(rdpRpc* rpc, wStream* s)
{
BOOL rc = FALSE;
rpcconn_hdr_t header = { 0 };
WINPR_ASSERT(rpc);
WINPR_ASSERT(rpc->auth);
WINPR_ASSERT(s);
if (!rts_read_pdu_header(s, &header))
goto fail;
rc = TRUE;
if (header.common.ptype != PTYPE_RTS)
{
WLog_Print(rpc->log, WLOG_ERROR, "received invalid ping PDU, type is 0x%" PRIx32,
header.common.ptype);
rc = FALSE;
}
if (header.rts.Flags != RTS_FLAG_PING)
{
WLog_Print(rpc->log, WLOG_ERROR, "received unexpected ping PDU::Flags 0x%" PRIx32,
header.rts.Flags);
rc = FALSE;
}
fail:
rts_free_pdu_header(&header, FALSE);
return rc;
}
static int rts_send_ping_pdu(rdpRpc* rpc)
{
BOOL status = FALSE;

View File

@ -104,4 +104,6 @@ FREERDP_LOCAL BOOL rts_send_flow_control_ack_pdu(rdpRpc* rpc);
FREERDP_LOCAL BOOL rts_recv_out_of_sequence_pdu(rdpRpc* rpc, wStream* buffer,
const rpcconn_hdr_t* header);
FREERDP_LOCAL BOOL rts_recv_ping_pdu(rdpRpc* rpc, wStream* s);
#endif /* FREERDP_LIB_CORE_GATEWAY_RTS_H */