Properly handle demand active state

The demand active state might be called when receiving data from the
client during initial connection phase or might be triggered server
side after sending a deactivate all pdu
This commit is contained in:
Armin Novak 2022-11-08 12:54:49 +01:00 committed by Martin Fleisz
parent 8210ee77db
commit 367ecf3c0b
3 changed files with 34 additions and 17 deletions

View File

@ -24,6 +24,7 @@
#include "info.h"
#include "input.h"
#include "rdp.h"
#include "peer.h"
#include "connection.h"
#include "transport.h"
@ -1550,8 +1551,9 @@ BOOL rdp_server_reactivate(rdpRdp* rdp)
return FALSE;
rdp_finalize_set_flag(rdp, FINALIZE_DEACTIVATE_REACTIVATE);
return rdp_server_transition_to_state(rdp,
CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE);
if (!rdp_server_transition_to_state(rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE))
return FALSE;
return rdp_peer_handle_state_demand_active(client) > 0;
}
BOOL rdp_server_transition_to_state(rdpRdp* rdp, CONNECTION_STATE state)

View File

@ -697,6 +697,33 @@ static int peer_unexpected_client_message(rdpRdp* rdp, UINT32 flag)
return 0; /* we ignore this as per spec input PDU are already allowed */
}
int rdp_peer_handle_state_demand_active(freerdp_peer* client)
{
int ret = -1;
WINPR_ASSERT(client);
WINPR_ASSERT(client->context);
rdpRdp* rdp = client->context->rdp;
WINPR_ASSERT(rdp);
if (client->Capabilities && !client->Capabilities(client))
{
WLog_ERR(TAG, "[%s] freerdp_peer::Capabilities() callback failed",
rdp_get_state_string(rdp));
}
else if (!rdp_send_demand_active(rdp))
{
WLog_ERR(TAG, "[%s] rdp_send_demand_active() fail", rdp_get_state_string(rdp));
}
else
{
rdp_server_transition_to_state(rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_MONITOR_LAYOUT);
ret = 1;
}
return ret;
}
static int peer_recv_callback_internal(rdpTransport* transport, wStream* s, void* extra)
{
UINT32 SelectedProtocol;
@ -891,21 +918,7 @@ static int peer_recv_callback_internal(rdpTransport* transport, wStream* s, void
break;
case CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE:
if (client->Capabilities && !client->Capabilities(client))
{
WLog_ERR(TAG, "[%s] freerdp_peer::Capabilities() callback failed",
rdp_get_state_string(rdp));
}
else if (!rdp_send_demand_active(rdp))
{
WLog_ERR(TAG, "[%s] rdp_send_demand_active() fail", rdp_get_state_string(rdp));
}
else
{
rdp_server_transition_to_state(
rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_MONITOR_LAYOUT);
ret = 1;
}
ret = rdp_peer_handle_state_demand_active(client);
break;
case CONNECTION_STATE_CAPABILITIES_EXCHANGE_MONITOR_LAYOUT:

View File

@ -26,4 +26,6 @@
#include <freerdp/peer.h>
FREERDP_LOCAL int rdp_peer_handle_state_demand_active(freerdp_peer* client);
#endif /* FREERDP_LIB_CORE_PEER_H */