2011-07-04 06:47:35 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-07-04 06:47:35 +04:00
|
|
|
* T.125 Multipoint Communication Service (MCS) Protocol
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2015-05-29 14:46:50 +03:00
|
|
|
* Copyright 2015 Thincast Technologies GmbH
|
|
|
|
* Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
|
2017-02-20 20:31:58 +03:00
|
|
|
* Copyright 2017 Armin Novak <armin.novak@thincast.com>
|
|
|
|
* Copyright 2017 Thincast Technologies GmbH
|
2011-07-04 06:47:35 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2012-08-15 01:09:01 +04:00
|
|
|
|
2012-11-22 04:22:41 +04:00
|
|
|
#include <winpr/crt.h>
|
2022-04-19 15:29:17 +03:00
|
|
|
#include <winpr/assert.h>
|
2014-09-12 16:36:29 +04:00
|
|
|
#include <freerdp/log.h>
|
2012-11-22 04:22:41 +04:00
|
|
|
|
2011-07-08 03:32:51 +04:00
|
|
|
#include "gcc.h"
|
|
|
|
|
2011-07-04 06:47:35 +04:00
|
|
|
#include "mcs.h"
|
2011-07-27 03:14:11 +04:00
|
|
|
#include "tpdu.h"
|
|
|
|
#include "tpkt.h"
|
2014-02-16 01:32:38 +04:00
|
|
|
#include "client.h"
|
2015-02-16 00:04:59 +03:00
|
|
|
#include "connection.h"
|
2011-07-04 06:47:35 +04:00
|
|
|
|
2014-09-12 16:36:29 +04:00
|
|
|
#define TAG FREERDP_TAG("core")
|
|
|
|
|
2011-07-04 06:47:35 +04:00
|
|
|
/**
|
|
|
|
* T.125 MCS is defined in:
|
|
|
|
*
|
|
|
|
* http://www.itu.int/rec/T-REC-T.125-199802-I/
|
|
|
|
* ITU-T T.125 Multipoint Communication Service Protocol Specification
|
|
|
|
*/
|
|
|
|
|
2011-07-07 23:35:09 +04:00
|
|
|
/**
|
|
|
|
* Connect-Initial ::= [APPLICATION 101] IMPLICIT SEQUENCE
|
|
|
|
* {
|
|
|
|
* callingDomainSelector OCTET_STRING,
|
|
|
|
* calledDomainSelector OCTET_STRING,
|
|
|
|
* upwardFlag BOOLEAN,
|
|
|
|
* targetParameters DomainParameters,
|
|
|
|
* minimumParameters DomainParameters,
|
|
|
|
* maximumParameters DomainParameters,
|
|
|
|
* userData OCTET_STRING
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* DomainParameters ::= SEQUENCE
|
|
|
|
* {
|
|
|
|
* maxChannelIds INTEGER (0..MAX),
|
|
|
|
* maxUserIds INTEGER (0..MAX),
|
|
|
|
* maxTokenIds INTEGER (0..MAX),
|
|
|
|
* numPriorities INTEGER (0..MAX),
|
|
|
|
* minThroughput INTEGER (0..MAX),
|
|
|
|
* maxHeight INTEGER (0..MAX),
|
|
|
|
* maxMCSPDUsize INTEGER (0..MAX),
|
|
|
|
* protocolVersion INTEGER (0..MAX)
|
|
|
|
* }
|
|
|
|
*
|
2011-07-09 23:28:59 +04:00
|
|
|
* Connect-Response ::= [APPLICATION 102] IMPLICIT SEQUENCE
|
|
|
|
* {
|
|
|
|
* result Result,
|
|
|
|
* calledConnectId INTEGER (0..MAX),
|
|
|
|
* domainParameters DomainParameters,
|
|
|
|
* userData OCTET_STRING
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* Result ::= ENUMERATED
|
|
|
|
* {
|
|
|
|
* rt-successful (0),
|
|
|
|
* rt-domain-merging (1),
|
|
|
|
* rt-domain-not-hierarchical (2),
|
|
|
|
* rt-no-such-channel (3),
|
|
|
|
* rt-no-such-domain (4),
|
|
|
|
* rt-no-such-user (5),
|
|
|
|
* rt-not-admitted (6),
|
|
|
|
* rt-other-user-id (7),
|
|
|
|
* rt-parameters-unacceptable (8),
|
|
|
|
* rt-token-not-available (9),
|
|
|
|
* rt-token-not-possessed (10),
|
|
|
|
* rt-too-many-channels (11),
|
|
|
|
* rt-too-many-tokens (12),
|
|
|
|
* rt-too-many-users (13),
|
|
|
|
* rt-unspecified-failure (14),
|
|
|
|
* rt-user-rejected (15)
|
|
|
|
* }
|
|
|
|
*
|
2011-07-10 07:54:23 +04:00
|
|
|
* ErectDomainRequest ::= [APPLICATION 1] IMPLICIT SEQUENCE
|
|
|
|
* {
|
|
|
|
* subHeight INTEGER (0..MAX),
|
|
|
|
* subInterval INTEGER (0..MAX)
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* AttachUserRequest ::= [APPPLICATION 10] IMPLICIT SEQUENCE
|
|
|
|
* {
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* AttachUserConfirm ::= [APPLICATION 11] IMPLICIT SEQUENCE
|
|
|
|
* {
|
|
|
|
* result Result,
|
|
|
|
* initiator UserId OPTIONAL
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* ChannelJoinRequest ::= [APPLICATION 14] IMPLICIT SEQUENCE
|
|
|
|
* {
|
|
|
|
* initiator UserId,
|
|
|
|
* channelId ChannelId
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* ChannelJoinConfirm ::= [APPLICATION 15] IMPLICIT SEQUENCE
|
|
|
|
* {
|
|
|
|
* result Result,
|
|
|
|
* initiator UserId,
|
|
|
|
* requested ChannelId,
|
|
|
|
* channelId ChannelId OPTIONAL
|
|
|
|
* }
|
|
|
|
*
|
2011-07-10 20:10:24 +04:00
|
|
|
* SendDataRequest ::= [APPLICATION 25] IMPLICIT SEQUENCE
|
|
|
|
* {
|
|
|
|
* initiator UserId,
|
|
|
|
* channelId ChannelId,
|
|
|
|
* dataPriority DataPriority,
|
|
|
|
* segmentation Segmentation,
|
|
|
|
* userData OCTET_STRING
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* DataPriority ::= CHOICE
|
|
|
|
* {
|
|
|
|
* top NULL,
|
|
|
|
* high NULL,
|
|
|
|
* medium NULL,
|
|
|
|
* low NULL,
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* Segmentation ::= BIT_STRING
|
|
|
|
* {
|
|
|
|
* begin (0),
|
|
|
|
* end (1)
|
|
|
|
* } (SIZE(2))
|
|
|
|
*
|
2011-07-11 23:58:39 +04:00
|
|
|
* SendDataIndication ::= SEQUENCE
|
|
|
|
* {
|
|
|
|
* initiator UserId,
|
|
|
|
* channelId ChannelId,
|
|
|
|
* reliability BOOLEAN,
|
|
|
|
* domainReferenceID INTEGER (0..65535) OPTIONAL,
|
|
|
|
* dataPriority DataPriority,
|
|
|
|
* segmentation Segmentation,
|
|
|
|
* userData OCTET_STRING,
|
|
|
|
* totalDataSize INTEGER OPTIONAL,
|
|
|
|
* nonStandard SEQUENCE OF NonStandardParameter OPTIONAL,
|
|
|
|
* ...
|
|
|
|
* }
|
|
|
|
*
|
2011-07-07 23:35:09 +04:00
|
|
|
*/
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
static const BYTE callingDomainSelector[1] = "\x01";
|
|
|
|
static const BYTE calledDomainSelector[1] = "\x01";
|
2011-07-07 23:35:09 +04:00
|
|
|
|
2011-12-01 02:40:36 +04:00
|
|
|
/*
|
|
|
|
static const char* const mcs_result_enumerated[] =
|
2011-07-09 23:28:59 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
"rt-successful",
|
|
|
|
"rt-domain-merging",
|
|
|
|
"rt-domain-not-hierarchical",
|
|
|
|
"rt-no-such-channel",
|
|
|
|
"rt-no-such-domain",
|
|
|
|
"rt-no-such-user",
|
|
|
|
"rt-not-admitted",
|
|
|
|
"rt-other-user-id",
|
|
|
|
"rt-parameters-unacceptable",
|
|
|
|
"rt-token-not-available",
|
|
|
|
"rt-token-not-possessed",
|
|
|
|
"rt-too-many-channels",
|
|
|
|
"rt-too-many-tokens",
|
|
|
|
"rt-too-many-users",
|
|
|
|
"rt-unspecified-failure",
|
|
|
|
"rt-user-rejected"
|
2011-07-09 23:28:59 +04:00
|
|
|
};
|
2011-12-01 02:40:36 +04:00
|
|
|
*/
|
2011-07-09 23:28:59 +04:00
|
|
|
|
2022-03-18 12:57:47 +03:00
|
|
|
const char* mcs_domain_pdu_string(DomainMCSPDU pdu)
|
|
|
|
{
|
|
|
|
switch (pdu)
|
|
|
|
{
|
|
|
|
case DomainMCSPDU_PlumbDomainIndication:
|
|
|
|
return "DomainMCSPDU_PlumbDomainIndication";
|
|
|
|
case DomainMCSPDU_ErectDomainRequest:
|
|
|
|
return "DomainMCSPDU_ErectDomainRequest";
|
|
|
|
case DomainMCSPDU_MergeChannelsRequest:
|
|
|
|
return "DomainMCSPDU_MergeChannelsRequest";
|
|
|
|
case DomainMCSPDU_MergeChannelsConfirm:
|
|
|
|
return "DomainMCSPDU_MergeChannelsConfirm";
|
|
|
|
case DomainMCSPDU_PurgeChannelsIndication:
|
|
|
|
return "DomainMCSPDU_PurgeChannelsIndication";
|
|
|
|
case DomainMCSPDU_MergeTokensRequest:
|
|
|
|
return "DomainMCSPDU_MergeTokensRequest";
|
|
|
|
case DomainMCSPDU_MergeTokensConfirm:
|
|
|
|
return "DomainMCSPDU_MergeTokensConfirm";
|
|
|
|
case DomainMCSPDU_PurgeTokensIndication:
|
|
|
|
return "DomainMCSPDU_PurgeTokensIndication";
|
|
|
|
case DomainMCSPDU_DisconnectProviderUltimatum:
|
|
|
|
return "DomainMCSPDU_DisconnectProviderUltimatum";
|
|
|
|
case DomainMCSPDU_RejectMCSPDUUltimatum:
|
|
|
|
return "DomainMCSPDU_RejectMCSPDUUltimatum";
|
|
|
|
case DomainMCSPDU_AttachUserRequest:
|
|
|
|
return "DomainMCSPDU_AttachUserRequest";
|
|
|
|
case DomainMCSPDU_AttachUserConfirm:
|
|
|
|
return "DomainMCSPDU_AttachUserConfirm";
|
|
|
|
case DomainMCSPDU_DetachUserRequest:
|
|
|
|
return "DomainMCSPDU_DetachUserRequest";
|
|
|
|
case DomainMCSPDU_DetachUserIndication:
|
|
|
|
return "DomainMCSPDU_DetachUserIndication";
|
|
|
|
case DomainMCSPDU_ChannelJoinRequest:
|
|
|
|
return "DomainMCSPDU_ChannelJoinRequest";
|
|
|
|
case DomainMCSPDU_ChannelJoinConfirm:
|
|
|
|
return "DomainMCSPDU_ChannelJoinConfirm";
|
|
|
|
case DomainMCSPDU_ChannelLeaveRequest:
|
|
|
|
return "DomainMCSPDU_ChannelLeaveRequest";
|
|
|
|
case DomainMCSPDU_ChannelConveneRequest:
|
|
|
|
return "DomainMCSPDU_ChannelConveneRequest";
|
|
|
|
case DomainMCSPDU_ChannelConveneConfirm:
|
|
|
|
return "DomainMCSPDU_ChannelConveneConfirm";
|
|
|
|
case DomainMCSPDU_ChannelDisbandRequest:
|
|
|
|
return "DomainMCSPDU_ChannelDisbandRequest";
|
|
|
|
case DomainMCSPDU_ChannelDisbandIndication:
|
|
|
|
return "DomainMCSPDU_ChannelDisbandIndication";
|
|
|
|
case DomainMCSPDU_ChannelAdmitRequest:
|
|
|
|
return "DomainMCSPDU_ChannelAdmitRequest";
|
|
|
|
case DomainMCSPDU_ChannelAdmitIndication:
|
|
|
|
return "DomainMCSPDU_ChannelAdmitIndication";
|
|
|
|
case DomainMCSPDU_ChannelExpelRequest:
|
|
|
|
return "DomainMCSPDU_ChannelExpelRequest";
|
|
|
|
case DomainMCSPDU_ChannelExpelIndication:
|
|
|
|
return "DomainMCSPDU_ChannelExpelIndication";
|
|
|
|
case DomainMCSPDU_SendDataRequest:
|
|
|
|
return "DomainMCSPDU_SendDataRequest";
|
|
|
|
case DomainMCSPDU_SendDataIndication:
|
|
|
|
return "DomainMCSPDU_SendDataIndication";
|
|
|
|
case DomainMCSPDU_UniformSendDataRequest:
|
|
|
|
return "DomainMCSPDU_UniformSendDataRequest";
|
|
|
|
case DomainMCSPDU_UniformSendDataIndication:
|
|
|
|
return "DomainMCSPDU_UniformSendDataIndication";
|
|
|
|
case DomainMCSPDU_TokenGrabRequest:
|
|
|
|
return "DomainMCSPDU_TokenGrabRequest";
|
|
|
|
case DomainMCSPDU_TokenGrabConfirm:
|
|
|
|
return "DomainMCSPDU_TokenGrabConfirm";
|
|
|
|
case DomainMCSPDU_TokenInhibitRequest:
|
|
|
|
return "DomainMCSPDU_TokenInhibitRequest";
|
|
|
|
case DomainMCSPDU_TokenInhibitConfirm:
|
|
|
|
return "DomainMCSPDU_TokenInhibitConfirm";
|
|
|
|
case DomainMCSPDU_TokenGiveRequest:
|
|
|
|
return "DomainMCSPDU_TokenGiveRequest";
|
|
|
|
case DomainMCSPDU_TokenGiveIndication:
|
|
|
|
return "DomainMCSPDU_TokenGiveIndication";
|
|
|
|
case DomainMCSPDU_TokenGiveResponse:
|
|
|
|
return "DomainMCSPDU_TokenGiveResponse";
|
|
|
|
case DomainMCSPDU_TokenGiveConfirm:
|
|
|
|
return "DomainMCSPDU_TokenGiveConfirm";
|
|
|
|
case DomainMCSPDU_TokenPleaseRequest:
|
|
|
|
return "DomainMCSPDU_TokenPleaseRequest";
|
|
|
|
case DomainMCSPDU_TokenPleaseConfirm:
|
|
|
|
return "DomainMCSPDU_TokenPleaseConfirm";
|
|
|
|
case DomainMCSPDU_TokenReleaseRequest:
|
|
|
|
return "DomainMCSPDU_TokenReleaseRequest";
|
|
|
|
case DomainMCSPDU_TokenReleaseConfirm:
|
|
|
|
return "DomainMCSPDU_TokenReleaseConfirm";
|
|
|
|
case DomainMCSPDU_TokenTestRequest:
|
|
|
|
return "DomainMCSPDU_TokenTestRequest";
|
|
|
|
case DomainMCSPDU_TokenTestConfirm:
|
|
|
|
return "DomainMCSPDU_TokenTestConfirm";
|
|
|
|
case DomainMCSPDU_enum_length:
|
|
|
|
return "DomainMCSPDU_enum_length";
|
|
|
|
default:
|
|
|
|
return "DomainMCSPDU_UNKNOWN";
|
2022-06-29 15:18:36 +03:00
|
|
|
}
|
2022-03-18 12:57:47 +03:00
|
|
|
}
|
2022-10-10 12:31:22 +03:00
|
|
|
|
2019-11-20 13:30:14 +03:00
|
|
|
static BOOL mcs_merge_domain_parameters(DomainParameters* targetParameters,
|
|
|
|
DomainParameters* minimumParameters,
|
|
|
|
DomainParameters* maximumParameters,
|
|
|
|
DomainParameters* pOutParameters);
|
|
|
|
|
|
|
|
static BOOL mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* userData);
|
|
|
|
static BOOL mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* userData);
|
2022-03-18 12:57:47 +03:00
|
|
|
static BOOL mcs_read_domain_mcspdu_header(wStream* s, DomainMCSPDU domainMCSPDU, UINT16* length,
|
|
|
|
DomainMCSPDU* actual);
|
2019-11-20 13:30:14 +03:00
|
|
|
|
2021-09-22 15:27:21 +03:00
|
|
|
static int mcs_initialize_client_channels(rdpMcs* mcs, const rdpSettings* settings)
|
2014-02-16 01:32:38 +04:00
|
|
|
{
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!mcs || !settings)
|
|
|
|
return -1;
|
|
|
|
|
2022-05-02 11:55:44 +03:00
|
|
|
mcs->channelCount = freerdp_settings_get_uint32(settings, FreeRDP_ChannelCount);
|
2014-02-16 01:32:38 +04:00
|
|
|
|
|
|
|
if (mcs->channelCount > mcs->channelMaxCount)
|
|
|
|
mcs->channelCount = mcs->channelMaxCount;
|
|
|
|
|
|
|
|
ZeroMemory(mcs->channels, sizeof(rdpMcsChannel) * mcs->channelMaxCount);
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 index = 0; index < mcs->channelCount; index++)
|
2014-02-16 01:32:38 +04:00
|
|
|
{
|
2021-08-24 15:09:40 +03:00
|
|
|
const CHANNEL_DEF* defchannel =
|
|
|
|
freerdp_settings_get_pointer_array(settings, FreeRDP_ChannelDefArray, index);
|
|
|
|
rdpMcsChannel* cur = &mcs->channels[index];
|
|
|
|
WINPR_ASSERT(defchannel);
|
|
|
|
CopyMemory(cur->Name, defchannel->name, CHANNEL_NAME_LEN);
|
|
|
|
cur->options = defchannel->options;
|
2014-02-16 01:32:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
|
|
|
* Read a DomainMCSPDU header.
|
|
|
|
* @param s stream
|
|
|
|
* @param domainMCSPDU DomainMCSPDU type
|
|
|
|
* @param length TPKT length
|
2022-12-09 16:35:03 +03:00
|
|
|
*
|
|
|
|
* @return \b TRUE for success, \b FALSE otherwise
|
2011-07-11 22:47:55 +04:00
|
|
|
*/
|
|
|
|
|
2022-03-18 12:57:47 +03:00
|
|
|
BOOL mcs_read_domain_mcspdu_header(wStream* s, DomainMCSPDU domainMCSPDU, UINT16* length,
|
|
|
|
DomainMCSPDU* actual)
|
2011-07-11 22:47:55 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 li = 0;
|
|
|
|
BYTE choice = 0;
|
2022-03-18 12:57:47 +03:00
|
|
|
|
|
|
|
if (actual)
|
|
|
|
*actual = DomainMCSPDU_invalid;
|
2011-07-11 22:47:55 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
WINPR_ASSERT(s);
|
|
|
|
WINPR_ASSERT(domainMCSPDU);
|
|
|
|
WINPR_ASSERT(length);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2017-05-29 11:50:22 +03:00
|
|
|
if (!tpkt_read_header(s, length))
|
|
|
|
return FALSE;
|
2011-07-18 10:34:28 +04:00
|
|
|
|
2020-02-20 10:22:19 +03:00
|
|
|
if (!tpdu_read_data(s, &li, *length))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-07-11 22:47:55 +04:00
|
|
|
|
2013-02-15 05:39:56 +04:00
|
|
|
if (!per_read_choice(s, &choice))
|
2013-01-12 17:49:01 +04:00
|
|
|
return FALSE;
|
2013-02-15 05:39:56 +04:00
|
|
|
|
2024-01-23 18:49:54 +03:00
|
|
|
const DomainMCSPDU MCSPDU = (choice >> 2);
|
2022-03-18 12:57:47 +03:00
|
|
|
if (actual)
|
|
|
|
*actual = MCSPDU;
|
2011-07-11 22:47:55 +04:00
|
|
|
|
2022-03-18 12:57:47 +03:00
|
|
|
if (domainMCSPDU != MCSPDU)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Expected MCS %s, got %s", mcs_domain_pdu_string(domainMCSPDU),
|
|
|
|
mcs_domain_pdu_string(MCSPDU));
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2022-03-18 12:57:47 +03:00
|
|
|
}
|
2011-07-11 22:47:55 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-07-11 22:47:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a DomainMCSPDU header.
|
|
|
|
* @param s stream
|
|
|
|
* @param domainMCSPDU DomainMCSPDU type
|
|
|
|
* @param length TPKT length
|
|
|
|
*/
|
|
|
|
|
2022-10-10 12:31:22 +03:00
|
|
|
BOOL mcs_write_domain_mcspdu_header(wStream* s, DomainMCSPDU domainMCSPDU, UINT16 length,
|
2017-02-20 20:31:58 +03:00
|
|
|
BYTE options)
|
2011-07-11 22:47:55 +04:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
WINPR_ASSERT(s);
|
|
|
|
WINPR_ASSERT((options & ~0x03) == 0);
|
|
|
|
WINPR_ASSERT((domainMCSPDU & ~0x3F) == 0);
|
|
|
|
|
2022-10-10 12:31:22 +03:00
|
|
|
if (!tpkt_write_header(s, length))
|
|
|
|
return FALSE;
|
|
|
|
if (!tpdu_write_data(s))
|
|
|
|
return FALSE;
|
|
|
|
return per_write_choice(s, (BYTE)((domainMCSPDU << 2) | options));
|
2011-07-11 22:47:55 +04:00
|
|
|
}
|
|
|
|
|
2011-07-07 23:35:09 +04:00
|
|
|
/**
|
|
|
|
* Initialize MCS Domain Parameters.
|
|
|
|
* @param domainParameters domain parameters
|
|
|
|
* @param maxChannelIds max channel ids
|
|
|
|
* @param maxUserIds max user ids
|
|
|
|
* @param maxTokenIds max token ids
|
|
|
|
* @param maxMCSPDUsize max MCS PDU size
|
|
|
|
*/
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
static BOOL mcs_init_domain_parameters(DomainParameters* domainParameters, UINT32 maxChannelIds,
|
|
|
|
UINT32 maxUserIds, UINT32 maxTokenIds, UINT32 maxMCSPDUsize)
|
2011-07-07 23:35:09 +04:00
|
|
|
{
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!domainParameters)
|
|
|
|
return FALSE;
|
|
|
|
|
2011-07-07 23:35:09 +04:00
|
|
|
domainParameters->maxChannelIds = maxChannelIds;
|
|
|
|
domainParameters->maxUserIds = maxUserIds;
|
|
|
|
domainParameters->maxTokenIds = maxTokenIds;
|
|
|
|
domainParameters->maxMCSPDUsize = maxMCSPDUsize;
|
2011-07-08 00:38:41 +04:00
|
|
|
domainParameters->numPriorities = 1;
|
|
|
|
domainParameters->minThroughput = 0;
|
|
|
|
domainParameters->maxHeight = 1;
|
|
|
|
domainParameters->protocolVersion = 2;
|
2017-02-20 20:31:58 +03:00
|
|
|
return TRUE;
|
2011-07-07 23:35:09 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
|
|
|
* Read MCS Domain Parameters.
|
|
|
|
* @param s stream
|
|
|
|
* @param domainParameters domain parameters
|
|
|
|
*/
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
static BOOL mcs_read_domain_parameters(wStream* s, DomainParameters* domainParameters)
|
2011-07-09 23:28:59 +04:00
|
|
|
{
|
2023-01-18 13:07:58 +03:00
|
|
|
size_t length = 0;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!s || !domainParameters)
|
|
|
|
return FALSE;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
return ber_read_sequence_tag(s, &length) &&
|
|
|
|
ber_read_integer(s, &(domainParameters->maxChannelIds)) &&
|
|
|
|
ber_read_integer(s, &(domainParameters->maxUserIds)) &&
|
|
|
|
ber_read_integer(s, &(domainParameters->maxTokenIds)) &&
|
|
|
|
ber_read_integer(s, &(domainParameters->numPriorities)) &&
|
|
|
|
ber_read_integer(s, &(domainParameters->minThroughput)) &&
|
|
|
|
ber_read_integer(s, &(domainParameters->maxHeight)) &&
|
|
|
|
ber_read_integer(s, &(domainParameters->maxMCSPDUsize)) &&
|
|
|
|
ber_read_integer(s, &(domainParameters->protocolVersion));
|
2011-07-09 23:28:59 +04:00
|
|
|
}
|
|
|
|
|
2011-07-07 23:35:09 +04:00
|
|
|
/**
|
|
|
|
* Write MCS Domain Parameters.
|
|
|
|
* @param s stream
|
|
|
|
* @param domainParameters domain parameters
|
|
|
|
*/
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
static BOOL mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters)
|
2011-07-07 23:35:09 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t length = 0;
|
|
|
|
wStream* tmps = NULL;
|
2012-01-17 13:45:10 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!s || !domainParameters)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
tmps = Stream_New(NULL, Stream_Capacity(s));
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!tmps)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2012-01-17 13:45:10 +04:00
|
|
|
ber_write_integer(tmps, domainParameters->maxChannelIds);
|
|
|
|
ber_write_integer(tmps, domainParameters->maxUserIds);
|
|
|
|
ber_write_integer(tmps, domainParameters->maxTokenIds);
|
|
|
|
ber_write_integer(tmps, domainParameters->numPriorities);
|
|
|
|
ber_write_integer(tmps, domainParameters->minThroughput);
|
|
|
|
ber_write_integer(tmps, domainParameters->maxHeight);
|
|
|
|
ber_write_integer(tmps, domainParameters->maxMCSPDUsize);
|
|
|
|
ber_write_integer(tmps, domainParameters->protocolVersion);
|
2013-04-30 06:35:15 +04:00
|
|
|
length = Stream_GetPosition(tmps);
|
2011-07-19 01:02:06 +04:00
|
|
|
ber_write_sequence_tag(s, length);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Write(s, Stream_Buffer(tmps), length);
|
2013-05-09 01:48:30 +04:00
|
|
|
Stream_Free(tmps, TRUE);
|
2015-05-29 14:46:50 +03:00
|
|
|
return TRUE;
|
2011-07-07 23:35:09 +04:00
|
|
|
}
|
|
|
|
|
2017-05-12 12:11:41 +03:00
|
|
|
#ifdef DEBUG_MCS
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
|
|
|
* Print MCS Domain Parameters.
|
|
|
|
* @param domainParameters domain parameters
|
|
|
|
*/
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
static void mcs_print_domain_parameters(DomainParameters* domainParameters)
|
2011-07-09 23:28:59 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_INFO(TAG, "DomainParameters {");
|
2017-02-20 20:31:58 +03:00
|
|
|
|
|
|
|
if (domainParameters)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_INFO(TAG, "\tmaxChannelIds:%" PRIu32 "", domainParameters->maxChannelIds);
|
|
|
|
WLog_INFO(TAG, "\tmaxUserIds:%" PRIu32 "", domainParameters->maxUserIds);
|
|
|
|
WLog_INFO(TAG, "\tmaxTokenIds:%" PRIu32 "", domainParameters->maxTokenIds);
|
|
|
|
WLog_INFO(TAG, "\tnumPriorities:%" PRIu32 "", domainParameters->numPriorities);
|
|
|
|
WLog_INFO(TAG, "\tminThroughput:%" PRIu32 "", domainParameters->minThroughput);
|
|
|
|
WLog_INFO(TAG, "\tmaxHeight:%" PRIu32 "", domainParameters->maxHeight);
|
|
|
|
WLog_INFO(TAG, "\tmaxMCSPDUsize:%" PRIu32 "", domainParameters->maxMCSPDUsize);
|
|
|
|
WLog_INFO(TAG, "\tprotocolVersion:%" PRIu32 "", domainParameters->protocolVersion);
|
2017-02-20 20:31:58 +03:00
|
|
|
}
|
|
|
|
else
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_INFO(TAG, "\tdomainParameters=%p", domainParameters);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_INFO(TAG, "}");
|
2011-07-09 23:28:59 +04:00
|
|
|
}
|
2017-05-12 12:11:41 +03:00
|
|
|
#endif
|
2011-07-09 23:28:59 +04:00
|
|
|
|
2014-02-14 02:06:33 +04:00
|
|
|
/**
|
|
|
|
* Merge MCS Domain Parameters.
|
2022-12-09 16:35:03 +03:00
|
|
|
* @param targetParameters target parameters
|
|
|
|
* @param minimumParameters minimum parameters
|
|
|
|
* @param maximumParameters maximum parameters
|
|
|
|
* @param pOutParameters output parameters
|
|
|
|
*
|
|
|
|
* @return \b TRUE for success, \b FALSE otherwise
|
2014-02-14 02:06:33 +04:00
|
|
|
*/
|
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
BOOL mcs_merge_domain_parameters(DomainParameters* targetParameters,
|
|
|
|
DomainParameters* minimumParameters,
|
2019-11-06 17:24:51 +03:00
|
|
|
DomainParameters* maximumParameters,
|
|
|
|
DomainParameters* pOutParameters)
|
2014-02-14 02:06:33 +04:00
|
|
|
{
|
|
|
|
/* maxChannelIds */
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!targetParameters || !minimumParameters || !maximumParameters || !pOutParameters)
|
|
|
|
return FALSE;
|
2014-02-14 02:06:33 +04:00
|
|
|
|
|
|
|
if (targetParameters->maxChannelIds >= 4)
|
|
|
|
{
|
|
|
|
pOutParameters->maxChannelIds = targetParameters->maxChannelIds;
|
|
|
|
}
|
|
|
|
else if (maximumParameters->maxChannelIds >= 4)
|
|
|
|
{
|
|
|
|
pOutParameters->maxChannelIds = 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "invalid maxChannelIds [%" PRIu32 ", %" PRIu32 "]",
|
2023-01-18 13:07:58 +03:00
|
|
|
targetParameters->maxChannelIds, maximumParameters->maxChannelIds);
|
2014-02-14 02:06:33 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* maxUserIds */
|
|
|
|
|
|
|
|
if (targetParameters->maxUserIds >= 3)
|
|
|
|
{
|
|
|
|
pOutParameters->maxUserIds = targetParameters->maxUserIds;
|
|
|
|
}
|
|
|
|
else if (maximumParameters->maxUserIds >= 3)
|
|
|
|
{
|
|
|
|
pOutParameters->maxUserIds = 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "invalid maxUserIds [%" PRIu32 ", %" PRIu32 "]", targetParameters->maxUserIds,
|
|
|
|
maximumParameters->maxUserIds);
|
2014-02-14 02:06:33 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* maxTokenIds */
|
|
|
|
pOutParameters->maxTokenIds = targetParameters->maxTokenIds;
|
|
|
|
|
|
|
|
/* numPriorities */
|
|
|
|
|
|
|
|
if (minimumParameters->numPriorities <= 1)
|
|
|
|
{
|
|
|
|
pOutParameters->numPriorities = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "invalid numPriorities [%" PRIu32 "]", maximumParameters->numPriorities);
|
2014-02-14 02:06:33 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* minThroughput */
|
|
|
|
pOutParameters->minThroughput = targetParameters->minThroughput;
|
|
|
|
|
|
|
|
/* maxHeight */
|
|
|
|
|
|
|
|
if ((targetParameters->maxHeight == 1) || (minimumParameters->maxHeight <= 1))
|
|
|
|
{
|
|
|
|
pOutParameters->maxHeight = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "invalid maxHeight [%" PRIu32 ", %" PRIu32 "]", targetParameters->maxHeight,
|
|
|
|
minimumParameters->maxHeight);
|
2014-02-14 02:06:33 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* maxMCSPDUsize */
|
|
|
|
|
|
|
|
if (targetParameters->maxMCSPDUsize >= 1024)
|
|
|
|
{
|
|
|
|
if (targetParameters->maxMCSPDUsize <= 65528)
|
|
|
|
{
|
|
|
|
pOutParameters->maxMCSPDUsize = targetParameters->maxMCSPDUsize;
|
|
|
|
}
|
2019-11-06 17:24:51 +03:00
|
|
|
else if ((minimumParameters->maxMCSPDUsize >= 124) &&
|
|
|
|
(minimumParameters->maxMCSPDUsize <= 65528))
|
2014-02-14 02:06:33 +04:00
|
|
|
{
|
|
|
|
pOutParameters->maxMCSPDUsize = 65528;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "invalid maxMCSPDUsize [%" PRIu32 ", %" PRIu32 "]",
|
2023-01-18 13:07:58 +03:00
|
|
|
targetParameters->maxMCSPDUsize, minimumParameters->maxMCSPDUsize);
|
2014-02-14 02:06:33 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (maximumParameters->maxMCSPDUsize >= 124)
|
|
|
|
{
|
|
|
|
pOutParameters->maxMCSPDUsize = maximumParameters->maxMCSPDUsize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "invalid maxMCSPDUsize [%" PRIu32 "]", maximumParameters->maxMCSPDUsize);
|
2014-02-14 02:06:33 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* protocolVersion */
|
|
|
|
|
|
|
|
if ((targetParameters->protocolVersion == 2) ||
|
2017-02-20 20:31:58 +03:00
|
|
|
((minimumParameters->protocolVersion <= 2) && (maximumParameters->protocolVersion >= 2)))
|
2014-02-14 02:06:33 +04:00
|
|
|
{
|
|
|
|
pOutParameters->protocolVersion = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_ERR(TAG, "invalid protocolVersion [%" PRIu32 ", %" PRIu32 ", %" PRIu32 "]",
|
|
|
|
targetParameters->protocolVersion, minimumParameters->protocolVersion,
|
|
|
|
maximumParameters->protocolVersion);
|
2014-02-14 02:06:33 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Read an MCS Connect Initial PDU.
|
|
|
|
* msdn{cc240508}
|
2011-08-19 13:39:37 +04:00
|
|
|
* @param mcs MCS module
|
|
|
|
* @param s stream
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL mcs_recv_connect_initial(rdpMcs* mcs, wStream* s)
|
2011-08-19 13:39:37 +04:00
|
|
|
{
|
2023-01-18 13:07:58 +03:00
|
|
|
UINT16 li = 0;
|
|
|
|
size_t length = 0;
|
|
|
|
BOOL upwardFlag = FALSE;
|
|
|
|
UINT16 tlength = 0;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
WINPR_ASSERT(mcs);
|
|
|
|
WINPR_ASSERT(s);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2017-05-29 11:50:22 +03:00
|
|
|
if (!tpkt_read_header(s, &tlength))
|
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2020-02-20 10:22:19 +03:00
|
|
|
if (!tpdu_read_data(s, &li, tlength))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
if (!ber_read_application_tag(s, MCS_TYPE_CONNECT_INITIAL, &length))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* callingDomainSelector (OCTET_STRING) */
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!ber_read_octet_string_tag(s, &length) ||
|
|
|
|
(!Stream_CheckAndLogRequiredLength(TAG, s, length)))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, length);
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* calledDomainSelector (OCTET_STRING) */
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!ber_read_octet_string_tag(s, &length) ||
|
|
|
|
(!Stream_CheckAndLogRequiredLength(TAG, s, length)))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, length);
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* upwardFlag (BOOLEAN) */
|
2012-10-09 10:38:39 +04:00
|
|
|
if (!ber_read_BOOL(s, &upwardFlag))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* targetParameters (DomainParameters) */
|
2013-07-20 02:24:56 +04:00
|
|
|
if (!mcs_read_domain_parameters(s, &mcs->targetParameters))
|
2013-01-12 17:49:01 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* minimumParameters (DomainParameters) */
|
2013-07-20 02:24:56 +04:00
|
|
|
if (!mcs_read_domain_parameters(s, &mcs->minimumParameters))
|
2013-01-12 17:49:01 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* maximumParameters (DomainParameters) */
|
2013-07-20 02:24:56 +04:00
|
|
|
if (!mcs_read_domain_parameters(s, &mcs->maximumParameters))
|
2013-01-12 17:49:01 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!ber_read_octet_string_tag(s, &length) ||
|
|
|
|
(!Stream_CheckAndLogRequiredLength(TAG, s, length)))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_conference_create_request(s, mcs))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2014-02-14 02:06:33 +04:00
|
|
|
if (!mcs_merge_domain_parameters(&mcs->targetParameters, &mcs->minimumParameters,
|
2017-02-20 20:31:58 +03:00
|
|
|
&mcs->maximumParameters, &mcs->domainParameters))
|
2014-02-14 02:06:33 +04:00
|
|
|
return FALSE;
|
|
|
|
|
2020-02-20 10:22:19 +03:00
|
|
|
return tpkt_ensure_stream_consumed(s, tlength);
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2011-07-07 23:35:09 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Write an MCS Connect Initial PDU.
|
|
|
|
* msdn{cc240508}
|
2011-07-07 23:35:09 +04:00
|
|
|
* @param s stream
|
|
|
|
* @param mcs MCS module
|
2022-12-09 16:35:03 +03:00
|
|
|
* @param userData GCC Conference Create Request
|
2011-07-07 23:35:09 +04:00
|
|
|
*/
|
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
BOOL mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* userData)
|
2011-07-07 23:35:09 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t length = 0;
|
|
|
|
wStream* tmps = NULL;
|
2015-05-29 14:46:50 +03:00
|
|
|
BOOL ret = FALSE;
|
2011-07-07 23:35:09 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!s || !mcs || !userData)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
tmps = Stream_New(NULL, Stream_Capacity(s));
|
2011-07-07 23:35:09 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!tmps)
|
|
|
|
{
|
2015-05-29 14:46:50 +03:00
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-07-07 23:35:09 +04:00
|
|
|
/* callingDomainSelector (OCTET_STRING) */
|
2012-01-17 13:45:10 +04:00
|
|
|
ber_write_octet_string(tmps, callingDomainSelector, sizeof(callingDomainSelector));
|
2011-07-07 23:35:09 +04:00
|
|
|
/* calledDomainSelector (OCTET_STRING) */
|
2012-01-17 13:45:10 +04:00
|
|
|
ber_write_octet_string(tmps, calledDomainSelector, sizeof(calledDomainSelector));
|
2011-07-07 23:35:09 +04:00
|
|
|
/* upwardFlag (BOOLEAN) */
|
2012-10-09 10:38:39 +04:00
|
|
|
ber_write_BOOL(tmps, TRUE);
|
2011-07-07 23:35:09 +04:00
|
|
|
|
|
|
|
/* targetParameters (DomainParameters) */
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!mcs_write_domain_parameters(tmps, &mcs->targetParameters))
|
|
|
|
goto out;
|
2011-07-07 23:35:09 +04:00
|
|
|
|
|
|
|
/* minimumParameters (DomainParameters) */
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!mcs_write_domain_parameters(tmps, &mcs->minimumParameters))
|
|
|
|
goto out;
|
2011-07-07 23:35:09 +04:00
|
|
|
|
|
|
|
/* maximumParameters (DomainParameters) */
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!mcs_write_domain_parameters(tmps, &mcs->maximumParameters))
|
|
|
|
goto out;
|
2011-07-07 23:35:09 +04:00
|
|
|
|
|
|
|
/* userData (OCTET_STRING) */
|
2016-02-25 22:01:12 +03:00
|
|
|
ber_write_octet_string(tmps, Stream_Buffer(userData), Stream_GetPosition(userData));
|
2013-04-30 06:35:15 +04:00
|
|
|
length = Stream_GetPosition(tmps);
|
2011-07-09 00:05:30 +04:00
|
|
|
/* Connect-Initial (APPLICATION 101, IMPLICIT SEQUENCE) */
|
|
|
|
ber_write_application_tag(s, MCS_TYPE_CONNECT_INITIAL, length);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Write(s, Stream_Buffer(tmps), length);
|
2015-05-29 14:46:50 +03:00
|
|
|
ret = TRUE;
|
|
|
|
out:
|
2013-05-09 01:48:30 +04:00
|
|
|
Stream_Free(tmps, TRUE);
|
2015-05-29 14:46:50 +03:00
|
|
|
return ret;
|
2011-07-07 23:35:09 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 19:56:47 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Write an MCS Connect Response PDU.
|
|
|
|
* msdn{cc240508}
|
2011-08-19 19:56:47 +04:00
|
|
|
* @param s stream
|
|
|
|
* @param mcs MCS module
|
2022-12-09 16:35:03 +03:00
|
|
|
* @param userData GCC Conference Create Response
|
|
|
|
*
|
|
|
|
* @return \b TRUE for success, \b FALSE otherwise
|
2011-08-19 19:56:47 +04:00
|
|
|
*/
|
|
|
|
|
2015-04-01 18:55:01 +03:00
|
|
|
BOOL mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* userData)
|
2011-08-19 19:56:47 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t length = 0;
|
|
|
|
wStream* tmps = NULL;
|
2015-05-29 14:46:50 +03:00
|
|
|
BOOL ret = FALSE;
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!s || !mcs || !userData)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
tmps = Stream_New(NULL, Stream_Capacity(s));
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-04-01 18:55:01 +03:00
|
|
|
if (!tmps)
|
2015-05-29 14:46:50 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
2015-04-01 18:55:01 +03:00
|
|
|
return FALSE;
|
2015-05-29 14:46:50 +03:00
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2012-01-17 13:45:10 +04:00
|
|
|
ber_write_enumerated(tmps, 0, MCS_Result_enum_length);
|
|
|
|
ber_write_integer(tmps, 0); /* calledConnectId */
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!mcs_write_domain_parameters(tmps, &(mcs->domainParameters)))
|
|
|
|
goto out;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2011-08-19 19:56:47 +04:00
|
|
|
/* userData (OCTET_STRING) */
|
2016-02-25 22:01:12 +03:00
|
|
|
ber_write_octet_string(tmps, Stream_Buffer(userData), Stream_GetPosition(userData));
|
2013-04-30 06:35:15 +04:00
|
|
|
length = Stream_GetPosition(tmps);
|
2011-08-19 19:56:47 +04:00
|
|
|
ber_write_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, length);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Write(s, Stream_Buffer(tmps), length);
|
2015-05-29 14:46:50 +03:00
|
|
|
ret = TRUE;
|
|
|
|
out:
|
2013-05-09 01:48:30 +04:00
|
|
|
Stream_Free(tmps, TRUE);
|
2015-05-29 14:46:50 +03:00
|
|
|
return ret;
|
2011-08-19 19:56:47 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Send MCS Connect Initial.
|
|
|
|
* msdn{cc240508}
|
2011-07-11 22:47:55 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2022-03-18 12:57:47 +03:00
|
|
|
static BOOL mcs_send_connect_initial(rdpMcs* mcs)
|
2011-07-08 03:32:51 +04:00
|
|
|
{
|
2015-05-29 14:46:50 +03:00
|
|
|
int status = -1;
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t length = 0;
|
2015-05-29 14:46:50 +03:00
|
|
|
wStream* s = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t bm = 0;
|
|
|
|
size_t em = 0;
|
2015-05-29 14:46:50 +03:00
|
|
|
wStream* gcc_CCrq = NULL;
|
|
|
|
wStream* client_data = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpContext* context = NULL;
|
2011-07-08 03:32:51 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!mcs)
|
|
|
|
return FALSE;
|
2014-02-16 01:32:38 +04:00
|
|
|
|
2021-09-06 12:01:36 +03:00
|
|
|
context = transport_get_context(mcs->transport);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
|
|
|
|
mcs_initialize_client_channels(mcs, context->settings);
|
2013-05-09 01:48:30 +04:00
|
|
|
client_data = Stream_New(NULL, 512);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!client_data)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-07-08 03:32:51 +04:00
|
|
|
|
2021-01-21 16:24:38 +03:00
|
|
|
if (!gcc_write_client_data_blocks(client_data, mcs))
|
|
|
|
goto out;
|
2014-01-31 22:52:37 +04:00
|
|
|
gcc_CCrq = Stream_New(NULL, 1024);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!gcc_CCrq)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
goto out;
|
|
|
|
}
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2020-11-18 09:51:45 +03:00
|
|
|
if (!gcc_write_conference_create_request(gcc_CCrq, client_data))
|
|
|
|
goto out;
|
2013-04-30 06:35:15 +04:00
|
|
|
length = Stream_GetPosition(gcc_CCrq) + 7;
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, 1024 + length);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
goto out;
|
|
|
|
}
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2013-05-15 22:42:37 +04:00
|
|
|
bm = Stream_GetPosition(s);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 7);
|
2011-07-08 03:32:51 +04:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!mcs_write_connect_initial(s, mcs, gcc_CCrq))
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "mcs_write_connect_initial failed!");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2013-05-15 22:42:37 +04:00
|
|
|
em = Stream_GetPosition(s);
|
2011-07-08 08:37:25 +04:00
|
|
|
length = (em - bm);
|
2020-02-20 10:22:19 +03:00
|
|
|
if (length > UINT16_MAX)
|
|
|
|
goto out;
|
2013-05-15 22:42:37 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
2020-11-19 17:21:49 +03:00
|
|
|
if (!tpkt_write_header(s, (UINT16)length))
|
|
|
|
goto out;
|
2022-10-21 10:25:12 +03:00
|
|
|
if (!tpdu_write_data(s))
|
|
|
|
goto out;
|
2013-05-15 22:42:37 +04:00
|
|
|
Stream_SetPosition(s, em);
|
2013-05-15 20:14:26 +04:00
|
|
|
Stream_SealLength(s);
|
2011-08-22 11:03:58 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
2015-05-29 14:46:50 +03:00
|
|
|
out:
|
2013-05-15 21:17:29 +04:00
|
|
|
Stream_Free(s, TRUE);
|
2013-05-09 01:48:30 +04:00
|
|
|
Stream_Free(gcc_CCrq, TRUE);
|
|
|
|
Stream_Free(client_data, TRUE);
|
2012-10-09 10:31:28 +04:00
|
|
|
return (status < 0 ? FALSE : TRUE);
|
2011-07-08 03:32:51 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Read MCS Connect Response.
|
|
|
|
* msdn{cc240501}
|
2011-07-11 22:47:55 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL mcs_recv_connect_response(rdpMcs* mcs, wStream* s)
|
2011-07-09 23:28:59 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t length = 0;
|
|
|
|
UINT16 tlength = 0;
|
|
|
|
BYTE result = 0;
|
|
|
|
UINT16 li = 0;
|
|
|
|
UINT32 calledConnectId = 0;
|
2011-07-09 23:28:59 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!mcs || !s)
|
|
|
|
return FALSE;
|
|
|
|
|
2017-05-29 11:50:22 +03:00
|
|
|
if (!tpkt_read_header(s, &tlength))
|
|
|
|
return FALSE;
|
2011-07-18 10:34:28 +04:00
|
|
|
|
2020-02-20 10:22:19 +03:00
|
|
|
if (!tpdu_read_data(s, &li, tlength))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-07-09 23:28:59 +04:00
|
|
|
|
2013-07-20 02:24:56 +04:00
|
|
|
if (!ber_read_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, &length) ||
|
2017-02-20 20:31:58 +03:00
|
|
|
!ber_read_enumerated(s, &result, MCS_Result_enum_length) ||
|
|
|
|
!ber_read_integer(s, &calledConnectId) ||
|
|
|
|
!mcs_read_domain_parameters(s, &(mcs->domainParameters)) ||
|
|
|
|
!ber_read_octet_string_tag(s, &length))
|
2013-01-12 17:49:01 +04:00
|
|
|
{
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2013-01-12 17:49:01 +04:00
|
|
|
}
|
2011-07-09 23:28:59 +04:00
|
|
|
|
2014-02-14 02:50:38 +04:00
|
|
|
if (!gcc_read_conference_create_response(s, mcs))
|
2011-09-05 22:02:52 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
WLog_ERR(TAG, "gcc_read_conference_create_response failed");
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-09-05 22:02:52 +04:00
|
|
|
}
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2020-02-20 10:22:19 +03:00
|
|
|
return tpkt_ensure_stream_consumed(s, tlength);
|
2011-07-09 23:28:59 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Send MCS Connect Response.
|
|
|
|
* msdn{cc240501}
|
2011-08-19 13:39:37 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL mcs_send_connect_response(rdpMcs* mcs)
|
2011-08-19 13:39:37 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t length = 0;
|
2020-11-19 17:21:49 +03:00
|
|
|
int status = -1;
|
|
|
|
wStream* s = NULL;
|
2024-01-23 18:49:54 +03:00
|
|
|
size_t bm = 0;
|
|
|
|
size_t em = 0;
|
2020-11-19 17:21:49 +03:00
|
|
|
wStream* gcc_CCrsp = NULL;
|
|
|
|
wStream* server_data = NULL;
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!mcs)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
server_data = Stream_New(NULL, 512);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!server_data)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
if (!gcc_write_server_data_blocks(server_data, mcs))
|
2020-11-19 17:21:49 +03:00
|
|
|
goto out;
|
2015-04-01 16:11:57 +03:00
|
|
|
|
|
|
|
gcc_CCrsp = Stream_New(NULL, 512 + Stream_Capacity(server_data));
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
if (!gcc_CCrsp)
|
2015-05-29 14:46:50 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
2020-11-19 17:21:49 +03:00
|
|
|
goto out;
|
2015-05-29 14:46:50 +03:00
|
|
|
}
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2020-11-18 09:51:45 +03:00
|
|
|
if (!gcc_write_conference_create_response(gcc_CCrsp, server_data))
|
|
|
|
goto out;
|
2013-04-30 06:35:15 +04:00
|
|
|
length = Stream_GetPosition(gcc_CCrsp) + 7;
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, length + 1024);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-04-01 16:11:57 +03:00
|
|
|
if (!s)
|
2015-05-29 14:46:50 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
2020-11-19 17:21:49 +03:00
|
|
|
goto out;
|
2015-05-29 14:46:50 +03:00
|
|
|
}
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2013-05-15 22:42:37 +04:00
|
|
|
bm = Stream_GetPosition(s);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 7);
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2015-04-01 18:55:01 +03:00
|
|
|
if (!mcs_write_connect_response(s, mcs, gcc_CCrsp))
|
2020-11-19 17:21:49 +03:00
|
|
|
goto out;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2013-05-15 22:42:37 +04:00
|
|
|
em = Stream_GetPosition(s);
|
2011-08-19 19:56:47 +04:00
|
|
|
length = (em - bm);
|
2020-02-20 10:22:19 +03:00
|
|
|
if (length > UINT16_MAX)
|
2020-11-19 17:21:49 +03:00
|
|
|
goto out;
|
2013-05-15 22:42:37 +04:00
|
|
|
Stream_SetPosition(s, bm);
|
2020-11-19 17:21:49 +03:00
|
|
|
if (!tpkt_write_header(s, (UINT16)length))
|
|
|
|
goto out;
|
2022-10-21 10:25:12 +03:00
|
|
|
if (!tpdu_write_data(s))
|
|
|
|
goto out;
|
2013-05-15 22:42:37 +04:00
|
|
|
Stream_SetPosition(s, em);
|
2013-05-15 20:14:26 +04:00
|
|
|
Stream_SealLength(s);
|
2013-05-15 21:17:29 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
2020-11-19 17:21:49 +03:00
|
|
|
out:
|
2013-05-15 21:17:29 +04:00
|
|
|
Stream_Free(s, TRUE);
|
2013-05-09 01:48:30 +04:00
|
|
|
Stream_Free(gcc_CCrsp, TRUE);
|
|
|
|
Stream_Free(server_data, TRUE);
|
2013-05-15 21:17:29 +04:00
|
|
|
return (status < 0) ? FALSE : TRUE;
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 22:03:48 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Read MCS Erect Domain Request.
|
|
|
|
* msdn{cc240523}
|
|
|
|
* @param mcs MCS module to use
|
2011-08-19 22:03:48 +04:00
|
|
|
* @param s stream
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL mcs_recv_erect_domain_request(rdpMcs* mcs, wStream* s)
|
2011-08-19 22:03:48 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 length = 0;
|
|
|
|
UINT32 subHeight = 0;
|
|
|
|
UINT32 subInterval = 0;
|
2011-08-19 22:03:48 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
WINPR_ASSERT(mcs);
|
|
|
|
WINPR_ASSERT(s);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2022-03-18 12:57:47 +03:00
|
|
|
if (!mcs_read_domain_mcspdu_header(s, DomainMCSPDU_ErectDomainRequest, &length, NULL))
|
2014-01-24 02:41:05 +04:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!per_read_integer(s, &subHeight)) /* subHeight (INTEGER) */
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!per_read_integer(s, &subInterval)) /* subInterval (INTEGER) */
|
|
|
|
return FALSE;
|
|
|
|
|
2020-02-20 10:22:19 +03:00
|
|
|
return tpkt_ensure_stream_consumed(s, length);
|
2011-08-19 22:03:48 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Send MCS Erect Domain Request.
|
|
|
|
* msdn{cc240523}
|
|
|
|
* @param mcs MCS module to use
|
2011-07-11 22:47:55 +04:00
|
|
|
*/
|
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL mcs_send_erect_domain_request(rdpMcs* mcs)
|
2011-07-10 07:54:23 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
int status = 0;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 12;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!mcs)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, length);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-07-10 07:54:23 +04:00
|
|
|
|
2011-08-19 22:03:48 +04:00
|
|
|
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_ErectDomainRequest, length, 0);
|
2011-07-10 07:54:23 +04:00
|
|
|
per_write_integer(s, 0); /* subHeight (INTEGER) */
|
|
|
|
per_write_integer(s, 0); /* subInterval (INTEGER) */
|
2013-05-15 20:14:26 +04:00
|
|
|
Stream_SealLength(s);
|
2013-05-15 21:17:29 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
return (status < 0) ? FALSE : TRUE;
|
2011-07-10 07:54:23 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 22:03:48 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Read MCS Attach User Request.
|
|
|
|
* msdn{cc240524}
|
2011-08-19 22:03:48 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
* @param s stream
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL mcs_recv_attach_user_request(rdpMcs* mcs, wStream* s)
|
2011-08-19 22:03:48 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 length = 0;
|
2011-08-19 22:03:48 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!mcs || !s)
|
|
|
|
return FALSE;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2022-03-18 12:57:47 +03:00
|
|
|
if (!mcs_read_domain_mcspdu_header(s, DomainMCSPDU_AttachUserRequest, &length, NULL))
|
2020-02-20 10:22:19 +03:00
|
|
|
return FALSE;
|
|
|
|
return tpkt_ensure_stream_consumed(s, length);
|
2011-08-19 22:03:48 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Send MCS Attach User Request.
|
|
|
|
* msdn{cc240524}
|
2011-07-11 22:47:55 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL mcs_send_attach_user_request(rdpMcs* mcs)
|
2011-07-10 07:54:23 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
int status = 0;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 8;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!mcs)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, length);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-07-10 07:54:23 +04:00
|
|
|
|
2011-08-19 22:03:48 +04:00
|
|
|
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_AttachUserRequest, length, 0);
|
2013-05-15 20:14:26 +04:00
|
|
|
Stream_SealLength(s);
|
2013-05-15 21:17:29 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
return (status < 0) ? FALSE : TRUE;
|
2011-07-10 07:54:23 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Read MCS Attach User Confirm.
|
|
|
|
* msdn{cc240525}
|
2011-07-11 22:47:55 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL mcs_recv_attach_user_confirm(rdpMcs* mcs, wStream* s)
|
2011-07-10 07:54:23 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE result = 0;
|
|
|
|
UINT16 length = 0;
|
2011-07-10 07:54:23 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!mcs || !s)
|
|
|
|
return FALSE;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2022-03-18 12:57:47 +03:00
|
|
|
if (!mcs_read_domain_mcspdu_header(s, DomainMCSPDU_AttachUserConfirm, &length, NULL))
|
2020-02-20 10:22:19 +03:00
|
|
|
return FALSE;
|
|
|
|
if (!per_read_enumerated(s, &result, MCS_Result_enum_length)) /* result */
|
|
|
|
return FALSE;
|
|
|
|
if (!per_read_integer16(s, &(mcs->userId), MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
|
|
|
return FALSE;
|
|
|
|
return tpkt_ensure_stream_consumed(s, length);
|
2011-07-10 07:54:23 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 22:03:48 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Send MCS Attach User Confirm.
|
|
|
|
* msdn{cc240525}
|
2011-08-19 22:03:48 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL mcs_send_attach_user_confirm(rdpMcs* mcs)
|
2011-08-19 22:03:48 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
int status = 0;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 11;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
|
|
|
if (!mcs)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, length);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-10-28 11:06:04 +03:00
|
|
|
mcs->userId = mcs->baseChannelId++;
|
2011-08-19 22:03:48 +04:00
|
|
|
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_AttachUserConfirm, length, 2);
|
2019-11-06 17:24:51 +03:00
|
|
|
per_write_enumerated(s, 0, MCS_Result_enum_length); /* result */
|
2014-02-14 02:06:33 +04:00
|
|
|
per_write_integer16(s, mcs->userId, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
|
2013-05-15 20:14:26 +04:00
|
|
|
Stream_SealLength(s);
|
2013-05-15 21:17:29 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
return (status < 0) ? FALSE : TRUE;
|
2011-08-19 22:03:48 +04:00
|
|
|
}
|
|
|
|
|
2011-08-20 10:05:03 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Read MCS Channel Join Request.
|
|
|
|
* msdn{cc240526}
|
2011-08-20 10:05:03 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
* @param s stream
|
|
|
|
*/
|
|
|
|
|
2022-10-10 12:31:22 +03:00
|
|
|
BOOL mcs_recv_channel_join_request(rdpMcs* mcs, const rdpSettings* settings, wStream* s,
|
|
|
|
UINT16* channelId)
|
2011-08-20 10:05:03 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 length = 0;
|
|
|
|
UINT16 userId = 0;
|
2011-08-20 10:05:03 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!mcs || !s || !channelId)
|
|
|
|
return FALSE;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2022-03-18 12:57:47 +03:00
|
|
|
if (!mcs_read_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinRequest, &length, NULL))
|
2020-02-20 10:22:19 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2022-10-10 12:31:22 +03:00
|
|
|
if (!per_read_integer16(s, &userId, MCS_BASE_CHANNEL_ID))
|
2020-02-20 10:22:19 +03:00
|
|
|
return FALSE;
|
2022-10-10 12:31:22 +03:00
|
|
|
if (userId != mcs->userId)
|
|
|
|
{
|
|
|
|
if (freerdp_settings_get_bool(settings, FreeRDP_TransportDumpReplay))
|
|
|
|
mcs->userId = userId;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
2020-02-20 10:22:19 +03:00
|
|
|
if (!per_read_integer16(s, channelId, 0))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return tpkt_ensure_stream_consumed(s, length);
|
2011-08-20 10:05:03 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Send MCS Channel Join Request.
|
|
|
|
* msdn{cc240526}
|
|
|
|
*
|
2011-07-11 22:47:55 +04:00
|
|
|
* @param mcs mcs module
|
2022-12-09 16:35:03 +03:00
|
|
|
* @param channelId channel id
|
|
|
|
*
|
|
|
|
* @return \b TRUE for success, \b FALSE otherwise
|
2011-07-11 22:47:55 +04:00
|
|
|
*/
|
|
|
|
|
2014-02-14 02:06:33 +04:00
|
|
|
BOOL mcs_send_channel_join_request(rdpMcs* mcs, UINT16 channelId)
|
2011-07-10 07:54:23 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
int status = 0;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 12;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2023-03-02 17:27:27 +03:00
|
|
|
WINPR_ASSERT(mcs);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, length);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-07-10 07:54:23 +04:00
|
|
|
|
2011-08-19 22:03:48 +04:00
|
|
|
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinRequest, length, 0);
|
2014-02-14 02:06:33 +04:00
|
|
|
per_write_integer16(s, mcs->userId, MCS_BASE_CHANNEL_ID);
|
|
|
|
per_write_integer16(s, channelId, 0);
|
2013-05-15 20:14:26 +04:00
|
|
|
Stream_SealLength(s);
|
2013-05-15 21:17:29 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
return (status < 0) ? FALSE : TRUE;
|
2011-07-10 07:54:23 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Read MCS Channel Join Confirm.
|
|
|
|
* msdn{cc240527}
|
2011-07-11 22:47:55 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:06:33 +04:00
|
|
|
BOOL mcs_recv_channel_join_confirm(rdpMcs* mcs, wStream* s, UINT16* channelId)
|
2011-07-10 07:54:23 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
UINT16 length = 0;
|
|
|
|
BYTE result = 0;
|
|
|
|
UINT16 initiator = 0;
|
|
|
|
UINT16 requested = 0;
|
2011-07-10 07:54:23 +04:00
|
|
|
|
2023-03-02 17:27:27 +03:00
|
|
|
WINPR_ASSERT(mcs);
|
|
|
|
WINPR_ASSERT(channelId);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2022-03-18 12:57:47 +03:00
|
|
|
if (!mcs_read_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinConfirm, &length, NULL))
|
2020-02-20 10:22:19 +03:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!per_read_enumerated(s, &result, MCS_Result_enum_length)) /* result */
|
|
|
|
return FALSE;
|
|
|
|
if (!per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
|
|
|
return FALSE;
|
|
|
|
if (!per_read_integer16(s, &requested, 0)) /* requested (ChannelId) */
|
|
|
|
return FALSE;
|
|
|
|
if (!per_read_integer16(s, channelId, 0)) /* channelId */
|
|
|
|
return FALSE;
|
|
|
|
return tpkt_ensure_stream_consumed(s, length);
|
2011-07-10 07:54:23 +04:00
|
|
|
}
|
|
|
|
|
2011-08-20 10:05:03 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Send MCS Channel Join Confirm.
|
|
|
|
* msdn{cc240527}
|
2011-08-20 10:05:03 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2014-02-14 02:06:33 +04:00
|
|
|
BOOL mcs_send_channel_join_confirm(rdpMcs* mcs, UINT16 channelId)
|
2011-08-20 10:05:03 +04:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
wStream* s = NULL;
|
2022-10-10 12:31:22 +03:00
|
|
|
int status = -1;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 15;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2017-02-20 20:31:58 +03:00
|
|
|
if (!mcs)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, length);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-20 10:05:03 +04:00
|
|
|
|
2022-10-10 12:31:22 +03:00
|
|
|
if (!mcs_write_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinConfirm, length, 2))
|
|
|
|
goto fail;
|
|
|
|
if (!per_write_enumerated(s, 0, MCS_Result_enum_length)) /* result */
|
|
|
|
goto fail;
|
|
|
|
if (!per_write_integer16(s, mcs->userId, MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
|
|
|
goto fail;
|
|
|
|
if (!per_write_integer16(s, channelId, 0)) /* requested (ChannelId) */
|
|
|
|
goto fail;
|
|
|
|
if (!per_write_integer16(s, channelId, 0)) /* channelId */
|
|
|
|
goto fail;
|
2013-05-15 20:14:26 +04:00
|
|
|
Stream_SealLength(s);
|
2013-05-15 21:17:29 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
2022-10-10 12:31:22 +03:00
|
|
|
fail:
|
2013-05-15 21:17:29 +04:00
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
return (status < 0) ? FALSE : TRUE;
|
2011-08-20 10:05:03 +04:00
|
|
|
}
|
|
|
|
|
2013-11-15 08:05:29 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Receive MCS Disconnect Provider Ultimatum PDU.
|
2013-11-15 08:05:29 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL mcs_recv_disconnect_provider_ultimatum(rdpMcs* mcs, wStream* s, int* reason)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
BYTE b1 = 0;
|
|
|
|
BYTE b2 = 0;
|
2013-11-15 08:05:29 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
WINPR_ASSERT(mcs);
|
|
|
|
WINPR_ASSERT(s);
|
|
|
|
WINPR_ASSERT(reason);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2013-11-15 08:05:29 +04:00
|
|
|
/*
|
|
|
|
* http://msdn.microsoft.com/en-us/library/cc240872.aspx:
|
|
|
|
*
|
|
|
|
* PER encoded (ALIGNED variant of BASIC-PER) PDU contents:
|
|
|
|
* 21 80
|
|
|
|
*
|
|
|
|
* 0x21:
|
|
|
|
* 0 - --\
|
|
|
|
* 0 - |
|
|
|
|
* 1 - | CHOICE: From DomainMCSPDU select disconnectProviderUltimatum (8)
|
|
|
|
* 0 - | of type DisconnectProviderUltimatum
|
|
|
|
* 0 - |
|
|
|
|
* 0 - --/
|
|
|
|
* 0 - --\
|
|
|
|
* 1 - |
|
|
|
|
* | DisconnectProviderUltimatum::reason = rn-user-requested (3)
|
|
|
|
* 0x80: |
|
|
|
|
* 1 - --/
|
|
|
|
* 0 - padding
|
|
|
|
* 0 - padding
|
|
|
|
* 0 - padding
|
|
|
|
* 0 - padding
|
|
|
|
* 0 - padding
|
|
|
|
* 0 - padding
|
|
|
|
* 0 - padding
|
|
|
|
*/
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
2013-11-15 08:05:29 +04:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Rewind_UINT8(s);
|
|
|
|
Stream_Read_UINT8(s, b1);
|
|
|
|
Stream_Read_UINT8(s, b2);
|
|
|
|
*reason = ((b1 & 0x01) << 1) | (b2 >> 7);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-08-26 14:14:34 +04:00
|
|
|
/**
|
2022-12-09 16:35:03 +03:00
|
|
|
* Send MCS Disconnect Provider Ultimatum PDU.
|
2011-08-26 14:14:34 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL mcs_send_disconnect_provider_ultimatum(rdpMcs* mcs)
|
2011-08-26 14:14:34 +04:00
|
|
|
{
|
2023-01-26 16:48:17 +03:00
|
|
|
wStream* s = NULL;
|
|
|
|
int status = -1;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 9;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
WINPR_ASSERT(mcs);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, length);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
2015-05-29 14:46:50 +03:00
|
|
|
if (!s)
|
2023-01-26 16:48:17 +03:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
if (!mcs_write_domain_mcspdu_header(s, DomainMCSPDU_DisconnectProviderUltimatum, length, 1))
|
|
|
|
goto fail;
|
2011-08-26 14:14:34 +04:00
|
|
|
|
2023-01-26 16:48:17 +03:00
|
|
|
if (!per_write_enumerated(s, 0x80, 0))
|
|
|
|
goto fail;
|
2013-05-15 21:17:29 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
2023-01-26 16:48:17 +03:00
|
|
|
fail:
|
2013-05-15 21:17:29 +04:00
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
return (status < 0) ? FALSE : TRUE;
|
2011-08-26 14:14:34 +04:00
|
|
|
}
|
|
|
|
|
2015-02-16 00:04:59 +03:00
|
|
|
BOOL mcs_client_begin(rdpMcs* mcs)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpContext* context = NULL;
|
2017-02-20 20:31:58 +03:00
|
|
|
|
|
|
|
if (!mcs || !mcs->transport)
|
|
|
|
return FALSE;
|
|
|
|
|
2021-09-06 12:01:36 +03:00
|
|
|
context = transport_get_context(mcs->transport);
|
2017-02-20 20:31:58 +03:00
|
|
|
|
|
|
|
if (!context)
|
|
|
|
return FALSE;
|
2015-02-16 00:04:59 +03:00
|
|
|
|
2022-03-18 12:57:47 +03:00
|
|
|
/* First transition state, we need this to trigger session recording */
|
2015-02-16 00:04:59 +03:00
|
|
|
if (!mcs_send_connect_initial(mcs))
|
|
|
|
{
|
2020-01-09 12:34:27 +03:00
|
|
|
freerdp_set_last_error_if_not(context, FREERDP_ERROR_MCS_CONNECT_INITIAL_ERROR);
|
2015-02-16 00:04:59 +03:00
|
|
|
|
|
|
|
WLog_ERR(TAG, "Error: unable to send MCS Connect Initial");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-07-07 23:35:09 +04:00
|
|
|
/**
|
|
|
|
* Instantiate new MCS module.
|
|
|
|
* @param transport transport
|
|
|
|
* @return new MCS module
|
|
|
|
*/
|
|
|
|
|
|
|
|
rdpMcs* mcs_new(rdpTransport* transport)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpMcs* mcs = NULL;
|
2011-07-07 23:35:09 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
mcs = (rdpMcs*)calloc(1, sizeof(rdpMcs));
|
2014-10-11 00:11:42 +04:00
|
|
|
|
2014-05-21 17:54:25 +04:00
|
|
|
if (!mcs)
|
|
|
|
return NULL;
|
2011-07-07 23:35:09 +04:00
|
|
|
|
2014-05-21 17:54:25 +04:00
|
|
|
mcs->transport = transport;
|
|
|
|
mcs_init_domain_parameters(&mcs->targetParameters, 34, 2, 0, 0xFFFF);
|
|
|
|
mcs_init_domain_parameters(&mcs->minimumParameters, 1, 1, 1, 0x420);
|
|
|
|
mcs_init_domain_parameters(&mcs->maximumParameters, 0xFFFF, 0xFC17, 0xFFFF, 0xFFFF);
|
|
|
|
mcs_init_domain_parameters(&mcs->domainParameters, 0, 0, 0, 0xFFFF);
|
|
|
|
mcs->channelCount = 0;
|
|
|
|
mcs->channelMaxCount = CHANNEL_MAX_COUNT;
|
2014-10-11 00:11:42 +04:00
|
|
|
mcs->baseChannelId = MCS_GLOBAL_CHANNEL_ID + 1;
|
2019-11-06 17:24:51 +03:00
|
|
|
mcs->channels = (rdpMcsChannel*)calloc(mcs->channelMaxCount, sizeof(rdpMcsChannel));
|
2014-10-11 00:11:42 +04:00
|
|
|
|
2014-05-21 17:54:25 +04:00
|
|
|
if (!mcs->channels)
|
|
|
|
goto out_free;
|
2011-07-07 23:35:09 +04:00
|
|
|
|
|
|
|
return mcs;
|
2014-05-21 17:54:25 +04:00
|
|
|
out_free:
|
|
|
|
free(mcs);
|
|
|
|
return NULL;
|
2011-07-07 23:35:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Free MCS module.
|
|
|
|
* @param mcs MCS module to be freed
|
|
|
|
*/
|
|
|
|
|
|
|
|
void mcs_free(rdpMcs* mcs)
|
|
|
|
{
|
2014-02-14 02:06:33 +04:00
|
|
|
if (mcs)
|
2011-07-07 23:35:09 +04:00
|
|
|
{
|
2014-04-09 20:28:03 +04:00
|
|
|
free(mcs->channels);
|
2012-10-09 07:21:26 +04:00
|
|
|
free(mcs);
|
2011-07-07 23:35:09 +04:00
|
|
|
}
|
|
|
|
}
|
2022-10-10 12:31:22 +03:00
|
|
|
|
|
|
|
BOOL mcs_server_apply_to_settings(const rdpMcs* mcs, rdpSettings* settings)
|
|
|
|
{
|
2023-01-18 13:07:58 +03:00
|
|
|
BOOL rc = FALSE;
|
2022-10-10 12:31:22 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(mcs);
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
|
|
|
if (!freerdp_settings_set_uint32(settings, FreeRDP_ChannelCount, mcs->channelCount))
|
2023-01-18 13:07:58 +03:00
|
|
|
goto fail;
|
2022-10-10 12:31:22 +03:00
|
|
|
|
2023-01-18 13:07:58 +03:00
|
|
|
for (UINT32 x = 0; x < mcs->channelCount; x++)
|
2022-10-10 12:31:22 +03:00
|
|
|
{
|
|
|
|
const rdpMcsChannel* current = &mcs->channels[x];
|
|
|
|
CHANNEL_DEF def = { 0 };
|
|
|
|
def.options = current->options;
|
|
|
|
memcpy(def.name, current->Name, sizeof(def.name));
|
|
|
|
if (!freerdp_settings_set_pointer_array(settings, FreeRDP_ChannelDefArray, x, &def))
|
2023-01-18 13:07:58 +03:00
|
|
|
goto fail;
|
2022-10-10 12:31:22 +03:00
|
|
|
}
|
|
|
|
|
2023-01-18 13:07:58 +03:00
|
|
|
rc = TRUE;
|
|
|
|
fail:
|
|
|
|
if (!rc)
|
2023-01-23 14:03:18 +03:00
|
|
|
WLog_WARN(TAG, "failed to apply settings");
|
2023-01-18 13:07:58 +03:00
|
|
|
|
|
|
|
return rc;
|
2022-10-10 12:31:22 +03:00
|
|
|
}
|