Cleaned CONNECT_STATE transition function

This commit is contained in:
akallabeth 2021-09-03 12:17:30 +02:00 committed by akallabeth
parent c2a7a78d94
commit d7d7c45b0e
2 changed files with 15 additions and 115 deletions

View File

@ -1132,86 +1132,33 @@ int rdp_client_connect_finalize(rdpRdp* rdp)
return 0; return 0;
} }
int rdp_client_transition_to_state(rdpRdp* rdp, int state) int rdp_client_transition_to_state(rdpRdp* rdp, CONNECTION_STATE state)
{ {
int status = 0; int status = 0;
WLog_DBG(TAG, "%s %s --> %s", __FUNCTION__, rdp_get_state_string(rdp), rdp_state_string(state)); WLog_DBG(TAG, "%s %s --> %s", __FUNCTION__, rdp_get_state_string(rdp), rdp_state_string(state));
rdp_set_state(rdp, state);
switch (state) switch (state)
{ {
case CONNECTION_STATE_INITIAL:
rdp_set_state(rdp, CONNECTION_STATE_INITIAL);
break;
case CONNECTION_STATE_NEGO:
rdp_set_state(rdp, CONNECTION_STATE_NEGO);
break;
case CONNECTION_STATE_NLA:
rdp_set_state(rdp, CONNECTION_STATE_NLA);
break;
case CONNECTION_STATE_MCS_CONNECT:
rdp_set_state(rdp, CONNECTION_STATE_MCS_CONNECT);
break;
case CONNECTION_STATE_MCS_ERECT_DOMAIN:
rdp_set_state(rdp, CONNECTION_STATE_MCS_ERECT_DOMAIN);
break;
case CONNECTION_STATE_MCS_ATTACH_USER:
rdp_set_state(rdp, CONNECTION_STATE_MCS_ATTACH_USER);
break;
case CONNECTION_STATE_MCS_CHANNEL_JOIN:
rdp_set_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN);
break;
case CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT:
rdp_set_state(rdp, CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT);
break;
case CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE:
rdp_set_state(rdp, CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE);
break;
case CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT:
rdp_set_state(rdp, CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT);
break;
case CONNECTION_STATE_LICENSING:
rdp_set_state(rdp, CONNECTION_STATE_LICENSING);
break;
case CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING:
rdp_set_state(rdp, CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING);
break;
case CONNECTION_STATE_CAPABILITIES_EXCHANGE:
rdp_set_state(rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE);
break;
case CONNECTION_STATE_FINALIZATION: case CONNECTION_STATE_FINALIZATION:
rdp_set_state(rdp, CONNECTION_STATE_FINALIZATION);
update_reset_state(rdp->update); update_reset_state(rdp->update);
rdp->finalize_sc_pdus = 0; rdp->finalize_sc_pdus = 0;
break; break;
case CONNECTION_STATE_ACTIVE: case CONNECTION_STATE_ACTIVE:
rdp_set_state(rdp, CONNECTION_STATE_ACTIVE); {
{ ActivatedEventArgs activatedEvent;
ActivatedEventArgs activatedEvent; rdpContext* context = rdp->context;
rdpContext* context = rdp->context; EventArgsInit(&activatedEvent, "libfreerdp");
EventArgsInit(&activatedEvent, "libfreerdp"); activatedEvent.firstActivation = !rdp->deactivation_reactivation;
activatedEvent.firstActivation = !rdp->deactivation_reactivation; PubSub_OnActivated(context->pubSub, context, &activatedEvent);
PubSub_OnActivated(context->pubSub, context, &activatedEvent);
} }
break; break;
default: default:
status = -1; break;
break;
} }
{ {
@ -1453,7 +1400,7 @@ BOOL rdp_server_reactivate(rdpRdp* rdp)
return TRUE; return TRUE;
} }
int rdp_server_transition_to_state(rdpRdp* rdp, int state) int rdp_server_transition_to_state(rdpRdp* rdp, CONNECTION_STATE state)
{ {
int status = 0; int status = 0;
freerdp_peer* client = NULL; freerdp_peer* client = NULL;
@ -1469,64 +1416,18 @@ int rdp_server_transition_to_state(rdpRdp* rdp, int state)
} }
WLog_DBG(TAG, "%s %s --> %s", __FUNCTION__, rdp_get_state_string(rdp), rdp_state_string(state)); WLog_DBG(TAG, "%s %s --> %s", __FUNCTION__, rdp_get_state_string(rdp), rdp_state_string(state));
rdp_set_state(rdp, state);
switch (state) switch (state)
{ {
case CONNECTION_STATE_INITIAL:
rdp_set_state(rdp, CONNECTION_STATE_INITIAL);
break;
case CONNECTION_STATE_NEGO:
rdp_set_state(rdp, CONNECTION_STATE_NEGO);
break;
case CONNECTION_STATE_MCS_CONNECT:
rdp_set_state(rdp, CONNECTION_STATE_MCS_CONNECT);
break;
case CONNECTION_STATE_MCS_ERECT_DOMAIN:
rdp_set_state(rdp, CONNECTION_STATE_MCS_ERECT_DOMAIN);
break;
case CONNECTION_STATE_MCS_ATTACH_USER:
rdp_set_state(rdp, CONNECTION_STATE_MCS_ATTACH_USER);
break;
case CONNECTION_STATE_MCS_CHANNEL_JOIN:
rdp_set_state(rdp, CONNECTION_STATE_MCS_CHANNEL_JOIN);
break;
case CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT:
rdp_set_state(rdp, CONNECTION_STATE_RDP_SECURITY_COMMENCEMENT);
break;
case CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE:
rdp_set_state(rdp, CONNECTION_STATE_SECURE_SETTINGS_EXCHANGE);
break;
case CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT:
rdp_set_state(rdp, CONNECTION_STATE_CONNECT_TIME_AUTO_DETECT);
break;
case CONNECTION_STATE_LICENSING:
rdp_set_state(rdp, CONNECTION_STATE_LICENSING);
break;
case CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING:
rdp_set_state(rdp, CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING);
break;
case CONNECTION_STATE_CAPABILITIES_EXCHANGE: case CONNECTION_STATE_CAPABILITIES_EXCHANGE:
rdp_set_state(rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE);
rdp->AwaitCapabilities = FALSE; rdp->AwaitCapabilities = FALSE;
break; break;
case CONNECTION_STATE_FINALIZATION: case CONNECTION_STATE_FINALIZATION:
rdp_set_state(rdp, CONNECTION_STATE_FINALIZATION);
rdp->finalize_sc_pdus = 0; rdp->finalize_sc_pdus = 0;
break; break;
case CONNECTION_STATE_ACTIVE: case CONNECTION_STATE_ACTIVE:
rdp_set_state(rdp, CONNECTION_STATE_ACTIVE);
update_reset_state(rdp->update); update_reset_state(rdp->update);
if (client) if (client)
@ -1555,7 +1456,6 @@ int rdp_server_transition_to_state(rdpRdp* rdp, int state)
break; break;
default: default:
status = -1;
break; break;
} }

View File

@ -46,7 +46,7 @@ FREERDP_LOCAL BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStr
FREERDP_LOCAL BOOL rdp_client_connect_auto_detect(rdpRdp* rdp, wStream* s); FREERDP_LOCAL BOOL rdp_client_connect_auto_detect(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL int rdp_client_connect_license(rdpRdp* rdp, wStream* s); FREERDP_LOCAL int rdp_client_connect_license(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL int rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s); FREERDP_LOCAL int rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL int rdp_client_transition_to_state(rdpRdp* rdp, int state); FREERDP_LOCAL int rdp_client_transition_to_state(rdpRdp* rdp, CONNECTION_STATE state);
FREERDP_LOCAL CONNECTION_STATE rdp_get_state(rdpRdp* rdp); FREERDP_LOCAL CONNECTION_STATE rdp_get_state(rdpRdp* rdp);
FREERDP_LOCAL const char* rdp_state_string(CONNECTION_STATE state); FREERDP_LOCAL const char* rdp_state_string(CONNECTION_STATE state);
@ -59,7 +59,7 @@ FREERDP_LOCAL BOOL rdp_server_accept_mcs_channel_join_request(rdpRdp* rdp, wStre
FREERDP_LOCAL BOOL rdp_server_accept_confirm_active(rdpRdp* rdp, wStream* s, UINT16 pduLength); FREERDP_LOCAL BOOL rdp_server_accept_confirm_active(rdpRdp* rdp, wStream* s, UINT16 pduLength);
FREERDP_LOCAL BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s); FREERDP_LOCAL BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL BOOL rdp_server_reactivate(rdpRdp* rdp); FREERDP_LOCAL BOOL rdp_server_reactivate(rdpRdp* rdp);
FREERDP_LOCAL int rdp_server_transition_to_state(rdpRdp* rdp, int state); FREERDP_LOCAL int rdp_server_transition_to_state(rdpRdp* rdp, CONNECTION_STATE state);
FREERDP_LOCAL const char* rdp_get_state_string(rdpRdp* rdp); FREERDP_LOCAL const char* rdp_get_state_string(rdpRdp* rdp);
FREERDP_LOCAL const char* rdp_client_connection_state_string(int state); FREERDP_LOCAL const char* rdp_client_connection_state_string(int state);