ReactOS 0.4.15-dev-7958-gcd0bb1a
mcs.c File Reference
#include "rdesktop.h"
Include dependency graph for mcs.c:

Go to the source code of this file.

Functions

static BOOL ber_parse_header (STREAM s, int tagval, int *length)
 
static void ber_out_header (STREAM s, int tagval, int length)
 
static void ber_out_integer (STREAM s, int value)
 
static void mcs_out_domain_params (STREAM s, int max_channels, int max_users, int max_tokens, int max_pdusize)
 
static BOOL mcs_parse_domain_params (STREAM s)
 
static BOOL mcs_send_connect_initial (RDPCLIENT *This, STREAM mcs_data)
 
static BOOL mcs_recv_connect_response (RDPCLIENT *This, STREAM mcs_data)
 
static BOOL mcs_send_edrq (RDPCLIENT *This)
 
static BOOL mcs_send_aurq (RDPCLIENT *This)
 
static BOOL mcs_recv_aucf (RDPCLIENT *This, uint16 *mcs_userid)
 
static BOOL mcs_send_cjrq (RDPCLIENT *This, uint16 chanid)
 
static BOOL mcs_recv_cjcf (RDPCLIENT *This)
 
STREAM mcs_init (RDPCLIENT *This, int length)
 
BOOL mcs_send_to_channel (RDPCLIENT *This, STREAM s, uint16 channel)
 
BOOL mcs_send (RDPCLIENT *This, STREAM s)
 
STREAM mcs_recv (RDPCLIENT *This, uint16 *channel, uint8 *rdpver)
 
BOOL mcs_connect (RDPCLIENT *This, char *server, char *cookie, STREAM mcs_data)
 
BOOL mcs_reconnect (RDPCLIENT *This, char *server, char *cookie, STREAM mcs_data)
 
void mcs_disconnect (RDPCLIENT *This)
 
void mcs_reset_state (RDPCLIENT *This)
 

Function Documentation

◆ ber_out_header()

static void ber_out_header ( STREAM  s,
int  tagval,
int  length 
)
static

Definition at line 60 of file mcs.c.

61{
62 if (tagval > 0xff)
63 {
64 out_uint16_be(s, tagval);
65 }
66 else
67 {
68 out_uint8(s, tagval);
69 }
70
71 if (length >= 0x80)
72 {
73 out_uint8(s, 0x82);
75 }
76 else
78}
#define out_uint8(s, v)
Definition: parse.h:92
#define out_uint16_be(s, v)
Definition: parse.h:77
GLdouble s
Definition: gl.h:2039
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

◆ ber_out_integer()

static void ber_out_integer ( STREAM  s,
int  value 
)
static

Definition at line 82 of file mcs.c.

83{
86}
void ber_out_header(STREAM s, int tagval, int length)
Definition: asn.c:61
#define BER_TAG_INTEGER
Definition: constants.h:78
Definition: pdh_main.c:94

◆ ber_parse_header()

static BOOL ber_parse_header ( STREAM  s,
int  tagval,
int length 
)
static

Definition at line 25 of file mcs.c.

26{
27 int tag, len;
28
29 if (tagval > 0xff)
30 {
32 }
33 else
34 {
35 in_uint8(s, tag)}
36
37 if (tag != tagval)
38 {
39 error("expected tag %d, got %d\n", tagval, tag);
40 return False;
41 }
42
43 in_uint8(s, len);
44
45 if (len & 0x80)
46 {
47 len &= ~0x80;
48 *length = 0;
49 while (len--)
50 next_be(s, *length);
51 }
52 else
53 *length = len;
54
55 return s_check(s);
56}
#define s_check(s)
Definition: parse.h:42
#define next_be(s, v)
Definition: parse.h:97
#define in_uint8(s, v)
Definition: parse.h:88
#define in_uint16_be(s, v)
Definition: parse.h:75
#define False
Definition: types.h:25
GLenum GLsizei len
Definition: glext.h:6722
#define error(str)
Definition: mkdosfs.c:1605
Definition: ecma_167.h:138

◆ mcs_connect()

BOOL mcs_connect ( RDPCLIENT This,
char server,
char cookie,
STREAM  mcs_data 
)

Definition at line 388 of file mcs.c.

389{
390 unsigned int i;
391
393 return False;
394
395 if (!mcs_send_connect_initial(This, mcs_data) || !mcs_recv_connect_response(This, mcs_data))
396 goto error;
397
399 goto error;
400
401 if (!mcs_recv_aucf(This, &This->mcs_userid))
402 goto error;
403
405 goto error;
406
408 goto error;
409
410 for (i = 0; i < This->num_channels; i++)
411 {
413 goto error;
414 }
415 return True;
416
417 error:
419 return False;
420}
#define MCS_USERCHANNEL_BASE
Definition: constants.h:88
#define MCS_GLOBAL_CHANNEL
Definition: constants.h:87
RD_BOOL iso_connect(char *server, char *username, char *domain, char *password, RD_BOOL reconnect, uint32 *selected_protocol)
Definition: iso.c:203
void iso_disconnect(void)
Definition: iso.c:362
static void mcs_send_cjrq(uint16 chanid)
Definition: mcs.c:192
static void mcs_send_edrq(void)
Definition: mcs.c:131
static RD_BOOL mcs_recv_aucf(uint16 *mcs_userid)
Definition: mcs.c:161
static void mcs_send_aurq(void)
Definition: mcs.c:147
static RD_BOOL mcs_recv_connect_response(STREAM mcs_data)
Definition: mcs.c:87
static RD_BOOL mcs_recv_cjcf(void)
Definition: mcs.c:210
static void mcs_send_connect_initial(STREAM mcs_data)
Definition: mcs.c:57
#define True
Definition: types.h:24
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: cookie.c:34
static rfbScreenInfoPtr server
Definition: vnc.c:74

Referenced by sec_connect().

◆ mcs_disconnect()

void mcs_disconnect ( RDPCLIENT This)

Definition at line 460 of file mcs.c.

461{
463}

◆ mcs_init()

STREAM mcs_init ( RDPCLIENT This,
int  length 
)

Definition at line 314 of file mcs.c.

315{
316 STREAM s;
317
318 s = iso_init(This, length + 8);
319
320 if(s == NULL)
321 return NULL;
322
323 s_push_layer(s, mcs_hdr, 8);
324
325 return s;
326}
STREAM iso_init(int length)
Definition: iso.c:150
#define s_push_layer(s, h, n)
Definition: parse.h:39
#define NULL
Definition: types.h:112
Definition: parse.h:23

◆ mcs_out_domain_params()

static void mcs_out_domain_params ( STREAM  s,
int  max_channels,
int  max_users,
int  max_tokens,
int  max_pdusize 
)
static

Definition at line 90 of file mcs.c.

91{
93 ber_out_integer(s, max_channels);
94 ber_out_integer(s, max_users);
95 ber_out_integer(s, max_tokens);
96 ber_out_integer(s, 1); /* num_priorities */
97 ber_out_integer(s, 0); /* min_throughput */
98 ber_out_integer(s, 1); /* max_height */
99 ber_out_integer(s, max_pdusize);
100 ber_out_integer(s, 2); /* ver_protocol */
101}
void ber_out_integer(STREAM s, int value)
Definition: asn.c:83
#define MCS_TAG_DOMAIN_PARAMS
Definition: constants.h:85

◆ mcs_parse_domain_params()

static BOOL mcs_parse_domain_params ( STREAM  s)
static

Definition at line 105 of file mcs.c.

106{
107 int length;
108
111
112 return s_check(s);
113}
RD_BOOL ber_parse_header(STREAM s, int tagval, int *length)
Definition: asn.c:25
#define in_uint8s(s, n)
Definition: parse.h:91

◆ mcs_reconnect()

BOOL mcs_reconnect ( RDPCLIENT This,
char server,
char cookie,
STREAM  mcs_data 
)

Definition at line 424 of file mcs.c.

425{
426 unsigned int i;
427
429 return False;
430
431 if (!mcs_send_connect_initial(This, mcs_data) || !mcs_recv_connect_response(This, mcs_data))
432 goto error;
433
435 goto error;
436
437 if (!mcs_recv_aucf(This, &This->mcs_userid))
438 goto error;
439
441 goto error;
442
444 goto error;
445
446 for (i = 0; i < This->num_channels; i++)
447 {
449 goto error;
450 }
451 return True;
452
453 error:
455 return False;
456}
BOOL iso_reconnect(RDPCLIENT *This, char *server, char *cookie)
Definition: iso.c:204

Referenced by sec_reconnect().

◆ mcs_recv()

STREAM mcs_recv ( RDPCLIENT This,
uint16 channel,
uint8 rdpver 
)

Definition at line 356 of file mcs.c.

357{
358 uint8 opcode, appid, length;
359 STREAM s;
360
361 s = iso_recv(This, rdpver);
362 if (s == NULL)
363 return NULL;
364 if (rdpver != NULL)
365 if (*rdpver != 3)
366 return s;
367 in_uint8(s, opcode);
368 appid = opcode >> 2;
369 if (appid != MCS_SDIN)
370 {
371 if (appid != MCS_DPUM)
372 {
373 error("expected data, got %d\n", opcode);
374 }
375 return NULL;
376 }
377 in_uint8s(s, 2); /* userid */
378 in_uint16_be(s, *channel);
379 in_uint8s(s, 1); /* flags */
380 in_uint8(s, length);
381 if (length & 0x80)
382 in_uint8s(s, 1); /* second byte of length */
383 return s;
384}
@ MCS_SDIN
Definition: constants.h:71
@ MCS_DPUM
Definition: constants.h:65
STREAM iso_recv(uint8 *rdpver)
Definition: iso.c:182
unsigned char uint8
Definition: types.h:28
char * appid
Definition: mkisofs.c:161

◆ mcs_recv_aucf()

static BOOL mcs_recv_aucf ( RDPCLIENT This,
uint16 mcs_userid 
)
static

Definition at line 230 of file mcs.c.

231{
232 uint8 opcode, result;
233 STREAM s;
234
235 s = iso_recv(This, NULL);
236 if (s == NULL)
237 return False;
238
239 in_uint8(s, opcode);
240 if ((opcode >> 2) != MCS_AUCF)
241 {
242 error("expected AUcf, got %d\n", opcode);
243 return False;
244 }
245
246 in_uint8(s, result);
247 if (result != 0)
248 {
249 error("AUrq: %d\n", result);
250 return False;
251 }
252
253 if (opcode & 2)
254 in_uint16_be(s, *mcs_userid);
255
256 return s_check_end(s);
257}
@ MCS_AUCF
Definition: constants.h:67
#define s_check_end(s)
Definition: parse.h:44
GLuint64EXT * result
Definition: glext.h:11304

◆ mcs_recv_cjcf()

static BOOL mcs_recv_cjcf ( RDPCLIENT This)
static

Definition at line 282 of file mcs.c.

283{
284 uint8 opcode, result;
285 STREAM s;
286
287 s = iso_recv(This, NULL);
288 if (s == NULL)
289 return False;
290
291 in_uint8(s, opcode);
292 if ((opcode >> 2) != MCS_CJCF)
293 {
294 error("expected CJcf, got %d\n", opcode);
295 return False;
296 }
297
298 in_uint8(s, result);
299 if (result != 0)
300 {
301 error("CJrq: %d\n", result);
302 return False;
303 }
304
305 in_uint8s(s, 4); /* mcs_userid, req_chanid */
306 if (opcode & 2)
307 in_uint8s(s, 2); /* join_chanid */
308
309 return s_check_end(s);
310}
@ MCS_CJCF
Definition: constants.h:69

◆ mcs_recv_connect_response()

static BOOL mcs_recv_connect_response ( RDPCLIENT This,
STREAM  mcs_data 
)
static

Definition at line 150 of file mcs.c.

151{
153 int length;
154 STREAM s;
155
156 s = iso_recv(This, NULL);
157 if (s == NULL)
158 return False;
159
161
163 in_uint8(s, result);
164 if (result != 0)
165 {
166 error("MCS connect: %d\n", result);
167 return False;
168 }
169
171 in_uint8s(s, length); /* connect id */
173
175
177 /*
178 if (length > mcs_data->size)
179 {
180 error("MCS data length %d, expected %d\n", length,
181 mcs_data->size);
182 length = mcs_data->size;
183 }
184
185 in_uint8a(s, mcs_data->data, length);
186 mcs_data->p = mcs_data->data;
187 mcs_data->end = mcs_data->data + length;
188 */
189 return s_check_end(s);
190}
#define BER_TAG_RESULT
Definition: constants.h:80
#define BER_TAG_OCTET_STRING
Definition: constants.h:79
#define MCS_CONNECT_RESPONSE
Definition: constants.h:75
static RD_BOOL mcs_parse_domain_params(STREAM s)
Definition: mcs.c:45
void sec_process_mcs_data(STREAM s)
Definition: secure.c:856

◆ mcs_reset_state()

void mcs_reset_state ( RDPCLIENT This)

Definition at line 467 of file mcs.c.

468{
469 This->mcs_userid = 0;
471}
void iso_reset_state(void)
Definition: iso.c:370

◆ mcs_send()

BOOL mcs_send ( RDPCLIENT This,
STREAM  s 
)

Definition at line 349 of file mcs.c.

350{
352}
void mcs_send_to_channel(STREAM s, uint16 channel)
Definition: mcs.c:254

◆ mcs_send_aurq()

static BOOL mcs_send_aurq ( RDPCLIENT This)
static

Definition at line 213 of file mcs.c.

214{
215 STREAM s;
216
217 s = iso_init(This, 1);
218
219 if(s == NULL)
220 return False;
221
222 out_uint8(s, (MCS_AURQ << 2));
223
224 s_mark_end(s);
225 return iso_send(This, s);
226}
@ MCS_AURQ
Definition: constants.h:66
void iso_send(STREAM s)
Definition: iso.c:162
#define s_mark_end(s)
Definition: parse.h:41

◆ mcs_send_cjrq()

static BOOL mcs_send_cjrq ( RDPCLIENT This,
uint16  chanid 
)
static

Definition at line 261 of file mcs.c.

262{
263 STREAM s;
264
265 DEBUG_RDP5(("Sending CJRQ for channel #%d\n", chanid));
266
267 s = iso_init(This, 5);
268
269 if(s == NULL)
270 return False;
271
272 out_uint8(s, (MCS_CJRQ << 2));
273 out_uint16_be(s, This->mcs_userid);
274 out_uint16_be(s, chanid);
275
276 s_mark_end(s);
277 return iso_send(This, s);
278}
@ MCS_CJRQ
Definition: constants.h:68
#define DEBUG_RDP5(args)
Definition: rdesktop.h:141

◆ mcs_send_connect_initial()

static BOOL mcs_send_connect_initial ( RDPCLIENT This,
STREAM  mcs_data 
)
static

Definition at line 117 of file mcs.c.

118{
119 int datalen = (uint16)(mcs_data->end - mcs_data->data);
120 int length = 9 + 3 * 34 + 4 + datalen;
121 STREAM s;
122
123 s = iso_init(This, length + 5);
124
125 if(s == NULL)
126 return False;
127
129 ber_out_header(s, BER_TAG_OCTET_STRING, 1); /* calling domain */
130 out_uint8(s, 1);
131 ber_out_header(s, BER_TAG_OCTET_STRING, 1); /* called domain */
132 out_uint8(s, 1);
133
135 out_uint8(s, 0xff); /* upward flag */
136
137 mcs_out_domain_params(s, 34, 2, 0, 0xffff); /* target params */
138 mcs_out_domain_params(s, 1, 1, 1, 0x420); /* min params */
139 mcs_out_domain_params(s, 0xffff, 0xfc17, 0xffff, 0xffff); /* max params */
140
142 out_uint8p(s, mcs_data->data, datalen);
143
144 s_mark_end(s);
145 return iso_send(This, s);
146}
#define MCS_CONNECT_INITIAL
Definition: constants.h:74
#define BER_TAG_BOOLEAN
Definition: constants.h:77
static void mcs_out_domain_params(STREAM s, int max_channels, int max_users, int max_tokens, int max_pdusize)
Definition: mcs.c:30
#define out_uint8p(s, v, n)
Definition: parse.h:93
unsigned short uint16
Definition: types.h:30
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1031
unsigned char * end
Definition: parse.h:25
unsigned char * data
Definition: parse.h:26

◆ mcs_send_edrq()

static BOOL mcs_send_edrq ( RDPCLIENT This)
static

Definition at line 194 of file mcs.c.

195{
196 STREAM s;
197
198 s = iso_init(This, 5);
199
200 if(s == NULL)
201 return False;
202
203 out_uint8(s, (MCS_EDRQ << 2));
204 out_uint16_be(s, 1); /* height */
205 out_uint16_be(s, 1); /* interval */
206
207 s_mark_end(s);
208 return iso_send(This, s);
209}
@ MCS_EDRQ
Definition: constants.h:64

◆ mcs_send_to_channel()

BOOL mcs_send_to_channel ( RDPCLIENT This,
STREAM  s,
uint16  channel 
)

Definition at line 330 of file mcs.c.

331{
333
334 s_pop_layer(s, mcs_hdr);
335 length = (uint16)(s->end - s->p - 8);
336 length |= 0x8000;
337
338 out_uint8(s, (MCS_SDRQ << 2));
339 out_uint16_be(s, This->mcs_userid);
340 out_uint16_be(s, channel);
341 out_uint8(s, 0x70); /* flags */
343
344 return iso_send(This, s);
345}
@ MCS_SDRQ
Definition: constants.h:70
#define s_pop_layer(s, h)
Definition: parse.h:40