/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (hide annotations)
Tue Aug 15 10:23:24 2000 UTC (23 years, 9 months ago) by matty
File MIME type: text/plain
File size: 15056 byte(s)
Major commit of work from laptop - done in various free moments.
Implemented encryption layer and some basic licensing negotiation.
Reorganised code somewhat. While this is not quite as clean, it is
a lot faster - our parser speed was becoming a bottle-neck.

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

  ViewVC Help
Powered by ViewVC 1.1.26