]> git.sesse.net Git - rdpsrv/blob - rdp5.c
Removed some debugging stuff, correct RDP5 bitmap sending.
[rdpsrv] / rdp5.c
1 /* -*- c-basic-offset: 8 -*-
2    rdesktop: A Remote Desktop Protocol client.
3    Protocol services - Multipoint Communications Service
4    Copyright (C) Matthew Chapman 1999-2002
5    Copyright (C) Erik Forsberg 2003
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "rdesktop.h"
23
24 extern uint8 *g_next_packet;
25 extern int listen_on_vnc;
26
27 void
28 rdp5_process(STREAM s, BOOL encryption)
29 {
30         uint16 length, count, x, y;
31         uint8 type;
32         uint8 *next;
33
34         if (encryption)
35         {
36                 in_uint8s(s, 8);        /* signature */
37                 sec_decrypt(s->p, s->end - s->p);
38         }
39
40 #if 1
41         printf("RDP5 data:\n");
42         hexdump(s->p, s->end - s->p);
43 #endif
44
45         while (s->p < s->end)
46         {
47                 in_uint8(s, type);
48
49                 switch (type)
50                 {
51                         case 32: { // mouse
52                                 listen_on_vnc = 1;
53                                 uint16 device_flags, x, y;
54                                 static int mouse1_down = 0, mouse2_down = 0;
55
56                                 in_uint16_le(s, device_flags);
57                                 in_uint16_le(s, x);
58                                 in_uint16_le(s, y);
59                                 
60                                 printf("- Type: Mouse\n");
61                                 printf("- Device flags: %x\n", device_flags);
62                                 printf("- Position: (%u,%u)\n", x, y);
63
64                                 if (device_flags & MOUSE_FLAG_BUTTON1)
65                                         mouse1_down = (device_flags & MOUSE_FLAG_DOWN) ? 0x01 : 0;
66                                 if (device_flags & MOUSE_FLAG_BUTTON2)
67                                         mouse2_down = (device_flags & MOUSE_FLAG_DOWN) ? 0x02 : 0;
68
69                                 printf("button mask = %x\n", mouse1_down | mouse2_down);
70
71                         /*      buf[0] = 5; // message type
72                                 buf[1] = mouse1_down | mouse2_down; // button mask
73                                 buf[2] = param1 >> 8;
74                                 buf[3] = param1 & 0xff;
75                                 buf[4] = param2 >> 8;
76                                 buf[5] = param2 & 0xff;
77                                 write(vnc_sock, buf, 6); */
78
79                                 break;
80                         }
81                         default:
82                                 printf("Unimplemented RDP5 opcode %d (len=%u)\n", type, length);
83                                 return;
84                 }
85         }
86 }