2 * FreeRDP: A Remote Desktop Protocol Client
3 * T.124 Generic Conference Control (GCC)
5 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include <freerdp/utils/print.h>
23 #include "certificate.h"
26 * T.124 GCC is defined in:
28 * http://www.itu.int/rec/T-REC-T.124-199802-S/en
29 * ITU-T T.124 (02/98): Generic Conference Control
33 * ConnectData ::= SEQUENCE
36 * connectPDU OCTET_STRING
41 * object OBJECT_IDENTIFIER,
42 * h221NonStandard H221NonStandardIdentifier
45 * ConnectGCCPDU ::= CHOICE
47 * conferenceCreateRequest ConferenceCreateRequest,
48 * conferenceCreateResponse ConferenceCreateResponse,
49 * conferenceQueryRequest ConferenceQueryRequest,
50 * conferenceQueryResponse ConferenceQueryResponse,
51 * conferenceJoinRequest ConferenceJoinRequest,
52 * conferenceJoinResponse ConferenceJoinResponse,
53 * conferenceInviteRequest ConferenceInviteRequest,
54 * conferenceInviteResponse ConferenceInviteResponse,
58 * ConferenceCreateRequest ::= SEQUENCE
60 * conferenceName ConferenceName,
61 * convenerPassword Password OPTIONAL,
62 * password Password OPTIONAL,
63 * lockedConference BOOLEAN,
64 * listedConference BOOLEAN,
65 * conductibleConference BOOLEAN,
66 * terminationMethod TerminationMethod,
67 * conductorPrivileges SET OF Privilege OPTIONAL,
68 * conductedPrivileges SET OF Privilege OPTIONAL,
69 * nonConductedPrivileges SET OF Privilege OPTIONAL,
70 * conferenceDescription TextString OPTIONAL,
71 * callerIdentifier TextString OPTIONAL,
72 * userData UserData OPTIONAL,
74 * conferencePriority ConferencePriority OPTIONAL,
75 * conferenceMode ConferenceMode OPTIONAL
78 * ConferenceCreateResponse ::= SEQUENCE
86 * resourcesNotAvailable (2),
87 * rejectedForSymmetryBreaking (3),
88 * lockedConferenceNotSupported (4)
90 * userData UserData OPTIONAL,
94 * ConferenceName ::= SEQUENCE
96 * numeric SimpleNumericString
97 * text SimpleTextString OPTIONAL,
101 * SimpleNumericString ::= NumericString (SIZE (1..255)) (FROM ("0123456789"))
103 * UserData ::= SET OF SEQUENCE
106 * value OCTET_STRING OPTIONAL
109 * H221NonStandardIdentifier ::= OCTET STRING (SIZE (4..255))
111 * UserID ::= DynamicChannelID
113 * ChannelID ::= INTEGER (1..65535)
114 * StaticChannelID ::= INTEGER (1..1000)
115 * DynamicChannelID ::= INTEGER (1001..65535)
120 * OID = 0.0.20.124.0.1
121 * { itu-t(0) recommendation(0) t(20) t124(124) version(0) 1 }
122 * v.1 of ITU-T Recommendation T.124 (Feb 1998): "Generic Conference Control"
124 uint8 t124_02_98_oid[6] = { 0, 0, 20, 124, 0, 1 };
126 uint8 h221_cs_key[4] = "Duca";
127 uint8 h221_sc_key[4] = "McDn";
130 * Read a GCC Conference Create Request.\n
133 * @param settings rdp settings
136 boolean gcc_read_conference_create_request(STREAM* s, rdpSettings* settings)
144 if (!per_read_choice(s, &choice))
146 if (!per_read_object_identifier(s, t124_02_98_oid))
149 /* ConnectData::connectPDU (OCTET_STRING) */
150 if (!per_read_length(s, &length))
154 if (!per_read_choice(s, &choice))
156 if (!per_read_selection(s, &selection))
159 /* ConferenceCreateRequest::conferenceName */
160 if (!per_read_numeric_string(s, 1)) /* ConferenceName::numeric */
162 if (!per_read_padding(s, 1)) /* padding */
165 /* UserData (SET OF SEQUENCE) */
166 if (!per_read_number_of_sets(s, &number) || number != 1) /* one set of UserData */
168 if (!per_read_choice(s, &choice) || choice != 0xC0) /* UserData::value present + select h221NonStandard (1) */
171 /* h221NonStandard */
172 if (!per_read_octet_string(s, h221_cs_key, 4, 4)) /* h221NonStandard, client-to-server H.221 key, "Duca" */
175 /* userData::value (OCTET_STRING) */
176 if (!per_read_length(s, &length))
178 if (stream_get_left(s) < length)
180 if (!gcc_read_client_data_blocks(s, settings, length))
187 * Write a GCC Conference Create Request.\n
190 * @param user_data client data blocks
193 void gcc_write_conference_create_request(STREAM* s, STREAM* user_data)
196 per_write_choice(s, 0); /* From Key select object (0) of type OBJECT_IDENTIFIER */
197 per_write_object_identifier(s, t124_02_98_oid); /* ITU-T T.124 (02/98) OBJECT_IDENTIFIER */
199 /* ConnectData::connectPDU (OCTET_STRING) */
200 per_write_length(s, stream_get_length(user_data) + 14); /* connectPDU length */
203 per_write_choice(s, 0); /* From ConnectGCCPDU select conferenceCreateRequest (0) of type ConferenceCreateRequest */
204 per_write_selection(s, 0x08); /* select optional userData from ConferenceCreateRequest */
206 /* ConferenceCreateRequest::conferenceName */
207 per_write_numeric_string(s, (uint8*)"1", 1, 1); /* ConferenceName::numeric */
208 per_write_padding(s, 1); /* padding */
210 /* UserData (SET OF SEQUENCE) */
211 per_write_number_of_sets(s, 1); /* one set of UserData */
212 per_write_choice(s, 0xC0); /* UserData::value present + select h221NonStandard (1) */
214 /* h221NonStandard */
215 per_write_octet_string(s, h221_cs_key, 4, 4); /* h221NonStandard, client-to-server H.221 key, "Duca" */
217 /* userData::value (OCTET_STRING) */
218 per_write_octet_string(s, user_data->data, stream_get_length(user_data), 0); /* array of client data blocks */
221 boolean gcc_read_conference_create_response(STREAM* s, rdpSettings* settings)
231 per_read_choice(s, &choice);
232 per_read_object_identifier(s, t124_02_98_oid);
234 /* ConnectData::connectPDU (OCTET_STRING) */
235 per_read_length(s, &length);
238 per_read_choice(s, &choice);
240 /* ConferenceCreateResponse::nodeID (UserID) */
241 per_read_integer16(s, &nodeID, 1001);
243 /* ConferenceCreateResponse::tag (INTEGER) */
244 per_read_integer(s, &tag);
246 /* ConferenceCreateResponse::result (ENUMERATED) */
247 per_read_enumerated(s, &result, MCS_Result_enum_length);
249 /* number of UserData sets */
250 per_read_number_of_sets(s, &number);
252 /* UserData::value present + select h221NonStandard (1) */
253 per_read_choice(s, &choice);
255 /* h221NonStandard */
256 if (!per_read_octet_string(s, h221_sc_key, 4, 4)) /* h221NonStandard, server-to-client H.221 key, "McDn" */
259 /* userData (OCTET_STRING) */
260 per_read_length(s, &length);
261 if (!gcc_read_server_data_blocks(s, settings, length))
263 printf("gcc_read_conference_create_response: gcc_read_server_data_blocks failed\n");
270 void gcc_write_conference_create_response(STREAM* s, STREAM* user_data)
273 per_write_choice(s, 0);
274 per_write_object_identifier(s, t124_02_98_oid);
276 /* ConnectData::connectPDU (OCTET_STRING) */
277 per_write_length(s, stream_get_length(user_data) + 2);
280 per_write_choice(s, 0x14);
282 /* ConferenceCreateResponse::nodeID (UserID) */
283 per_write_integer16(s, 0x79F3, 1001);
285 /* ConferenceCreateResponse::tag (INTEGER) */
286 per_write_integer(s, 1);
288 /* ConferenceCreateResponse::result (ENUMERATED) */
289 per_write_enumerated(s, 0, MCS_Result_enum_length);
291 /* number of UserData sets */
292 per_write_number_of_sets(s, 1);
294 /* UserData::value present + select h221NonStandard (1) */
295 per_write_choice(s, 0xC0);
297 /* h221NonStandard */
298 per_write_octet_string(s, h221_sc_key, 4, 4); /* h221NonStandard, server-to-client H.221 key, "McDn" */
300 /* userData (OCTET_STRING) */
301 per_write_octet_string(s, user_data->data, stream_get_length(user_data), 0); /* array of server data blocks */
304 boolean gcc_read_client_data_blocks(STREAM* s, rdpSettings *settings, int length)
312 pos = stream_get_pos(s);
313 gcc_read_user_data_header(s, &type, &blockLength);
318 if (!gcc_read_client_core_data(s, settings, blockLength - 4))
323 if (!gcc_read_client_security_data(s, settings, blockLength - 4))
328 if (!gcc_read_client_network_data(s, settings, blockLength - 4))
333 if (!gcc_read_client_cluster_data(s, settings, blockLength - 4))
338 if (!gcc_read_client_monitor_data(s, settings, blockLength - 4))
346 length -= blockLength;
347 stream_set_pos(s, pos + blockLength);
353 void gcc_write_client_data_blocks(STREAM* s, rdpSettings* settings)
355 gcc_write_client_core_data(s, settings);
356 gcc_write_client_cluster_data(s, settings);
357 gcc_write_client_security_data(s, settings);
358 gcc_write_client_network_data(s, settings);
360 /* extended client data supported */
362 if (settings->negotiationFlags)
363 gcc_write_client_monitor_data(s, settings);
366 boolean gcc_read_server_data_blocks(STREAM* s, rdpSettings* settings, int length)
373 while (offset < length)
377 if (!gcc_read_user_data_header(s, &type, &blockLength))
379 printf("gcc_read_server_data_blocks: gcc_read_user_data_header failed\n");
386 if (!gcc_read_server_core_data(s, settings))
388 printf("gcc_read_server_data_blocks: gcc_read_server_core_data failed\n");
394 if (!gcc_read_server_security_data(s, settings))
396 printf("gcc_read_server_data_blocks: gcc_read_server_security_data failed\n");
402 if (!gcc_read_server_network_data(s, settings))
404 printf("gcc_read_server_data_blocks: gcc_read_server_network_data failed\n");
412 offset += blockLength;
413 s->p = holdp + blockLength;
419 void gcc_write_server_data_blocks(STREAM* s, rdpSettings *settings)
421 gcc_write_server_core_data(s, settings);
422 gcc_write_server_network_data(s, settings);
423 gcc_write_server_security_data(s, settings);
426 boolean gcc_read_user_data_header(STREAM* s, uint16* type, uint16* length)
428 stream_read_uint16(s, *type); /* type */
429 stream_read_uint16(s, *length); /* length */
434 if (stream_get_left(s) < *length - 4)
441 * Write a user data header (TS_UD_HEADER).\n
444 * @param type data block type
445 * @param length data block length
448 void gcc_write_user_data_header(STREAM* s, uint16 type, uint16 length)
450 stream_write_uint16(s, type); /* type */
451 stream_write_uint16(s, length); /* length */
455 * Read a client core data block (TS_UD_CS_CORE).\n
458 * @param settings rdp settings
461 boolean gcc_read_client_core_data(STREAM* s, rdpSettings *settings, uint16 blockLength)
464 uint16 colorDepth = 0;
465 uint16 postBeta2ColorDepth = 0;
466 uint16 highColorDepth = 0;
467 uint16 supportedColorDepths = 0;
468 uint16 earlyCapabilityFlags = 0;
469 uint32 serverSelectedProtocol = 0;
472 /* Length of all required fields, until imeFileName */
473 if (blockLength < 128)
476 stream_read_uint32(s, version); /* version */
477 settings->rdp_version = (version == RDP_VERSION_4 ? 4 : 7);
479 stream_read_uint16(s, settings->width); /* desktopWidth */
480 stream_read_uint16(s, settings->height); /* desktopHeight */
481 stream_read_uint16(s, colorDepth); /* colorDepth */
482 stream_seek_uint16(s); /* SASSequence (Secure Access Sequence) */
483 stream_read_uint32(s, settings->kbd_layout); /* keyboardLayout */
484 stream_read_uint32(s, settings->client_build); /* clientBuild */
486 /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
487 str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 32);
489 snprintf(settings->client_hostname, sizeof(settings->client_hostname), "%s", str);
492 stream_read_uint32(s, settings->kbd_type); /* keyboardType */
493 stream_read_uint32(s, settings->kbd_subtype); /* keyboardSubType */
494 stream_read_uint32(s, settings->kbd_fn_keys); /* keyboardFunctionKey */
496 stream_seek(s, 64); /* imeFileName */
501 * The following fields are all optional. If one field is present, all of the preceding
502 * fields MUST also be present. If one field is not present, all of the subsequent fields
503 * MUST NOT be present.
504 * We must check the bytes left before reading each field.
511 stream_read_uint16(s, postBeta2ColorDepth); /* postBeta2ColorDepth */
516 stream_seek_uint16(s); /* clientProductID */
521 stream_seek_uint32(s); /* serialNumber */
526 stream_read_uint16(s, highColorDepth); /* highColorDepth */
531 stream_read_uint16(s, supportedColorDepths); /* supportedColorDepths */
536 stream_read_uint16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */
539 if (blockLength < 64)
541 str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 64);
543 snprintf(settings->client_product_id, sizeof(settings->client_product_id), "%s", str);
549 stream_read_uint8(s, settings->performance_flags); /* connectionType */
554 stream_seek_uint8(s); /* pad1octet */
559 stream_read_uint32(s, serverSelectedProtocol); /* serverSelectedProtocol */
562 if (settings->selected_protocol != serverSelectedProtocol)
566 if (highColorDepth > 0)
567 settings->color_depth = highColorDepth;
568 else if (postBeta2ColorDepth > 0)
570 switch (postBeta2ColorDepth)
572 case RNS_UD_COLOR_4BPP:
573 settings->color_depth = 4;
575 case RNS_UD_COLOR_8BPP:
576 settings->color_depth = 8;
578 case RNS_UD_COLOR_16BPP_555:
579 settings->color_depth = 15;
581 case RNS_UD_COLOR_16BPP_565:
582 settings->color_depth = 16;
584 case RNS_UD_COLOR_24BPP:
585 settings->color_depth = 24;
595 case RNS_UD_COLOR_4BPP:
596 settings->color_depth = 4;
598 case RNS_UD_COLOR_8BPP:
599 settings->color_depth = 8;
610 * Write a client core data block (TS_UD_CS_CORE).\n
613 * @param settings rdp settings
616 void gcc_write_client_core_data(STREAM* s, rdpSettings *settings)
620 size_t clientNameLength;
621 uint8 connectionType;
622 uint16 highColorDepth;
623 uint16 supportedColorDepths;
624 uint16 earlyCapabilityFlags;
625 char* clientDigProductId;
626 size_t clientDigProductIdLength;
628 gcc_write_user_data_header(s, CS_CORE, 216);
630 version = settings->rdp_version >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4;
631 clientName = freerdp_uniconv_out(settings->uniconv, settings->client_hostname, &clientNameLength);
632 clientDigProductId = freerdp_uniconv_out(settings->uniconv, settings->client_product_id, &clientDigProductIdLength);
634 stream_write_uint32(s, version); /* version */
635 stream_write_uint16(s, settings->width); /* desktopWidth */
636 stream_write_uint16(s, settings->height); /* desktopHeight */
637 stream_write_uint16(s, RNS_UD_COLOR_8BPP); /* colorDepth, ignored because of postBeta2ColorDepth */
638 stream_write_uint16(s, RNS_UD_SAS_DEL); /* SASSequence (Secure Access Sequence) */
639 stream_write_uint32(s, settings->kbd_layout); /* keyboardLayout */
640 stream_write_uint32(s, settings->client_build); /* clientBuild */
642 /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
643 if (clientNameLength > 30)
645 clientNameLength = 30;
646 clientName[clientNameLength] = 0;
647 clientName[clientNameLength + 1] = 0;
649 stream_write(s, clientName, clientNameLength + 2);
650 stream_write_zero(s, 32 - clientNameLength - 2);
653 stream_write_uint32(s, settings->kbd_type); /* keyboardType */
654 stream_write_uint32(s, settings->kbd_subtype); /* keyboardSubType */
655 stream_write_uint32(s, settings->kbd_fn_keys); /* keyboardFunctionKey */
657 stream_write_zero(s, 64); /* imeFileName */
659 stream_write_uint16(s, RNS_UD_COLOR_8BPP); /* postBeta2ColorDepth */
660 stream_write_uint16(s, 1); /* clientProductID */
661 stream_write_uint32(s, 0); /* serialNumber (should be initialized to 0) */
663 highColorDepth = MIN(settings->color_depth, 24);
665 supportedColorDepths =
666 RNS_UD_24BPP_SUPPORT |
667 RNS_UD_16BPP_SUPPORT |
668 RNS_UD_15BPP_SUPPORT;
670 connectionType = settings->connection_type;
671 earlyCapabilityFlags = RNS_UD_CS_SUPPORT_ERRINFO_PDU;
673 if (settings->rfx_codec)
674 connectionType = CONNECTION_TYPE_LAN;
676 if (connectionType != 0)
677 earlyCapabilityFlags |= RNS_UD_CS_VALID_CONNECTION_TYPE;
679 if (settings->color_depth == 32)
681 supportedColorDepths |= RNS_UD_32BPP_SUPPORT;
682 earlyCapabilityFlags |= RNS_UD_CS_WANT_32BPP_SESSION;
685 stream_write_uint16(s, highColorDepth); /* highColorDepth */
686 stream_write_uint16(s, supportedColorDepths); /* supportedColorDepths */
688 stream_write_uint16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */
690 /* clientDigProductId (64 bytes, null-terminated unicode, truncated to 30 characters) */
691 if (clientDigProductIdLength > 62)
693 clientDigProductIdLength = 62;
694 clientDigProductId[clientDigProductIdLength] = 0;
695 clientDigProductId[clientDigProductIdLength + 1] = 0;
697 stream_write(s, clientDigProductId, clientDigProductIdLength + 2);
698 stream_write_zero(s, 64 - clientDigProductIdLength - 2);
699 xfree(clientDigProductId);
701 stream_write_uint8(s, connectionType); /* connectionType */
702 stream_write_uint8(s, 0); /* pad1octet */
704 stream_write_uint32(s, settings->selected_protocol); /* serverSelectedProtocol */
707 boolean gcc_read_server_core_data(STREAM* s, rdpSettings *settings)
710 uint32 clientRequestedProtocols;
712 stream_read_uint32(s, version); /* version */
713 stream_read_uint32(s, clientRequestedProtocols); /* clientRequestedProtocols */
715 if (version == RDP_VERSION_4 && settings->rdp_version > 4)
716 settings->rdp_version = 4;
717 else if (version == RDP_VERSION_5_PLUS && settings->rdp_version < 5)
718 settings->rdp_version = 7;
723 void gcc_write_server_core_data(STREAM* s, rdpSettings *settings)
725 gcc_write_user_data_header(s, SC_CORE, 12);
727 stream_write_uint32(s, settings->rdp_version == 4 ? RDP_VERSION_4 : RDP_VERSION_5_PLUS);
728 stream_write_uint32(s, settings->requested_protocols); /* clientRequestedProtocols */
732 * Read a client security data block (TS_UD_CS_SEC).\n
735 * @param settings rdp settings
738 boolean gcc_read_client_security_data(STREAM* s, rdpSettings *settings, uint16 blockLength)
743 stream_read_uint32(s, settings->encryption_method); /* encryptionMethods */
744 if (settings->encryption_method == 0)
745 stream_read_uint32(s, settings->encryption_method); /* extEncryptionMethods */
751 * Write a client security data block (TS_UD_CS_SEC).\n
754 * @param settings rdp settings
757 void gcc_write_client_security_data(STREAM* s, rdpSettings *settings)
759 gcc_write_user_data_header(s, CS_SECURITY, 12);
761 if (settings->encryption)
763 stream_write_uint32(s, settings->encryption_method); /* encryptionMethods */
764 stream_write_uint32(s, 0); /* extEncryptionMethods */
768 /* French locale, disable encryption */
769 stream_write_uint32(s, 0); /* encryptionMethods */
770 stream_write_uint32(s, settings->encryption_method); /* extEncryptionMethods */
774 boolean gcc_read_server_security_data(STREAM* s, rdpSettings *settings)
778 uint32 serverRandomLen;
779 uint32 serverCertLen;
781 stream_read_uint32(s, settings->encryption_method); /* encryptionMethod */
782 stream_read_uint32(s, settings->encryption_level); /* encryptionLevel */
784 if (settings->encryption_method == 0 && settings->encryption_level == 0)
786 /* serverRandom and serverRandom must not be present */
787 settings->encryption = false;
788 settings->encryption_method = ENCRYPTION_METHOD_NONE;
789 settings->encryption_level = ENCRYPTION_LEVEL_NONE;
793 stream_read_uint32(s, serverRandomLen); /* serverRandomLen */
794 stream_read_uint32(s, serverCertLen); /* serverCertLen */
796 if (serverRandomLen > 0)
799 freerdp_blob_alloc(settings->server_random, serverRandomLen);
800 stream_read(s, settings->server_random->data, serverRandomLen);
807 if (serverCertLen > 0)
809 /* serverCertificate */
810 freerdp_blob_alloc(settings->server_certificate, serverCertLen);
811 stream_read(s, settings->server_certificate->data, serverCertLen);
812 certificate_free(settings->server_cert);
813 settings->server_cert = certificate_new();
814 data = settings->server_certificate->data;
815 length = settings->server_certificate->length;
817 if (!certificate_read_server_certificate(settings->server_cert, data, length))
828 void gcc_write_server_security_data(STREAM* s, rdpSettings *settings)
830 gcc_write_user_data_header(s, SC_SECURITY, 12);
832 stream_write_uint32(s, ENCRYPTION_METHOD_NONE); /* encryptionMethod */
833 stream_write_uint32(s, ENCRYPTION_LEVEL_NONE); /* encryptionLevel */
835 stream_write_uint32(s, 0); /* serverRandomLen */
836 stream_write_uint32(s, 0); /* serverCertLen */
841 * Read a client network data block (TS_UD_CS_NET).\n
844 * @param settings rdp settings
847 boolean gcc_read_client_network_data(STREAM* s, rdpSettings *settings, uint16 blockLength)
854 stream_read_uint32(s, settings->num_channels); /* channelCount */
855 if (blockLength < 4 + settings->num_channels * 12)
857 if (settings->num_channels > 16)
860 /* channelDefArray */
861 for (i = 0; i < settings->num_channels; i++)
864 stream_read(s, settings->channels[i].name, 8); /* name (8 bytes) */
865 stream_read_uint32(s, settings->channels[i].options); /* options (4 bytes) */
866 settings->channels[i].channel_id = MCS_GLOBAL_CHANNEL_ID + 1 + i;
873 * Write a client network data block (TS_UD_CS_NET).\n
876 * @param settings rdp settings
879 void gcc_write_client_network_data(STREAM* s, rdpSettings *settings)
884 if (settings->num_channels > 0)
886 length = settings->num_channels * 12 + 8;
887 gcc_write_user_data_header(s, CS_NET, length);
889 stream_write_uint32(s, settings->num_channels); /* channelCount */
891 /* channelDefArray */
892 for (i = 0; i < settings->num_channels; i++)
895 stream_write(s, settings->channels[i].name, 8); /* name (8 bytes) */
896 stream_write_uint32(s, settings->channels[i].options); /* options (4 bytes) */
901 boolean gcc_read_server_network_data(STREAM* s, rdpSettings *settings)
908 stream_read_uint16(s, MCSChannelId); /* MCSChannelId */
909 stream_read_uint16(s, channelCount); /* channelCount */
911 if (channelCount != settings->num_channels)
913 printf("requested %d channels, got %d instead\n",
914 settings->num_channels, channelCount);
917 for (i = 0; i < channelCount; i++)
919 stream_read_uint16(s, channelId); /* channelId */
920 settings->channels[i].channel_id = channelId;
923 if (channelCount % 2 == 1)
924 stream_seek(s, 2); /* padding */
929 void gcc_write_server_network_data(STREAM* s, rdpSettings *settings)
933 gcc_write_user_data_header(s, SC_NET, 8 + settings->num_channels * 2 + (settings->num_channels % 2 == 1 ? 2 : 0));
935 stream_write_uint16(s, MCS_GLOBAL_CHANNEL_ID); /* MCSChannelId */
936 stream_write_uint16(s, settings->num_channels); /* channelCount */
938 for (i = 0; i < settings->num_channels; i++)
940 stream_write_uint16(s, settings->channels[i].channel_id);
943 if (settings->num_channels % 2 == 1)
944 stream_write_uint16(s, 0);
948 * Read a client cluster data block (TS_UD_CS_CLUSTER).\n
951 * @param settings rdp settings
954 boolean gcc_read_client_cluster_data(STREAM* s, rdpSettings *settings, uint16 blockLength)
961 stream_read_uint32(s, flags); /* flags */
963 if ((flags | REDIRECTED_SESSIONID_FIELD_VALID))
964 stream_read_uint32(s, settings->redirected_session_id); /* redirectedSessionID */
970 * Write a client cluster data block (TS_UD_CS_CLUSTER).\n
973 * @param settings rdp settings
976 void gcc_write_client_cluster_data(STREAM* s, rdpSettings *settings)
980 gcc_write_user_data_header(s, CS_CLUSTER, 12);
982 flags = REDIRECTION_SUPPORTED | (REDIRECTION_VERSION4 << 2);
984 if (settings->console_session || settings->redirected_session_id)
985 flags |= REDIRECTED_SESSIONID_FIELD_VALID;
987 stream_write_uint32(s, flags); /* flags */
988 stream_write_uint32(s, settings->redirected_session_id); /* redirectedSessionID */
992 * Read a client monitor data block (TS_UD_CS_MONITOR).\n
995 * @param settings rdp settings
998 boolean gcc_read_client_monitor_data(STREAM* s, rdpSettings *settings, uint16 blockLength)
1000 printf("CS_MONITOR\n");
1005 * Write a client monitor data block (TS_UD_CS_MONITOR).\n
1008 * @param settings rdp settings
1011 void gcc_write_client_monitor_data(STREAM* s, rdpSettings *settings)
1015 uint32 left, top, right, bottom, flags;
1017 if (settings->num_monitors > 1)
1019 length = (20 * settings->num_monitors) + 12;
1020 gcc_write_user_data_header(s, CS_MONITOR, length);
1022 stream_write_uint32(s, 0); /* flags */
1023 stream_write_uint32(s, settings->num_monitors); /* monitorCount */
1025 for (i = 0; i < settings->num_monitors; i++)
1027 left = settings->monitors[i].x;
1028 top = settings->monitors[i].y;
1029 right = settings->monitors[i].x + settings->monitors[i].width - 1;
1030 bottom = settings->monitors[i].y + settings->monitors[i].height - 1;
1031 flags = settings->monitors[i].is_primary ? MONITOR_PRIMARY : 0;
1033 stream_write_uint32(s, left); /* left */
1034 stream_write_uint32(s, top); /* top */
1035 stream_write_uint32(s, right); /* right */
1036 stream_write_uint32(s, bottom); /* bottom */
1037 stream_write_uint32(s, flags); /* flags */