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>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-11-22 04:22:41 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
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"
|
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
|
|
|
{
|
|
|
|
"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-12-01 02:40:36 +04:00
|
|
|
*/
|
2011-07-09 23:28:59 +04:00
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
|
|
|
* Read a DomainMCSPDU header.
|
|
|
|
* @param s stream
|
|
|
|
* @param domainMCSPDU DomainMCSPDU type
|
|
|
|
* @param length TPKT length
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL mcs_read_domain_mcspdu_header(wStream* s, enum DomainMCSPDU* domainMCSPDU, UINT16* length)
|
2011-07-11 22:47:55 +04:00
|
|
|
{
|
2013-02-15 05:39:56 +04:00
|
|
|
UINT16 li;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE choice;
|
2011-07-11 22:47:55 +04:00
|
|
|
enum DomainMCSPDU MCSPDU;
|
|
|
|
|
|
|
|
*length = tpkt_read_header(s);
|
2011-07-18 10:34:28 +04:00
|
|
|
|
2013-01-12 17:49:01 +04:00
|
|
|
if (!tpdu_read_data(s, &li))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-07-11 22:47:55 +04:00
|
|
|
|
|
|
|
MCSPDU = *domainMCSPDU;
|
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
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
*domainMCSPDU = (choice >> 2);
|
|
|
|
|
|
|
|
if (*domainMCSPDU != MCSPDU)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
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
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
void mcs_write_domain_mcspdu_header(wStream* s, enum DomainMCSPDU domainMCSPDU, UINT16 length, BYTE options)
|
2011-07-11 22:47:55 +04:00
|
|
|
{
|
|
|
|
tpkt_write_header(s, length);
|
|
|
|
tpdu_write_data(s);
|
2011-08-19 22:03:48 +04:00
|
|
|
per_write_choice(s, (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
|
|
|
|
*/
|
|
|
|
|
2011-07-10 07:54:23 +04:00
|
|
|
static void mcs_init_domain_parameters(DomainParameters* domainParameters,
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 maxChannelIds, UINT32 maxUserIds, UINT32 maxTokenIds, UINT32 maxMCSPDUsize)
|
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;
|
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
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL mcs_read_domain_parameters(wStream* s, DomainParameters* domainParameters)
|
2011-07-09 23:28:59 +04:00
|
|
|
{
|
|
|
|
int length;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2013-01-12 17:49:01 +04: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
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
void mcs_write_domain_parameters(wStream* s, DomainParameters* domainParameters)
|
2011-07-07 23:35:09 +04:00
|
|
|
{
|
2011-07-09 00:05:30 +04:00
|
|
|
int length;
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* tmps;
|
2012-01-17 13:45:10 +04:00
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
tmps = Stream_New(NULL, Stream_Capacity(s));
|
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);
|
2011-07-07 23:35:09 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
|
|
|
* Print MCS Domain Parameters.
|
|
|
|
* @param domainParameters domain parameters
|
|
|
|
*/
|
|
|
|
|
2011-07-10 07:54:23 +04:00
|
|
|
void mcs_print_domain_parameters(DomainParameters* domainParameters)
|
2011-07-09 23:28:59 +04:00
|
|
|
{
|
2013-03-29 02:06:34 +04:00
|
|
|
fprintf(stderr, "DomainParameters {\n");
|
|
|
|
fprintf(stderr, "\tmaxChannelIds:%d\n", domainParameters->maxChannelIds);
|
|
|
|
fprintf(stderr, "\tmaxUserIds:%d\n", domainParameters->maxUserIds);
|
|
|
|
fprintf(stderr, "\tmaxTokenIds:%d\n", domainParameters->maxTokenIds);
|
|
|
|
fprintf(stderr, "\tnumPriorities:%d\n", domainParameters->numPriorities);
|
|
|
|
fprintf(stderr, "\tminThroughput:%d\n", domainParameters->minThroughput);
|
|
|
|
fprintf(stderr, "\tmaxHeight:%d\n", domainParameters->maxHeight);
|
|
|
|
fprintf(stderr, "\tmaxMCSPDUsize:%d\n", domainParameters->maxMCSPDUsize);
|
|
|
|
fprintf(stderr, "\tprotocolVersion:%d\n", domainParameters->protocolVersion);
|
|
|
|
fprintf(stderr, "}\n");
|
2011-07-09 23:28:59 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/**
|
|
|
|
* Read an MCS Connect Initial PDU.\n
|
|
|
|
* @msdn{cc240508}
|
|
|
|
* @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
|
|
|
{
|
2013-01-12 17:49:01 +04:00
|
|
|
UINT16 li;
|
2011-08-19 13:39:37 +04:00
|
|
|
int length;
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL upwardFlag;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
tpkt_read_header(s);
|
|
|
|
|
2013-01-12 17:49:01 +04:00
|
|
|
if (!tpdu_read_data(s, &li))
|
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) */
|
2013-04-30 06:35:15 +04:00
|
|
|
if (!ber_read_octet_string_tag(s, &length) || Stream_GetRemainingLength(s) < length)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, length);
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* calledDomainSelector (OCTET_STRING) */
|
2013-04-30 06:35:15 +04:00
|
|
|
if (!ber_read_octet_string_tag(s, &length) || Stream_GetRemainingLength(s) < length)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
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-01-12 17:49:01 +04:00
|
|
|
if(!mcs_read_domain_parameters(s, &mcs->targetParameters))
|
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* minimumParameters (DomainParameters) */
|
2013-01-12 17:49:01 +04:00
|
|
|
if(!mcs_read_domain_parameters(s, &mcs->minimumParameters))
|
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
/* maximumParameters (DomainParameters) */
|
2013-01-12 17:49:01 +04:00
|
|
|
if(!mcs_read_domain_parameters(s, &mcs->maximumParameters))
|
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2013-04-30 06:35:15 +04:00
|
|
|
if (!ber_read_octet_string_tag(s, &length) || Stream_GetRemainingLength(s) < length)
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
|
|
|
if (!gcc_read_conference_create_request(s, mcs->transport->settings))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-19 13:39:37 +04:00
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-19 13:39:37 +04:00
|
|
|
}
|
|
|
|
|
2011-07-07 23:35:09 +04:00
|
|
|
/**
|
2011-07-11 23:58:39 +04:00
|
|
|
* Write an MCS Connect Initial PDU.\n
|
|
|
|
* @msdn{cc240508}
|
2011-07-07 23:35:09 +04:00
|
|
|
* @param s stream
|
|
|
|
* @param mcs MCS module
|
|
|
|
* @param user_data GCC Conference Create Request
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
void mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* user_data)
|
2011-07-07 23:35:09 +04:00
|
|
|
{
|
|
|
|
int length;
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* tmps;
|
2011-07-07 23:35:09 +04:00
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
tmps = Stream_New(NULL, Stream_Capacity(s));
|
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) */
|
2012-01-17 13:45:10 +04:00
|
|
|
mcs_write_domain_parameters(tmps, &mcs->targetParameters);
|
2011-07-07 23:35:09 +04:00
|
|
|
|
|
|
|
/* minimumParameters (DomainParameters) */
|
2012-01-17 13:45:10 +04:00
|
|
|
mcs_write_domain_parameters(tmps, &mcs->minimumParameters);
|
2011-07-07 23:35:09 +04:00
|
|
|
|
|
|
|
/* maximumParameters (DomainParameters) */
|
2012-01-17 13:45:10 +04:00
|
|
|
mcs_write_domain_parameters(tmps, &mcs->maximumParameters);
|
2011-07-07 23:35:09 +04:00
|
|
|
|
|
|
|
/* userData (OCTET_STRING) */
|
2013-04-30 06:35:15 +04:00
|
|
|
ber_write_octet_string(tmps, user_data->buffer, Stream_GetPosition(user_data));
|
2011-07-09 00:05:30 +04:00
|
|
|
|
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);
|
2013-05-09 01:48:30 +04:00
|
|
|
Stream_Free(tmps, TRUE);
|
2011-07-07 23:35:09 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 19:56:47 +04:00
|
|
|
/**
|
|
|
|
* Write an MCS Connect Response PDU.\n
|
|
|
|
* @msdn{cc240508}
|
|
|
|
* @param s stream
|
|
|
|
* @param mcs MCS module
|
|
|
|
* @param user_data GCC Conference Create Response
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
void mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* user_data)
|
2011-08-19 19:56:47 +04:00
|
|
|
{
|
|
|
|
int length;
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* tmps;
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
tmps = Stream_New(NULL, Stream_Capacity(s));
|
2012-01-17 13:45:10 +04:00
|
|
|
ber_write_enumerated(tmps, 0, MCS_Result_enum_length);
|
|
|
|
ber_write_integer(tmps, 0); /* calledConnectId */
|
2011-08-19 19:56:47 +04:00
|
|
|
mcs->domainParameters = mcs->targetParameters;
|
2012-01-17 13:45:10 +04:00
|
|
|
mcs_write_domain_parameters(tmps, &(mcs->domainParameters));
|
2011-08-19 19:56:47 +04:00
|
|
|
/* userData (OCTET_STRING) */
|
2013-04-30 06:35:15 +04:00
|
|
|
ber_write_octet_string(tmps, user_data->buffer, Stream_GetPosition(user_data));
|
2011-08-19 19:56:47 +04:00
|
|
|
|
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);
|
2013-05-09 01:48:30 +04:00
|
|
|
Stream_Free(tmps, TRUE);
|
2011-08-19 19:56:47 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2011-07-11 23:58:39 +04:00
|
|
|
* Send MCS Connect Initial.\n
|
|
|
|
* @msdn{cc240508}
|
2011-07-11 22:47:55 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL mcs_send_connect_initial(rdpMcs* mcs)
|
2011-07-08 03:32:51 +04:00
|
|
|
{
|
2013-05-15 21:17:29 +04:00
|
|
|
int status;
|
2011-07-08 03:32:51 +04:00
|
|
|
int length;
|
2013-05-15 21:17:29 +04:00
|
|
|
wStream* s;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE *bm, *em;
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* gcc_CCrq;
|
|
|
|
wStream* client_data;
|
2011-07-08 03:32:51 +04:00
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
client_data = Stream_New(NULL, 512);
|
2011-07-10 07:54:23 +04:00
|
|
|
gcc_write_client_data_blocks(client_data, mcs->transport->settings);
|
2011-07-08 03:32:51 +04:00
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
gcc_CCrq = Stream_New(NULL, 512);
|
2011-07-10 01:28:30 +04:00
|
|
|
gcc_write_conference_create_request(gcc_CCrq, client_data);
|
2013-04-30 06:35:15 +04:00
|
|
|
length = Stream_GetPosition(gcc_CCrq) + 7;
|
2011-07-08 03:32:51 +04:00
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, 1024 + length);
|
|
|
|
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_GetPointer(s, bm);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 7);
|
2011-07-08 03:32:51 +04:00
|
|
|
|
|
|
|
mcs_write_connect_initial(s, mcs, gcc_CCrq);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_GetPointer(s, em);
|
2011-07-08 08:37:25 +04:00
|
|
|
length = (em - bm);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_SetPointer(s, bm);
|
2011-07-08 03:32:51 +04:00
|
|
|
|
|
|
|
tpkt_write_header(s, length);
|
2011-07-10 20:10:24 +04:00
|
|
|
tpdu_write_data(s);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_SetPointer(s, em);
|
2013-05-15 20:14:26 +04:00
|
|
|
Stream_SealLength(s);
|
2011-07-08 03:32:51 +04:00
|
|
|
|
2011-08-22 11:03:58 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
2011-07-11 22:47:55 +04:00
|
|
|
|
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);
|
2011-08-22 11:03:58 +04:00
|
|
|
|
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
|
|
|
/**
|
2011-08-22 11:03:58 +04:00
|
|
|
* Read MCS Connect Response.\n
|
2011-07-11 23:58:39 +04:00
|
|
|
* @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
|
|
|
{
|
|
|
|
int length;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE result;
|
2013-01-12 17:49:01 +04:00
|
|
|
UINT16 li;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 calledConnectId;
|
2011-07-09 23:28:59 +04:00
|
|
|
|
|
|
|
tpkt_read_header(s);
|
2011-07-18 10:34:28 +04:00
|
|
|
|
2013-01-12 17:49:01 +04:00
|
|
|
if (!tpdu_read_data(s, &li))
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-07-09 23:28:59 +04:00
|
|
|
|
2013-01-12 17:49:01 +04:00
|
|
|
if(!ber_read_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, &length) ||
|
|
|
|
!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))
|
|
|
|
{
|
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
|
|
|
|
2011-08-22 11:03:58 +04:00
|
|
|
if (!gcc_read_conference_create_response(s, mcs->transport->settings))
|
2011-09-05 22:02:52 +04:00
|
|
|
{
|
2013-03-29 02:06:34 +04:00
|
|
|
fprintf(stderr, "mcs_recv_connect_response: gcc_read_conference_create_response failed\n");
|
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
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-07-09 23:28:59 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 13:39:37 +04:00
|
|
|
/**
|
|
|
|
* Send MCS Connect Response.\n
|
|
|
|
* @msdn{cc240501}
|
|
|
|
* @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
|
|
|
{
|
2011-08-19 19:56:47 +04:00
|
|
|
int length;
|
2013-05-15 21:17:29 +04:00
|
|
|
int status;
|
|
|
|
wStream* s;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE *bm, *em;
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* gcc_CCrsp;
|
|
|
|
wStream* server_data;
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
server_data = Stream_New(NULL, 512);
|
2011-08-19 19:56:47 +04:00
|
|
|
gcc_write_server_data_blocks(server_data, mcs->transport->settings);
|
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
gcc_CCrsp = Stream_New(NULL, 512);
|
2011-08-19 19:56:47 +04:00
|
|
|
gcc_write_conference_create_response(gcc_CCrsp, server_data);
|
2013-04-30 06:35:15 +04:00
|
|
|
length = Stream_GetPosition(gcc_CCrsp) + 7;
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, length + 1024);
|
|
|
|
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_GetPointer(s, bm);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 7);
|
2011-08-19 19:56:47 +04:00
|
|
|
|
|
|
|
mcs_write_connect_response(s, mcs, gcc_CCrsp);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_GetPointer(s, em);
|
2011-08-19 19:56:47 +04:00
|
|
|
length = (em - bm);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_SetPointer(s, bm);
|
2011-08-19 19:56:47 +04:00
|
|
|
|
|
|
|
tpkt_write_header(s, length);
|
|
|
|
tpdu_write_data(s);
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_SetPointer(s, em);
|
2013-05-15 20:14:26 +04:00
|
|
|
Stream_SealLength(s);
|
2011-08-19 19:56:47 +04:00
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
2011-08-19 19:56:47 +04:00
|
|
|
|
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);
|
2011-08-19 19:56:47 +04:00
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Read MCS Erect Domain Request.\n
|
|
|
|
* @msdn{cc240523}
|
|
|
|
* @param mcs
|
|
|
|
* @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
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length;
|
2011-08-19 22:03:48 +04:00
|
|
|
enum DomainMCSPDU MCSPDU;
|
|
|
|
|
|
|
|
MCSPDU = DomainMCSPDU_ErectDomainRequest;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2013-01-12 17:49:01 +04:00
|
|
|
return mcs_read_domain_mcspdu_header(s, &MCSPDU, &length);
|
2011-08-19 22:03:48 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2011-07-11 23:58:39 +04:00
|
|
|
* Send MCS Erect Domain Request.\n
|
|
|
|
* @msdn{cc240523}
|
2011-07-11 22:47:55 +04:00
|
|
|
* @param mcs
|
|
|
|
*/
|
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL mcs_send_erect_domain_request(rdpMcs* mcs)
|
2011-07-10 07:54:23 +04:00
|
|
|
{
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* s;
|
2013-05-15 21:17:29 +04:00
|
|
|
int status;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 12;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
|
|
|
s = Stream_New(NULL, length);
|
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);
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
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
|
|
|
/**
|
|
|
|
* Read MCS Attach User Request.\n
|
|
|
|
* @msdn{cc240524}
|
|
|
|
* @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
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length;
|
2011-08-19 22:03:48 +04:00
|
|
|
enum DomainMCSPDU MCSPDU;
|
|
|
|
|
|
|
|
MCSPDU = DomainMCSPDU_AttachUserRequest;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2013-01-12 17:49:01 +04:00
|
|
|
return mcs_read_domain_mcspdu_header(s, &MCSPDU, &length);
|
2011-08-19 22:03:48 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2011-07-11 23:58:39 +04:00
|
|
|
* Send MCS Attach User Request.\n
|
|
|
|
* @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
|
|
|
{
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* s;
|
2013-05-15 21:17:29 +04:00
|
|
|
int status;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 8;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
|
|
|
s = Stream_New(NULL, length);
|
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);
|
2011-07-10 07:54:23 +04:00
|
|
|
|
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);
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
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
|
|
|
/**
|
2011-08-22 11:03:58 +04:00
|
|
|
* Read MCS Attach User Confirm.\n
|
2011-07-11 23:58:39 +04:00
|
|
|
* @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
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length;
|
|
|
|
BYTE result;
|
2011-07-11 22:47:55 +04:00
|
|
|
enum DomainMCSPDU MCSPDU;
|
2011-07-10 07:54:23 +04:00
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
MCSPDU = DomainMCSPDU_AttachUserConfirm;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2013-01-12 17:49:01 +04:00
|
|
|
return
|
|
|
|
mcs_read_domain_mcspdu_header(s, &MCSPDU, &length) &&
|
|
|
|
per_read_enumerated(s, &result, MCS_Result_enum_length) && /* result */
|
|
|
|
per_read_integer16(s, &(mcs->user_id), MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
|
2011-07-10 07:54:23 +04:00
|
|
|
}
|
|
|
|
|
2011-08-19 22:03:48 +04:00
|
|
|
/**
|
|
|
|
* Send MCS Attach User Confirm.\n
|
|
|
|
* @msdn{cc240525}
|
|
|
|
* @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
|
|
|
{
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* s;
|
2013-05-15 21:17:29 +04:00
|
|
|
int status;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 11;
|
2011-08-19 22:03:48 +04:00
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
s = Stream_New(NULL, length);
|
2011-08-19 22:03:48 +04:00
|
|
|
|
|
|
|
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_AttachUserConfirm, length, 2);
|
|
|
|
|
|
|
|
per_write_enumerated(s, 0, MCS_Result_enum_length); /* result */
|
2012-11-08 08:29:24 +04:00
|
|
|
mcs->user_id = MCS_GLOBAL_CHANNEL_ID + 1 + mcs->transport->settings->ChannelCount;
|
2011-08-19 22:03:48 +04:00
|
|
|
per_write_integer16(s, mcs->user_id, 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);
|
2011-08-19 22:03:48 +04:00
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
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
|
|
|
/**
|
|
|
|
* Read MCS Channel Join Request.\n
|
|
|
|
* @msdn{cc240526}
|
|
|
|
* @param mcs mcs module
|
|
|
|
* @param s stream
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL mcs_recv_channel_join_request(rdpMcs* mcs, wStream* s, UINT16* channel_id)
|
2011-08-20 10:05:03 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length;
|
2011-08-20 10:05:03 +04:00
|
|
|
enum DomainMCSPDU MCSPDU;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 user_id;
|
2011-08-20 10:05:03 +04:00
|
|
|
|
|
|
|
MCSPDU = DomainMCSPDU_ChannelJoinRequest;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
2013-01-12 17:49:01 +04:00
|
|
|
return
|
|
|
|
mcs_read_domain_mcspdu_header(s, &MCSPDU, &length) &&
|
|
|
|
per_read_integer16(s, &user_id, MCS_BASE_CHANNEL_ID) &&
|
|
|
|
(user_id == mcs->user_id) &&
|
|
|
|
per_read_integer16(s, channel_id, 0);
|
2011-08-20 10:05:03 +04:00
|
|
|
}
|
|
|
|
|
2011-07-11 22:47:55 +04:00
|
|
|
/**
|
2011-07-11 23:58:39 +04:00
|
|
|
* Send MCS Channel Join Request.\n
|
|
|
|
* @msdn{cc240526}
|
2011-07-11 22:47:55 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
* @param channel_id channel id
|
|
|
|
*/
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BOOL mcs_send_channel_join_request(rdpMcs* mcs, UINT16 channel_id)
|
2011-07-10 07:54:23 +04:00
|
|
|
{
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* s;
|
2013-05-15 21:17:29 +04:00
|
|
|
int status;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 12;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
|
|
|
s = Stream_New(NULL, length);
|
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);
|
2011-07-10 07:54:23 +04:00
|
|
|
|
|
|
|
per_write_integer16(s, mcs->user_id, MCS_BASE_CHANNEL_ID);
|
2011-07-11 22:47:55 +04:00
|
|
|
per_write_integer16(s, channel_id, 0);
|
2011-07-10 07:54:23 +04:00
|
|
|
|
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);
|
2011-08-22 11:03:58 +04:00
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
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
|
|
|
/**
|
2011-08-22 11:03:58 +04:00
|
|
|
* Read MCS Channel Join Confirm.\n
|
2011-07-11 23:58:39 +04:00
|
|
|
* @msdn{cc240527}
|
2011-07-11 22:47:55 +04:00
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2013-03-21 23:19:33 +04:00
|
|
|
BOOL mcs_recv_channel_join_confirm(rdpMcs* mcs, wStream* s, UINT16* channel_id)
|
2011-07-10 07:54:23 +04:00
|
|
|
{
|
2013-02-15 05:39:56 +04:00
|
|
|
BOOL status;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length;
|
|
|
|
BYTE result;
|
|
|
|
UINT16 initiator;
|
|
|
|
UINT16 requested;
|
2011-07-11 22:47:55 +04:00
|
|
|
enum DomainMCSPDU MCSPDU;
|
2011-07-10 07:54:23 +04:00
|
|
|
|
2013-02-15 05:39:56 +04:00
|
|
|
status = TRUE;
|
2011-07-11 22:47:55 +04:00
|
|
|
MCSPDU = DomainMCSPDU_ChannelJoinConfirm;
|
2013-02-15 05:39:56 +04:00
|
|
|
|
|
|
|
status &= mcs_read_domain_mcspdu_header(s, &MCSPDU, &length);
|
|
|
|
status &= per_read_enumerated(s, &result, MCS_Result_enum_length); /* result */
|
|
|
|
status &= per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
|
|
|
|
status &= per_read_integer16(s, &requested, 0); /* requested (ChannelId) */
|
|
|
|
status &= per_read_integer16(s, channel_id, 0); /* channelId */
|
|
|
|
|
|
|
|
return status;
|
2011-07-10 07:54:23 +04:00
|
|
|
}
|
|
|
|
|
2011-08-20 10:05:03 +04:00
|
|
|
/**
|
|
|
|
* Send MCS Channel Join Confirm.\n
|
|
|
|
* @msdn{cc240527}
|
|
|
|
* @param mcs mcs module
|
|
|
|
*/
|
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BOOL mcs_send_channel_join_confirm(rdpMcs* mcs, UINT16 channel_id)
|
2011-08-20 10:05:03 +04:00
|
|
|
{
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* s;
|
2013-05-15 21:17:29 +04:00
|
|
|
int status;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 15;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
|
|
|
s = Stream_New(NULL, length);
|
2011-08-20 10:05:03 +04:00
|
|
|
|
|
|
|
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinConfirm, length, 2);
|
|
|
|
|
|
|
|
per_write_enumerated(s, 0, MCS_Result_enum_length); /* result */
|
|
|
|
per_write_integer16(s, mcs->user_id, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
|
|
|
|
per_write_integer16(s, channel_id, 0); /* requested (ChannelId) */
|
|
|
|
per_write_integer16(s, channel_id, 0); /* channelId */
|
|
|
|
|
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);
|
2011-08-20 10:05:03 +04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-08-26 14:14:34 +04:00
|
|
|
/**
|
|
|
|
* Send MCS Disconnect Provider Ultimatum PDU.\n
|
|
|
|
* @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
|
|
|
{
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* s;
|
2013-05-15 21:17:29 +04:00
|
|
|
int status;
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 length = 9;
|
2013-05-15 21:17:29 +04:00
|
|
|
|
|
|
|
s = Stream_New(NULL, length);
|
2011-08-26 14:14:34 +04:00
|
|
|
|
|
|
|
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_DisconnectProviderUltimatum, length, 1);
|
|
|
|
|
|
|
|
per_write_enumerated(s, 0, 0); /* reason */
|
|
|
|
|
2013-05-15 21:17:29 +04:00
|
|
|
status = transport_write(mcs->transport, s);
|
2011-08-26 14:14:34 +04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-07-07 23:35:09 +04:00
|
|
|
/**
|
|
|
|
* Instantiate new MCS module.
|
|
|
|
* @param transport transport
|
|
|
|
* @return new MCS module
|
|
|
|
*/
|
|
|
|
|
|
|
|
rdpMcs* mcs_new(rdpTransport* transport)
|
|
|
|
{
|
|
|
|
rdpMcs* mcs;
|
|
|
|
|
2012-11-22 04:22:41 +04:00
|
|
|
mcs = (rdpMcs*) malloc(sizeof(rdpMcs));
|
2011-07-07 23:35:09 +04:00
|
|
|
|
|
|
|
if (mcs != NULL)
|
|
|
|
{
|
2012-11-22 04:22:41 +04:00
|
|
|
ZeroMemory(mcs, sizeof(rdpMcs));
|
|
|
|
|
2011-07-07 23:35:09 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mcs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Free MCS module.
|
|
|
|
* @param mcs MCS module to be freed
|
|
|
|
*/
|
|
|
|
|
|
|
|
void mcs_free(rdpMcs* mcs)
|
|
|
|
{
|
|
|
|
if (mcs != NULL)
|
|
|
|
{
|
2012-10-09 07:21:26 +04:00
|
|
|
free(mcs);
|
2011-07-07 23:35:09 +04:00
|
|
|
}
|
|
|
|
}
|