1 |
/* -*- c-basic-offset: 8 -*- |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Protocol services - Multipoint Communications Service |
Protocol services - Multipoint Communications Service |
4 |
Copyright (C) Matthew Chapman 1999-2002 |
Copyright (C) Matthew Chapman 1999-2008 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
8 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
9 |
(at your option) any later version. |
(at your option) any later version. |
10 |
|
|
11 |
This program is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
GNU General Public License for more details. |
GNU General Public License for more details. |
15 |
|
|
16 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
17 |
along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software |
18 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 |
extern unsigned int g_num_channels; |
extern unsigned int g_num_channels; |
26 |
|
|
27 |
/* Parse an ASN.1 BER header */ |
/* Parse an ASN.1 BER header */ |
28 |
static BOOL |
static RD_BOOL |
29 |
ber_parse_header(STREAM s, int tagval, int *length) |
ber_parse_header(STREAM s, int tagval, int *length) |
30 |
{ |
{ |
31 |
int tag, len; |
int tag, len; |
36 |
} |
} |
37 |
else |
else |
38 |
{ |
{ |
39 |
in_uint8(s, tag)} |
in_uint8(s, tag); |
40 |
|
} |
41 |
|
|
42 |
if (tag != tagval) |
if (tag != tagval) |
43 |
{ |
{ |
106 |
} |
} |
107 |
|
|
108 |
/* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */ |
/* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */ |
109 |
static BOOL |
static RD_BOOL |
110 |
mcs_parse_domain_params(STREAM s) |
mcs_parse_domain_params(STREAM s) |
111 |
{ |
{ |
112 |
int length; |
int length; |
148 |
} |
} |
149 |
|
|
150 |
/* Expect a MCS_CONNECT_RESPONSE message (ASN.1 BER) */ |
/* Expect a MCS_CONNECT_RESPONSE message (ASN.1 BER) */ |
151 |
static BOOL |
static RD_BOOL |
152 |
mcs_recv_connect_response(STREAM mcs_data) |
mcs_recv_connect_response(STREAM mcs_data) |
153 |
{ |
{ |
154 |
uint8 result; |
uint8 result; |
222 |
} |
} |
223 |
|
|
224 |
/* Expect a AUcf message (ASN.1 PER) */ |
/* Expect a AUcf message (ASN.1 PER) */ |
225 |
static BOOL |
static RD_BOOL |
226 |
mcs_recv_aucf(uint16 * mcs_userid) |
mcs_recv_aucf(uint16 * mcs_userid) |
227 |
{ |
{ |
228 |
uint8 opcode, result; |
uint8 opcode, result; |
271 |
} |
} |
272 |
|
|
273 |
/* Expect a CJcf message (ASN.1 PER) */ |
/* Expect a CJcf message (ASN.1 PER) */ |
274 |
static BOOL |
static RD_BOOL |
275 |
mcs_recv_cjcf(void) |
mcs_recv_cjcf(void) |
276 |
{ |
{ |
277 |
uint8 opcode, result; |
uint8 opcode, result; |
373 |
} |
} |
374 |
|
|
375 |
/* Establish a connection up to the MCS layer */ |
/* Establish a connection up to the MCS layer */ |
376 |
BOOL |
RD_BOOL |
377 |
mcs_connect(char *server, STREAM mcs_data, char *username) |
mcs_connect(char *server, STREAM mcs_data, char *username) |
378 |
{ |
{ |
379 |
unsigned int i; |
unsigned int i; |
413 |
return False; |
return False; |
414 |
} |
} |
415 |
|
|
416 |
|
/* Establish a connection up to the MCS layer */ |
417 |
|
RD_BOOL |
418 |
|
mcs_reconnect(char *server, STREAM mcs_data) |
419 |
|
{ |
420 |
|
unsigned int i; |
421 |
|
|
422 |
|
if (!iso_reconnect(server)) |
423 |
|
return False; |
424 |
|
|
425 |
|
mcs_send_connect_initial(mcs_data); |
426 |
|
if (!mcs_recv_connect_response(mcs_data)) |
427 |
|
goto error; |
428 |
|
|
429 |
|
mcs_send_edrq(); |
430 |
|
|
431 |
|
mcs_send_aurq(); |
432 |
|
if (!mcs_recv_aucf(&g_mcs_userid)) |
433 |
|
goto error; |
434 |
|
|
435 |
|
mcs_send_cjrq(g_mcs_userid + MCS_USERCHANNEL_BASE); |
436 |
|
|
437 |
|
if (!mcs_recv_cjcf()) |
438 |
|
goto error; |
439 |
|
|
440 |
|
mcs_send_cjrq(MCS_GLOBAL_CHANNEL); |
441 |
|
if (!mcs_recv_cjcf()) |
442 |
|
goto error; |
443 |
|
|
444 |
|
for (i = 0; i < g_num_channels; i++) |
445 |
|
{ |
446 |
|
mcs_send_cjrq(g_channels[i].mcs_id); |
447 |
|
if (!mcs_recv_cjcf()) |
448 |
|
goto error; |
449 |
|
} |
450 |
|
return True; |
451 |
|
|
452 |
|
error: |
453 |
|
iso_disconnect(); |
454 |
|
return False; |
455 |
|
} |
456 |
|
|
457 |
/* Disconnect from the MCS layer */ |
/* Disconnect from the MCS layer */ |
458 |
void |
void |
459 |
mcs_disconnect(void) |
mcs_disconnect(void) |
460 |
{ |
{ |
461 |
iso_disconnect(); |
iso_disconnect(); |
462 |
} |
} |
463 |
|
|
464 |
|
/* reset the state of the mcs layer */ |
465 |
|
void |
466 |
|
mcs_reset_state(void) |
467 |
|
{ |
468 |
|
g_mcs_userid = 0; |
469 |
|
iso_reset_state(); |
470 |
|
} |