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.
23 * T.124 GCC is defined in:
25 * http://www.itu.int/rec/T-REC-T.124-199802-S/en
26 * ITU-T T.124 (02/98): Generic Conference Control
30 * ConnectData ::= SEQUENCE
33 * connectPDU OCTET_STRING
38 * object OBJECT_IDENTIFIER,
39 * h221NonStandard H221NonStandardIdentifier
42 * ConnectGCCPDU ::= CHOICE
44 * conferenceCreateRequest ConferenceCreateRequest,
45 * conferenceCreateResponse ConferenceCreateResponse,
46 * conferenceQueryRequest ConferenceQueryRequest,
47 * conferenceQueryResponse ConferenceQueryResponse,
48 * conferenceJoinRequest ConferenceJoinRequest,
49 * conferenceJoinResponse ConferenceJoinResponse,
50 * conferenceInviteRequest ConferenceInviteRequest,
51 * conferenceInviteResponse ConferenceInviteResponse,
55 * ConferenceCreateRequest ::= SEQUENCE
57 * conferenceName ConferenceName,
58 * convenerPassword Password OPTIONAL,
59 * password Password OPTIONAL,
60 * lockedConference BOOLEAN,
61 * listedConference BOOLEAN,
62 * conductibleConference BOOLEAN,
63 * terminationMethod TerminationMethod,
64 * conductorPrivileges SET OF Privilege OPTIONAL,
65 * conductedPrivileges SET OF Privilege OPTIONAL,
66 * nonConductedPrivileges SET OF Privilege OPTIONAL,
67 * conferenceDescription TextString OPTIONAL,
68 * callerIdentifier TextString OPTIONAL,
69 * userData UserData OPTIONAL,
71 * conferencePriority ConferencePriority OPTIONAL,
72 * conferenceMode ConferenceMode OPTIONAL
75 * ConferenceCreateResponse ::= SEQUENCE
83 * resourcesNotAvailable (2),
84 * rejectedForSymmetryBreaking (3),
85 * lockedConferenceNotSupported (4)
87 * userData UserData OPTIONAL,
91 * ConferenceName ::= SEQUENCE
93 * numeric SimpleNumericString
94 * text SimpleTextString OPTIONAL,
98 * SimpleNumericString ::= NumericString (SIZE (1..255)) (FROM ("0123456789"))
100 * UserData ::= SET OF SEQUENCE
103 * value OCTET_STRING OPTIONAL
106 * H221NonStandardIdentifier ::= OCTET STRING (SIZE (4..255))
108 * UserID ::= DynamicChannelID
110 * ChannelID ::= INTEGER (1..65535)
111 * StaticChannelID ::= INTEGER (1..1000)
112 * DynamicChannelID ::= INTEGER (1001..65535)
117 * OID = 0.0.20.124.0.1
118 * { itu-t(0) recommendation(0) t(20) t124(124) version(0) 1 }
119 * v.1 of ITU-T Recommendation T.124 (Feb 1998): "Generic Conference Control"
121 uint8 t124_02_98_oid[6] = { 0, 0, 20, 124, 0, 1 };
123 uint8 h221_cs_key[4] = "Duca";
124 uint8 h221_sc_key[4] = "McDn";
127 * Read a GCC Conference Create Request.\n
130 * @param settings rdp settings
133 boolean gcc_read_conference_create_request(STREAM* s, rdpSettings* settings)
141 if (!per_read_choice(s, &choice))
143 if (!per_read_object_identifier(s, t124_02_98_oid))
146 /* ConnectData::connectPDU (OCTET_STRING) */
147 if (!per_read_length(s, &length))
151 if (!per_read_choice(s, &choice))
153 if (!per_read_selection(s, &selection))
156 /* ConferenceCreateRequest::conferenceName */
157 if (!per_read_numeric_string(s, 1)) /* ConferenceName::numeric */
159 if (!per_read_padding(s, 1)) /* padding */
162 /* UserData (SET OF SEQUENCE) */
163 if (!per_read_number_of_sets(s, &number) || number != 1) /* one set of UserData */
165 if (!per_read_choice(s, &choice) || choice != 0xC0) /* UserData::value present + select h221NonStandard (1) */
168 /* h221NonStandard */
169 if (!per_read_octet_string(s, h221_cs_key, 4, 4)) /* h221NonStandard, client-to-server H.221 key, "Duca" */
172 /* userData::value (OCTET_STRING) */
173 if (!per_read_length(s, &length))
175 if (stream_get_left(s) < length)
177 if (!gcc_read_client_data_blocks(s, settings, length))
184 * Write a GCC Conference Create Request.\n
187 * @param user_data client data blocks
190 void gcc_write_conference_create_request(STREAM* s, STREAM* user_data)
193 per_write_choice(s, 0); /* From Key select object (0) of type OBJECT_IDENTIFIER */
194 per_write_object_identifier(s, t124_02_98_oid); /* ITU-T T.124 (02/98) OBJECT_IDENTIFIER */
196 /* ConnectData::connectPDU (OCTET_STRING) */
197 per_write_length(s, stream_get_length(user_data) + 14); /* connectPDU length */
200 per_write_choice(s, 0); /* From ConnectGCCPDU select conferenceCreateRequest (0) of type ConferenceCreateRequest */
201 per_write_selection(s, 0x08); /* select optional userData from ConferenceCreateRequest */
203 /* ConferenceCreateRequest::conferenceName */
204 per_write_numeric_string(s, (uint8*)"1", 1, 1); /* ConferenceName::numeric */
205 per_write_padding(s, 1); /* padding */
207 /* UserData (SET OF SEQUENCE) */
208 per_write_number_of_sets(s, 1); /* one set of UserData */
209 per_write_choice(s, 0xC0); /* UserData::value present + select h221NonStandard (1) */
211 /* h221NonStandard */
212 per_write_octet_string(s, h221_cs_key, 4, 4); /* h221NonStandard, client-to-server H.221 key, "Duca" */
214 /* userData::value (OCTET_STRING) */
215 per_write_octet_string(s, user_data->data, stream_get_length(user_data), 0); /* array of client data blocks */
218 void gcc_read_conference_create_response(STREAM* s, rdpSettings* settings)
228 per_read_choice(s, &choice);
229 per_read_object_identifier(s, t124_02_98_oid);
231 /* ConnectData::connectPDU (OCTET_STRING) */
232 per_read_length(s, &length);
235 per_read_choice(s, &choice);
237 /* ConferenceCreateResponse::nodeID (UserID) */
238 per_read_integer16(s, &nodeID, 1001);
240 /* ConferenceCreateResponse::tag (INTEGER) */
241 per_read_integer(s, &tag);
243 /* ConferenceCreateResponse::result (ENUMERATED) */
244 per_read_enumerated(s, &result, MCS_Result_enum_length);
246 /* number of UserData sets */
247 per_read_number_of_sets(s, &number);
249 /* UserData::value present + select h221NonStandard (1) */
250 per_read_choice(s, &choice);
252 /* h221NonStandard */
253 per_read_octet_string(s, h221_sc_key, 4, 4); /* h221NonStandard, server-to-client H.221 key, "McDn" */
255 /* userData (OCTET_STRING) */
256 per_read_length(s, &length);
257 gcc_read_server_data_blocks(s, settings, length);
260 void gcc_write_conference_create_response(STREAM* s, STREAM* user_data)
263 per_write_choice(s, 0);
264 per_write_object_identifier(s, t124_02_98_oid);
266 /* ConnectData::connectPDU (OCTET_STRING) */
267 per_write_length(s, stream_get_length(user_data) + 2);
270 per_write_choice(s, 0x14);
272 /* ConferenceCreateResponse::nodeID (UserID) */
273 per_write_integer16(s, 0x79F3, 1001);
275 /* ConferenceCreateResponse::tag (INTEGER) */
276 per_write_integer(s, 1);
278 /* ConferenceCreateResponse::result (ENUMERATED) */
279 per_write_enumerated(s, 0, MCS_Result_enum_length);
281 /* number of UserData sets */
282 per_write_number_of_sets(s, 1);
284 /* UserData::value present + select h221NonStandard (1) */
285 per_write_choice(s, 0xC0);
287 /* h221NonStandard */
288 per_write_octet_string(s, h221_sc_key, 4, 4); /* h221NonStandard, server-to-client H.221 key, "McDn" */
290 /* userData (OCTET_STRING) */
291 per_write_octet_string(s, user_data->data, stream_get_length(user_data), 0); /* array of server data blocks */
294 boolean gcc_read_client_data_blocks(STREAM* s, rdpSettings *settings, int length)
302 pos = stream_get_pos(s);
303 gcc_read_user_data_header(s, &type, &blockLength);
308 if (!gcc_read_client_core_data(s, settings, blockLength - 4))
313 if (!gcc_read_client_security_data(s, settings, blockLength - 4))
318 if (!gcc_read_client_network_data(s, settings, blockLength - 4))
323 if (!gcc_read_client_cluster_data(s, settings, blockLength - 4))
328 if (!gcc_read_client_monitor_data(s, settings, blockLength - 4))
336 length -= blockLength;
337 stream_set_pos(s, pos + blockLength);
343 void gcc_write_client_data_blocks(STREAM* s, rdpSettings *settings)
345 gcc_write_client_core_data(s, settings);
346 gcc_write_client_cluster_data(s, settings);
347 gcc_write_client_security_data(s, settings);
348 gcc_write_client_network_data(s, settings);
349 gcc_write_client_monitor_data(s, settings);
352 void gcc_read_server_data_blocks(STREAM* s, rdpSettings *settings, int length)
358 while (offset < length)
360 gcc_read_user_data_header(s, &type, &blockLength);
365 gcc_read_server_core_data(s, settings);
369 gcc_read_server_security_data(s, settings);
373 gcc_read_server_network_data(s, settings);
380 offset += blockLength;
384 void gcc_write_server_data_blocks(STREAM* s, rdpSettings *settings)
386 gcc_write_server_core_data(s, settings);
387 gcc_write_server_network_data(s, settings);
388 gcc_write_server_security_data(s, settings);
391 void gcc_read_user_data_header(STREAM* s, uint16* type, uint16* length)
393 stream_read_uint16(s, *type); /* type */
394 stream_read_uint16(s, *length); /* length */
398 * Write a user data header (TS_UD_HEADER).\n
401 * @param type data block type
402 * @param length data block length
405 void gcc_write_user_data_header(STREAM* s, uint16 type, uint16 length)
407 stream_write_uint16(s, type); /* type */
408 stream_write_uint16(s, length); /* length */
412 * Read a client core data block (TS_UD_CS_CORE).\n
415 * @param settings rdp settings
418 boolean gcc_read_client_core_data(STREAM* s, rdpSettings *settings, uint16 blockLength)
421 uint16 colorDepth = 0;
422 uint16 postBeta2ColorDepth = 0;
423 uint16 highColorDepth = 0;
424 uint16 supportedColorDepths = 0;
425 uint16 earlyCapabilityFlags = 0;
426 uint32 serverSelectedProtocol = 0;
429 /* Length of all required fields, until imeFileName */
430 if (blockLength < 128)
433 stream_read_uint32(s, version); /* version */
434 settings->rdp_version = (version == RDP_VERSION_4 ? 4 : 7);
436 stream_read_uint16(s, settings->width); /* desktopWidth */
437 stream_read_uint16(s, settings->height); /* desktopHeight */
438 stream_read_uint16(s, colorDepth); /* colorDepth */
439 stream_seek_uint16(s); /* SASSequence (Secure Access Sequence) */
440 stream_read_uint32(s, settings->kbd_layout); /* keyboardLayout */
441 stream_read_uint32(s, settings->client_build); /* clientBuild */
443 /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
444 str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 32);
446 snprintf(settings->client_hostname, sizeof(settings->client_hostname), "%s", str);
449 stream_read_uint32(s, settings->kbd_type); /* keyboardType */
450 stream_read_uint32(s, settings->kbd_subtype); /* keyboardSubType */
451 stream_read_uint32(s, settings->kbd_fn_keys); /* keyboardFunctionKey */
453 stream_seek(s, 64); /* imeFileName */
458 * The following fields are all optional. If one field is present, all of the preceding
459 * fields MUST also be present. If one field is not present, all of the subsequent fields
460 * MUST NOT be present.
461 * We must check the bytes left before reading each field.
468 stream_read_uint16(s, postBeta2ColorDepth); /* postBeta2ColorDepth */
473 stream_seek_uint16(s); /* clientProductID */
478 stream_seek_uint32(s); /* serialNumber */
483 stream_read_uint16(s, highColorDepth); /* highColorDepth */
488 stream_read_uint16(s, supportedColorDepths); /* supportedColorDepths */
493 stream_read_uint16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */
496 if (blockLength < 64)
498 str = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), 64);
500 snprintf(settings->client_product_id, sizeof(settings->client_product_id), "%s", str);
506 stream_read_uint8(s, settings->performance_flags); /* connectionType */
511 stream_seek_uint8(s); /* pad1octet */
516 stream_read_uint32(s, serverSelectedProtocol); /* serverSelectedProtocol */
519 if (settings->selected_protocol != serverSelectedProtocol)
523 if (highColorDepth > 0)
524 settings->color_depth = highColorDepth;
525 else if (postBeta2ColorDepth > 0)
527 switch (postBeta2ColorDepth)
529 case RNS_UD_COLOR_4BPP:
530 settings->color_depth = 4;
532 case RNS_UD_COLOR_8BPP:
533 settings->color_depth = 8;
535 case RNS_UD_COLOR_16BPP_555:
536 settings->color_depth = 15;
538 case RNS_UD_COLOR_16BPP_565:
539 settings->color_depth = 16;
541 case RNS_UD_COLOR_24BPP:
542 settings->color_depth = 24;
552 case RNS_UD_COLOR_4BPP:
553 settings->color_depth = 4;
555 case RNS_UD_COLOR_8BPP:
556 settings->color_depth = 8;
567 * Write a client core data block (TS_UD_CS_CORE).\n
570 * @param settings rdp settings
573 void gcc_write_client_core_data(STREAM* s, rdpSettings *settings)
577 size_t clientNameLength;
578 uint8 connectionType;
579 uint16 highColorDepth;
580 uint16 supportedColorDepths;
581 uint16 earlyCapabilityFlags;
582 char* clientDigProductId;
583 size_t clientDigProductIdLength;
585 gcc_write_user_data_header(s, CS_CORE, 216);
587 version = settings->rdp_version >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4;
588 clientName = freerdp_uniconv_out(settings->uniconv, settings->client_hostname, &clientNameLength);
589 clientDigProductId = freerdp_uniconv_out(settings->uniconv, settings->client_product_id, &clientDigProductIdLength);
591 stream_write_uint32(s, version); /* version */
592 stream_write_uint16(s, settings->width); /* desktopWidth */
593 stream_write_uint16(s, settings->height); /* desktopHeight */
594 stream_write_uint16(s, RNS_UD_COLOR_8BPP); /* colorDepth, ignored because of postBeta2ColorDepth */
595 stream_write_uint16(s, RNS_UD_SAS_DEL); /* SASSequence (Secure Access Sequence) */
596 stream_write_uint32(s, settings->kbd_layout); /* keyboardLayout */
597 stream_write_uint32(s, settings->client_build); /* clientBuild */
599 /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
600 if (clientNameLength > 30)
602 clientNameLength = 30;
603 clientName[clientNameLength] = 0;
604 clientName[clientNameLength + 1] = 0;
606 stream_write(s, clientName, clientNameLength + 2);
607 stream_write_zero(s, 32 - clientNameLength - 2);
610 stream_write_uint32(s, settings->kbd_type); /* keyboardType */
611 stream_write_uint32(s, settings->kbd_subtype); /* keyboardSubType */
612 stream_write_uint32(s, settings->kbd_fn_keys); /* keyboardFunctionKey */
614 stream_write_zero(s, 64); /* imeFileName */
616 stream_write_uint16(s, RNS_UD_COLOR_8BPP); /* postBeta2ColorDepth */
617 stream_write_uint16(s, 1); /* clientProductID */
618 stream_write_uint32(s, 0); /* serialNumber (should be initialized to 0) */
620 highColorDepth = MIN(settings->color_depth, 24);
622 supportedColorDepths =
623 RNS_UD_24BPP_SUPPORT |
624 RNS_UD_16BPP_SUPPORT |
625 RNS_UD_15BPP_SUPPORT;
628 earlyCapabilityFlags = RNS_UD_CS_SUPPORT_ERRINFO_PDU;
630 if (settings->performance_flags == PERF_FLAG_NONE)
632 earlyCapabilityFlags |= RNS_UD_CS_VALID_CONNECTION_TYPE;
633 connectionType = CONNECTION_TYPE_LAN;
636 if (settings->color_depth == 32)
638 supportedColorDepths |= RNS_UD_32BPP_SUPPORT;
639 earlyCapabilityFlags |= RNS_UD_CS_WANT_32BPP_SESSION;
642 stream_write_uint16(s, highColorDepth); /* highColorDepth */
643 stream_write_uint16(s, supportedColorDepths); /* supportedColorDepths */
645 stream_write_uint16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */
647 /* clientDigProductId (64 bytes, null-terminated unicode, truncated to 30 characters) */
648 if (clientDigProductIdLength > 62)
650 clientDigProductIdLength = 62;
651 clientDigProductId[clientDigProductIdLength] = 0;
652 clientDigProductId[clientDigProductIdLength + 1] = 0;
654 stream_write(s, clientDigProductId, clientDigProductIdLength + 2);
655 stream_write_zero(s, 64 - clientDigProductIdLength - 2);
656 xfree(clientDigProductId);
658 stream_write_uint8(s, connectionType); /* connectionType */
659 stream_write_uint8(s, 0); /* pad1octet */
661 stream_write_uint32(s, settings->selected_protocol); /* serverSelectedProtocol */
664 void gcc_read_server_core_data(STREAM* s, rdpSettings *settings)
667 uint32 clientRequestedProtocols;
669 stream_read_uint32(s, version); /* version */
670 stream_read_uint32(s, clientRequestedProtocols); /* clientRequestedProtocols */
672 if (version == RDP_VERSION_4 && settings->rdp_version > 4)
673 settings->rdp_version = 4;
674 else if (version == RDP_VERSION_5_PLUS && settings->rdp_version < 5)
675 settings->rdp_version = 7;
678 void gcc_write_server_core_data(STREAM* s, rdpSettings *settings)
680 gcc_write_user_data_header(s, SC_CORE, 12);
682 stream_write_uint32(s, settings->rdp_version == 4 ? RDP_VERSION_4 : RDP_VERSION_5_PLUS);
683 stream_write_uint32(s, settings->requested_protocols); /* clientRequestedProtocols */
687 * Read a client security data block (TS_UD_CS_SEC).\n
690 * @param settings rdp settings
693 boolean gcc_read_client_security_data(STREAM* s, rdpSettings *settings, uint16 blockLength)
698 stream_read_uint32(s, settings->encryption_method); /* encryptionMethods */
699 if (settings->encryption_method == 0)
700 stream_read_uint32(s, settings->encryption_method); /* extEncryptionMethods */
706 * Write a client security data block (TS_UD_CS_SEC).\n
709 * @param settings rdp settings
712 void gcc_write_client_security_data(STREAM* s, rdpSettings *settings)
714 gcc_write_user_data_header(s, CS_SECURITY, 12);
716 if (settings->encryption > 0)
718 stream_write_uint32(s, settings->encryption_method); /* encryptionMethods */
719 stream_write_uint32(s, 0); /* extEncryptionMethods */
723 /* French locale, disable encryption */
724 stream_write_uint32(s, 0); /* encryptionMethods */
725 stream_write_uint32(s, settings->encryption_method); /* extEncryptionMethods */
729 void gcc_read_server_security_data(STREAM* s, rdpSettings *settings)
731 uint32 encryptionMethod;
732 uint32 encryptionLevel;
733 uint32 serverRandomLen;
734 uint32 serverCertLen;
736 stream_read_uint32(s, encryptionMethod); /* encryptionMethod */
737 stream_read_uint32(s, encryptionLevel); /* encryptionLevel */
738 stream_read_uint32(s, serverRandomLen); /* serverRandomLen */
739 stream_read_uint32(s, serverCertLen); /* serverCertLen */
741 if (encryptionMethod == 0 && encryptionLevel == 0)
743 /* serverRandom and serverRandom must not be present */
747 if (serverRandomLen > 0)
750 freerdp_blob_alloc(&settings->server_random, serverRandomLen);
751 memcpy(settings->server_random.data, s->p, serverRandomLen);
752 stream_seek(s, serverRandomLen);
755 if (serverCertLen > 0)
757 /* serverCertificate */
758 freerdp_blob_alloc(&settings->server_certificate, serverCertLen);
759 memcpy(settings->server_certificate.data, s->p, serverCertLen);
760 stream_seek(s, serverCertLen);
764 void gcc_write_server_security_data(STREAM* s, rdpSettings *settings)
766 gcc_write_user_data_header(s, SC_SECURITY, 12);
768 stream_write_uint32(s, ENCRYPTION_METHOD_NONE); /* encryptionMethod */
769 stream_write_uint32(s, ENCRYPTION_LEVEL_NONE); /* encryptionLevel */
771 stream_write_uint32(s, 0); /* serverRandomLen */
772 stream_write_uint32(s, 0); /* serverCertLen */
777 * Read a client network data block (TS_UD_CS_NET).\n
780 * @param settings rdp settings
783 boolean gcc_read_client_network_data(STREAM* s, rdpSettings *settings, uint16 blockLength)
790 stream_read_uint32(s, settings->num_channels); /* channelCount */
791 if (blockLength < 4 + settings->num_channels * 12)
793 if (settings->num_channels > 16)
796 /* channelDefArray */
797 for (i = 0; i < settings->num_channels; i++)
800 stream_read(s, settings->channels[i].name, 8); /* name (8 bytes) */
801 stream_read_uint32(s, settings->channels[i].options); /* options (4 bytes) */
802 settings->channels[i].chan_id = MCS_GLOBAL_CHANNEL_ID + 1 + i;
809 * Write a client network data block (TS_UD_CS_NET).\n
812 * @param settings rdp settings
815 void gcc_write_client_network_data(STREAM* s, rdpSettings *settings)
820 if (settings->num_channels > 0)
822 length = settings->num_channels * 12 + 8;
823 gcc_write_user_data_header(s, CS_NET, length);
825 stream_write_uint32(s, settings->num_channels); /* channelCount */
827 /* channelDefArray */
828 for (i = 0; i < settings->num_channels; i++)
831 stream_write(s, settings->channels[i].name, 8); /* name (8 bytes) */
832 stream_write_uint32(s, settings->channels[i].options); /* options (4 bytes) */
837 void gcc_read_server_network_data(STREAM* s, rdpSettings *settings)
844 stream_read_uint16(s, MCSChannelId); /* MCSChannelId */
845 stream_read_uint16(s, channelCount); /* channelCount */
847 if (channelCount != settings->num_channels)
849 printf("requested %d channels, got %d instead\n",
850 settings->num_channels, channelCount);
853 for (i = 0; i < channelCount; i++)
855 stream_read_uint16(s, channelId); /* channelId */
856 settings->channels[i].chan_id = channelId;
859 if (channelCount % 2 == 1)
860 stream_seek(s, 2); /* padding */
863 void gcc_write_server_network_data(STREAM* s, rdpSettings *settings)
867 gcc_write_user_data_header(s, SC_NET, 8 + settings->num_channels * 2 + (settings->num_channels % 2 == 1 ? 2 : 0));
869 stream_write_uint16(s, MCS_GLOBAL_CHANNEL_ID); /* MCSChannelId */
870 stream_write_uint16(s, settings->num_channels); /* channelCount */
872 for (i = 0; i < settings->num_channels; i++)
874 stream_write_uint16(s, settings->channels[i].chan_id);
877 if (settings->num_channels % 2 == 1)
878 stream_write_uint16(s, 0);
882 * Read a client cluster data block (TS_UD_CS_CLUSTER).\n
885 * @param settings rdp settings
888 boolean gcc_read_client_cluster_data(STREAM* s, rdpSettings *settings, uint16 blockLength)
895 stream_read_uint32(s, flags); /* flags */
897 if ((flags | REDIRECTED_SESSIONID_FIELD_VALID))
898 stream_read_uint32(s, settings->redirected_session_id); /* redirectedSessionID */
904 * Write a client cluster data block (TS_UD_CS_CLUSTER).\n
907 * @param settings rdp settings
910 void gcc_write_client_cluster_data(STREAM* s, rdpSettings *settings)
914 gcc_write_user_data_header(s, CS_CLUSTER, 12);
916 flags = REDIRECTION_SUPPORTED | (REDIRECTION_VERSION4 << 2);
918 if (settings->console_session || settings->redirected_session_id)
919 flags |= REDIRECTED_SESSIONID_FIELD_VALID;
921 stream_write_uint32(s, flags); /* flags */
922 stream_write_uint32(s, settings->redirected_session_id); /* redirectedSessionID */
926 * Read a client monitor data block (TS_UD_CS_MONITOR).\n
929 * @param settings rdp settings
932 boolean gcc_read_client_monitor_data(STREAM* s, rdpSettings *settings, uint16 blockLength)
934 printf("CS_MONITOR\n");
939 * Write a client monitor data block (TS_UD_CS_MONITOR).\n
942 * @param settings rdp settings
945 void gcc_write_client_monitor_data(STREAM* s, rdpSettings *settings)
949 uint32 left, top, right, bottom, flags;
951 if (settings->num_monitors > 1)
953 length = (20 * settings->num_monitors) + 12;
954 gcc_write_user_data_header(s, CS_MONITOR, length);
956 stream_write_uint32(s, 0); /* flags */
957 stream_write_uint32(s, settings->num_monitors); /* monitorCount */
959 for (i = 0; i < settings->num_monitors; i++)
961 left = settings->monitors[i].x;
962 top = settings->monitors[i].y;
963 right = settings->monitors[i].x + settings->monitors[i].width - 1;
964 bottom = settings->monitors[i].y + settings->monitors[i].height - 1;
965 flags = settings->monitors[i].is_primary ? MONITOR_PRIMARY : 0;
967 stream_write_uint32(s, left); /* left */
968 stream_write_uint32(s, top); /* top */
969 stream_write_uint32(s, right); /* right */
970 stream_write_uint32(s, bottom); /* bottom */
971 stream_write_uint32(s, flags); /* flags */