/[rdesktop]/sourceforge.net/trunk/rdesktop/rdp.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /sourceforge.net/trunk/rdesktop/rdp.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (show annotations)
Tue Jul 30 07:18:48 2002 UTC (21 years, 9 months ago) by astrand
File MIME type: text/plain
File size: 16761 byte(s)
Changed max line length to 100

1 /*
2 rdesktop: A Remote Desktop Protocol client.
3 Protocol services - RDP layer
4 Copyright (C) Matthew Chapman 1999-2001
5
6 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
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "rdesktop.h"
22
23 extern uint16 mcs_userid;
24 extern char username[16];
25 extern BOOL bitmap_compression;
26 extern BOOL orders;
27 extern BOOL encryption;
28 extern BOOL desktop_save;
29
30 uint8 *next_packet;
31 uint32 rdp_shareid;
32
33 /* Initialise an RDP packet */
34 static STREAM
35 rdp_init(int maxlen)
36 {
37 STREAM s;
38
39 s = sec_init(encryption ? SEC_ENCRYPT : 0, maxlen + 6);
40 s_push_layer(s, rdp_hdr, 6);
41
42 return s;
43 }
44
45 /* Send an RDP packet */
46 static void
47 rdp_send(STREAM s, uint8 pdu_type)
48 {
49 uint16 length;
50
51 s_pop_layer(s, rdp_hdr);
52 length = s->end - s->p;
53
54 out_uint16_le(s, length);
55 out_uint16_le(s, (pdu_type | 0x10)); /* Version 1 */
56 out_uint16_le(s, (mcs_userid + 1001));
57
58 sec_send(s, encryption ? SEC_ENCRYPT : 0);
59 }
60
61 /* Receive an RDP packet */
62 static STREAM
63 rdp_recv(uint8 * type)
64 {
65 static STREAM rdp_s;
66 uint16 length, pdu_type;
67
68 if ((rdp_s == NULL) || (next_packet >= rdp_s->end))
69 {
70 rdp_s = sec_recv();
71 if (rdp_s == NULL)
72 return NULL;
73
74 next_packet = rdp_s->p;
75 }
76 else
77 {
78 rdp_s->p = next_packet;
79 }
80
81 in_uint16_le(rdp_s, length);
82 in_uint16_le(rdp_s, pdu_type);
83 in_uint8s(rdp_s, 2); /* userid */
84 *type = pdu_type & 0xf;
85
86 #if WITH_DEBUG
87 DEBUG(("RDP packet (type %x):\n", *type));
88 hexdump(next_packet, length);
89 #endif /* */
90
91 next_packet += length;
92 return rdp_s;
93 }
94
95 /* Initialise an RDP data packet */
96 static STREAM
97 rdp_init_data(int maxlen)
98 {
99 STREAM s;
100
101 s = sec_init(encryption ? SEC_ENCRYPT : 0, maxlen + 18);
102 s_push_layer(s, rdp_hdr, 18);
103
104 return s;
105 }
106
107 /* Send an RDP data packet */
108 static void
109 rdp_send_data(STREAM s, uint8 data_pdu_type)
110 {
111 uint16 length;
112
113 s_pop_layer(s, rdp_hdr);
114 length = s->end - s->p;
115
116 out_uint16_le(s, length);
117 out_uint16_le(s, (RDP_PDU_DATA | 0x10));
118 out_uint16_le(s, (mcs_userid + 1001));
119
120 out_uint32_le(s, rdp_shareid);
121 out_uint8(s, 0); /* pad */
122 out_uint8(s, 1); /* streamid */
123 out_uint16(s, (length - 14));
124 out_uint8(s, data_pdu_type);
125 out_uint8(s, 0); /* compress_type */
126 out_uint16(s, 0); /* compress_len */
127
128 sec_send(s, encryption ? SEC_ENCRYPT : 0);
129 }
130
131 /* Output a string in Unicode */
132 void
133 rdp_out_unistr(STREAM s, char *string, int len)
134 {
135 int i = 0, j = 0;
136
137 len += 2;
138
139 while (i < len)
140 {
141 s->p[i++] = string[j++];
142 s->p[i++] = 0;
143 }
144
145 s->p += len;
146 }
147
148 /* Parse a logon info packet */
149 static void
150 rdp_send_logon_info(uint32 flags, char *domain, char *user,
151 char *password, char *program, char *directory)
152 {
153 int len_domain = 2 * strlen(domain);
154 int len_user = 2 * strlen(user);
155 int len_password = 2 * strlen(password);
156 int len_program = 2 * strlen(program);
157 int len_directory = 2 * strlen(directory);
158 uint32 sec_flags = encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT) : SEC_LOGON_INFO;
159 STREAM s;
160
161 s = sec_init(sec_flags, 18 + len_domain + len_user + len_password
162 + len_program + len_directory + 10);
163
164 out_uint32(s, 0);
165 out_uint32_le(s, flags);
166 out_uint16_le(s, len_domain);
167 out_uint16_le(s, len_user);
168 out_uint16_le(s, len_password);
169 out_uint16_le(s, len_program);
170 out_uint16_le(s, len_directory);
171 rdp_out_unistr(s, domain, len_domain);
172 rdp_out_unistr(s, user, len_user);
173 rdp_out_unistr(s, password, len_password);
174 rdp_out_unistr(s, program, len_program);
175 rdp_out_unistr(s, directory, len_directory);
176
177 s_mark_end(s);
178 sec_send(s, sec_flags);
179 }
180
181 /* Send a control PDU */
182 static void
183 rdp_send_control(uint16 action)
184 {
185 STREAM s;
186
187 s = rdp_init_data(8);
188
189 out_uint16_le(s, action);
190 out_uint16(s, 0); /* userid */
191 out_uint32(s, 0); /* control id */
192
193 s_mark_end(s);
194 rdp_send_data(s, RDP_DATA_PDU_CONTROL);
195 }
196
197 /* Send a synchronisation PDU */
198 static void
199 rdp_send_synchronise()
200 {
201 STREAM s;
202
203 s = rdp_init_data(4);
204
205 out_uint16_le(s, 1); /* type */
206 out_uint16_le(s, 1002);
207
208 s_mark_end(s);
209 rdp_send_data(s, RDP_DATA_PDU_SYNCHRONISE);
210 }
211
212 /* Send a single input event */
213 void
214 rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, uint16 param1, uint16 param2)
215 {
216 STREAM s;
217
218 s = rdp_init_data(16);
219
220 out_uint16_le(s, 1); /* number of events */
221 out_uint16(s, 0); /* pad */
222
223 out_uint32_le(s, time);
224 out_uint16_le(s, message_type);
225 out_uint16_le(s, device_flags);
226 out_uint16_le(s, param1);
227 out_uint16_le(s, param2);
228
229 s_mark_end(s);
230 rdp_send_data(s, RDP_DATA_PDU_INPUT);
231 }
232
233 /* Send an (empty) font information PDU */
234 static void
235 rdp_send_fonts(uint16 seq)
236 {
237 STREAM s;
238
239 s = rdp_init_data(8);
240
241 out_uint16(s, 0); /* number of fonts */
242 out_uint16_le(s, 0x3e); /* unknown */
243 out_uint16_le(s, seq); /* unknown */
244 out_uint16_le(s, 0x32); /* entry size */
245
246 s_mark_end(s);
247 rdp_send_data(s, RDP_DATA_PDU_FONT2);
248 }
249
250 /* Output general capability set */
251 static void
252 rdp_out_general_caps(STREAM s)
253 {
254 out_uint16_le(s, RDP_CAPSET_GENERAL);
255 out_uint16_le(s, RDP_CAPLEN_GENERAL);
256
257 out_uint16_le(s, 1); /* OS major type */
258 out_uint16_le(s, 3); /* OS minor type */
259 out_uint16_le(s, 0x200); /* Protocol version */
260 out_uint16(s, 0); /* Pad */
261 out_uint16(s, 0); /* Compression types */
262 out_uint16(s, 0); /* Pad */
263 out_uint16(s, 0); /* Update capability */
264 out_uint16(s, 0); /* Remote unshare capability */
265 out_uint16(s, 0); /* Compression level */
266 out_uint16(s, 0); /* Pad */
267 }
268
269 /* Output bitmap capability set */
270 static void
271 rdp_out_bitmap_caps(STREAM s)
272 {
273 out_uint16_le(s, RDP_CAPSET_BITMAP);
274 out_uint16_le(s, RDP_CAPLEN_BITMAP);
275
276 out_uint16_le(s, 8); /* Preferred BPP */
277 out_uint16(s, 1); /* Receive 1 BPP */
278 out_uint16(s, 1); /* Receive 4 BPP */
279 out_uint16_le(s, 1); /* Receive 8 BPP */
280 out_uint16_le(s, 800); /* Desktop width */
281 out_uint16_le(s, 600); /* Desktop height */
282 out_uint16(s, 0); /* Pad */
283 out_uint16(s, 0); /* Allow resize */
284 out_uint16_le(s, bitmap_compression ? 1 : 0); /* Support compression */
285 out_uint16(s, 0); /* Unknown */
286 out_uint16_le(s, 1); /* Unknown */
287 out_uint16(s, 0); /* Pad */
288 }
289
290 /* Output order capability set */
291 static void
292 rdp_out_order_caps(STREAM s)
293 {
294 uint8 order_caps[32];
295
296
297 memset(order_caps, 0, 32);
298 order_caps[0] = 1; /* dest blt */
299 order_caps[1] = 1; /* pat blt */
300 order_caps[2] = 1; /* screen blt */
301 order_caps[8] = 1; /* line */
302 order_caps[9] = 1; /* line */
303 order_caps[10] = 1; /* rect */
304 order_caps[11] = (desktop_save == False ? 0 : 1); /* desksave */
305 order_caps[13] = 1; /* memblt */
306 order_caps[14] = 1; /* triblt */
307 order_caps[22] = 1; /* polyline */
308 order_caps[27] = 1; /* text2 */
309 out_uint16_le(s, RDP_CAPSET_ORDER);
310 out_uint16_le(s, RDP_CAPLEN_ORDER);
311
312 out_uint8s(s, 20); /* Terminal desc, pad */
313 out_uint16_le(s, 1); /* Cache X granularity */
314 out_uint16_le(s, 20); /* Cache Y granularity */
315 out_uint16(s, 0); /* Pad */
316 out_uint16_le(s, 1); /* Max order level */
317 out_uint16_le(s, 0x147); /* Number of fonts */
318 out_uint16_le(s, 0x2a); /* Capability flags */
319 out_uint8p(s, order_caps, 32); /* Orders supported */
320 out_uint16_le(s, 0x6a1); /* Text capability flags */
321 out_uint8s(s, 6); /* Pad */
322 out_uint32(s, desktop_save == False ? 0 : 0x38400); /* Desktop cache size */
323 out_uint32(s, 0); /* Unknown */
324 out_uint32(s, 0x4e4); /* Unknown */
325 }
326
327 /* Output bitmap cache capability set */
328 static void
329 rdp_out_bmpcache_caps(STREAM s)
330 {
331 out_uint16_le(s, RDP_CAPSET_BMPCACHE);
332 out_uint16_le(s, RDP_CAPLEN_BMPCACHE);
333
334 out_uint8s(s, 24); /* unused */
335 out_uint16_le(s, 0x258); /* entries */
336 out_uint16_le(s, 0x100); /* max cell size */
337 out_uint16_le(s, 0x12c); /* entries */
338 out_uint16_le(s, 0x400); /* max cell size */
339 out_uint16_le(s, 0x106); /* entries */
340 out_uint16_le(s, 0x1000); /* max cell size */
341 }
342
343 /* Output control capability set */
344 static void
345 rdp_out_control_caps(STREAM s)
346 {
347 out_uint16_le(s, RDP_CAPSET_CONTROL);
348 out_uint16_le(s, RDP_CAPLEN_CONTROL);
349
350 out_uint16(s, 0); /* Control capabilities */
351 out_uint16(s, 0); /* Remote detach */
352 out_uint16_le(s, 2); /* Control interest */
353 out_uint16_le(s, 2); /* Detach interest */
354 }
355
356 /* Output activation capability set */
357 static void
358 rdp_out_activate_caps(STREAM s)
359 {
360 out_uint16_le(s, RDP_CAPSET_ACTIVATE);
361 out_uint16_le(s, RDP_CAPLEN_ACTIVATE);
362
363 out_uint16(s, 0); /* Help key */
364 out_uint16(s, 0); /* Help index key */
365 out_uint16(s, 0); /* Extended help key */
366 out_uint16(s, 0); /* Window activate */
367 }
368
369 /* Output pointer capability set */
370 static void
371 rdp_out_pointer_caps(STREAM s)
372 {
373 out_uint16_le(s, RDP_CAPSET_POINTER);
374 out_uint16_le(s, RDP_CAPLEN_POINTER);
375
376 out_uint16(s, 0); /* Colour pointer */
377 out_uint16_le(s, 20); /* Cache size */
378 }
379
380 /* Output share capability set */
381 static void
382 rdp_out_share_caps(STREAM s)
383 {
384 out_uint16_le(s, RDP_CAPSET_SHARE);
385 out_uint16_le(s, RDP_CAPLEN_SHARE);
386
387 out_uint16(s, 0); /* userid */
388 out_uint16(s, 0); /* pad */
389 }
390
391 /* Output colour cache capability set */
392 static void
393 rdp_out_colcache_caps(STREAM s)
394 {
395 out_uint16_le(s, RDP_CAPSET_COLCACHE);
396 out_uint16_le(s, RDP_CAPLEN_COLCACHE);
397
398 out_uint16_le(s, 6); /* cache size */
399 out_uint16(s, 0); /* pad */
400 }
401
402 static uint8 canned_caps[] = {
403 0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x04,
404 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00,
405 0x00, 0x00, 0x00, 0x00, 0x00,
406 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
407 0x00, 0x00, 0x00, 0x00, 0x00,
408 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
409 0x00, 0x00, 0x00, 0x00, 0x00,
410 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
411 0x00, 0x00, 0x00, 0x00, 0x00,
412 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
413 0x0C, 0x00, 0x08, 0x00, 0x01,
414 0x00, 0x00, 0x00, 0x0E, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
415 0x10, 0x00, 0x34, 0x00, 0xFE,
416 0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x08, 0x00,
417 0xFE, 0x00, 0x08, 0x00, 0xFE,
418 0x00, 0x10, 0x00, 0xFE, 0x00, 0x20, 0x00, 0xFE, 0x00, 0x40, 0x00,
419 0xFE, 0x00, 0x80, 0x00, 0xFE,
420 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01,
421 0x02, 0x00, 0x00, 0x00
422 };
423
424 /* Output unknown capability set */
425 static void
426 rdp_out_unknown_caps(STREAM s)
427 {
428 out_uint16_le(s, RDP_CAPSET_UNKNOWN);
429 out_uint16_le(s, 0x58);
430
431 out_uint8p(s, canned_caps, RDP_CAPLEN_UNKNOWN - 4);
432 }
433
434 /* Send a confirm active PDU */
435 static void
436 rdp_send_confirm_active()
437 {
438 STREAM s;
439 uint16 caplen =
440 RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER +
441 RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE +
442 RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL +
443 RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE + RDP_CAPLEN_UNKNOWN + 4 /* w2k fix, why? */ ;
444
445 s = rdp_init(14 + caplen + sizeof(RDP_SOURCE));
446
447 out_uint32_le(s, rdp_shareid);
448 out_uint16_le(s, 0x3ea); /* userid */
449 out_uint16_le(s, sizeof(RDP_SOURCE));
450 out_uint16_le(s, caplen);
451
452 out_uint8p(s, RDP_SOURCE, sizeof(RDP_SOURCE));
453 out_uint16_le(s, 0xd); /* num_caps */
454 out_uint8s(s, 2); /* pad */
455
456 rdp_out_general_caps(s);
457 rdp_out_bitmap_caps(s);
458 rdp_out_order_caps(s);
459 rdp_out_bmpcache_caps(s);
460 rdp_out_colcache_caps(s);
461 rdp_out_activate_caps(s);
462 rdp_out_control_caps(s);
463 rdp_out_pointer_caps(s);
464 rdp_out_share_caps(s);
465 rdp_out_unknown_caps(s);
466
467 s_mark_end(s);
468 rdp_send(s, RDP_PDU_CONFIRM_ACTIVE);
469 }
470
471 /* Respond to a demand active PDU */
472 static void
473 process_demand_active(STREAM s)
474 {
475 uint8 type;
476
477 in_uint32_le(s, rdp_shareid);
478
479 DEBUG(("DEMAND_ACTIVE(id=0x%x)\n", rdp_shareid));
480
481 rdp_send_confirm_active();
482 rdp_send_synchronise();
483 rdp_send_control(RDP_CTL_COOPERATE);
484 rdp_send_control(RDP_CTL_REQUEST_CONTROL);
485 rdp_recv(&type); /* RDP_PDU_SYNCHRONIZE */
486 rdp_recv(&type); /* RDP_CTL_COOPERATE */
487 rdp_recv(&type); /* RDP_CTL_GRANT_CONTROL */
488 rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, 0, 0);
489 rdp_send_fonts(1);
490 rdp_send_fonts(2);
491 rdp_recv(&type); /* RDP_PDU_UNKNOWN 0x28 */
492 reset_order_state();
493 }
494
495 /* Process a pointer PDU */
496 static void
497 process_pointer_pdu(STREAM s)
498 {
499 uint16 message_type;
500 uint16 x, y, width, height, cache_idx, masklen, datalen;
501 uint8 *mask, *data;
502 HCURSOR cursor;
503
504 in_uint16_le(s, message_type);
505 in_uint8s(s, 2); /* pad */
506
507 switch (message_type)
508 {
509 case RDP_POINTER_MOVE:
510 in_uint16_le(s, x);
511 in_uint16_le(s, y);
512 if (s_check(s))
513 ui_move_pointer(x, y);
514 break;
515
516 case RDP_POINTER_COLOR:
517 in_uint16_le(s, cache_idx);
518 in_uint16_le(s, x);
519 in_uint16_le(s, y);
520 in_uint16_le(s, width);
521 in_uint16_le(s, height);
522 in_uint16_le(s, masklen);
523 in_uint16_le(s, datalen);
524 in_uint8p(s, data, datalen);
525 in_uint8p(s, mask, masklen);
526 cursor = ui_create_cursor(x, y, width, height, mask, data);
527 ui_set_cursor(cursor);
528 cache_put_cursor(cache_idx, cursor);
529 break;
530
531 case RDP_POINTER_CACHED:
532 in_uint16_le(s, cache_idx);
533 ui_set_cursor(cache_get_cursor(cache_idx));
534 break;
535
536 default:
537 DEBUG(("Pointer message 0x%x\n", message_type));
538 }
539 }
540
541 /* Process bitmap updates */
542 static void
543 process_bitmap_updates(STREAM s)
544 {
545 uint16 num_updates;
546 uint16 left, top, right, bottom, width, height;
547 uint16 cx, cy, bpp, compress, bufsize, size;
548 uint8 *data, *bmpdata;
549 int i;
550
551 in_uint16_le(s, num_updates);
552
553 for (i = 0; i < num_updates; i++)
554 {
555 in_uint16_le(s, left);
556 in_uint16_le(s, top);
557 in_uint16_le(s, right);
558 in_uint16_le(s, bottom);
559 in_uint16_le(s, width);
560 in_uint16_le(s, height);
561 in_uint16_le(s, bpp);
562 in_uint16_le(s, compress);
563 in_uint16_le(s, bufsize);
564
565 cx = right - left + 1;
566 cy = bottom - top + 1;
567
568 DEBUG(("UPDATE(l=%d,t=%d,r=%d,b=%d,w=%d,h=%d,cmp=%d)\n",
569 left, top, right, bottom, width, height, compress));
570
571 if (!compress)
572 {
573 int y;
574 bmpdata = xmalloc(width * height);
575 for (y = 0; y < height; y++)
576 {
577 in_uint8a(s, &bmpdata[(height - y - 1) * width], width);
578 }
579 ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);
580 xfree(bmpdata);
581 continue;
582 }
583
584 in_uint8s(s, 2); /* pad */
585 in_uint16_le(s, size);
586 in_uint8s(s, 4); /* line_size, final_size */
587 in_uint8p(s, data, size);
588
589 bmpdata = xmalloc(width * height);
590 if (bitmap_decompress(bmpdata, width, height, data, size))
591 {
592 ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata);
593 }
594
595 xfree(bmpdata);
596 }
597 }
598
599 /* Process a palette update */
600 static void
601 process_palette(STREAM s)
602 {
603 HCOLOURMAP hmap;
604 COLOURMAP map;
605 uint8 *colours;
606
607 in_uint8s(s, 2); /* pad */
608 in_uint16_le(s, map.ncolours);
609 in_uint8s(s, 2); /* pad */
610 in_uint8p(s, colours, (map.ncolours * 3));
611 map.colours = (COLOURENTRY *) colours;
612
613 hmap = ui_create_colourmap(&map);
614 ui_set_colourmap(hmap);
615 }
616
617 /* Process an update PDU */
618 static void
619 process_update_pdu(STREAM s)
620 {
621 uint16 update_type;
622
623 in_uint16_le(s, update_type);
624
625 switch (update_type)
626 {
627 case RDP_UPDATE_ORDERS:
628 process_orders(s);
629 break;
630
631 case RDP_UPDATE_BITMAP:
632 process_bitmap_updates(s);
633 break;
634
635 case RDP_UPDATE_PALETTE:
636 process_palette(s);
637 break;
638
639 case RDP_UPDATE_SYNCHRONIZE:
640 break;
641
642 default:
643 unimpl("update %d\n", update_type);
644 }
645
646 }
647
648 /* Process data PDU */
649 static void
650 process_data_pdu(STREAM s)
651 {
652 uint8 data_pdu_type;
653
654 in_uint8s(s, 8); /* shareid, pad, streamid, length */
655 in_uint8(s, data_pdu_type);
656 in_uint8s(s, 3); /* compress_type, compress_len */
657
658 switch (data_pdu_type)
659 {
660 case RDP_DATA_PDU_UPDATE:
661 process_update_pdu(s);
662 break;
663
664 case RDP_DATA_PDU_POINTER:
665 process_pointer_pdu(s);
666 break;
667
668 case RDP_DATA_PDU_BELL:
669 ui_bell();
670 break;
671
672 case RDP_DATA_PDU_LOGON:
673 /* User logged on */
674 break;
675
676 default:
677 unimpl("data PDU %d\n", data_pdu_type);
678 }
679 }
680
681 /* Process incoming packets */
682 void
683 rdp_main_loop()
684 {
685 uint8 type;
686 STREAM s;
687
688 while ((s = rdp_recv(&type)) != NULL)
689 {
690 switch (type)
691 {
692 case RDP_PDU_DEMAND_ACTIVE:
693 process_demand_active(s);
694 break;
695
696 case RDP_PDU_DEACTIVATE:
697 break;
698
699 case RDP_PDU_DATA:
700 process_data_pdu(s);
701 break;
702
703 default:
704 unimpl("PDU %d\n", type);
705 }
706 }
707 }
708
709 /* Establish a connection up to the RDP layer */
710 BOOL
711 rdp_connect(char *server, uint32 flags, char *domain, char *password,
712 char *command, char *directory)
713 {
714 if (!sec_connect(server))
715 return False;
716
717 rdp_send_logon_info(flags, domain, username, password, command, directory);
718 return True;
719 }
720
721 /* Disconnect from the RDP layer */
722 void
723 rdp_disconnect()
724 {
725 sec_disconnect();
726 }

  ViewVC Help
Powered by ViewVC 1.1.26