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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 10 by matty, Tue Aug 15 10:23:24 2000 UTC revision 25 by matty, Sat Jan 6 03:47:04 2001 UTC
# Line 28  unsigned char *next_packet; Line 28  unsigned char *next_packet;
28  uint32 rdp_shareid;  uint32 rdp_shareid;
29    
30  /* Initialise an RDP packet */  /* Initialise an RDP packet */
31  static STREAM rdp_init(int maxlen)  static STREAM
32    rdp_init(int maxlen)
33  {  {
34          STREAM s;          STREAM s;
35    
# Line 39  static STREAM rdp_init(int maxlen) Line 40  static STREAM rdp_init(int maxlen)
40  }  }
41    
42  /* Send an RDP packet */  /* Send an RDP packet */
43  static void rdp_send(STREAM s, uint8 pdu_type)  static void
44    rdp_send(STREAM s, uint8 pdu_type)
45  {  {
46          uint16 length;          uint16 length;
47    
# Line 47  static void rdp_send(STREAM s, uint8 pdu Line 49  static void rdp_send(STREAM s, uint8 pdu
49          length = s->end - s->p;          length = s->end - s->p;
50    
51          out_uint16_le(s, length);          out_uint16_le(s, length);
52          out_uint16_le(s, (pdu_type | 0x10)); /* Version 1 */          out_uint16_le(s, (pdu_type | 0x10));    /* Version 1 */
53          out_uint16_le(s, (mcs_userid + 1001));          out_uint16_le(s, (mcs_userid + 1001));
54    
55          sec_send(s, SEC_ENCRYPT);          sec_send(s, SEC_ENCRYPT);
56  }  }
57    
58  /* Receive an RDP packet */  /* Receive an RDP packet */
59  static STREAM rdp_recv(uint8 *type)  static STREAM
60    rdp_recv(uint8 *type)
61  {  {
62          static STREAM rdp_s;          static STREAM rdp_s;
63          uint16 length, pdu_type;          uint16 length, pdu_type;
# Line 74  static STREAM rdp_recv(uint8 *type) Line 77  static STREAM rdp_recv(uint8 *type)
77    
78          in_uint16_le(rdp_s, length);          in_uint16_le(rdp_s, length);
79          in_uint16_le(rdp_s, pdu_type);          in_uint16_le(rdp_s, pdu_type);
80          in_uint8s(rdp_s, 2); /* userid */          in_uint8s(rdp_s, 2);    /* userid */
81    
82          next_packet += length;          next_packet += length;
83          *type = pdu_type & 0xf;          *type = pdu_type & 0xf;
# Line 88  static STREAM rdp_recv(uint8 *type) Line 91  static STREAM rdp_recv(uint8 *type)
91  }  }
92    
93  /* Initialise an RDP data packet */  /* Initialise an RDP data packet */
94  static STREAM rdp_init_data(int maxlen)  static STREAM
95    rdp_init_data(int maxlen)
96  {  {
97          STREAM s;          STREAM s;
98    
# Line 99  static STREAM rdp_init_data(int maxlen) Line 103  static STREAM rdp_init_data(int maxlen)
103  }  }
104    
105  /* Send an RDP data packet */  /* Send an RDP data packet */
106  static void rdp_send_data(STREAM s, uint8 data_pdu_type)  static void
107    rdp_send_data(STREAM s, uint8 data_pdu_type)
108  {  {
109          uint16 length;          uint16 length;
110    
# Line 111  static void rdp_send_data(STREAM s, uint Line 116  static void rdp_send_data(STREAM s, uint
116          out_uint16_le(s, (mcs_userid + 1001));          out_uint16_le(s, (mcs_userid + 1001));
117    
118          out_uint32_le(s, rdp_shareid);          out_uint32_le(s, rdp_shareid);
119          out_uint8(s, 0);  /* pad */          out_uint8(s, 0);        /* pad */
120          out_uint8(s, 1);  /* streamid */          out_uint8(s, 1);        /* streamid */
121          out_uint16(s, (length - 14));          out_uint16(s, (length - 14));
122          out_uint8(s, data_pdu_type);          out_uint8(s, data_pdu_type);
123          out_uint8(s, 0);  /* compress_type */          out_uint8(s, 0);        /* compress_type */
124          out_uint16(s, 0); /* compress_len */          out_uint16(s, 0);       /* compress_len */
125    
126          sec_send(s, SEC_ENCRYPT);          sec_send(s, SEC_ENCRYPT);
127  }  }
128    
129  /* Output a string in Unicode */  /* Output a string in Unicode */
130  void rdp_out_unistr(STREAM s, char *string, int len)  void
131    rdp_out_unistr(STREAM s, char *string, int len)
132  {  {
133          int i = 0, j = 0;          int i = 0, j = 0;
134    
# Line 138  void rdp_out_unistr(STREAM s, char *stri Line 144  void rdp_out_unistr(STREAM s, char *stri
144  }  }
145    
146  /* Parse a logon info packet */  /* Parse a logon info packet */
147  static void rdp_send_logon_info(uint32 flags, char *domain, char *user,  static void
148                                  char *password, char *program, char *directory)  rdp_send_logon_info(uint32 flags, char *domain, char *user,
149  {                      char *password, char *program, char *directory)
150          int len_domain    = 2 * strlen(domain);  {
151          int len_user      = 2 * strlen(user);          int len_domain = 2 * strlen(domain);
152          int len_password  = 2 * strlen(password);          int len_user = 2 * strlen(user);
153          int len_program   = 2 * strlen(program);          int len_password = 2 * strlen(password);
154            int len_program = 2 * strlen(program);
155          int len_directory = 2 * strlen(directory);          int len_directory = 2 * strlen(directory);
156          uint32 sec_flags = SEC_LOGON_INFO | SEC_ENCRYPT;          uint32 sec_flags = SEC_LOGON_INFO | SEC_ENCRYPT;
157          STREAM s;          STREAM s;
158    
159          s = sec_init(sec_flags, 18 + len_domain + len_user + len_password          s = sec_init(sec_flags, 18 + len_domain + len_user + len_password
160                                          + len_program + len_directory + 10);                       + len_program + len_directory + 10);
161    
162          out_uint32(s, 0);          out_uint32(s, 0);
163          out_uint32_le(s, flags);          out_uint32_le(s, flags);
# Line 159  static void rdp_send_logon_info(uint32 f Line 166  static void rdp_send_logon_info(uint32 f
166          out_uint16_le(s, len_password);          out_uint16_le(s, len_password);
167          out_uint16_le(s, len_program);          out_uint16_le(s, len_program);
168          out_uint16_le(s, len_directory);          out_uint16_le(s, len_directory);
169          rdp_out_unistr(s, domain,    len_domain);          rdp_out_unistr(s, domain, len_domain);
170          rdp_out_unistr(s, user,      len_user);          rdp_out_unistr(s, user, len_user);
171          rdp_out_unistr(s, password,  len_password);          rdp_out_unistr(s, password, len_password);
172          rdp_out_unistr(s, program,   len_program);          rdp_out_unistr(s, program, len_program);
173          rdp_out_unistr(s, directory, len_directory);          rdp_out_unistr(s, directory, len_directory);
174    
175          s_mark_end(s);          s_mark_end(s);
# Line 170  static void rdp_send_logon_info(uint32 f Line 177  static void rdp_send_logon_info(uint32 f
177  }  }
178    
179  /* Send a control PDU */  /* Send a control PDU */
180  static void rdp_send_control(uint16 action)  static void
181    rdp_send_control(uint16 action)
182  {  {
183          STREAM s;          STREAM s;
184    
185          s = rdp_init_data(8);          s = rdp_init_data(8);
186    
187          out_uint16_le(s, action);          out_uint16_le(s, action);
188          out_uint16(s, 0); /* userid */          out_uint16(s, 0);       /* userid */
189          out_uint32(s, 0); /* control id */          out_uint32(s, 0);       /* control id */
190    
191          s_mark_end(s);          s_mark_end(s);
192          rdp_send_data(s, RDP_DATA_PDU_CONTROL);          rdp_send_data(s, RDP_DATA_PDU_CONTROL);
193  }  }
194    
195  /* Send a synchronisation PDU */  /* Send a synchronisation PDU */
196  static void rdp_send_synchronise()  static void
197    rdp_send_synchronise()
198  {  {
199          STREAM s;          STREAM s;
200    
201          s = rdp_init_data(4);          s = rdp_init_data(4);
202    
203          out_uint16_le(s, 1); /* type */          out_uint16_le(s, 1);    /* type */
204          out_uint16_le(s, 1002);          out_uint16_le(s, 1002);
205    
206          s_mark_end(s);          s_mark_end(s);
# Line 199  static void rdp_send_synchronise() Line 208  static void rdp_send_synchronise()
208  }  }
209    
210  /* Send a single input event */  /* Send a single input event */
211  void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags,  void
212                      uint16 param1, uint16 param2)  rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags,
213                   uint16 param1, uint16 param2)
214  {  {
215          STREAM s;          STREAM s;
216    
217          s = rdp_init_data(16);          s = rdp_init_data(16);
218    
219          out_uint16_le(s, 1); /* number of events */          out_uint16_le(s, 1);    /* number of events */
220          out_uint16(s, 0);    /* pad */          out_uint16(s, 0);       /* pad */
221    
222          out_uint32_le(s, time);          out_uint32_le(s, time);
223          out_uint16_le(s, message_type);          out_uint16_le(s, message_type);
# Line 220  void rdp_send_input(uint32 time, uint16 Line 230  void rdp_send_input(uint32 time, uint16
230  }  }
231    
232  /* Send an (empty) font information PDU */  /* Send an (empty) font information PDU */
233  static void rdp_send_fonts(uint16 seq)  static void
234    rdp_send_fonts(uint16 seq)
235  {  {
236          STREAM s;          STREAM s;
237    
# Line 236  static void rdp_send_fonts(uint16 seq) Line 247  static void rdp_send_fonts(uint16 seq)
247  }  }
248    
249  /* Output general capability set */  /* Output general capability set */
250  static void rdp_out_general_caps(STREAM s)  static void
251    rdp_out_general_caps(STREAM s)
252  {  {
253          out_uint16_le(s, RDP_CAPSET_GENERAL);          out_uint16_le(s, RDP_CAPSET_GENERAL);
254          out_uint16_le(s, RDP_CAPLEN_GENERAL);          out_uint16_le(s, RDP_CAPLEN_GENERAL);
255    
256          out_uint16_le(s, 1);    /* OS major type */          out_uint16_le(s, 1);    /* OS major type */
257          out_uint16_le(s, 3);    /* OS minor type */          out_uint16_le(s, 3);    /* OS minor type */
258          out_uint16_le(s, 0x200); /* Protocol version */          out_uint16_le(s, 0x200);        /* Protocol version */
259          out_uint16(s, 0);       /* Pad */          out_uint16(s, 0);       /* Pad */
260          out_uint16(s, 0);       /* Compression types */          out_uint16(s, 0);       /* Compression types */
261          out_uint16(s, 0);       /* Pad */          out_uint16(s, 0);       /* Pad */
# Line 254  static void rdp_out_general_caps(STREAM Line 266  static void rdp_out_general_caps(STREAM
266  }  }
267    
268  /* Output bitmap capability set */  /* Output bitmap capability set */
269  static void rdp_out_bitmap_caps(STREAM s)  static void
270    rdp_out_bitmap_caps(STREAM s)
271  {  {
272          out_uint16_le(s, RDP_CAPSET_BITMAP);          out_uint16_le(s, RDP_CAPSET_BITMAP);
273          out_uint16_le(s, RDP_CAPLEN_BITMAP);          out_uint16_le(s, RDP_CAPLEN_BITMAP);
# Line 274  static void rdp_out_bitmap_caps(STREAM s Line 287  static void rdp_out_bitmap_caps(STREAM s
287  }  }
288    
289  /* Output order capability set */  /* Output order capability set */
290  static void rdp_out_order_caps(STREAM s)  static void
291    rdp_out_order_caps(STREAM s)
292  {  {
293          uint8 order_caps[32];          uint8 order_caps[32];
294    
# Line 289  static void rdp_out_order_caps(STREAM s) Line 303  static void rdp_out_order_caps(STREAM s)
303          out_uint16(s, 0);       /* Pad */          out_uint16(s, 0);       /* Pad */
304          out_uint16_le(s, 1);    /* Max order level */          out_uint16_le(s, 1);    /* Max order level */
305          out_uint16_le(s, 0x147);        /* Number of fonts */          out_uint16_le(s, 0x147);        /* Number of fonts */
306          out_uint16_le(s, 0x2a);         /* Capability flags */          out_uint16_le(s, 0x2a); /* Capability flags */
307          out_uint8p(s, order_caps, 32);  /* Orders supported */          out_uint8p(s, order_caps, 32);  /* Orders supported */
308          out_uint16_le(s, 0x6a1);        /* Text capability flags */          out_uint16_le(s, 0x6a1);        /* Text capability flags */
309          out_uint8s(s, 6);       /* Pad */          out_uint8s(s, 6);       /* Pad */
# Line 299  static void rdp_out_order_caps(STREAM s) Line 313  static void rdp_out_order_caps(STREAM s)
313  }  }
314    
315  /* Output bitmap cache capability set */  /* Output bitmap cache capability set */
316  static void rdp_out_bmpcache_caps(STREAM s)  static void
317    rdp_out_bmpcache_caps(STREAM s)
318  {  {
319          out_uint16_le(s, RDP_CAPSET_BMPCACHE);          out_uint16_le(s, RDP_CAPSET_BMPCACHE);
320          out_uint16_le(s, RDP_CAPLEN_BMPCACHE);          out_uint16_le(s, RDP_CAPLEN_BMPCACHE);
321    
322          out_uint8s(s, 24); /* unused */          out_uint8s(s, 24);      /* unused */
323          out_uint16_le(s, 0x258); /* entries */          out_uint16_le(s, 0x258);        /* entries */
324          out_uint16_le(s, 0x100); /* max cell size */          out_uint16_le(s, 0x100);        /* max cell size */
325          out_uint16_le(s, 0x12c); /* entries */          out_uint16_le(s, 0x12c);        /* entries */
326          out_uint16_le(s, 0x400); /* max cell size */          out_uint16_le(s, 0x400);        /* max cell size */
327          out_uint16_le(s, 0x106); /* entries */          out_uint16_le(s, 0x106);        /* entries */
328          out_uint16_le(s, 0x1000); /* max cell size */          out_uint16_le(s, 0x1000);       /* max cell size */
329  }  }
330    
331  /* Output control capability set */  /* Output control capability set */
332  static void rdp_out_control_caps(STREAM s)  static void
333    rdp_out_control_caps(STREAM s)
334  {  {
335          out_uint16_le(s, RDP_CAPSET_CONTROL);          out_uint16_le(s, RDP_CAPSET_CONTROL);
336          out_uint16_le(s, RDP_CAPLEN_CONTROL);          out_uint16_le(s, RDP_CAPLEN_CONTROL);
# Line 326  static void rdp_out_control_caps(STREAM Line 342  static void rdp_out_control_caps(STREAM
342  }  }
343    
344  /* Output activation capability set */  /* Output activation capability set */
345  static void rdp_out_activate_caps(STREAM s)  static void
346    rdp_out_activate_caps(STREAM s)
347  {  {
348          out_uint16_le(s, RDP_CAPSET_ACTIVATE);          out_uint16_le(s, RDP_CAPSET_ACTIVATE);
349          out_uint16_le(s, RDP_CAPLEN_ACTIVATE);          out_uint16_le(s, RDP_CAPLEN_ACTIVATE);
# Line 338  static void rdp_out_activate_caps(STREAM Line 355  static void rdp_out_activate_caps(STREAM
355  }  }
356    
357  /* Output pointer capability set */  /* Output pointer capability set */
358  static void rdp_out_pointer_caps(STREAM s)  static void
359    rdp_out_pointer_caps(STREAM s)
360  {  {
361          out_uint16_le(s, RDP_CAPSET_POINTER);          out_uint16_le(s, RDP_CAPSET_POINTER);
362          out_uint16_le(s, RDP_CAPLEN_POINTER);          out_uint16_le(s, RDP_CAPLEN_POINTER);
# Line 348  static void rdp_out_pointer_caps(STREAM Line 366  static void rdp_out_pointer_caps(STREAM
366  }  }
367    
368  /* Output share capability set */  /* Output share capability set */
369  static void rdp_out_share_caps(STREAM s)  static void
370    rdp_out_share_caps(STREAM s)
371  {  {
372          out_uint16_le(s, RDP_CAPSET_SHARE);          out_uint16_le(s, RDP_CAPSET_SHARE);
373          out_uint16_le(s, RDP_CAPLEN_SHARE);          out_uint16_le(s, RDP_CAPLEN_SHARE);
# Line 358  static void rdp_out_share_caps(STREAM s) Line 377  static void rdp_out_share_caps(STREAM s)
377  }  }
378    
379  /* Output colour cache capability set */  /* Output colour cache capability set */
380  static void rdp_out_colcache_caps(STREAM s)  static void
381    rdp_out_colcache_caps(STREAM s)
382  {  {
383          out_uint16_le(s, RDP_CAPSET_COLCACHE);          out_uint16_le(s, RDP_CAPSET_COLCACHE);
384          out_uint16_le(s, RDP_CAPLEN_COLCACHE);          out_uint16_le(s, RDP_CAPLEN_COLCACHE);
# Line 368  static void rdp_out_colcache_caps(STREAM Line 388  static void rdp_out_colcache_caps(STREAM
388  }  }
389    
390  static uint8 canned_caps[] = {  static uint8 canned_caps[] = {
391  0x01,0x00,0x00,0x00,0x09,0x04,0x00,0x00,0x04,          0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x04,
392  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00,
393  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,          0x00, 0x00, 0x00, 0x00, 0x00,
394  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
395  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,          0x00, 0x00, 0x00, 0x00, 0x00,
396  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x08,0x00,0x01,          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
397  0x00,0x00,0x00,0x0E,0x00,0x08,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x34,0x00,0xFE,          0x00, 0x00, 0x00, 0x00, 0x00,
398  0x00,0x04,0x00,0xFE,0x00,0x04,0x00,0xFE,0x00,0x08,0x00,0xFE,0x00,0x08,0x00,0xFE,          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
399  0x00,0x10,0x00,0xFE,0x00,0x20,0x00,0xFE,0x00,0x40,0x00,0xFE,0x00,0x80,0x00,0xFE,          0x00, 0x00, 0x00, 0x00, 0x00,
400  0x00,0x00,0x01,0x40,0x00,0x00,0x08,0x00,0x01,0x00,0x01,0x02,0x00,0x00,0x00          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
401            0x0C, 0x00, 0x08, 0x00, 0x01,
402            0x00, 0x00, 0x00, 0x0E, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00,
403            0x10, 0x00, 0x34, 0x00, 0xFE,
404            0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x08, 0x00,
405            0xFE, 0x00, 0x08, 0x00, 0xFE,
406            0x00, 0x10, 0x00, 0xFE, 0x00, 0x20, 0x00, 0xFE, 0x00, 0x40, 0x00,
407            0xFE, 0x00, 0x80, 0x00, 0xFE,
408            0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01,
409            0x02, 0x00, 0x00, 0x00
410  };  };
411    
412  /* Output unknown capability set */  /* Output unknown capability set */
413  static void rdp_out_unknown_caps(STREAM s)  static void
414    rdp_out_unknown_caps(STREAM s)
415  {  {
416          out_uint16_le(s, RDP_CAPSET_UNKNOWN);          out_uint16_le(s, RDP_CAPSET_UNKNOWN);
417          out_uint16_le(s, 0x58);          out_uint16_le(s, 0x58);
418            
419          out_uint8p(s, canned_caps, RDP_CAPLEN_UNKNOWN-4);          out_uint8p(s, canned_caps, RDP_CAPLEN_UNKNOWN - 4);
420  }  }
421    
422  /* Send a confirm active PDU */  /* Send a confirm active PDU */
423  static void rdp_send_confirm_active()  static void
424    rdp_send_confirm_active()
425  {  {
426          STREAM s;          STREAM s;
427          uint16 caplen = RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER          uint16 caplen =
428                  + RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE + RDP_CAPLEN_ACTIVATE                  RDP_CAPLEN_GENERAL + RDP_CAPLEN_BITMAP + RDP_CAPLEN_ORDER +
429                  + RDP_CAPLEN_CONTROL + RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE                  RDP_CAPLEN_BMPCACHE + RDP_CAPLEN_COLCACHE +
430                  + RDP_CAPLEN_UNKNOWN;                  RDP_CAPLEN_ACTIVATE + RDP_CAPLEN_CONTROL +
431                    RDP_CAPLEN_POINTER + RDP_CAPLEN_SHARE + RDP_CAPLEN_UNKNOWN;
432    
433          s = rdp_init(14 + caplen + sizeof(RDP_SOURCE));          s = rdp_init(14 + caplen + sizeof(RDP_SOURCE));
434    
435          out_uint32_le(s, rdp_shareid);          out_uint32_le(s, rdp_shareid);
436          out_uint16_le(s, 0x3ea); /* userid */          out_uint16_le(s, 0x3ea);        /* userid */
437          out_uint16_le(s, sizeof(RDP_SOURCE));          out_uint16_le(s, sizeof(RDP_SOURCE));
438          out_uint16_le(s, caplen);          out_uint16_le(s, caplen);
439    
440          out_uint8p(s, RDP_SOURCE, sizeof(RDP_SOURCE));          out_uint8p(s, RDP_SOURCE, sizeof(RDP_SOURCE));
441          out_uint16_le(s, 0xd); /* num_caps */          out_uint16_le(s, 0xd);  /* num_caps */
442          out_uint8s(s, 2);     /* pad */          out_uint8s(s, 2);       /* pad */
443    
444          rdp_out_general_caps(s);          rdp_out_general_caps(s);
445          rdp_out_bitmap_caps(s);          rdp_out_bitmap_caps(s);
# Line 425  static void rdp_send_confirm_active() Line 457  static void rdp_send_confirm_active()
457  }  }
458    
459  /* Respond to a demand active PDU */  /* Respond to a demand active PDU */
460  static void process_demand_active(STREAM s)  static void
461    process_demand_active(STREAM s)
462  {  {
463          uint8 type;          uint8 type;
464    
# Line 437  static void process_demand_active(STREAM Line 470  static void process_demand_active(STREAM
470          rdp_send_synchronise();          rdp_send_synchronise();
471          rdp_send_control(RDP_CTL_COOPERATE);          rdp_send_control(RDP_CTL_COOPERATE);
472          rdp_send_control(RDP_CTL_REQUEST_CONTROL);          rdp_send_control(RDP_CTL_REQUEST_CONTROL);
473          rdp_recv(&type); // RDP_PDU_SYNCHRONIZE          rdp_recv(&type);        // RDP_PDU_SYNCHRONIZE
474          rdp_recv(&type); // RDP_CTL_COOPERATE          rdp_recv(&type);        // RDP_CTL_COOPERATE
475          rdp_recv(&type); // RDP_CTL_GRANT_CONTROL          rdp_recv(&type);        // RDP_CTL_GRANT_CONTROL
476          rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, 0, 0);          rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, 0, 0);
477          rdp_send_fonts(1);          rdp_send_fonts(1);
478          rdp_send_fonts(2);          rdp_send_fonts(2);
479          rdp_recv(&type); // RDP_PDU_UNKNOWN 0x28          rdp_recv(&type);        // RDP_PDU_UNKNOWN 0x28
480          reset_order_state();          reset_order_state();
481  }  }
482    
483  /* Process a pointer PDU */  /* Process a pointer PDU */
484  static void process_pointer_pdu(STREAM s)  static void
485    process_pointer_pdu(STREAM s)
486  {  {
487          uint16 message_type;          uint16 message_type;
488          uint16 x, y;          uint16 x, y;
489    
490          in_uint16_le(s, message_type);          in_uint16_le(s, message_type);
491          in_uint8s(s, 2); /* pad */          in_uint8s(s, 2);        /* pad */
492    
493          switch (message_type)          switch (message_type)
494          {          {
# Line 471  static void process_pointer_pdu(STREAM s Line 505  static void process_pointer_pdu(STREAM s
505  }  }
506    
507  /* Process bitmap updates */  /* Process bitmap updates */
508  static void process_bitmap_updates(STREAM s)  static void
509    process_bitmap_updates(STREAM s)
510  {  {
511          uint16 num_updates;          uint16 num_updates;
512          uint16 left, top, right, bottom, width, height;          uint16 left, top, right, bottom, width, height;
# Line 497  static void process_bitmap_updates(STREA Line 532  static void process_bitmap_updates(STREA
532                  cy = bottom - top + 1;                  cy = bottom - top + 1;
533    
534                  DEBUG("UPDATE(l=%d,t=%d,r=%d,b=%d,w=%d,h=%d,cmp=%d)\n",                  DEBUG("UPDATE(l=%d,t=%d,r=%d,b=%d,w=%d,h=%d,cmp=%d)\n",
535                          left, top, right, bottom, width, height, compress);                        left, top, right, bottom, width, height, compress);
536    
537                  if (!compress)                  if (!compress)
538                  {                  {
539                          in_uint8p(s, data, bufsize);                          in_uint8p(s, data, bufsize);
540                          ui_paint_bitmap(left, top, cx, cy, width, height, data);                          ui_paint_bitmap(left, top, cx, cy, width, height,
541                                            data);
542                          return;                          return;
543                  }                  }
544    
545                  in_uint8s(s, 2); /* pad */                  in_uint8s(s, 2);        /* pad */
546                  in_uint16_le(s, size);                  in_uint16_le(s, size);
547                  in_uint8s(s, 4); /* line_size, final_size */                  in_uint8s(s, 4);        /* line_size, final_size */
548                  in_uint8p(s, data, size);                  in_uint8p(s, data, size);
549    
550                  rawdata = xmalloc(width * height);                  rawdata = xmalloc(width * height);
# Line 523  static void process_bitmap_updates(STREA Line 559  static void process_bitmap_updates(STREA
559  }  }
560    
561  /* Process a palette update */  /* Process a palette update */
562  static void process_palette(STREAM s)  static void
563    process_palette(STREAM s)
564  {  {
565          HCOLOURMAP hmap;          HCOLOURMAP hmap;
566          COLOURMAP map;          COLOURMAP map;
567    
568          in_uint8s(s, 2); /* pad */          in_uint8s(s, 2);        /* pad */
569          in_uint16_le(s, map.ncolours);          in_uint16_le(s, map.ncolours);
570          in_uint8s(s, 2); /* pad */          in_uint8s(s, 2);        /* pad */
571          in_uint8p(s, (uint8 *)map.colours, (map.ncolours * 3));          in_uint8p(s, (uint8 *) map.colours, (map.ncolours * 3));
572    
573          hmap = ui_create_colourmap(&map);          hmap = ui_create_colourmap(&map);
574          ui_set_colourmap(hmap);          ui_set_colourmap(hmap);
575  }  }
576    
577  /* Process an update PDU */  /* Process an update PDU */
578  static void process_update_pdu(STREAM s)  static void
579    process_update_pdu(STREAM s)
580  {  {
581          uint16 update_type;          uint16 update_type;
582    
# Line 568  static void process_update_pdu(STREAM s) Line 606  static void process_update_pdu(STREAM s)
606  }  }
607    
608  /* Process data PDU */  /* Process data PDU */
609  static void process_data_pdu(STREAM s)  static void
610    process_data_pdu(STREAM s)
611  {  {
612          uint8 data_pdu_type;          uint8 data_pdu_type;
613    
614          in_uint8s(s, 8); /* shareid, pad, streamid, length */          in_uint8s(s, 8);        /* shareid, pad, streamid, length */
615          in_uint8(s, data_pdu_type);          in_uint8(s, data_pdu_type);
616          in_uint8s(s, 3); /* compress_type, compress_len */          in_uint8s(s, 3);        /* compress_type, compress_len */
617    
618          switch (data_pdu_type)          switch (data_pdu_type)
619          {          {
# Line 600  static void process_data_pdu(STREAM s) Line 639  static void process_data_pdu(STREAM s)
639  }  }
640    
641  /* Process incoming packets */  /* Process incoming packets */
642  void rdp_main_loop()  void
643    rdp_main_loop()
644  {  {
645          uint8 type;          uint8 type;
646          STREAM s;          STREAM s;
# Line 627  void rdp_main_loop() Line 667  void rdp_main_loop()
667  }  }
668    
669  /* Establish a connection up to the RDP layer */  /* Establish a connection up to the RDP layer */
670  BOOL rdp_connect(char *server)  BOOL
671    rdp_connect(char *server, uint32 flags, char *domain, char *password,
672                char *command, char *directory)
673  {  {
674          if (!sec_connect(server))          if (!sec_connect(server))
675                  return False;                  return False;
676    
677          rdp_send_logon_info(0x33, "", username, "", "", "");          rdp_send_logon_info(flags, domain, username, password,
678                                command, directory);
679          return True;          return True;
680  }  }
681    
682  /* Disconnect from the RDP layer */  /* Disconnect from the RDP layer */
683  void rdp_disconnect()  void
684    rdp_disconnect()
685  {  {
686          sec_disconnect();          sec_disconnect();
687  }  }
   

Legend:
Removed from v.10  
changed lines
  Added in v.25

  ViewVC Help
Powered by ViewVC 1.1.26