00001 #ifndef RFBPROTO_H 00002 #define RFBPROTO_H 00003 00015 /* 00016 * Copyright (C) 2009-2010 D. R. Commander. All Rights Reserved. 00017 * Copyright (C) 2005 Rohit Kumar, Johannes E. Schindelin 00018 * Copyright (C) 2004-2008 Sun Microsystems, Inc. All Rights Reserved. 00019 * Copyright (C) 2000-2002 Constantin Kaplinsky. All Rights Reserved. 00020 * Copyright (C) 2000 Tridia Corporation. All Rights Reserved. 00021 * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. 00022 * 00023 * This is free software; you can redistribute it and/or modify 00024 * it under the terms of the GNU General Public License as published by 00025 * the Free Software Foundation; either version 2 of the License, or 00026 * (at your option) any later version. 00027 * 00028 * This software is distributed in the hope that it will be useful, 00029 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00031 * GNU General Public License for more details. 00032 * 00033 * You should have received a copy of the GNU General Public License 00034 * along with this software; if not, write to the Free Software 00035 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00036 * USA. 00037 */ 00038 00039 /* 00040 * rfbproto.h - header file for the RFB protocol version 3.3 00041 * 00042 * Uses types CARD<n> for an n-bit unsigned integer, INT<n> for an n-bit signed 00043 * integer (for n = 8, 16 and 32). 00044 * 00045 * All multiple byte integers are in big endian (network) order (most 00046 * significant byte first). Unless noted otherwise there is no special 00047 * alignment of protocol structures. 00048 * 00049 * 00050 * Once the initial handshaking is done, all messages start with a type byte, 00051 * (usually) followed by message-specific data. The order of definitions in 00052 * this file is as follows: 00053 * 00054 * (1) Structures used in several types of message. 00055 * (2) Structures used in the initial handshaking. 00056 * (3) Message types. 00057 * (4) Encoding types. 00058 * (5) For each message type, the form of the data following the type byte. 00059 * Sometimes this is defined by a single structure but the more complex 00060 * messages have to be explained by comments. 00061 */ 00062 00063 00064 #if defined(WIN32) && !defined(__MINGW32__) 00065 #define LIBVNCSERVER_WORDS_BIGENDIAN 00066 #define rfbBool int 00067 #include <sys/timeb.h> 00068 #include <winsock.h> 00069 #undef SOCKET 00070 #define SOCKET int 00071 #else 00072 #include <rfb/rfbconfig.h> 00073 #include <rfb/rfbint.h> 00074 #endif 00075 00076 #ifdef LIBVNCSERVER_HAVE_LIBZ 00077 #include <zlib.h> 00078 #ifdef __CHECKER__ 00079 #undef Z_NULL 00080 #define Z_NULL NULL 00081 #endif 00082 #endif 00083 00084 /* some autotool versions do not properly prefix 00085 WORDS_BIGENDIAN, so do that manually */ 00086 #ifdef WORDS_BIGENDIAN 00087 #define LIBVNCSERVER_WORDS_BIGENDIAN 00088 #endif 00089 00090 /* MS compilers don't have strncasecmp */ 00091 #ifdef _MSC_VER 00092 #define strncasecmp _strnicmp 00093 #endif 00094 00095 #if !defined(WIN32) || defined(__MINGW32__) 00096 #define max(a,b) (((a)>(b))?(a):(b)) 00097 #ifdef LIBVNCSERVER_HAVE_SYS_TIME_H 00098 #include <sys/time.h> 00099 #endif 00100 #ifdef LIBVNCSERVER_HAVE_NETINET_IN_H 00101 #include <netinet/in.h> 00102 #endif 00103 #define SOCKET int 00104 typedef int8_t rfbBool; 00105 #undef FALSE 00106 #define FALSE 0 00107 #undef TRUE 00108 #define TRUE -1 00109 #endif 00110 00111 typedef uint32_t rfbKeySym; 00112 typedef uint32_t rfbPixel; 00113 00114 #ifdef LIBVNCSERVER_NEED_INADDR_T 00115 typedef uint32_t in_addr_t; 00116 #endif 00117 00118 #ifndef INADDR_NONE 00119 #define INADDR_NONE ((in_addr_t) 0xffffffff) 00120 #endif 00121 00122 #define MAX_ENCODINGS 21 00123 00124 /***************************************************************************** 00125 * 00126 * Structures used in several messages 00127 * 00128 *****************************************************************************/ 00129 00130 /*----------------------------------------------------------------------------- 00131 * Structure used to specify a rectangle. This structure is a multiple of 4 00132 * bytes so that it can be interspersed with 32-bit pixel data without 00133 * affecting alignment. 00134 */ 00135 00136 typedef struct { 00137 uint16_t x; 00138 uint16_t y; 00139 uint16_t w; 00140 uint16_t h; 00141 } rfbRectangle; 00142 00143 #define sz_rfbRectangle 8 00144 00145 00146 /*----------------------------------------------------------------------------- 00147 * Structure used to specify pixel format. 00148 */ 00149 00150 typedef struct { 00151 00152 uint8_t bitsPerPixel; /* 8,16,32 only */ 00153 00154 uint8_t depth; /* 8 to 32 */ 00155 00156 uint8_t bigEndian; /* True if multi-byte pixels are interpreted 00157 as big endian, or if single-bit-per-pixel 00158 has most significant bit of the byte 00159 corresponding to first (leftmost) pixel. Of 00160 course this is meaningless for 8 bits/pix */ 00161 00162 uint8_t trueColour; /* If false then we need a "colour map" to 00163 convert pixels to RGB. If true, xxxMax and 00164 xxxShift specify bits used for red, green 00165 and blue */ 00166 00167 /* the following fields are only meaningful if trueColour is true */ 00168 00169 uint16_t redMax; /* maximum red value (= 2^n - 1 where n is the 00170 number of bits used for red). Note this 00171 value is always in big endian order. */ 00172 00173 uint16_t greenMax; /* similar for green */ 00174 00175 uint16_t blueMax; /* and blue */ 00176 00177 uint8_t redShift; /* number of shifts needed to get the red 00178 value in a pixel to the least significant 00179 bit. To find the red value from a given 00180 pixel, do the following: 00181 1) Swap pixel value according to bigEndian 00182 (e.g. if bigEndian is false and host byte 00183 order is big endian, then swap). 00184 2) Shift right by redShift. 00185 3) AND with redMax (in host byte order). 00186 4) You now have the red value between 0 and 00187 redMax. */ 00188 00189 uint8_t greenShift; /* similar for green */ 00190 00191 uint8_t blueShift; /* and blue */ 00192 00193 uint8_t pad1; 00194 uint16_t pad2; 00195 00196 } rfbPixelFormat; 00197 00198 #define sz_rfbPixelFormat 16 00199 00200 /* UltraVNC: Color settings values */ 00201 #define rfbPFFullColors 0 00202 #define rfbPF256Colors 1 00203 #define rfbPF64Colors 2 00204 #define rfbPF8Colors 3 00205 #define rfbPF8GreyColors 4 00206 #define rfbPF4GreyColors 5 00207 #define rfbPF2GreyColors 6 00208 00209 00210 /***************************************************************************** 00211 * 00212 * Initial handshaking messages 00213 * 00214 *****************************************************************************/ 00215 00216 /*----------------------------------------------------------------------------- 00217 * Protocol Version 00218 * 00219 * The server always sends 12 bytes to start which identifies the latest RFB 00220 * protocol version number which it supports. These bytes are interpreted 00221 * as a string of 12 ASCII characters in the format "RFB xxx.yyy\n" where 00222 * xxx and yyy are the major and minor version numbers (for version 3.3 00223 * this is "RFB 003.003\n"). 00224 * 00225 * The client then replies with a similar 12-byte message giving the version 00226 * number of the protocol which should actually be used (which may be different 00227 * to that quoted by the server). 00228 * 00229 * It is intended that both clients and servers may provide some level of 00230 * backwards compatibility by this mechanism. Servers in particular should 00231 * attempt to provide backwards compatibility, and even forwards compatibility 00232 * to some extent. For example if a client demands version 3.1 of the 00233 * protocol, a 3.0 server can probably assume that by ignoring requests for 00234 * encoding types it doesn't understand, everything will still work OK. This 00235 * will probably not be the case for changes in the major version number. 00236 * 00237 * The format string below can be used in sprintf or sscanf to generate or 00238 * decode the version string respectively. 00239 */ 00240 00241 #define rfbProtocolVersionFormat "RFB %03d.%03d\n" 00242 #define rfbProtocolMajorVersion 3 00243 #define rfbProtocolMinorVersion 8 00244 /* UltraVNC Viewer examines rfbProtocolMinorVersion number (4, and 6) 00245 * to identify if the server supports File Transfer 00246 */ 00247 00248 typedef char rfbProtocolVersionMsg[13]; /* allow extra byte for null */ 00249 00250 #define sz_rfbProtocolVersionMsg 12 00251 00252 /* 00253 * Negotiation of the security type (protocol version 3.7) 00254 * 00255 * Once the protocol version has been decided, the server either sends a list 00256 * of supported security types, or informs the client about an error (when the 00257 * number of security types is 0). Security type rfbSecTypeTight is used to 00258 * enable TightVNC-specific protocol extensions. The value rfbSecTypeVncAuth 00259 * stands for classic VNC authentication. 00260 * 00261 * The client selects a particular security type from the list provided by the 00262 * server. 00263 */ 00264 00265 #define rfbSecTypeInvalid 0 00266 #define rfbSecTypeNone 1 00267 #define rfbSecTypeVncAuth 2 00268 00269 00270 /*----------------------------------------------------------------------------- 00271 * Authentication 00272 * 00273 * Once the protocol version has been decided, the server then sends a 32-bit 00274 * word indicating whether any authentication is needed on the connection. 00275 * The value of this word determines the authentication scheme in use. For 00276 * version 3.0 of the protocol this may have one of the following values: 00277 */ 00278 00279 #define rfbConnFailed 0 00280 #define rfbNoAuth 1 00281 #define rfbVncAuth 2 00282 00283 #define rfbRA2 5 00284 #define rfbRA2ne 6 00285 #define rfbSSPI 7 00286 #define rfbSSPIne 8 00287 #define rfbTight 16 00288 #define rfbUltra 17 00289 #define rfbTLS 18 00290 #define rfbVeNCrypt 19 00291 #define rfbARD 30 00292 #define rfbMSLogon 0xfffffffa 00293 00294 #define rfbVeNCryptPlain 256 00295 #define rfbVeNCryptTLSNone 257 00296 #define rfbVeNCryptTLSVNC 258 00297 #define rfbVeNCryptTLSPlain 259 00298 #define rfbVeNCryptX509None 260 00299 #define rfbVeNCryptX509VNC 261 00300 #define rfbVeNCryptX509Plain 262 00301 #define rfbVeNCryptX509SASL 263 00302 #define rfbVeNCryptTLSSASL 264 00303 00304 /* 00305 * rfbConnFailed: For some reason the connection failed (e.g. the server 00306 * cannot support the desired protocol version). This is 00307 * followed by a string describing the reason (where a 00308 * string is specified as a 32-bit length followed by that 00309 * many ASCII characters). 00310 * 00311 * rfbNoAuth: No authentication is needed. 00312 * 00313 * rfbVncAuth: The VNC authentication scheme is to be used. A 16-byte 00314 * challenge follows, which the client encrypts as 00315 * appropriate using the password and sends the resulting 00316 * 16-byte response. If the response is correct, the 00317 * server sends the 32-bit word rfbVncAuthOK. If a simple 00318 * failure happens, the server sends rfbVncAuthFailed and 00319 * closes the connection. If the server decides that too 00320 * many failures have occurred, it sends rfbVncAuthTooMany 00321 * and closes the connection. In the latter case, the 00322 * server should not allow an immediate reconnection by 00323 * the client. 00324 */ 00325 00326 #define rfbVncAuthOK 0 00327 #define rfbVncAuthFailed 1 00328 #define rfbVncAuthTooMany 2 00329 00330 00331 /*----------------------------------------------------------------------------- 00332 * Client Initialisation Message 00333 * 00334 * Once the client and server are sure that they're happy to talk to one 00335 * another, the client sends an initialisation message. At present this 00336 * message only consists of a boolean indicating whether the server should try 00337 * to share the desktop by leaving other clients connected, or give exclusive 00338 * access to this client by disconnecting all other clients. 00339 */ 00340 00341 typedef struct { 00342 uint8_t shared; 00343 } rfbClientInitMsg; 00344 00345 #define sz_rfbClientInitMsg 1 00346 00347 00348 /*----------------------------------------------------------------------------- 00349 * Server Initialisation Message 00350 * 00351 * After the client initialisation message, the server sends one of its own. 00352 * This tells the client the width and height of the server's framebuffer, 00353 * its pixel format and the name associated with the desktop. 00354 */ 00355 00356 typedef struct { 00357 uint16_t framebufferWidth; 00358 uint16_t framebufferHeight; 00359 rfbPixelFormat format; /* the server's preferred pixel format */ 00360 uint32_t nameLength; 00361 /* followed by char name[nameLength] */ 00362 } rfbServerInitMsg; 00363 00364 #define sz_rfbServerInitMsg (8 + sz_rfbPixelFormat) 00365 00366 00367 /* 00368 * Following the server initialisation message it's up to the client to send 00369 * whichever protocol messages it wants. Typically it will send a 00370 * SetPixelFormat message and a SetEncodings message, followed by a 00371 * FramebufferUpdateRequest. From then on the server will send 00372 * FramebufferUpdate messages in response to the client's 00373 * FramebufferUpdateRequest messages. The client should send 00374 * FramebufferUpdateRequest messages with incremental set to true when it has 00375 * finished processing one FramebufferUpdate and is ready to process another. 00376 * With a fast client, the rate at which FramebufferUpdateRequests are sent 00377 * should be regulated to avoid hogging the network. 00378 */ 00379 00380 00381 00382 /***************************************************************************** 00383 * 00384 * Message types 00385 * 00386 *****************************************************************************/ 00387 00388 /* server -> client */ 00389 00390 #define rfbFramebufferUpdate 0 00391 #define rfbSetColourMapEntries 1 00392 #define rfbBell 2 00393 #define rfbServerCutText 3 00394 /* Modif sf@2002 */ 00395 #define rfbResizeFrameBuffer 4 00396 #define rfbPalmVNCReSizeFrameBuffer 0xF 00397 00398 /* client -> server */ 00399 00400 #define rfbSetPixelFormat 0 00401 #define rfbFixColourMapEntries 1 /* not currently supported */ 00402 #define rfbSetEncodings 2 00403 #define rfbFramebufferUpdateRequest 3 00404 #define rfbKeyEvent 4 00405 #define rfbPointerEvent 5 00406 #define rfbClientCutText 6 00407 /* Modif sf@2002 - actually bidirectionnal */ 00408 #define rfbFileTransfer 7 00409 /* Modif sf@2002 */ 00410 #define rfbSetScale 8 00411 /* Modif rdv@2002 */ 00412 #define rfbSetServerInput 9 00413 /* Modif rdv@2002 */ 00414 #define rfbSetSW 10 00415 /* Modif sf@2002 - TextChat - Bidirectionnal */ 00416 #define rfbTextChat 11 00417 /* Modif cs@2005 */ 00418 /* PalmVNC 1.4 & 2.0 SetScale Factor message */ 00419 #define rfbPalmVNCSetScaleFactor 0xF 00420 /* Xvp message - bidirectional */ 00421 #define rfbXvp 250 00422 00423 00424 00425 00426 /***************************************************************************** 00427 * 00428 * Encoding types 00429 * 00430 *****************************************************************************/ 00431 00432 #define rfbEncodingRaw 0 00433 #define rfbEncodingCopyRect 1 00434 #define rfbEncodingRRE 2 00435 #define rfbEncodingCoRRE 4 00436 #define rfbEncodingHextile 5 00437 #define rfbEncodingZlib 6 00438 #define rfbEncodingTight 7 00439 #define rfbEncodingTightPng 0xFFFFFEFC /* -260 */ 00440 #define rfbEncodingZlibHex 8 00441 #define rfbEncodingUltra 9 00442 #define rfbEncodingZRLE 16 00443 #define rfbEncodingZYWRLE 17 00444 00445 /* Cache & XOR-Zlib - rdv@2002 */ 00446 #define rfbEncodingCache 0xFFFF0000 00447 #define rfbEncodingCacheEnable 0xFFFF0001 00448 #define rfbEncodingXOR_Zlib 0xFFFF0002 00449 #define rfbEncodingXORMonoColor_Zlib 0xFFFF0003 00450 #define rfbEncodingXORMultiColor_Zlib 0xFFFF0004 00451 #define rfbEncodingSolidColor 0xFFFF0005 00452 #define rfbEncodingXOREnable 0xFFFF0006 00453 #define rfbEncodingCacheZip 0xFFFF0007 00454 #define rfbEncodingSolMonoZip 0xFFFF0008 00455 #define rfbEncodingUltraZip 0xFFFF0009 00456 00457 /* Xvp pseudo-encoding */ 00458 #define rfbEncodingXvp 0xFFFFFECB 00459 00460 /* 00461 * Special encoding numbers: 00462 * 0xFFFFFD00 .. 0xFFFFFD05 -- subsampling level 00463 * 0xFFFFFE00 .. 0xFFFFFE64 -- fine-grained quality level (0-100 scale) 00464 * 0xFFFFFF00 .. 0xFFFFFF0F -- encoding-specific compression levels; 00465 * 0xFFFFFF10 .. 0xFFFFFF1F -- mouse cursor shape data; 00466 * 0xFFFFFF20 .. 0xFFFFFF2F -- various protocol extensions; 00467 * 0xFFFFFF30 .. 0xFFFFFFDF -- not allocated yet; 00468 * 0xFFFFFFE0 .. 0xFFFFFFEF -- quality level for JPEG compressor; 00469 * 0xFFFFFFF0 .. 0xFFFFFFFF -- cross-encoding compression levels. 00470 */ 00471 00472 #define rfbEncodingFineQualityLevel0 0xFFFFFE00 00473 #define rfbEncodingFineQualityLevel100 0xFFFFFE64 00474 #define rfbEncodingSubsamp1X 0xFFFFFD00 00475 #define rfbEncodingSubsamp4X 0xFFFFFD01 00476 #define rfbEncodingSubsamp2X 0xFFFFFD02 00477 #define rfbEncodingSubsampGray 0xFFFFFD03 00478 #define rfbEncodingSubsamp8X 0xFFFFFD04 00479 #define rfbEncodingSubsamp16X 0xFFFFFD05 00480 00481 #define rfbEncodingCompressLevel0 0xFFFFFF00 00482 #define rfbEncodingCompressLevel1 0xFFFFFF01 00483 #define rfbEncodingCompressLevel2 0xFFFFFF02 00484 #define rfbEncodingCompressLevel3 0xFFFFFF03 00485 #define rfbEncodingCompressLevel4 0xFFFFFF04 00486 #define rfbEncodingCompressLevel5 0xFFFFFF05 00487 #define rfbEncodingCompressLevel6 0xFFFFFF06 00488 #define rfbEncodingCompressLevel7 0xFFFFFF07 00489 #define rfbEncodingCompressLevel8 0xFFFFFF08 00490 #define rfbEncodingCompressLevel9 0xFFFFFF09 00491 00492 #define rfbEncodingXCursor 0xFFFFFF10 00493 #define rfbEncodingRichCursor 0xFFFFFF11 00494 #define rfbEncodingPointerPos 0xFFFFFF18 00495 00496 #define rfbEncodingLastRect 0xFFFFFF20 00497 #define rfbEncodingNewFBSize 0xFFFFFF21 00498 00499 #define rfbEncodingQualityLevel0 0xFFFFFFE0 00500 #define rfbEncodingQualityLevel1 0xFFFFFFE1 00501 #define rfbEncodingQualityLevel2 0xFFFFFFE2 00502 #define rfbEncodingQualityLevel3 0xFFFFFFE3 00503 #define rfbEncodingQualityLevel4 0xFFFFFFE4 00504 #define rfbEncodingQualityLevel5 0xFFFFFFE5 00505 #define rfbEncodingQualityLevel6 0xFFFFFFE6 00506 #define rfbEncodingQualityLevel7 0xFFFFFFE7 00507 #define rfbEncodingQualityLevel8 0xFFFFFFE8 00508 #define rfbEncodingQualityLevel9 0xFFFFFFE9 00509 00510 00511 /* LibVNCServer additions. We claim 0xFFFE0000 - 0xFFFE00FF */ 00512 #define rfbEncodingKeyboardLedState 0xFFFE0000 00513 #define rfbEncodingSupportedMessages 0xFFFE0001 00514 #define rfbEncodingSupportedEncodings 0xFFFE0002 00515 #define rfbEncodingServerIdentity 0xFFFE0003 00516 00517 00518 /***************************************************************************** 00519 * 00520 * Server -> client message definitions 00521 * 00522 *****************************************************************************/ 00523 00524 00525 /*----------------------------------------------------------------------------- 00526 * FramebufferUpdate - a block of rectangles to be copied to the framebuffer. 00527 * 00528 * This message consists of a header giving the number of rectangles of pixel 00529 * data followed by the rectangles themselves. The header is padded so that 00530 * together with the type byte it is an exact multiple of 4 bytes (to help 00531 * with alignment of 32-bit pixels): 00532 */ 00533 00534 typedef struct { 00535 uint8_t type; /* always rfbFramebufferUpdate */ 00536 uint8_t pad; 00537 uint16_t nRects; 00538 /* followed by nRects rectangles */ 00539 } rfbFramebufferUpdateMsg; 00540 00541 #define sz_rfbFramebufferUpdateMsg 4 00542 00543 /* 00544 * Each rectangle of pixel data consists of a header describing the position 00545 * and size of the rectangle and a type word describing the encoding of the 00546 * pixel data, followed finally by the pixel data. Note that if the client has 00547 * not sent a SetEncodings message then it will only receive raw pixel data. 00548 * Also note again that this structure is a multiple of 4 bytes. 00549 */ 00550 00551 typedef struct { 00552 rfbRectangle r; 00553 uint32_t encoding; /* one of the encoding types rfbEncoding... */ 00554 } rfbFramebufferUpdateRectHeader; 00555 00556 #define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4) 00557 00558 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00559 * Supported Messages Encoding. This encoding does not contain any pixel data. 00560 * Instead, it contains 2 sets of bitflags. These bitflags indicate what messages 00561 * are supported by the server. 00562 * rect->w contains byte count 00563 */ 00564 00565 typedef struct { 00566 uint8_t client2server[32]; /* maximum of 256 message types (256/8)=32 */ 00567 uint8_t server2client[32]; /* maximum of 256 message types (256/8)=32 */ 00568 } rfbSupportedMessages; 00569 00570 #define sz_rfbSupportedMessages 64 00571 00572 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00573 * Supported Encodings Encoding. This encoding does not contain any pixel data. 00574 * Instead, it contains a list of (uint32_t) Encodings supported by this server. 00575 * rect->w contains byte count 00576 * rect->h contains encoding count 00577 */ 00578 00579 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00580 * Server Identity Encoding. This encoding does not contain any pixel data. 00581 * Instead, it contains a text string containing information about the server. 00582 * ie: "x11vnc: 0.8.1 lastmod: 2006-04-25 (libvncserver 0.9pre)\0" 00583 * rect->w contains byte count 00584 */ 00585 00586 00587 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00588 * Raw Encoding. Pixels are sent in top-to-bottom scanline order, 00589 * left-to-right within a scanline with no padding in between. 00590 */ 00591 00592 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00593 * KeyboardLedState Encoding. The X coordinate contains the Locked Modifiers 00594 * so that a remote troubleshooter can identify that the users 'Caps Lock' 00595 * is set... (It helps a *lot* when the users are untrained) 00596 */ 00597 #define rfbKeyboardMaskShift 1 00598 #define rfbKeyboardMaskCapsLock 2 00599 #define rfbKeyboardMaskControl 4 00600 #define rfbKeyboardMaskAlt 8 00601 #define rfbKeyboardMaskMeta 16 00602 #define rfbKeyboardMaskSuper 32 00603 #define rfbKeyboardMaskHyper 64 00604 #define rfbKeyboardMaskNumLock 128 00605 #define rfbKeyboardMaskScrollLock 256 00606 #define rfbKeyboardMaskAltGraph 512 00607 00608 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00609 * CopyRect Encoding. The pixels are specified simply by the x and y position 00610 * of the source rectangle. 00611 */ 00612 00613 typedef struct { 00614 uint16_t srcX; 00615 uint16_t srcY; 00616 } rfbCopyRect; 00617 00618 #define sz_rfbCopyRect 4 00619 00620 00621 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00622 * RRE - Rise-and-Run-length Encoding. We have an rfbRREHeader structure 00623 * giving the number of subrectangles following. Finally the data follows in 00624 * the form [<bgpixel><subrect><subrect>...] where each <subrect> is 00625 * [<pixel><rfbRectangle>]. 00626 */ 00627 00628 typedef struct { 00629 uint32_t nSubrects; 00630 } rfbRREHeader; 00631 00632 #define sz_rfbRREHeader 4 00633 00634 00635 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00636 * CoRRE - Compact RRE Encoding. We have an rfbRREHeader structure giving 00637 * the number of subrectangles following. Finally the data follows in the form 00638 * [<bgpixel><subrect><subrect>...] where each <subrect> is 00639 * [<pixel><rfbCoRRERectangle>]. This means that 00640 * the whole rectangle must be at most 255x255 pixels. 00641 */ 00642 00643 typedef struct { 00644 uint8_t x; 00645 uint8_t y; 00646 uint8_t w; 00647 uint8_t h; 00648 } rfbCoRRERectangle; 00649 00650 #define sz_rfbCoRRERectangle 4 00651 00652 00653 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00654 * Hextile Encoding. The rectangle is divided up into "tiles" of 16x16 pixels, 00655 * starting at the top left going in left-to-right, top-to-bottom order. If 00656 * the width of the rectangle is not an exact multiple of 16 then the width of 00657 * the last tile in each row will be correspondingly smaller. Similarly if the 00658 * height is not an exact multiple of 16 then the height of each tile in the 00659 * final row will also be smaller. Each tile begins with a "subencoding" type 00660 * byte, which is a mask made up of a number of bits. If the Raw bit is set 00661 * then the other bits are irrelevant; w*h pixel values follow (where w and h 00662 * are the width and height of the tile). Otherwise the tile is encoded in a 00663 * similar way to RRE, except that the position and size of each subrectangle 00664 * can be specified in just two bytes. The other bits in the mask are as 00665 * follows: 00666 * 00667 * BackgroundSpecified - if set, a pixel value follows which specifies 00668 * the background colour for this tile. The first non-raw tile in a 00669 * rectangle must have this bit set. If this bit isn't set then the 00670 * background is the same as the last tile. 00671 * 00672 * ForegroundSpecified - if set, a pixel value follows which specifies 00673 * the foreground colour to be used for all subrectangles in this tile. 00674 * If this bit is set then the SubrectsColoured bit must be zero. 00675 * 00676 * AnySubrects - if set, a single byte follows giving the number of 00677 * subrectangles following. If not set, there are no subrectangles (i.e. 00678 * the whole tile is just solid background colour). 00679 * 00680 * SubrectsColoured - if set then each subrectangle is preceded by a pixel 00681 * value giving the colour of that subrectangle. If not set, all 00682 * subrectangles are the same colour, the foreground colour; if the 00683 * ForegroundSpecified bit wasn't set then the foreground is the same as 00684 * the last tile. 00685 * 00686 * The position and size of each subrectangle is specified in two bytes. The 00687 * Pack macros below can be used to generate the two bytes from x, y, w, h, 00688 * and the Extract macros can be used to extract the x, y, w, h values from 00689 * the two bytes. 00690 */ 00691 00692 #define rfbHextileRaw (1 << 0) 00693 #define rfbHextileBackgroundSpecified (1 << 1) 00694 #define rfbHextileForegroundSpecified (1 << 2) 00695 #define rfbHextileAnySubrects (1 << 3) 00696 #define rfbHextileSubrectsColoured (1 << 4) 00697 00698 #define rfbHextilePackXY(x,y) (((x) << 4) | (y)) 00699 #define rfbHextilePackWH(w,h) ((((w)-1) << 4) | ((h)-1)) 00700 #define rfbHextileExtractX(byte) ((byte) >> 4) 00701 #define rfbHextileExtractY(byte) ((byte) & 0xf) 00702 #define rfbHextileExtractW(byte) (((byte) >> 4) + 1) 00703 #define rfbHextileExtractH(byte) (((byte) & 0xf) + 1) 00704 00705 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00706 * zlib - zlib compressed Encoding. We have an rfbZlibHeader structure 00707 * giving the number of bytes following. Finally the data follows is 00708 * zlib compressed version of the raw pixel data as negotiated. 00709 * (NOTE: also used by Ultra Encoding) 00710 */ 00711 00712 typedef struct { 00713 uint32_t nBytes; 00714 } rfbZlibHeader; 00715 00716 #define sz_rfbZlibHeader 4 00717 00718 #ifdef LIBVNCSERVER_HAVE_LIBZ 00719 00720 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00721 * Tight and TightPng Encoding. 00722 * 00723 *-- TightPng is like Tight but basic compression is not used, instead PNG 00724 * data is sent. 00725 * 00726 *-- The first byte of each Tight-encoded rectangle is a "compression control 00727 * byte". Its format is as follows (bit 0 is the least significant one): 00728 * 00729 * bit 0: if 1, then compression stream 0 should be reset; 00730 * bit 1: if 1, then compression stream 1 should be reset; 00731 * bit 2: if 1, then compression stream 2 should be reset; 00732 * bit 3: if 1, then compression stream 3 should be reset; 00733 * bits 7-4: if 1000 (0x08), then the compression type is "fill", 00734 * if 1001 (0x09), then the compression type is "jpeg", 00735 * (Tight only) if 1010 (0x0A), then the compression type is 00736 * "basic" and no Zlib compression was used, 00737 * (Tight only) if 1110 (0x0E), then the compression type is 00738 * "basic", no Zlib compression was used, and a "filter id" byte 00739 * follows this byte, 00740 * (TightPng only) if 1010 (0x0A), then the compression type is 00741 * "png", 00742 * if 0xxx, then the compression type is "basic" and Zlib 00743 * compression was used, 00744 * values greater than 1010 are not valid. 00745 * 00746 * If the compression type is "basic" and Zlib compression was used, then bits 00747 * 6..4 of the compression control byte (those xxx in 0xxx) specify the 00748 * following: 00749 * 00750 * bits 5-4: decimal representation is the index of a particular zlib 00751 * stream which should be used for decompressing the data; 00752 * bit 6: if 1, then a "filter id" byte is following this byte. 00753 * 00754 *-- The data that follows after the compression control byte described 00755 * above depends on the compression type ("fill", "jpeg", "png" or "basic"). 00756 * 00757 *-- If the compression type is "fill", then the only pixel value follows, in 00758 * client pixel format (see NOTE 1). This value applies to all pixels of the 00759 * rectangle. 00760 * 00761 *-- If the compression type is "jpeg" or "png", the following data stream 00762 * looks like this: 00763 * 00764 * 1..3 bytes: data size (N) in compact representation; 00765 * N bytes: JPEG or PNG image. 00766 * 00767 * Data size is compactly represented in one, two or three bytes, according 00768 * to the following scheme: 00769 * 00770 * 0xxxxxxx (for values 0..127) 00771 * 1xxxxxxx 0yyyyyyy (for values 128..16383) 00772 * 1xxxxxxx 1yyyyyyy zzzzzzzz (for values 16384..4194303) 00773 * 00774 * Here each character denotes one bit, xxxxxxx are the least significant 7 00775 * bits of the value (bits 0-6), yyyyyyy are bits 7-13, and zzzzzzzz are the 00776 * most significant 8 bits (bits 14-21). For example, decimal value 10000 00777 * should be represented as two bytes: binary 10010000 01001110, or 00778 * hexadecimal 90 4E. 00779 * 00780 *-- If the compression type is "basic" and bit 6 of the compression control 00781 * byte was set to 1, then the next (second) byte specifies "filter id" which 00782 * tells the decoder what filter type was used by the encoder to pre-process 00783 * pixel data before the compression. The "filter id" byte can be one of the 00784 * following: 00785 * 00786 * 0: no filter ("copy" filter); 00787 * 1: "palette" filter; 00788 * 2: "gradient" filter. 00789 * 00790 *-- If bit 6 of the compression control byte is set to 0 (no "filter id" 00791 * byte), or if the filter id is 0, then raw pixel values in the client 00792 * format (see NOTE 1) will be compressed. See below details on the 00793 * compression. 00794 * 00795 *-- The "gradient" filter pre-processes pixel data with a simple algorithm 00796 * which converts each color component to a difference between a "predicted" 00797 * intensity and the actual intensity. Such a technique does not affect 00798 * uncompressed data size, but helps to compress photo-like images better. 00799 * Pseudo-code for converting intensities to differences is the following: 00800 * 00801 * P[i,j] := V[i-1,j] + V[i,j-1] - V[i-1,j-1]; 00802 * if (P[i,j] < 0) then P[i,j] := 0; 00803 * if (P[i,j] > MAX) then P[i,j] := MAX; 00804 * D[i,j] := V[i,j] - P[i,j]; 00805 * 00806 * Here V[i,j] is the intensity of a color component for a pixel at 00807 * coordinates (i,j). MAX is the maximum value of intensity for a color 00808 * component. 00809 * 00810 *-- The "palette" filter converts true-color pixel data to indexed colors 00811 * and a palette which can consist of 2..256 colors. If the number of colors 00812 * is 2, then each pixel is encoded in 1 bit, otherwise 8 bits is used to 00813 * encode one pixel. 1-bit encoding is performed such way that the most 00814 * significant bits correspond to the leftmost pixels, and each raw of pixels 00815 * is aligned to the byte boundary. When "palette" filter is used, the 00816 * palette is sent before the pixel data. The palette begins with an unsigned 00817 * byte which value is the number of colors in the palette minus 1 (i.e. 1 00818 * means 2 colors, 255 means 256 colors in the palette). Then follows the 00819 * palette itself which consist of pixel values in client pixel format (see 00820 * NOTE 1). 00821 * 00822 *-- The pixel data is compressed using the zlib library. But if the data 00823 * size after applying the filter but before the compression is less then 12, 00824 * then the data is sent as is, uncompressed. Four separate zlib streams 00825 * (0..3) can be used and the decoder should read the actual stream id from 00826 * the compression control byte (see NOTE 2). 00827 * 00828 * If the compression is not used, then the pixel data is sent as is, 00829 * otherwise the data stream looks like this: 00830 * 00831 * 1..3 bytes: data size (N) in compact representation; 00832 * N bytes: zlib-compressed data. 00833 * 00834 * Data size is compactly represented in one, two or three bytes, just like 00835 * in the "jpeg" compression method (see above). 00836 * 00837 *-- NOTE 1. If the color depth is 24, and all three color components are 00838 * 8-bit wide, then one pixel in Tight encoding is always represented by 00839 * three bytes, where the first byte is red component, the second byte is 00840 * green component, and the third byte is blue component of the pixel color 00841 * value. This applies to colors in palettes as well. 00842 * 00843 *-- NOTE 2. The decoder must reset compression streams' states before 00844 * decoding the rectangle, if some of bits 0,1,2,3 in the compression control 00845 * byte are set to 1. Note that the decoder must reset zlib streams even if 00846 * the compression type is "fill", "jpeg" or "png". 00847 * 00848 *-- NOTE 3. The "gradient" filter and "jpeg" compression may be used only 00849 * when bits-per-pixel value is either 16 or 32, not 8. 00850 * 00851 *-- NOTE 4. The width of any Tight-encoded rectangle cannot exceed 2048 00852 * pixels. If a rectangle is wider, it must be split into several rectangles 00853 * and each one should be encoded separately. 00854 * 00855 */ 00856 00857 #define rfbTightExplicitFilter 0x04 00858 #define rfbTightFill 0x08 00859 #define rfbTightJpeg 0x09 00860 #define rfbTightNoZlib 0x0A 00861 #define rfbTightPng 0x0A 00862 #define rfbTightMaxSubencoding 0x0A 00863 00864 /* Filters to improve compression efficiency */ 00865 #define rfbTightFilterCopy 0x00 00866 #define rfbTightFilterPalette 0x01 00867 #define rfbTightFilterGradient 0x02 00868 00869 #endif 00870 00871 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00872 * XCursor encoding. This is a special encoding used to transmit X-style 00873 * cursor shapes from server to clients. Note that for this encoding, 00874 * coordinates in rfbFramebufferUpdateRectHeader structure hold hotspot 00875 * position (r.x, r.y) and cursor size (r.w, r.h). If (w * h != 0), two RGB 00876 * samples are sent after header in the rfbXCursorColors structure. They 00877 * denote foreground and background colors of the cursor. If a client 00878 * supports only black-and-white cursors, it should ignore these colors and 00879 * assume that foreground is black and background is white. Next, two bitmaps 00880 * (1 bits per pixel) follow: first one with actual data (value 0 denotes 00881 * background color, value 1 denotes foreground color), second one with 00882 * transparency data (bits with zero value mean that these pixels are 00883 * transparent). Both bitmaps represent cursor data in a byte stream, from 00884 * left to right, from top to bottom, and each row is byte-aligned. Most 00885 * significant bits correspond to leftmost pixels. The number of bytes in 00886 * each row can be calculated as ((w + 7) / 8). If (w * h == 0), cursor 00887 * should be hidden (or default local cursor should be set by the client). 00888 */ 00889 00890 typedef struct { 00891 uint8_t foreRed; 00892 uint8_t foreGreen; 00893 uint8_t foreBlue; 00894 uint8_t backRed; 00895 uint8_t backGreen; 00896 uint8_t backBlue; 00897 } rfbXCursorColors; 00898 00899 #define sz_rfbXCursorColors 6 00900 00901 00902 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00903 * RichCursor encoding. This is a special encoding used to transmit cursor 00904 * shapes from server to clients. It is similar to the XCursor encoding but 00905 * uses client pixel format instead of two RGB colors to represent cursor 00906 * image. For this encoding, coordinates in rfbFramebufferUpdateRectHeader 00907 * structure hold hotspot position (r.x, r.y) and cursor size (r.w, r.h). 00908 * After header, two pixmaps follow: first one with cursor image in current 00909 * client pixel format (like in raw encoding), second with transparency data 00910 * (1 bit per pixel, exactly the same format as used for transparency bitmap 00911 * in the XCursor encoding). If (w * h == 0), cursor should be hidden (or 00912 * default local cursor should be set by the client). 00913 */ 00914 00915 00916 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00917 * ZRLE - encoding combining Zlib compression, tiling, palettisation and 00918 * run-length encoding. 00919 */ 00920 00921 typedef struct { 00922 uint32_t length; 00923 } rfbZRLEHeader; 00924 00925 #define sz_rfbZRLEHeader 4 00926 00927 #define rfbZRLETileWidth 64 00928 #define rfbZRLETileHeight 64 00929 00930 00931 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 00932 * ZLIBHEX - zlib compressed Hextile Encoding. Essentially, this is the 00933 * hextile encoding with zlib compression on the tiles that can not be 00934 * efficiently encoded with one of the other hextile subencodings. The 00935 * new zlib subencoding uses two bytes to specify the length of the 00936 * compressed tile and then the compressed data follows. As with the 00937 * raw sub-encoding, the zlib subencoding invalidates the other 00938 * values, if they are also set. 00939 */ 00940 00941 #define rfbHextileZlibRaw (1 << 5) 00942 #define rfbHextileZlibHex (1 << 6) 00943 #define rfbHextileZlibMono (1 << 7) 00944 00945 00946 /*----------------------------------------------------------------------------- 00947 * SetColourMapEntries - these messages are only sent if the pixel 00948 * format uses a "colour map" (i.e. trueColour false) and the client has not 00949 * fixed the entire colour map using FixColourMapEntries. In addition they 00950 * will only start being sent after the client has sent its first 00951 * FramebufferUpdateRequest. So if the client always tells the server to use 00952 * trueColour then it never needs to process this type of message. 00953 */ 00954 00955 typedef struct { 00956 uint8_t type; /* always rfbSetColourMapEntries */ 00957 uint8_t pad; 00958 uint16_t firstColour; 00959 uint16_t nColours; 00960 00961 /* Followed by nColours * 3 * uint16_t 00962 r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ 00963 00964 } rfbSetColourMapEntriesMsg; 00965 00966 #define sz_rfbSetColourMapEntriesMsg 6 00967 00968 00969 00970 /*----------------------------------------------------------------------------- 00971 * Bell - ring a bell on the client if it has one. 00972 */ 00973 00974 typedef struct { 00975 uint8_t type; /* always rfbBell */ 00976 } rfbBellMsg; 00977 00978 #define sz_rfbBellMsg 1 00979 00980 00981 00982 /*----------------------------------------------------------------------------- 00983 * ServerCutText - the server has new text in its cut buffer. 00984 */ 00985 00986 typedef struct { 00987 uint8_t type; /* always rfbServerCutText */ 00988 uint8_t pad1; 00989 uint16_t pad2; 00990 uint32_t length; 00991 /* followed by char text[length] */ 00992 } rfbServerCutTextMsg; 00993 00994 #define sz_rfbServerCutTextMsg 8 00995 00996 00997 /*----------------------------------------------------------------------------- 00998 * // Modif sf@2002 00999 * FileTransferMsg - The client sends FileTransfer message. 01000 * Bidirectional message - Files can be sent from client to server & vice versa 01001 */ 01002 01003 typedef struct _rfbFileTransferMsg { 01004 uint8_t type; /* always rfbFileTransfer */ 01005 uint8_t contentType; /* See defines below */ 01006 uint8_t contentParam;/* Other possible content classification (Dir or File name, etc..) */ 01007 uint8_t pad; /* It appears that UltraVNC *forgot* to Swap16IfLE(contentParam) */ 01008 uint32_t size; /* FileSize or packet index or error or other */ 01009 /* uint32_t sizeH; Additional 32Bits params to handle big values. Only for V2 (we want backward compatibility between all V1 versions) */ 01010 uint32_t length; 01011 /* followed by data char text[length] */ 01012 } rfbFileTransferMsg; 01013 01014 #define sz_rfbFileTransferMsg 12 01015 01016 #define rfbFileTransferVersion 2 /* v1 is the old FT version ( <= 1.0.0 RC18 versions) */ 01017 01018 /* FileTransfer Content types and Params defines */ 01019 #define rfbDirContentRequest 1 /* Client asks for the content of a given Server directory */ 01020 #define rfbDirPacket 2 /* Full directory name or full file name. */ 01021 /* Null content means end of Directory */ 01022 #define rfbFileTransferRequest 3 /* Client asks the server for the transfer of a given file */ 01023 #define rfbFileHeader 4 /* First packet of a file transfer, containing file's features */ 01024 #define rfbFilePacket 5 /* One chunk of the file */ 01025 #define rfbEndOfFile 6 /* End of file transfer (the file has been received or error) */ 01026 #define rfbAbortFileTransfer 7 /* The file transfer must be aborted, whatever the state */ 01027 #define rfbFileTransferOffer 8 /* The client offers to send a file to the server */ 01028 #define rfbFileAcceptHeader 9 /* The server accepts or rejects the file */ 01029 #define rfbCommand 10 /* The Client sends a simple command (File Delete, Dir create etc...) */ 01030 #define rfbCommandReturn 11 /* The Client receives the server's answer about a simple command */ 01031 #define rfbFileChecksums 12 /* The zipped checksums of the destination file (Delta Transfer) */ 01032 #define rfbFileTransferAccess 14 /* Request FileTransfer authorization */ 01033 01034 /* rfbDirContentRequest client Request - content params */ 01035 #define rfbRDirContent 1 /* Request a Server Directory contents */ 01036 #define rfbRDrivesList 2 /* Request the server's drives list */ 01037 #define rfbRDirRecursiveList 3 /* Request a server directory content recursive sorted list */ 01038 #define rfbRDirRecursiveSize 4 /* Request a server directory content recursive size */ 01039 01040 /* rfbDirPacket & rfbCommandReturn server Answer - content params */ 01041 #define rfbADirectory 1 /* Reception of a directory name */ 01042 #define rfbAFile 2 /* Reception of a file name */ 01043 #define rfbADrivesList 3 /* Reception of a list of drives */ 01044 #define rfbADirCreate 4 /* Response to a create dir command */ 01045 #define rfbADirDelete 5 /* Response to a delete dir command */ 01046 #define rfbAFileCreate 6 /* Response to a create file command */ 01047 #define rfbAFileDelete 7 /* Response to a delete file command */ 01048 #define rfbAFileRename 8 /* Response to a rename file command */ 01049 #define rfbADirRename 9 /* Response to a rename dir command */ 01050 #define rfbADirRecursiveListItem 10 01051 #define rfbADirRecursiveSize 11 01052 01053 /* rfbCommand Command - content params */ 01054 #define rfbCDirCreate 1 /* Request the server to create the given directory */ 01055 #define rfbCDirDelete 2 /* Request the server to delete the given directory */ 01056 #define rfbCFileCreate 3 /* Request the server to create the given file */ 01057 #define rfbCFileDelete 4 /* Request the server to delete the given file */ 01058 #define rfbCFileRename 5 /* Request the server to rename the given file */ 01059 #define rfbCDirRename 6 /* Request the server to rename the given directory */ 01060 01061 /* Errors - content params or "size" field */ 01062 #define rfbRErrorUnknownCmd 1 /* Unknown FileTransfer command. */ 01063 #define rfbRErrorCmd 0xFFFFFFFF/* Error when a command fails on remote side (ret in "size" field) */ 01064 01065 #define sz_rfbBlockSize 8192 /* Size of a File Transfer packet (before compression) */ 01066 #define rfbZipDirectoryPrefix "!UVNCDIR-\0" /* Transfered directory are zipped in a file with this prefix. Must end with "-" */ 01067 #define sz_rfbZipDirectoryPrefix 9 01068 #define rfbDirPrefix "[ " 01069 #define rfbDirSuffix " ]" 01070 01071 01072 01073 /*----------------------------------------------------------------------------- 01074 * Modif sf@2002 01075 * TextChatMsg - Utilized to order the TextChat mode on server or client 01076 * Bidirectional message 01077 */ 01078 01079 typedef struct _rfbTextChatMsg { 01080 uint8_t type; /* always rfbTextChat */ 01081 uint8_t pad1; /* Could be used later as an additionnal param */ 01082 uint16_t pad2; /* Could be used later as text offset, for instance */ 01083 uint32_t length; /* Specific values for Open, close, finished (-1, -2, -3) */ 01084 /* followed by char text[length] */ 01085 } rfbTextChatMsg; 01086 01087 #define sz_rfbTextChatMsg 8 01088 01089 #define rfbTextMaxSize 4096 01090 #define rfbTextChatOpen 0xFFFFFFFF 01091 #define rfbTextChatClose 0xFFFFFFFE 01092 #define rfbTextChatFinished 0xFFFFFFFD 01093 01094 01095 /*----------------------------------------------------------------------------- 01096 * Xvp Message 01097 * Bidirectional message 01098 * A server which supports the xvp extension declares this by sending a message 01099 * with an Xvp_INIT xvp-message-code when it receives a request from the client 01100 * to use the xvp Pseudo-encoding. The server must specify in this message the 01101 * highest xvp-extension-version it supports: the client may assume that the 01102 * server supports all versions from 1 up to this value. The client is then 01103 * free to use any supported version. Currently, only version 1 is defined. 01104 * 01105 * A server which subsequently receives an xvp Client Message requesting an 01106 * operation which it is unable to perform, informs the client of this by 01107 * sending a message with an Xvp_FAIL xvp-message-code, and the same 01108 * xvp-extension-version as included in the client's operation request. 01109 * 01110 * A client supporting the xvp extension sends this to request that the server 01111 * initiate a clean shutdown, clean reboot or abrupt reset of the system whose 01112 * framebuffer the client is displaying. 01113 */ 01114 01115 01116 typedef struct { 01117 uint8_t type; /* always rfbXvp */ 01118 uint8_t pad; 01119 uint8_t version; /* xvp extension version */ 01120 uint8_t code; /* xvp message code */ 01121 } rfbXvpMsg; 01122 01123 #define sz_rfbXvpMsg (4) 01124 01125 /* server message codes */ 01126 #define rfbXvp_Fail 0 01127 #define rfbXvp_Init 1 01128 /* client message codes */ 01129 #define rfbXvp_Shutdown 2 01130 #define rfbXvp_Reboot 3 01131 #define rfbXvp_Reset 4 01132 01133 01134 /*----------------------------------------------------------------------------- 01135 * Modif sf@2002 01136 * ResizeFrameBuffer - The Client must change the size of its framebuffer 01137 */ 01138 01139 typedef struct _rfbResizeFrameBufferMsg { 01140 uint8_t type; /* always rfbResizeFrameBuffer */ 01141 uint8_t pad1; 01142 uint16_t framebufferWidth; /* FrameBuffer width */ 01143 uint16_t framebufferHeigth; /* FrameBuffer height */ 01144 } rfbResizeFrameBufferMsg; 01145 01146 #define sz_rfbResizeFrameBufferMsg 6 01147 01148 01149 /*----------------------------------------------------------------------------- 01150 * Copyright (C) 2001 Harakan Software 01151 * PalmVNC 1.4 & 2.? ResizeFrameBuffer message 01152 * ReSizeFrameBuffer - tell the RFB client to alter its framebuffer, either 01153 * due to a resize of the server desktop or a client-requested scaling factor. 01154 * The pixel format remains unchanged. 01155 */ 01156 01157 typedef struct { 01158 uint8_t type; /* always rfbReSizeFrameBuffer */ 01159 uint8_t pad1; 01160 uint16_t desktop_w; /* Desktop width */ 01161 uint16_t desktop_h; /* Desktop height */ 01162 uint16_t buffer_w; /* FrameBuffer width */ 01163 uint16_t buffer_h; /* Framebuffer height */ 01164 uint16_t pad2; 01165 01166 } rfbPalmVNCReSizeFrameBufferMsg; 01167 01168 #define sz_rfbPalmVNCReSizeFrameBufferMsg (12) 01169 01170 01171 01172 01173 /*----------------------------------------------------------------------------- 01174 * Union of all server->client messages. 01175 */ 01176 01177 typedef union { 01178 uint8_t type; 01179 rfbFramebufferUpdateMsg fu; 01180 rfbSetColourMapEntriesMsg scme; 01181 rfbBellMsg b; 01182 rfbServerCutTextMsg sct; 01183 rfbResizeFrameBufferMsg rsfb; 01184 rfbPalmVNCReSizeFrameBufferMsg prsfb; 01185 rfbFileTransferMsg ft; 01186 rfbTextChatMsg tc; 01187 rfbXvpMsg xvp; 01188 } rfbServerToClientMsg; 01189 01190 01191 01192 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 01193 * RDV Cache Encoding. 01194 * special is not used at this point, can be used to reset cache or other specials 01195 * just put it to make sure we don't have to change the encoding again. 01196 */ 01197 01198 typedef struct { 01199 uint16_t special; 01200 } rfbCacheRect; 01201 01202 #define sz_rfbCacheRect 2 01203 01204 01205 01206 01207 /***************************************************************************** 01208 * 01209 * Message definitions (client -> server) 01210 * 01211 *****************************************************************************/ 01212 01213 01214 /*----------------------------------------------------------------------------- 01215 * SetPixelFormat - tell the RFB server the format in which the client wants 01216 * pixels sent. 01217 */ 01218 01219 typedef struct { 01220 uint8_t type; /* always rfbSetPixelFormat */ 01221 uint8_t pad1; 01222 uint16_t pad2; 01223 rfbPixelFormat format; 01224 } rfbSetPixelFormatMsg; 01225 01226 #define sz_rfbSetPixelFormatMsg (sz_rfbPixelFormat + 4) 01227 01228 01229 /*----------------------------------------------------------------------------- 01230 * FixColourMapEntries - when the pixel format uses a "colour map", fix 01231 * read-only colour map entries. 01232 * 01233 * ***************** NOT CURRENTLY SUPPORTED ***************** 01234 */ 01235 01236 typedef struct { 01237 uint8_t type; /* always rfbFixColourMapEntries */ 01238 uint8_t pad; 01239 uint16_t firstColour; 01240 uint16_t nColours; 01241 01242 /* Followed by nColours * 3 * uint16_t 01243 r1, g1, b1, r2, g2, b2, r3, g3, b3, ..., rn, bn, gn */ 01244 01245 } rfbFixColourMapEntriesMsg; 01246 01247 #define sz_rfbFixColourMapEntriesMsg 6 01248 01249 01250 /*----------------------------------------------------------------------------- 01251 * SetEncodings - tell the RFB server which encoding types we accept. Put them 01252 * in order of preference, if we have any. We may always receive raw 01253 * encoding, even if we don't specify it here. 01254 */ 01255 01256 typedef struct { 01257 uint8_t type; /* always rfbSetEncodings */ 01258 uint8_t pad; 01259 uint16_t nEncodings; 01260 /* followed by nEncodings * uint32_t encoding types */ 01261 } rfbSetEncodingsMsg; 01262 01263 #define sz_rfbSetEncodingsMsg 4 01264 01265 01266 /*----------------------------------------------------------------------------- 01267 * FramebufferUpdateRequest - request for a framebuffer update. If incremental 01268 * is true then the client just wants the changes since the last update. If 01269 * false then it wants the whole of the specified rectangle. 01270 */ 01271 01272 typedef struct { 01273 uint8_t type; /* always rfbFramebufferUpdateRequest */ 01274 uint8_t incremental; 01275 uint16_t x; 01276 uint16_t y; 01277 uint16_t w; 01278 uint16_t h; 01279 } rfbFramebufferUpdateRequestMsg; 01280 01281 #define sz_rfbFramebufferUpdateRequestMsg 10 01282 01283 01284 /*----------------------------------------------------------------------------- 01285 * KeyEvent - key press or release 01286 * 01287 * Keys are specified using the "keysym" values defined by the X Window System. 01288 * For most ordinary keys, the keysym is the same as the corresponding ASCII 01289 * value. Other common keys are: 01290 * 01291 * BackSpace 0xff08 01292 * Tab 0xff09 01293 * Return or Enter 0xff0d 01294 * Escape 0xff1b 01295 * Insert 0xff63 01296 * Delete 0xffff 01297 * Home 0xff50 01298 * End 0xff57 01299 * Page Up 0xff55 01300 * Page Down 0xff56 01301 * Left 0xff51 01302 * Up 0xff52 01303 * Right 0xff53 01304 * Down 0xff54 01305 * F1 0xffbe 01306 * F2 0xffbf 01307 * ... ... 01308 * F12 0xffc9 01309 * Shift 0xffe1 01310 * Control 0xffe3 01311 * Meta 0xffe7 01312 * Alt 0xffe9 01313 */ 01314 01315 typedef struct { 01316 uint8_t type; /* always rfbKeyEvent */ 01317 uint8_t down; /* true if down (press), false if up */ 01318 uint16_t pad; 01319 uint32_t key; /* key is specified as an X keysym */ 01320 } rfbKeyEventMsg; 01321 01322 #define sz_rfbKeyEventMsg 8 01323 01324 01325 /*----------------------------------------------------------------------------- 01326 * PointerEvent - mouse/pen move and/or button press. 01327 */ 01328 01329 typedef struct { 01330 uint8_t type; /* always rfbPointerEvent */ 01331 uint8_t buttonMask; /* bits 0-7 are buttons 1-8, 0=up, 1=down */ 01332 uint16_t x; 01333 uint16_t y; 01334 } rfbPointerEventMsg; 01335 01336 #define rfbButton1Mask 1 01337 #define rfbButton2Mask 2 01338 #define rfbButton3Mask 4 01339 #define rfbButton4Mask 8 01340 #define rfbButton5Mask 16 01341 /* RealVNC 335 method */ 01342 #define rfbWheelUpMask rfbButton4Mask 01343 #define rfbWheelDownMask rfbButton5Mask 01344 01345 #define sz_rfbPointerEventMsg 6 01346 01347 01348 01349 /*----------------------------------------------------------------------------- 01350 * ClientCutText - the client has new text in its cut buffer. 01351 */ 01352 01353 typedef struct { 01354 uint8_t type; /* always rfbClientCutText */ 01355 uint8_t pad1; 01356 uint16_t pad2; 01357 uint32_t length; 01358 /* followed by char text[length] */ 01359 } rfbClientCutTextMsg; 01360 01361 #define sz_rfbClientCutTextMsg 8 01362 01363 01364 01365 /*----------------------------------------------------------------------------- 01366 * sf@2002 - Set Server Scale 01367 * SetServerScale - Server must change the scale of the client buffer. 01368 */ 01369 01370 typedef struct _rfbSetScaleMsg { 01371 uint8_t type; /* always rfbSetScale */ 01372 uint8_t scale; /* Scale value 1<sv<n */ 01373 uint16_t pad; 01374 } rfbSetScaleMsg; 01375 01376 #define sz_rfbSetScaleMsg 4 01377 01378 01379 /*----------------------------------------------------------------------------- 01380 * Copyright (C) 2001 Harakan Software 01381 * PalmVNC 1.4 & 2.? SetScale Factor message 01382 * SetScaleFactor - tell the RFB server to alter the scale factor for the 01383 * client buffer. 01384 */ 01385 typedef struct { 01386 uint8_t type; /* always rfbPalmVNCSetScaleFactor */ 01387 01388 uint8_t scale; /* Scale factor (positive non-zero integer) */ 01389 uint16_t pad2; 01390 } rfbPalmVNCSetScaleFactorMsg; 01391 01392 #define sz_rfbPalmVNCSetScaleFactorMsg (4) 01393 01394 01395 /*----------------------------------------------------------------------------- 01396 * rdv@2002 - Set input status 01397 * SetServerInput - Server input is dis/enabled 01398 */ 01399 01400 typedef struct _rfbSetServerInputMsg { 01401 uint8_t type; /* always rfbSetScale */ 01402 uint8_t status; /* Scale value 1<sv<n */ 01403 uint16_t pad; 01404 } rfbSetServerInputMsg; 01405 01406 #define sz_rfbSetServerInputMsg 4 01407 01408 /*----------------------------------------------------------------------------- 01409 * rdv@2002 - Set SW 01410 * SetSW - Server SW/full desktop 01411 */ 01412 01413 typedef struct _rfbSetSWMsg { 01414 uint8_t type; /* always rfbSetSW */ 01415 uint8_t status; 01416 uint16_t x; 01417 uint16_t y; 01418 } rfbSetSWMsg; 01419 01420 #define sz_rfbSetSWMsg 6 01421 01422 01423 01424 /*----------------------------------------------------------------------------- 01425 * Union of all client->server messages. 01426 */ 01427 01428 typedef union { 01429 uint8_t type; 01430 rfbSetPixelFormatMsg spf; 01431 rfbFixColourMapEntriesMsg fcme; 01432 rfbSetEncodingsMsg se; 01433 rfbFramebufferUpdateRequestMsg fur; 01434 rfbKeyEventMsg ke; 01435 rfbPointerEventMsg pe; 01436 rfbClientCutTextMsg cct; 01437 rfbSetScaleMsg ssc; 01438 rfbPalmVNCSetScaleFactorMsg pssf; 01439 rfbSetServerInputMsg sim; 01440 rfbFileTransferMsg ft; 01441 rfbSetSWMsg sw; 01442 rfbTextChatMsg tc; 01443 rfbXvpMsg xvp; 01444 } rfbClientToServerMsg; 01445 01446 /* 01447 * vncauth.h - describes the functions provided by the vncauth library. 01448 */ 01449 01450 #define MAXPWLEN 8 01451 #define CHALLENGESIZE 16 01452 01453 extern int rfbEncryptAndStorePasswd(char *passwd, char *fname); 01454 extern char *rfbDecryptPasswdFromFile(char *fname); 01455 extern void rfbRandomBytes(unsigned char *bytes); 01456 extern void rfbEncryptBytes(unsigned char *bytes, char *passwd); 01457 01458 01459 #endif
1.7.1