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
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.
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.
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.
24 extern uint8 *g_next_packet;
25 extern int listen_on_vnc;
27 extern uint8 sec_sign_key[16];
28 extern int rc4_key_len;
30 /* Initialise secure transport packet */
32 rdp5_init(int maxlen, BOOL encryption)
37 hdrlen = encryption ? 11 : 3;
38 s = tcp_init(maxlen + hdrlen);
39 s_push_layer(s, sec_hdr, hdrlen);
45 rdp5_send(STREAM s, BOOL encryption)
49 s_pop_layer(s, sec_hdr);
51 datalen = s->end - s->p;
53 out_uint8(s, encryption ? 0x80 : 0); // protocol
54 out_uint8(s, 0x80 | (datalen >> 8));
55 out_uint8(s, datalen & 0xff);
60 sec_sign(s->p, 8, sec_sign_key, rc4_key_len, s->p + 8, datalen);
61 sec_encrypt(s->p + 8, datalen);
68 rdp5_process(STREAM s, BOOL encryption)
70 uint16 length, count, x, y;
76 in_uint8s(s, 8); /* signature */
77 sec_decrypt(s->p, s->end - s->p);
81 printf("RDP5 data:\n");
82 hexdump(s->p, s->end - s->p);
92 // unknown, but looks like some sort of
93 // "count" of how many packets there are
94 printf("Unimplemented RDP5 opcode (count?) %d, skipping\n", type);
98 uint16 device_flags, x, y;
99 static int mouse1_down = 0, mouse2_down = 0;
101 in_uint16_le(s, device_flags);
105 printf("- Type: Mouse\n");
106 printf("- Device flags: %x\n", device_flags);
107 printf("- Position: (%u,%u)\n", x, y);
109 if (device_flags & MOUSE_FLAG_BUTTON1)
110 mouse1_down = (device_flags & MOUSE_FLAG_DOWN) ? 0x01 : 0;
111 if (device_flags & MOUSE_FLAG_BUTTON2)
112 mouse2_down = (device_flags & MOUSE_FLAG_DOWN) ? 0x02 : 0;
114 printf("button mask = %x\n", mouse1_down | mouse2_down);
116 /* buf[0] = 5; // message type
117 buf[1] = mouse1_down | mouse2_down; // button mask
118 buf[2] = param1 >> 8;
119 buf[3] = param1 & 0xff;
120 buf[4] = param2 >> 8;
121 buf[5] = param2 & 0xff;
122 write(vnc_sock, buf, 6); */
127 printf("Unimplemented RDP5 opcode %d\n", type);