Fixes to process new command line options (autodetect, heartbeat, multitransport), join the MCS message channel and process auto-detect PDUs during the connection sequence.

This commit is contained in:
Mike McDonald 2014-01-29 22:53:32 -05:00
parent 159f539ef2
commit 02c9d07bcf
6 changed files with 98 additions and 4 deletions

View File

@ -148,6 +148,8 @@ COMMAND_LINE_ARGUMENT_A args[] =
{ "auth-only", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Authenticate only." },
{ "reconnect-cookie", COMMAND_LINE_VALUE_REQUIRED, "<base64 cookie>", NULL, NULL, -1, NULL, "Pass base64 reconnect cookie to the connection" },
{ "print-reconnect-cookie", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Print base64 reconnect cookie after connecting" },
{ "heartbeat", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Support heartbeat PDUs" },
{ "multitransport", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Support multitransport protocol" },
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
};
@ -719,6 +721,15 @@ int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_ARGUMENT
freerdp_client_add_dynamic_channel(settings, count, p);
}
}
CommandLineSwitchCase(arg, "heartbeat")
{
settings->SupportHeartbeatPdu = TRUE;
}
CommandLineSwitchCase(arg, "multitransport")
{
settings->SupportMultitransport = TRUE;
settings->MultitransportFlags = (TRANSPORT_TYPE_UDP_FECR | TRANSPORT_TYPE_UDP_FECL | TRANSPORT_TYPE_UDP_PREFERRED);
}
CommandLineSwitchEnd(arg)
@ -1796,6 +1807,13 @@ int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
settings->AudioCapture = TRUE;
}
if (settings->NetworkAutoDetect ||
settings->SupportHeartbeatPdu ||
settings->SupportMultitransport)
{
settings->DeviceRedirection = TRUE; /* these RDP 8 features require rdpdr to be registered */
}
if (settings->RedirectDrives)
{
settings->DeviceRedirection = TRUE;

View File

@ -21,7 +21,7 @@
#include "config.h"
#endif
#define WITH_DEBUG_AUTODETECT
//#define WITH_DEBUG_AUTODETECT
#include "autodetect.h"
@ -111,7 +111,7 @@ static BOOL autodetect_recv_bandwidth_measure_start(rdpRdp* rdp, wStream* s, AUT
if (autodetectReqPdu->headerLength != 0x06)
return FALSE;
DEBUG_AUTODETECT("received Bandwidth Measure Start PDU");
DEBUG_AUTODETECT("received Bandwidth Measure Start PDU - time=%lu", GetTickCount());
/* Initialize bandwidth measurement parameters */
rdp->autodetect->bandwidthMeasureStartTime = GetTickCount();
@ -222,6 +222,11 @@ int rdp_recv_autodetect_packet(rdpRdp* rdp, wStream* s)
Stream_Read_UINT16(s, autodetectReqPdu.sequenceNumber); /* sequenceNumber (2 bytes) */
Stream_Read_UINT16(s, autodetectReqPdu.requestType); /* requestType (2 bytes) */
DEBUG_AUTODETECT(
"rdp_recv_autodetect_packet: headerLength=%u, headerTypeId=%u, sequenceNumber=%u, requestType=%04x",
autodetectReqPdu.headerLength, autodetectReqPdu.headerTypeId,
autodetectReqPdu.sequenceNumber, autodetectReqPdu.requestType);
if (autodetectReqPdu.headerTypeId != TYPE_ID_AUTODETECT_REQUEST)
return -1;

View File

@ -3389,8 +3389,13 @@ BOOL rdp_recv_get_active_header(rdpRdp* rdp, wStream* s, UINT16* pChannelId)
if (*pChannelId != MCS_GLOBAL_CHANNEL_ID)
{
fprintf(stderr, "expected MCS_GLOBAL_CHANNEL_ID %04x, got %04x\n", MCS_GLOBAL_CHANNEL_ID, *pChannelId);
return FALSE;
UINT16 mcsMessageChannelId = rdp->mcs->message_channel_id;
if ((mcsMessageChannelId == 0) || (*pChannelId != mcsMessageChannelId))
{
fprintf(stderr, "unexpected MCS channel id %04x received\n", *pChannelId);
return FALSE;
}
}
return TRUE;

View File

@ -581,6 +581,31 @@ BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s)
rdp->mcs->global_channel_joined = TRUE;
if (rdp->mcs->message_channel_id != 0)
{
if (!mcs_send_channel_join_request(rdp->mcs, rdp->mcs->message_channel_id))
return FALSE;
all_joined = FALSE;
}
else
{
if (rdp->settings->ChannelCount > 0)
{
if (!mcs_send_channel_join_request(rdp->mcs, rdp->settings->ChannelDefArray[0].ChannelId))
return FALSE;
all_joined = FALSE;
}
}
}
else if ((rdp->mcs->message_channel_id != 0) && !rdp->mcs->message_channel_joined)
{
if (channel_id != rdp->mcs->message_channel_id)
return FALSE;
rdp->mcs->message_channel_joined = TRUE;
if (rdp->settings->ChannelCount > 0)
{
if (!mcs_send_channel_join_request(rdp->mcs, rdp->settings->ChannelDefArray[0].ChannelId))
@ -626,6 +651,33 @@ BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s)
return TRUE;
}
BOOL rdp_client_connect_auto_detect(rdpRdp* rdp, wStream *s)
{
BYTE* mark;
UINT16 length;
UINT16 channelId;
/* If the MCS message channel has been joined... */
if (rdp->mcs->message_channel_id != 0)
{
/* Process any MCS message channel PDUs. */
Stream_GetPointer(s, mark);
if (rdp_read_header(rdp, s, &length, &channelId))
{
if (channelId == rdp->mcs->message_channel_id)
{
if (rdp_recv_message_channel_pdu(rdp, s) == 0)
return TRUE;
}
}
Stream_SetPointer(s, mark);
}
return FALSE;
}
int rdp_client_connect_license(rdpRdp* rdp, wStream* s)
{
int status;

View File

@ -53,6 +53,7 @@ BOOL rdp_client_reconnect(rdpRdp* rdp);
BOOL rdp_client_connect_mcs_connect_response(rdpRdp* rdp, wStream* s);
BOOL rdp_client_connect_mcs_attach_user_confirm(rdpRdp* rdp, wStream* s);
BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s);
BOOL rdp_client_connect_auto_detect(rdpRdp* rdp, wStream* s);
int rdp_client_connect_license(rdpRdp* rdp, wStream* s);
int rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s);
int rdp_client_connect_finalize(rdpRdp* rdp);

View File

@ -1103,6 +1103,19 @@ static int rdp_recv_callback(rdpTransport* transport, wStream* s, void* extra)
int status = 0;
rdpRdp* rdp = (rdpRdp*) extra;
/*
* At any point in the connection sequence between when all
* MCS channels have been joined and when the RDP connection
* enters the active state, an auto-detect PDU can be received
* on the MCS message channel.
*/
if ((rdp->state > CONNECTION_STATE_MCS_CHANNEL_JOIN) &&
(rdp->state < CONNECTION_STATE_ACTIVE))
{
if (rdp_client_connect_auto_detect(rdp, s))
return 0;
}
switch (rdp->state)
{
case CONNECTION_STATE_NEGO: