2 rdesktop: A Remote Desktop Protocol client.
4 Copyright (C) Matthew Chapman 1999-2005
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.
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.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef WIN32_LEAN_AND_MEAN
22 #define WIN32_LEAN_AND_MEAN
35 #ifdef HAVE_SYS_SELECT_H
36 #include <sys/select.h>
38 #include <sys/types.h>
41 #include <limits.h> /* PATH_MAX */
46 #include <X11/Xatom.h>
51 #include <openssl/rc4.h>
52 #include <openssl/md5.h>
53 #include <openssl/sha.h>
54 #include <openssl/bn.h>
55 #include <openssl/x509v3.h>
57 #define VERSION "1.4.1"
60 #define DEBUG(args) printf args;
66 #define DEBUG_KBD(args) printf args;
68 #define DEBUG_KBD(args)
71 #ifdef WITH_DEBUG_RDP5
72 #define DEBUG_RDP5(args) printf args;
74 #define DEBUG_RDP5(args)
77 #ifdef WITH_DEBUG_CLIPBOARD
78 #define DEBUG_CLIPBOARD(args) printf args;
80 #define DEBUG_CLIPBOARD(args)
83 #ifdef WITH_DEBUG_CHANNEL
84 #define DEBUG_CHANNEL(args) printf args;
86 #define DEBUG_CHANNEL(args)
89 #define STRNCPY(dst,src,n) { strncpy(dst,src,n-1); dst[n-1] = 0; }
92 #define MIN(x,y) (((x) < (y)) ? (x) : (y))
96 #define MAX(x,y) (((x) > (y)) ? (x) : (y))
101 #define timerisset(tvp)\
102 ((tvp)->tv_sec || (tvp)->tv_usec)
105 #define timercmp(tvp, uvp, cmp)\
106 ((tvp)->tv_sec cmp (uvp)->tv_sec ||\
107 (tvp)->tv_sec == (uvp)->tv_sec &&\
108 (tvp)->tv_usec cmp (uvp)->tv_usec)
111 #define timerclear(tvp)\
112 ((tvp)->tv_sec = (tvp)->tv_usec = 0)
115 /* If configure does not define the endianess, try
117 #if !defined(L_ENDIAN) && !defined(B_ENDIAN)
118 #if __BYTE_ORDER == __LITTLE_ENDIAN
120 #elif __BYTE_ORDER == __BIG_ENDIAN
123 #error Unknown endianness. Edit rdesktop.h.
125 #endif /* B_ENDIAN, L_ENDIAN from configure */
127 /* No need for alignment on x86 and amd64 */
128 #if !defined(NEED_ALIGN)
129 #if !(defined(__x86__) || defined(__x86_64__) || \
130 defined(__AMD64__) || defined(_M_IX86) || \
137 typedef struct rdpclient RDPCLIENT
;
140 #include "constants.h"
145 /* Used to store incoming io request, until they are ready to be completed */
146 /* using a linked list ensures that they are processed in the right order, */
147 /* if multiple ios are being done on the same fd */
148 struct async_iorequest
150 uint32 fd
, major
, minor
, offset
, device
, id
, length
, partial_len
;
151 long timeout
, /* Total timeout */
152 itv_timeout
; /* Interval timeout (between serial characters) */
156 struct async_iorequest
*next
; /* next element in list */
160 struct bmpcache_entry
167 /* holds the whole state of the RDP client */
171 CHANNEL_DEF channel_defs
[CHANNEL_MAX_COUNT
];
172 unsigned int num_channels
;
175 char * licence_username
;
176 char licence_hostname
[MAX_COMPUTERNAME_LENGTH
+ 1];
188 BOOL pstcache_enumerated
;
191 int disconnect_reason
;
192 unsigned int keylayout
;
194 int keyboard_subtype
;
195 int keyboard_functionkeys
;
200 BOOL bitmap_compression
;
202 BOOL bitmap_cache_persist_enable
;
203 BOOL bitmap_cache_precache
;
205 BOOL packet_encryption
;
206 BOOL desktop_save
; /* desktop save order */
207 BOOL polygon_ellipse_orders
; /* polygon / ellipse orders */
209 BOOL console_session
;
210 uint32 rdp5_performanceflags
;
212 /* Session Directory redirection */
214 wchar_t * redirect_server
;
215 wchar_t * redirect_domain
;
216 wchar_t * redirect_password
;
217 wchar_t * redirect_username
;
218 char * redirect_cookie
;
219 uint32 redirect_flags
;
226 uint16 server_rdp_version
;
234 struct bmpcache_entry bmpcache
[3][0xa00];
235 HBITMAP volatile_bc
[3];
239 int bmpcache_count
[3];
241 FONTGLYPH fontcache
[12][256];
242 DATABLOB textcache
[256];
243 uint8 deskcache
[0x38400 * 4];
244 HCURSOR cursorcache
[0x20];
259 RDP_ORDER_STATE order_state
;
282 RC4_KEY rc4_decrypt_key
;
283 RC4_KEY rc4_encrypt_key
;
284 RSA
*server_public_key
;
285 uint32 server_public_key_len
;
288 uint8 decrypt_key
[16];
289 uint8 encrypt_key
[16];
290 uint8 decrypt_update_key
[16];
291 uint8 encrypt_update_key
[16];
292 uint8 crypted_random
[SEC_MAX_MODULUS_SIZE
];
294 /* These values must be available to reset state - Session Directory */
295 int encrypt_use_count
;
296 int decrypt_use_count
;
306 long connection_timeout
;