1 |
/* |
/* |
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-2000 |
Copyright (C) Matthew Chapman 1999-2001 |
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 |
23 |
uint16 mcs_userid; |
uint16 mcs_userid; |
24 |
|
|
25 |
/* Parse an ASN.1 BER header */ |
/* Parse an ASN.1 BER header */ |
26 |
static BOOL ber_parse_header(STREAM s, int tagval, int *length) |
static BOOL |
27 |
|
ber_parse_header(STREAM s, int tagval, int *length) |
28 |
{ |
{ |
29 |
int tag, len; |
int tag, len; |
30 |
|
|
38 |
|
|
39 |
if (tag != tagval) |
if (tag != tagval) |
40 |
{ |
{ |
41 |
ERROR("expected tag %d, got %d\n", tagval, tag); |
error("expected tag %d, got %d\n", tagval, tag); |
42 |
return False; |
return False; |
43 |
} |
} |
44 |
|
|
58 |
} |
} |
59 |
|
|
60 |
/* Output an ASN.1 BER header */ |
/* Output an ASN.1 BER header */ |
61 |
static void ber_out_header(STREAM s, int tagval, int length) |
static void |
62 |
|
ber_out_header(STREAM s, int tagval, int length) |
63 |
{ |
{ |
64 |
if (tagval > 0xff) |
if (tagval > 0xff) |
65 |
{ |
{ |
80 |
} |
} |
81 |
|
|
82 |
/* Output an ASN.1 BER integer */ |
/* Output an ASN.1 BER integer */ |
83 |
static void ber_out_integer(STREAM s, int value) |
static void |
84 |
|
ber_out_integer(STREAM s, int value) |
85 |
{ |
{ |
86 |
ber_out_header(s, BER_TAG_INTEGER, 2); |
ber_out_header(s, BER_TAG_INTEGER, 2); |
87 |
out_uint16_be(s, value); |
out_uint16_be(s, value); |
88 |
} |
} |
89 |
|
|
90 |
/* Output a DOMAIN_PARAMS structure (ASN.1 BER) */ |
/* Output a DOMAIN_PARAMS structure (ASN.1 BER) */ |
91 |
static void mcs_out_domain_params(STREAM s, int max_channels, int max_users, |
static void |
92 |
int max_tokens, int max_pdusize) |
mcs_out_domain_params(STREAM s, int max_channels, int max_users, |
93 |
|
int max_tokens, int max_pdusize) |
94 |
{ |
{ |
95 |
ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32); |
ber_out_header(s, MCS_TAG_DOMAIN_PARAMS, 32); |
96 |
ber_out_integer(s, max_channels); |
ber_out_integer(s, max_channels); |
104 |
} |
} |
105 |
|
|
106 |
/* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */ |
/* Parse a DOMAIN_PARAMS structure (ASN.1 BER) */ |
107 |
static BOOL mcs_parse_domain_params(STREAM s) |
static BOOL |
108 |
|
mcs_parse_domain_params(STREAM s) |
109 |
{ |
{ |
110 |
int length; |
int length; |
111 |
|
|
116 |
} |
} |
117 |
|
|
118 |
/* Send an MCS_CONNECT_INITIAL message (ASN.1 BER) */ |
/* Send an MCS_CONNECT_INITIAL message (ASN.1 BER) */ |
119 |
static void mcs_send_connect_initial(STREAM mcs_data) |
static void |
120 |
|
mcs_send_connect_initial(STREAM mcs_data) |
121 |
{ |
{ |
122 |
int datalen = mcs_data->end - mcs_data->data; |
int datalen = mcs_data->end - mcs_data->data; |
123 |
int length = 7 + 3 * 34 + 4 + datalen; |
int length = 7 + 3 * 34 + 4 + datalen; |
144 |
} |
} |
145 |
|
|
146 |
/* Expect a MCS_CONNECT_RESPONSE message (ASN.1 BER) */ |
/* Expect a MCS_CONNECT_RESPONSE message (ASN.1 BER) */ |
147 |
static BOOL mcs_recv_connect_response(STREAM mcs_data) |
static BOOL |
148 |
|
mcs_recv_connect_response(STREAM mcs_data) |
149 |
{ |
{ |
150 |
uint8 result; |
uint8 result; |
151 |
int length; |
int length; |
161 |
in_uint8(s, result); |
in_uint8(s, result); |
162 |
if (result != 0) |
if (result != 0) |
163 |
{ |
{ |
164 |
ERROR("MCS connect: %d\n", result); |
error("MCS connect: %d\n", result); |
165 |
return False; |
return False; |
166 |
} |
} |
167 |
|
|
172 |
ber_parse_header(s, BER_TAG_OCTET_STRING, &length); |
ber_parse_header(s, BER_TAG_OCTET_STRING, &length); |
173 |
if (length > mcs_data->size) |
if (length > mcs_data->size) |
174 |
{ |
{ |
175 |
WARN("MCS data length %d\n", length); |
error("MCS data length %d\n", length); |
176 |
length = mcs_data->size; |
length = mcs_data->size; |
177 |
} |
} |
178 |
|
|
184 |
} |
} |
185 |
|
|
186 |
/* Send an EDrq message (ASN.1 PER) */ |
/* Send an EDrq message (ASN.1 PER) */ |
187 |
static void mcs_send_edrq() |
static void |
188 |
|
mcs_send_edrq() |
189 |
{ |
{ |
190 |
STREAM s; |
STREAM s; |
191 |
|
|
200 |
} |
} |
201 |
|
|
202 |
/* Send an AUrq message (ASN.1 PER) */ |
/* Send an AUrq message (ASN.1 PER) */ |
203 |
static void mcs_send_aurq() |
static void |
204 |
|
mcs_send_aurq() |
205 |
{ |
{ |
206 |
STREAM s; |
STREAM s; |
207 |
|
|
214 |
} |
} |
215 |
|
|
216 |
/* Expect a AUcf message (ASN.1 PER) */ |
/* Expect a AUcf message (ASN.1 PER) */ |
217 |
static BOOL mcs_recv_aucf(uint16 *mcs_userid) |
static BOOL |
218 |
|
mcs_recv_aucf(uint16 * mcs_userid) |
219 |
{ |
{ |
220 |
uint8 opcode, result; |
uint8 opcode, result; |
221 |
STREAM s; |
STREAM s; |
227 |
in_uint8(s, opcode); |
in_uint8(s, opcode); |
228 |
if ((opcode >> 2) != MCS_AUCF) |
if ((opcode >> 2) != MCS_AUCF) |
229 |
{ |
{ |
230 |
ERROR("expected AUcf, got %d\n", opcode); |
error("expected AUcf, got %d\n", opcode); |
231 |
return False; |
return False; |
232 |
} |
} |
233 |
|
|
234 |
in_uint8(s, result); |
in_uint8(s, result); |
235 |
if (result != 0) |
if (result != 0) |
236 |
{ |
{ |
237 |
ERROR("AUrq: %d\n", result); |
error("AUrq: %d\n", result); |
238 |
return False; |
return False; |
239 |
} |
} |
240 |
|
|
245 |
} |
} |
246 |
|
|
247 |
/* Send a CJrq message (ASN.1 PER) */ |
/* Send a CJrq message (ASN.1 PER) */ |
248 |
static void mcs_send_cjrq(uint16 chanid) |
static void |
249 |
|
mcs_send_cjrq(uint16 chanid) |
250 |
{ |
{ |
251 |
STREAM s; |
STREAM s; |
252 |
|
|
261 |
} |
} |
262 |
|
|
263 |
/* Expect a CJcf message (ASN.1 PER) */ |
/* Expect a CJcf message (ASN.1 PER) */ |
264 |
static BOOL mcs_recv_cjcf() |
static BOOL |
265 |
|
mcs_recv_cjcf() |
266 |
{ |
{ |
267 |
uint8 opcode, result; |
uint8 opcode, result; |
268 |
STREAM s; |
STREAM s; |
274 |
in_uint8(s, opcode); |
in_uint8(s, opcode); |
275 |
if ((opcode >> 2) != MCS_CJCF) |
if ((opcode >> 2) != MCS_CJCF) |
276 |
{ |
{ |
277 |
ERROR("expected CJcf, got %d\n", opcode); |
error("expected CJcf, got %d\n", opcode); |
278 |
return False; |
return False; |
279 |
} |
} |
280 |
|
|
281 |
in_uint8(s, result); |
in_uint8(s, result); |
282 |
if (result != 0) |
if (result != 0) |
283 |
{ |
{ |
284 |
ERROR("CJrq: %d\n", result); |
error("CJrq: %d\n", result); |
285 |
return False; |
return False; |
286 |
} |
} |
287 |
|
|
293 |
} |
} |
294 |
|
|
295 |
/* Initialise an MCS transport data packet */ |
/* Initialise an MCS transport data packet */ |
296 |
STREAM mcs_init(int length) |
STREAM |
297 |
|
mcs_init(int length) |
298 |
{ |
{ |
299 |
STREAM s; |
STREAM s; |
300 |
|
|
305 |
} |
} |
306 |
|
|
307 |
/* Send an MCS transport data packet */ |
/* Send an MCS transport data packet */ |
308 |
void mcs_send(STREAM s) |
void |
309 |
|
mcs_send(STREAM s) |
310 |
{ |
{ |
311 |
uint16 length; |
uint16 length; |
312 |
|
|
324 |
} |
} |
325 |
|
|
326 |
/* Receive an MCS transport data packet */ |
/* Receive an MCS transport data packet */ |
327 |
STREAM mcs_recv() |
STREAM |
328 |
|
mcs_recv() |
329 |
{ |
{ |
330 |
uint8 opcode, appid, length; |
uint8 opcode, appid, length; |
331 |
STREAM s; |
STREAM s; |
340 |
{ |
{ |
341 |
if (appid != MCS_DPUM) |
if (appid != MCS_DPUM) |
342 |
{ |
{ |
343 |
ERROR("expected data, got %d\n", opcode); |
error("expected data, got %d\n", opcode); |
344 |
} |
} |
345 |
return NULL; |
return NULL; |
346 |
} |
} |
354 |
} |
} |
355 |
|
|
356 |
/* Establish a connection up to the MCS layer */ |
/* Establish a connection up to the MCS layer */ |
357 |
BOOL mcs_connect(char *server, STREAM mcs_data) |
BOOL |
358 |
|
mcs_connect(char *server, STREAM mcs_data) |
359 |
{ |
{ |
360 |
if (!iso_connect(server)) |
if (!iso_connect(server)) |
361 |
return False; |
return False; |
386 |
} |
} |
387 |
|
|
388 |
/* Disconnect from the MCS layer */ |
/* Disconnect from the MCS layer */ |
389 |
void mcs_disconnect() |
void |
390 |
|
mcs_disconnect() |
391 |
{ |
{ |
392 |
iso_disconnect(); |
iso_disconnect(); |
393 |
} |
} |