~ubuntu-branches/ubuntu/raring/freerdp/raring-proposed

« back to all changes in this revision

Viewing changes to libfreerdp-core/connection.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt, Jeremy Bicha, Jean-Louis Dupond, Martin Pitt
  • Date: 2012-01-31 10:02:14 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120131100214-jaok3uwvni7sqxth
Tags: 1.0.0-0git1
Upload current Debian packaging git to get this rolling for precise.

[ Jeremy Bicha ]
* New upstream release. Closes: #647498.
* Updated symbols and bumped soname
* debian/control:
  - Added new build dependencies
  - Bump Standards-Version to 3.9.2
* debian/source/format: Set to 3.0 (quilt)
* debian/rules: Turn on strict symbols checking
* debian/watch: Watch github

[ Jean-Louis Dupond ]
* debian/control: Updated homepage
* debian/copyright: Reflect upstream switch to the Apache license

[ Martin Pitt ]
* debian/libfreerdp0.symbols: Fix version number, should
  be 1.0~beta5, not 1.0-beta5.
* debian/control: Add libavcodec-dev build dependency, upstream build system
  checks for that. Thanks Jean-Louis Dupond!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * FreeRDP: A Remote Desktop Protocol Client
 
3
 * Connection Sequence
 
4
 *
 
5
 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 
6
 *
 
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
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
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.
 
18
 */
 
19
 
 
20
#include "per.h"
 
21
#include "info.h"
 
22
#include "input.h"
 
23
 
 
24
#include "connection.h"
 
25
 
 
26
/**
 
27
 *                                      Connection Sequence
 
28
 *     client                                                                    server
 
29
 *        |                                                                         |
 
30
 *        |-----------------------X.224 Connection Request PDU--------------------->|
 
31
 *        |<----------------------X.224 Connection Confirm PDU----------------------|
 
32
 *        |-------MCS Connect-Initial PDU with GCC Conference Create Request------->|
 
33
 *        |<-----MCS Connect-Response PDU with GCC Conference Create Response-------|
 
34
 *        |------------------------MCS Erect Domain Request PDU-------------------->|
 
35
 *        |------------------------MCS Attach User Request PDU--------------------->|
 
36
 *        |<-----------------------MCS Attach User Confirm PDU----------------------|
 
37
 *        |------------------------MCS Channel Join Request PDU-------------------->|
 
38
 *        |<-----------------------MCS Channel Join Confirm PDU---------------------|
 
39
 *        |----------------------------Security Exchange PDU----------------------->|
 
40
 *        |-------------------------------Client Info PDU-------------------------->|
 
41
 *        |<---------------------License Error PDU - Valid Client-------------------|
 
42
 *        |<-----------------------------Demand Active PDU--------------------------|
 
43
 *        |------------------------------Confirm Active PDU------------------------>|
 
44
 *        |-------------------------------Synchronize PDU-------------------------->|
 
45
 *        |---------------------------Control PDU - Cooperate---------------------->|
 
46
 *        |------------------------Control PDU - Request Control------------------->|
 
47
 *        |--------------------------Persistent Key List PDU(s)-------------------->|
 
48
 *        |--------------------------------Font List PDU--------------------------->|
 
49
 *        |<------------------------------Synchronize PDU---------------------------|
 
50
 *        |<--------------------------Control PDU - Cooperate-----------------------|
 
51
 *        |<-----------------------Control PDU - Granted Control--------------------|
 
52
 *        |<-------------------------------Font Map PDU-----------------------------|
 
53
 *
 
54
 */
 
55
 
 
56
/**
 
57
 * Establish RDP Connection.\n
 
58
 * @msdn{cc240452}
 
59
 * @param rdp RDP module
 
60
 */
 
61
 
 
62
boolean rdp_client_connect(rdpRdp* rdp)
 
63
{
 
64
        boolean status;
 
65
        uint32 selectedProtocol;
 
66
        rdpSettings* settings = rdp->settings;
 
67
 
 
68
        nego_init(rdp->nego);
 
69
        nego_set_target(rdp->nego, settings->hostname, settings->port);
 
70
        nego_set_cookie(rdp->nego, settings->username);
 
71
        nego_enable_rdp(rdp->nego, settings->rdp_security);
 
72
        nego_enable_nla(rdp->nego, settings->nla_security);
 
73
        nego_enable_tls(rdp->nego, settings->tls_security);
 
74
 
 
75
        if (nego_connect(rdp->nego) != true)
 
76
        {
 
77
                printf("Error: protocol security negotiation failure\n");
 
78
                return false;
 
79
        }
 
80
 
 
81
        selectedProtocol = rdp->nego->selected_protocol;
 
82
 
 
83
        if ((selectedProtocol & PROTOCOL_TLS) || (selectedProtocol == PROTOCOL_RDP))
 
84
        {
 
85
                if ((settings->username != NULL) && (settings->password != NULL))
 
86
                        settings->autologon = true;
 
87
        }
 
88
 
 
89
        status = false;
 
90
        if (selectedProtocol & PROTOCOL_NLA)
 
91
                status = transport_connect_nla(rdp->transport);
 
92
        else if (selectedProtocol & PROTOCOL_TLS)
 
93
                status = transport_connect_tls(rdp->transport);
 
94
        else if (selectedProtocol == PROTOCOL_RDP) /* 0 */
 
95
                status = transport_connect_rdp(rdp->transport);
 
96
 
 
97
        if (status != true)
 
98
                return false;
 
99
 
 
100
        rdp_set_blocking_mode(rdp, false);
 
101
        rdp->state = CONNECTION_STATE_NEGO;
 
102
        rdp->finalize_sc_pdus = 0;
 
103
 
 
104
        if (mcs_send_connect_initial(rdp->mcs) != true)
 
105
        {
 
106
                printf("Error: unable to send MCS Connect Initial\n");
 
107
                return false;
 
108
        }
 
109
 
 
110
        while (rdp->state != CONNECTION_STATE_ACTIVE)
 
111
        {
 
112
                if (rdp_check_fds(rdp) < 0)
 
113
                        return false;
 
114
        }
 
115
 
 
116
        return true;
 
117
}
 
118
 
 
119
boolean rdp_client_disconnect(rdpRdp* rdp)
 
120
{
 
121
        return transport_disconnect(rdp->transport);
 
122
}
 
123
 
 
124
boolean rdp_client_redirect(rdpRdp* rdp)
 
125
{
 
126
        rdpSettings* settings = rdp->settings;
 
127
        rdpRedirection* redirection = rdp->redirection;
 
128
 
 
129
        rdp_client_disconnect(rdp);
 
130
 
 
131
        mcs_free(rdp->mcs);
 
132
        nego_free(rdp->nego);
 
133
        license_free(rdp->license);
 
134
        transport_free(rdp->transport);
 
135
        rdp->transport = transport_new(settings);
 
136
        rdp->license = license_new(rdp);
 
137
        rdp->nego = nego_new(rdp->transport);
 
138
        rdp->mcs = mcs_new(rdp->transport);
 
139
 
 
140
        rdp->transport->layer = TRANSPORT_LAYER_TCP;
 
141
        settings->redirected_session_id = redirection->sessionID;
 
142
 
 
143
        if (redirection->flags & LB_LOAD_BALANCE_INFO)
 
144
                nego_set_routing_token(rdp->nego, &redirection->loadBalanceInfo);
 
145
 
 
146
        if (redirection->flags & LB_TARGET_NET_ADDRESS)
 
147
        {
 
148
                xfree(settings->hostname);
 
149
                settings->hostname = redirection->targetNetAddress.ascii;
 
150
        }
 
151
        else if (redirection->flags & LB_TARGET_FQDN)
 
152
        {
 
153
                xfree(settings->hostname);
 
154
                settings->hostname = redirection->targetFQDN.ascii;
 
155
        }
 
156
        else if (redirection->flags & LB_TARGET_NETBIOS_NAME)
 
157
        {
 
158
                xfree(settings->hostname);
 
159
                settings->hostname = redirection->targetNetBiosName.ascii;
 
160
        }
 
161
 
 
162
        if (redirection->flags & LB_USERNAME)
 
163
        {
 
164
                xfree(settings->username);
 
165
                settings->username = redirection->username.ascii;
 
166
        }
 
167
 
 
168
        if (redirection->flags & LB_DOMAIN)
 
169
        {
 
170
                xfree(settings->domain);
 
171
                settings->domain = redirection->domain.ascii;
 
172
        }
 
173
 
 
174
        if (redirection->flags & LB_PASSWORD)
 
175
        {
 
176
                xfree(settings->password);
 
177
                settings->password = redirection->password.ascii;
 
178
        }
 
179
 
 
180
        return rdp_client_connect(rdp);
 
181
}
 
182
 
 
183
static boolean rdp_establish_keys(rdpRdp* rdp)
 
184
{
 
185
        uint8 client_random[32];
 
186
        uint8 crypt_client_random[256 + 8];
 
187
        uint32 key_len;
 
188
        uint8* mod;
 
189
        uint8* exp;
 
190
        uint32 length;
 
191
        STREAM* s;
 
192
 
 
193
        if (rdp->settings->encryption == false)
 
194
        {
 
195
                /* no RDP encryption */
 
196
                return true;
 
197
        }
 
198
 
 
199
        /* encrypt client random */
 
200
        memset(crypt_client_random, 0, sizeof(crypt_client_random));
 
201
        memset(client_random, 0x5e, 32);
 
202
        crypto_nonce(client_random, 32);
 
203
        key_len = rdp->settings->server_cert->cert_info.modulus.length;
 
204
        mod = rdp->settings->server_cert->cert_info.modulus.data;
 
205
        exp = rdp->settings->server_cert->cert_info.exponent;
 
206
        crypto_rsa_encrypt(client_random, 32, key_len, mod, exp, crypt_client_random);
 
207
 
 
208
        /* send crypt client random to server */
 
209
        length = 7 + 8 + 4 + 4 + key_len + 8;
 
210
        s = transport_send_stream_init(rdp->mcs->transport, length);
 
211
        tpkt_write_header(s, length);
 
212
        tpdu_write_header(s, 2, 0xf0);
 
213
        per_write_choice(s, DomainMCSPDU_SendDataRequest << 2);
 
214
        per_write_integer16(s, rdp->mcs->user_id, MCS_BASE_CHANNEL_ID);
 
215
        per_write_integer16(s, MCS_GLOBAL_CHANNEL_ID, 0);
 
216
        stream_write_uint8(s, 0x70);
 
217
        length = (4 + 4 + key_len + 8) | 0x8000;
 
218
        stream_write_uint16_be(s, length);
 
219
        stream_write_uint32(s, 1); /* SEC_CLIENT_RANDOM */
 
220
        length = key_len + 8;
 
221
        stream_write_uint32(s, length);
 
222
        stream_write(s, crypt_client_random, length);
 
223
        if (transport_write(rdp->mcs->transport, s) < 0)
 
224
        {
 
225
                return false;
 
226
        }
 
227
 
 
228
        /* now calculate encrypt / decrypt and update keys */
 
229
        if (!security_establish_keys(client_random, rdp))
 
230
        {
 
231
                return false;
 
232
        }
 
233
 
 
234
        rdp->do_crypt = true;
 
235
 
 
236
        if (rdp->settings->encryption_method == ENCRYPTION_METHOD_FIPS)
 
237
        {
 
238
                uint8 fips_ivec[8] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
 
239
                rdp->fips_encrypt = crypto_des3_encrypt_init(rdp->fips_encrypt_key, fips_ivec);
 
240
                rdp->fips_decrypt = crypto_des3_decrypt_init(rdp->fips_decrypt_key, fips_ivec);
 
241
 
 
242
                rdp->fips_hmac = crypto_hmac_new();
 
243
                return true;
 
244
        }
 
245
 
 
246
        rdp->rc4_decrypt_key = crypto_rc4_init(rdp->decrypt_key, rdp->rc4_key_len);
 
247
        rdp->rc4_encrypt_key = crypto_rc4_init(rdp->encrypt_key, rdp->rc4_key_len);
 
248
 
 
249
        return true;
 
250
}
 
251
 
 
252
boolean rdp_client_connect_mcs_connect_response(rdpRdp* rdp, STREAM* s)
 
253
{
 
254
        if (!mcs_recv_connect_response(rdp->mcs, s))
 
255
        {
 
256
                printf("rdp_client_connect_mcs_connect_response: mcs_recv_connect_response failed\n");
 
257
                return false;
 
258
        }
 
259
        if (!mcs_send_erect_domain_request(rdp->mcs))
 
260
                return false;
 
261
        if (!mcs_send_attach_user_request(rdp->mcs))
 
262
                return false;
 
263
 
 
264
        rdp->state = CONNECTION_STATE_MCS_ATTACH_USER;
 
265
 
 
266
        return true;
 
267
}
 
268
 
 
269
boolean rdp_client_connect_mcs_attach_user_confirm(rdpRdp* rdp, STREAM* s)
 
270
{
 
271
        if (!mcs_recv_attach_user_confirm(rdp->mcs, s))
 
272
                return false;
 
273
 
 
274
        if (!mcs_send_channel_join_request(rdp->mcs, rdp->mcs->user_id))
 
275
                return false;
 
276
 
 
277
        rdp->state = CONNECTION_STATE_MCS_CHANNEL_JOIN;
 
278
 
 
279
        return true;
 
280
}
 
281
 
 
282
boolean rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, STREAM* s)
 
283
{
 
284
        int i;
 
285
        uint16 channel_id;
 
286
        boolean all_joined = true;
 
287
 
 
288
        if (!mcs_recv_channel_join_confirm(rdp->mcs, s, &channel_id))
 
289
                return false;
 
290
 
 
291
        if (!rdp->mcs->user_channel_joined)
 
292
        {
 
293
                if (channel_id != rdp->mcs->user_id)
 
294
                        return false;
 
295
                rdp->mcs->user_channel_joined = true;
 
296
 
 
297
                if (!mcs_send_channel_join_request(rdp->mcs, MCS_GLOBAL_CHANNEL_ID))
 
298
                        return false;
 
299
        }
 
300
        else if (!rdp->mcs->global_channel_joined)
 
301
        {
 
302
                if (channel_id != MCS_GLOBAL_CHANNEL_ID)
 
303
                        return false;
 
304
                rdp->mcs->global_channel_joined = true;
 
305
 
 
306
                if (rdp->settings->num_channels > 0)
 
307
                {
 
308
                        if (!mcs_send_channel_join_request(rdp->mcs, rdp->settings->channels[0].channel_id))
 
309
                                return false;
 
310
 
 
311
                        all_joined = false;
 
312
                }
 
313
        }
 
314
        else
 
315
        {
 
316
                for (i = 0; i < rdp->settings->num_channels; i++)
 
317
                {
 
318
                        if (rdp->settings->channels[i].joined)
 
319
                                continue;
 
320
 
 
321
                        if (rdp->settings->channels[i].channel_id != channel_id)
 
322
                                return false;
 
323
 
 
324
                        rdp->settings->channels[i].joined = true;
 
325
                        break;
 
326
                }
 
327
                if (i + 1 < rdp->settings->num_channels)
 
328
                {
 
329
                        if (!mcs_send_channel_join_request(rdp->mcs, rdp->settings->channels[i + 1].channel_id))
 
330
                                return false;
 
331
 
 
332
                        all_joined = false;
 
333
                }
 
334
        }
 
335
 
 
336
        if (rdp->mcs->user_channel_joined && rdp->mcs->global_channel_joined && all_joined)
 
337
        {
 
338
                if (!rdp_establish_keys(rdp))
 
339
                        return false;
 
340
                if (!rdp_send_client_info(rdp))
 
341
                        return false;
 
342
                rdp->state = CONNECTION_STATE_LICENSE;
 
343
        }
 
344
 
 
345
        return true;
 
346
}
 
347
 
 
348
boolean rdp_client_connect_license(rdpRdp* rdp, STREAM* s)
 
349
{
 
350
        if (!license_recv(rdp->license, s))
 
351
                return false;
 
352
 
 
353
        if (rdp->license->state == LICENSE_STATE_ABORTED)
 
354
        {
 
355
                printf("license connection sequence aborted.\n");
 
356
                return false;
 
357
        }
 
358
 
 
359
        if (rdp->license->state == LICENSE_STATE_COMPLETED)
 
360
        {
 
361
                rdp->state = CONNECTION_STATE_CAPABILITY;
 
362
        }
 
363
 
 
364
        return true;
 
365
}
 
366
 
 
367
boolean rdp_client_connect_demand_active(rdpRdp* rdp, STREAM* s)
 
368
{
 
369
        uint8* mark;
 
370
        uint16 width;
 
371
        uint16 height;
 
372
 
 
373
        width = rdp->settings->width;
 
374
        height = rdp->settings->height;
 
375
 
 
376
        stream_get_mark(s, mark);
 
377
 
 
378
        if (!rdp_recv_demand_active(rdp, s))
 
379
        {
 
380
                stream_set_mark(s, mark);
 
381
                stream_seek(s, RDP_PACKET_HEADER_LENGTH);
 
382
 
 
383
                if (rdp_recv_out_of_sequence_pdu(rdp, s) != true)
 
384
                        return false;
 
385
 
 
386
                return true;
 
387
        }
 
388
 
 
389
        if (!rdp_send_confirm_active(rdp))
 
390
                return false;
 
391
 
 
392
        input_register_client_callbacks(rdp->input);
 
393
 
 
394
        /**
 
395
         * The server may request a different desktop size during Deactivation-Reactivation sequence.
 
396
         * In this case, the UI should be informed and do actual window resizing at this point.
 
397
         */
 
398
        if (width != rdp->settings->width || height != rdp->settings->height)
 
399
        {
 
400
                IFCALL(rdp->update->DesktopResize, rdp->update->context);
 
401
        }
 
402
 
 
403
        rdp->state = CONNECTION_STATE_FINALIZATION;
 
404
        update_reset_state(rdp->update);
 
405
 
 
406
        rdp_client_connect_finalize(rdp);
 
407
 
 
408
        return true;
 
409
}
 
410
 
 
411
boolean rdp_client_connect_finalize(rdpRdp* rdp)
 
412
{
 
413
        /**
 
414
         * [MS-RDPBCGR] 1.3.1.1 - 8.
 
415
         * The client-to-server PDUs sent during this phase have no dependencies on any of the server-to-
 
416
         * client PDUs; they may be sent as a single batch, provided that sequencing is maintained.
 
417
         */
 
418
 
 
419
        if (!rdp_send_client_synchronize_pdu(rdp))
 
420
                return false;
 
421
        if (!rdp_send_client_control_pdu(rdp, CTRLACTION_COOPERATE))
 
422
                return false;
 
423
        if (!rdp_send_client_control_pdu(rdp, CTRLACTION_REQUEST_CONTROL))
 
424
                return false;
 
425
 
 
426
        rdp->input->SynchronizeEvent(rdp->input, 0);
 
427
 
 
428
        if (!rdp_send_client_persistent_key_list_pdu(rdp))
 
429
                return false;
 
430
        if (!rdp_send_client_font_list_pdu(rdp, FONTLIST_FIRST | FONTLIST_LAST))
 
431
                return false;
 
432
 
 
433
        return true;
 
434
}
 
435
 
 
436
boolean rdp_server_accept_nego(rdpRdp* rdp, STREAM* s)
 
437
{
 
438
        boolean ret;
 
439
 
 
440
        transport_set_blocking_mode(rdp->transport, true);
 
441
 
 
442
        if (!nego_read_request(rdp->nego, s))
 
443
                return false;
 
444
        if (rdp->nego->requested_protocols == PROTOCOL_RDP)
 
445
        {
 
446
                printf("Standard RDP encryption is not supported.\n");
 
447
                return false;
 
448
        }
 
449
 
 
450
        printf("Requested protocols:");
 
451
        if ((rdp->nego->requested_protocols | PROTOCOL_TLS))
 
452
        {
 
453
                printf(" TLS");
 
454
                if (rdp->settings->tls_security)
 
455
                {
 
456
                        printf("(Y)");
 
457
                        rdp->nego->selected_protocol |= PROTOCOL_TLS;
 
458
                }
 
459
                else
 
460
                        printf("(n)");
 
461
        }
 
462
        if ((rdp->nego->requested_protocols | PROTOCOL_NLA))
 
463
        {
 
464
                printf(" NLA");
 
465
                if (rdp->settings->nla_security)
 
466
                {
 
467
                        printf("(Y)");
 
468
                        rdp->nego->selected_protocol |= PROTOCOL_NLA;
 
469
                }
 
470
                else
 
471
                        printf("(n)");
 
472
        }
 
473
        printf("\n");
 
474
 
 
475
        if (!nego_send_negotiation_response(rdp->nego))
 
476
                return false;
 
477
 
 
478
        ret = false;
 
479
        if (rdp->nego->selected_protocol & PROTOCOL_NLA)
 
480
                ret = transport_accept_nla(rdp->transport);
 
481
        else if (rdp->nego->selected_protocol & PROTOCOL_TLS)
 
482
                ret = transport_accept_tls(rdp->transport);
 
483
        else if (rdp->nego->selected_protocol & PROTOCOL_RDP)
 
484
                ret = transport_accept_rdp(rdp->transport);
 
485
 
 
486
        if (!ret)
 
487
                return false;
 
488
 
 
489
        transport_set_blocking_mode(rdp->transport, false);
 
490
 
 
491
        rdp->state = CONNECTION_STATE_NEGO;
 
492
 
 
493
        return true;
 
494
}
 
495
 
 
496
boolean rdp_server_accept_mcs_connect_initial(rdpRdp* rdp, STREAM* s)
 
497
{
 
498
        int i;
 
499
 
 
500
        if (!mcs_recv_connect_initial(rdp->mcs, s))
 
501
                return false;
 
502
 
 
503
        printf("Accepted client: %s\n", rdp->settings->client_hostname);
 
504
        printf("Accepted channels:");
 
505
        for (i = 0; i < rdp->settings->num_channels; i++)
 
506
        {
 
507
                printf(" %s", rdp->settings->channels[i].name);
 
508
        }
 
509
        printf("\n");
 
510
 
 
511
        if (!mcs_send_connect_response(rdp->mcs))
 
512
                return false;
 
513
 
 
514
        rdp->state = CONNECTION_STATE_MCS_CONNECT;
 
515
 
 
516
        return true;
 
517
}
 
518
 
 
519
boolean rdp_server_accept_mcs_erect_domain_request(rdpRdp* rdp, STREAM* s)
 
520
{
 
521
        if (!mcs_recv_erect_domain_request(rdp->mcs, s))
 
522
                return false;
 
523
 
 
524
        rdp->state = CONNECTION_STATE_MCS_ERECT_DOMAIN;
 
525
 
 
526
        return true;
 
527
}
 
528
 
 
529
boolean rdp_server_accept_mcs_attach_user_request(rdpRdp* rdp, STREAM* s)
 
530
{
 
531
        if (!mcs_recv_attach_user_request(rdp->mcs, s))
 
532
                return false;
 
533
 
 
534
        if (!mcs_send_attach_user_confirm(rdp->mcs))
 
535
                return false;
 
536
 
 
537
        rdp->state = CONNECTION_STATE_MCS_ATTACH_USER;
 
538
 
 
539
        return true;
 
540
}
 
541
 
 
542
boolean rdp_server_accept_mcs_channel_join_request(rdpRdp* rdp, STREAM* s)
 
543
{
 
544
        int i;
 
545
        uint16 channel_id;
 
546
        boolean all_joined = true;
 
547
 
 
548
        if (!mcs_recv_channel_join_request(rdp->mcs, s, &channel_id))
 
549
                return false;
 
550
 
 
551
        if (!mcs_send_channel_join_confirm(rdp->mcs, channel_id))
 
552
                return false;
 
553
 
 
554
        if (channel_id == rdp->mcs->user_id)
 
555
                rdp->mcs->user_channel_joined = true;
 
556
        else if (channel_id == MCS_GLOBAL_CHANNEL_ID)
 
557
                rdp->mcs->global_channel_joined = true;
 
558
 
 
559
        for (i = 0; i < rdp->settings->num_channels; i++)
 
560
        {
 
561
                if (rdp->settings->channels[i].channel_id == channel_id)
 
562
                        rdp->settings->channels[i].joined = true;
 
563
 
 
564
                if (!rdp->settings->channels[i].joined)
 
565
                        all_joined = false;
 
566
        }
 
567
 
 
568
        if (rdp->mcs->user_channel_joined && rdp->mcs->global_channel_joined && all_joined)
 
569
                rdp->state = CONNECTION_STATE_MCS_CHANNEL_JOIN;
 
570
 
 
571
        return true;
 
572
}
 
573
 
 
574
boolean rdp_server_accept_client_info(rdpRdp* rdp, STREAM* s)
 
575
{
 
576
        if (!rdp_recv_client_info(rdp, s))
 
577
                return false;
 
578
 
 
579
        if (!license_send_valid_client_error_packet(rdp->license))
 
580
                return false;
 
581
 
 
582
        rdp->state = CONNECTION_STATE_LICENSE;
 
583
 
 
584
        return true;
 
585
}
 
586
 
 
587
boolean rdp_server_accept_confirm_active(rdpRdp* rdp, STREAM* s)
 
588
{
 
589
        if (!rdp_recv_confirm_active(rdp, s))
 
590
                return false;
 
591
 
 
592
        rdp->state = CONNECTION_STATE_ACTIVE;
 
593
        update_reset_state(rdp->update);
 
594
 
 
595
        if (!rdp_send_server_synchronize_pdu(rdp))
 
596
                return false;
 
597
 
 
598
        if (!rdp_send_server_control_cooperate_pdu(rdp))
 
599
                return false;
 
600
 
 
601
        return true;
 
602
}
 
603
 
 
604
boolean rdp_server_reactivate(rdpRdp* rdp)
 
605
{
 
606
        if (!rdp_send_deactivate_all(rdp))
 
607
                return false;
 
608
 
 
609
        rdp->state = CONNECTION_STATE_LICENSE;
 
610
 
 
611
        if (!rdp_send_demand_active(rdp))
 
612
                return false;
 
613
 
 
614
        return true;
 
615
}
 
616