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 * ConferenceName ::= SEQUENCE
77 * numeric SimpleNumericString
78 * text SimpleTextString OPTIONAL,
82 * SimpleNumericString ::= NumericString (SIZE (1..255)) (FROM ("0123456789"))
84 * UserData ::= SET OF SEQUENCE
87 * value OCTET_STRING OPTIONAL
90 * H221NonStandardIdentifier ::= OCTET STRING (SIZE (4..255))
95 * OID = 0.0.20.124.0.1
96 * { itu-t(0) recommendation(0) t(20) t124(124) version(0) 1 }
97 * v.1 of ITU-T Recommendation T.124 (Feb 1998): "Generic Conference Control"
99 uint8 t124_02_98_oid[6] = { 0, 0, 20, 124, 0, 1 };
102 * Write a GCC Conference Create Request.\n
105 * @param user_data client data blocks
108 void gcc_write_create_conference_request(STREAM* s, STREAM* user_data)
111 per_write_choice(s, 0); /* From Key select object (0) of type OBJECT_IDENTIFIER */
112 per_write_object_identifier(s, t124_02_98_oid); /* ITU-T T.124 (02/98) OBJECT_IDENTIFIER */
114 /* ConnectData::connectPDU (OCTET_STRING) */
115 per_write_length(s, stream_get_length(user_data) + 14); /* connectPDU length */
118 per_write_choice(s, 0); /* From ConnectGCCPDU select conferenceCreateRequest (0) of type ConferenceCreateRequest */
119 per_write_selection(s, 0x08); /* select optional userData from ConferenceCreateRequest */
121 /* ConferenceCreateRequest::conferenceName */
122 per_write_numeric_string(s, "1", 1, 1); /* ConferenceName::numeric */
123 per_write_padding(s, 1); /* padding */
125 /* UserData (SET OF SEQUENCE) */
126 per_write_number_of_sets(s, 1); /* one set of UserData */
127 per_write_choice(s, 0xC0); /* UserData::value present + select h221NonStandard (1) */
129 /* h221NonStandard */
130 per_write_octet_string(s, "Duca", 4, 4); /* h221NonStandard, client-to-server H.221 key, "Duca" */
132 /* userData::value (OCTET_STRING) */
133 per_write_octet_string(s, user_data->data, stream_get_length(user_data), 0); /* array of client data blocks */
137 * Write a user data header (TS_UD_HEADER).\n
140 * @param type data block type
141 * @param length data block length
144 void gcc_write_user_data_header(STREAM* s, uint16 type, uint16 length)
146 stream_write_uint16(s, type); /* type */
147 stream_write_uint16(s, length); /* length */
151 * Write a client core data block (TS_UD_CS_CORE).\n
154 * @param settings rdp settings
157 void gcc_write_client_core_data(STREAM* s, rdpSettings *settings)
161 size_t clientNameLength;
162 uint8 connectionType;
163 uint16 highColorDepth;
164 uint16 supportedColorDepths;
165 uint16 earlyCapabilityFlags;
166 uint8* clientDigProductId;
167 size_t clientDigProductIdLength;
169 gcc_write_user_data_header(s, CS_CORE, 216);
171 version = settings->rdp_version >= 5 ? RDP_VERSION_5_PLUS : RDP_VERSION_4;
172 clientName = freerdp_uniconv_out(settings->uniconv, settings->client_hostname, &clientNameLength);
173 clientDigProductId = freerdp_uniconv_out(settings->uniconv, settings->client_product_id, &clientDigProductIdLength);
175 stream_write_uint32(s, version); /* version */
176 stream_write_uint16(s, settings->width); /* desktopWidth */
177 stream_write_uint16(s, settings->height); /* desktopHeight */
178 stream_write_uint16(s, RNS_UD_COLOR_8BPP); /* colorDepth, ignored because of postBeta2ColorDepth */
179 stream_write_uint16(s, RNS_UD_SAS_DEL); /* SASSequence (Secure Access Sequence) */
180 stream_write_uint32(s, settings->kbd_layout); /* keyboardLayout */
181 stream_write_uint32(s, settings->client_build); /* clientBuild */
183 /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
184 if (clientNameLength > 30)
186 clientNameLength = 30;
187 clientName[clientNameLength] = 0;
188 clientName[clientNameLength + 1] = 0;
190 stream_write(s, clientName, clientNameLength + 2);
191 stream_write_zero(s, 32 - clientNameLength - 2);
194 stream_write_uint32(s, settings->kbd_type); /* keyboardType */
195 stream_write_uint32(s, settings->kbd_subtype); /* keyboardSubType */
196 stream_write_uint32(s, settings->kbd_fn_keys); /* keyboardFunctionKey */
198 stream_write_zero(s, 64); /* imeFileName */
200 stream_write_uint16(s, RNS_UD_COLOR_8BPP); /* postBeta2ColorDepth */
201 stream_write_uint16(s, 1); /* clientProductID */
202 stream_write_uint32(s, 0); /* serialNumber (should be initialized to 0) */
204 highColorDepth = MIN(settings->color_depth, 24);
206 supportedColorDepths =
207 RNS_UD_32BPP_SUPPORT |
208 RNS_UD_24BPP_SUPPORT |
209 RNS_UD_16BPP_SUPPORT |
210 RNS_UD_15BPP_SUPPORT;
213 earlyCapabilityFlags = RNS_UD_CS_SUPPORT_ERRINFO_PDU;
215 if (settings->performance_flags == PERF_FLAG_NONE)
217 earlyCapabilityFlags |= RNS_UD_CS_VALID_CONNECTION_TYPE;
218 connectionType = CONNECTION_TYPE_LAN;
221 if (settings->color_depth == 32)
223 supportedColorDepths |= RNS_UD_32BPP_SUPPORT;
224 earlyCapabilityFlags |= RNS_UD_CS_WANT_32BPP_SESSION;
227 stream_write_uint16(s, highColorDepth); /* highColorDepth */
228 stream_write_uint16(s, supportedColorDepths); /* supportedColorDepths */
230 stream_write_uint16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */
232 /* clientDigProductId (64 bytes, null-terminated unicode, truncated to 30 characters) */
233 if (clientDigProductIdLength > 62)
235 clientDigProductIdLength = 62;
236 clientDigProductId[clientDigProductIdLength] = 0;
237 clientDigProductId[clientDigProductIdLength + 1] = 0;
239 stream_write(s, clientDigProductId, clientDigProductIdLength + 2);
240 stream_write_zero(s, 64 - clientDigProductIdLength - 2);
241 xfree(clientDigProductId);
243 stream_write_uint8(s, connectionType); /* connectionType */
244 stream_write_uint8(s, 0); /* pad1octet */
246 stream_write_uint32(s, settings->selected_protocol); /* serverSelectedProtocol */
250 * Write a client security data block (TS_UD_CS_SEC).\n
253 * @param settings rdp settings
256 void gcc_write_client_security_data(STREAM* s, rdpSettings *settings)
258 uint16 encryptionMethods;
260 gcc_write_user_data_header(s, CS_SECURITY, 12);
262 encryptionMethods = ENCRYPTION_40BIT_FLAG | ENCRYPTION_128BIT_FLAG;
264 if (settings->encryption > 0)
266 stream_write_uint32(s, encryptionMethods); /* encryptionMethods */
267 stream_write_uint32(s, 0); /* extEncryptionMethods */
271 /* French locale, disable encryption */
272 stream_write_uint32(s, 0); /* encryptionMethods */
273 stream_write_uint32(s, encryptionMethods); /* extEncryptionMethods */
278 * Write a client network data block (TS_UD_CS_NET).\n
281 * @param settings rdp settings
284 void gcc_write_client_network_data(STREAM* s, rdpSettings *settings)
289 if (settings->num_channels > 0)
291 length = settings->num_channels * 12 + 8;
292 gcc_write_user_data_header(s, CS_NET, length);
294 stream_write_uint32(s, settings->num_channels); /* channelCount */
296 /* channelDefArray */
297 for (i = 0; i < settings->num_channels; i++)
300 stream_write(s, settings->channels[i].name, 8); /* name (8 bytes) */
301 stream_write_uint32(s, settings->channels[i].options); /* options (4 bytes) */
307 * Write a client cluster data block (TS_UD_CS_CLUSTER).\n
310 * @param settings rdp settings
313 void gcc_write_client_cluster_data(STREAM* s, rdpSettings *settings)
317 gcc_write_user_data_header(s, CS_CLUSTER, 12);
319 flags = REDIRECTION_SUPPORTED | (REDIRECTION_VERSION4 << 2);
321 if (settings->console_session || settings->redirected_session_id)
322 flags |= REDIRECTED_SESSIONID_FIELD_VALID;
324 stream_write_uint32(s, flags); /* flags */
325 stream_write_uint32(s, settings->redirected_session_id); /* redirectedSessionID */
329 * Write a client monitor data block (TS_UD_CS_MONITOR).\n
332 * @param settings rdp settings
335 void gcc_write_client_monitor_data(STREAM* s, rdpSettings *settings)
339 uint32 left, top, right, bottom, flags;
341 if (settings->num_monitors > 1)
343 length = (20 * settings->num_monitors) + 12;
344 gcc_write_user_data_header(s, CS_MONITOR, length);
346 stream_write_uint32(s, 0); /* flags */
347 stream_write_uint32(s, settings->num_monitors); /* monitorCount */
349 for (i = 0; i < settings->num_monitors; i++)
351 left = settings->monitors[i].x;
352 top = settings->monitors[i].y;
353 right = settings->monitors[i].x + settings->monitors[i].width - 1;
354 bottom = settings->monitors[i].y + settings->monitors[i].height - 1;
355 flags = settings->monitors[i].is_primary ? MONITOR_PRIMARY : 0;
357 stream_write_uint32(s, left); /* left */
358 stream_write_uint32(s, top); /* top */
359 stream_write_uint32(s, right); /* right */
360 stream_write_uint32(s, bottom); /* bottom */
361 stream_write_uint32(s, flags); /* flags */