/* ********************************************************** * Copyright (C) 2002 VMware, Inc. * All Rights Reserved * **********************************************************/ #ifndef _VNC_H_ #define _VNC_H_ /* * vnc.h -- * * Contains definitions and static data for the VNC/RFB protocol, version * 3.8 and all of the VMware-specific protocol extensions. The VNC * protocol specification document is available at http://www.realvnc.com. */ /* * VMware VNC Extensions * The VNC protocol was designed to be extensible; the client specifies a * set of encoding types which it supports (each encoding is specified as * a unique 32-bit value), and servers behave appropriately, i.e. by not * sending encoded data in forms that the client does not support. For * example, if a client does not support the ZRLE rectangle encoding, the * server might fallback to Raw or Hextile encoding for framebuffer * updates. * * This encoding/extension scheme provides an arbitrarily extensible * server->client data channel, and thus it can (and is) also be used to * provide new functionality unrelated to the actual screen contents, * such as the ability for the server to notify the clients of changes in * screen geometry. * * Unfortunately, the protocol does not provide a similarly convenient * capability in the client->server direction. However, RealVNC does * assign client->server and server->client message IDs so * extension-specific negotiation schemes are possible. * * The VMware client and server use several VMware-specific protocol * extensions designed in-house. These extensions include performance * enhancements (such as support for FillRect encodings) as well as * usability requirements and improvements (support for grab and ungrab, * depth change, keyboard LED state). * * The VMware extensions come in one of two forms: * * (1) VNC_VMW_ENC_BASE* and VNC_VMW_ENC_END* define two ranges of * encodings allocated to us by RealVNC for VMware-specific VNC * rectangle encoding extensions. * * Ideally, we'll eventually publish the specification for these * encodings so that third-party clients will support some of these * features that are of use to any client (such as the alpha cursor * and the display mode change encodings). * * (2) VNC_VMW_CLIMSG_ID* and VNC_VMW_SRVMSG_ID* define two sets of * client->server and server->client message IDs also allocated to us by * RealVNC. The message structure itself includes a second ID field * that we use to multiplex our few message IDs for all the * VMware-specific messages we need. Note that this is essentially * the same as the server->client encoding scheme, without the * negotiation phase. (if needed, we can define a VMware specific * messages to negotiate capabilities) * * Note that changing these values will break both forward and backward * compatibility. * * --Dustin, Dec. 13 2007 */ #include "keycodes.h" #define VNC_STD_PORT 5900 /* default VNC port */ #define VNC_STD_MAX_PORT 5909 /* default max port to try */ /* * Version information */ #define VNC_VERSION "RFB 003.008\n" /* server version string to report */ #define VNC_VERSION_LENGTH (sizeof(VNC_VERSION) - 1) #define VNC_VERSION_MAJOR 3 /* server major version number */ #define VNC_VERSION_MINOR 8 /* server minor version number */ #define VNC_VERSION_CHUNK_START 4 /* for parsing version strings */ #define VNC_VERSION_CHUNK_SIZE 3 /* * Handshaking/Authentication */ #define VNC_PASSWORD_MAX_LENGTH 8 #define VNC_CHALLENGE_LENGTH 16 #define VNC_RESPONSE_LENGTH 16 typedef unsigned int VNCAuthKey[32]; typedef enum VNCAuthScheme { VNCAuthEarlyFailure = 0, VNCAuthNone = 1, VNCAuthVNC = 2, VNCAuthRA2 = 5, VNCAuthRA2ne = 6, VNCAuthTight = 16, VNCAuthUltra = 17, VNCAuthTLS = 18, VNCAuthVeNCrypt = 19, } VNCAuthScheme; typedef enum VNCAuthResult { VNCAuthSuccess = 0, VNCAuthFailure = 1, VNCAuthTooMany = 2, } VNCAuthResult; /* * Initialisation */ #define VNC_WANT_EXCLUSIVE 0 /* does the client want exclusive access? */ /* * Message types and encodings allocated to VMware by RealVNC * * Client->Server */ #define VNC_VMW_CLIMSG_ID 127 #define VNC_VMW_CLIMSG_ID2 254 /* * Server->Client */ #define VNC_VMW_SRVMSG_ID 127 #define VNC_VMW_SRVMSG_ID2 254 /* * Rectangle Encodings */ #define VNC_VMW_ENC_BASE 0x574d5600 /* "VMW" */ #define VNC_VMW_ENC_END (VNC_VMW_ENC_BASE + 255) #define VNC_VMW_ENC_BASE2 (-304) #define VNC_VMW_ENC_END2 (VNC_VMW_ENC_BASE2 + 31) /* * Message data structures */ #define VNC_TYPE_ID_LENGTH 1 /* length of the id/type field in bytes */ typedef #include "vmware_pack_begin.h" struct { uint16 x; uint16 y; uint16 width; uint16 height; } #include "vmware_pack_end.h" VNCRectangle; typedef #include "vmware_pack_begin.h" struct { uint8 bpp; uint8 depth; uint8 bigEndian; uint8 trueColor; uint16 redMax; uint16 greenMax; uint16 blueMax; uint8 redShift; uint8 greenShift; uint8 blueShift; uint8 _padding[3]; } #include "vmware_pack_end.h" VNCPixelFormat; typedef #include "vmware_pack_begin.h" struct { uint16 width; uint16 height; VNCPixelFormat format; } #include "vmware_pack_end.h" VNCServerInitHeader; typedef #include "vmware_pack_begin.h" struct { uint8 id; uint8 _padding[3]; VNCPixelFormat format; } #include "vmware_pack_end.h" VNCClientPixelFormat; typedef #include "vmware_pack_begin.h" struct { uint8 id; uint8 _padding; uint16 numEncodings; } #include "vmware_pack_end.h" VNCEncodingsHeader; typedef #include "vmware_pack_begin.h" struct { uint8 id; uint8 incremental; uint16 x; uint16 y; uint16 width; uint16 height; } #include "vmware_pack_end.h" VNCUpdateRequest; typedef uint32 VNCKeySym; typedef #include "vmware_pack_begin.h" struct { uint8 id; uint8 down; uint16 _padding; VNCKeySym key; } #include "vmware_pack_end.h" VNCKeyEvent; typedef #include "vmware_pack_begin.h" struct { uint8 id; uint8 buttons; uint16 x; uint16 y; } #include "vmware_pack_end.h" VNCPointerEvent; typedef #include "vmware_pack_begin.h" struct { uint8 id; uint8 _padding[3]; uint32 length; } #include "vmware_pack_end.h" VNCCutTextHeader; typedef #include "vmware_pack_begin.h" struct { uint8 id; uint8 padding; uint16 numRects; } #include "vmware_pack_end.h" VNCUpdateHeader; typedef #include "vmware_pack_begin.h" struct { uint16 x; uint16 y; uint16 width; uint16 height; uint32 encoding; } #include "vmware_pack_end.h" VNCRectangleHeader; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint16 srcx; uint16 srcy; } #include "vmware_pack_end.h" VNCCopyRectangle; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 compressed_data_length; } #include "vmware_pack_end.h" VNCZRLERectangle; typedef #include "vmware_pack_begin.h" struct { uint8 id; uint8 padding; uint16 firstColor; uint16 numColors; } #include "vmware_pack_end.h" VNCColorMapHeader; typedef #include "vmware_pack_begin.h" struct { uint16 red; uint16 green; uint16 blue; } #include "vmware_pack_end.h" VNCColor; /* * VNC Hextile Encoding Constants */ typedef enum { VNCHextileRaw = 0x01, VNCHextileBgSpecified = 0x02, VNCHextileFgSpecified = 0x04, VNCHextileAnySubrects = 0x08, VNCHextileAnySubrectsColoured = 0x10, } VNCHextileSubEncodings; /* * VNC ZYUVOverlay Encoding Constants */ typedef enum { VNCZYUVOverlayYUY2 = 0x01, VNCZYUVOverlayYV12 = 0x02, VNCZYUVOverlayUYVY = 0x03, } VNCZYUVOverlaySourceFormat; typedef enum { VNCZYUVOverlayRaw = 0x01, VNCZYUVOverlayZlib0 = 0x02, VNCZYUVOverlayZlib1 = 0x03, VNCZYUVOverlayZlib2 = 0x04, VNCZYUVOverlayZlib3 = 0x05, VNCZYUVOverlayResetZlib0 = 0x82, VNCZYUVOverlayResetZlib1 = 0x83, VNCZYUVOverlayResetZlib2 = 0x84, VNCZYUVOverlayResetZlib3 = 0x85, } VNCZYUVOverlayCompress; #define VNC_ZYUVOVERLAY_RESET_COMPRESS 0x80 #define VNC_ZYUVOVERLAY_NO_COLORKEY (-1) /* * VMware extension message structures */ typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 color; uint32 rop; } #include "vmware_pack_end.h" VNCROPFillRectangle; typedef enum { VNCSharedFBInfoNameTagType = 1, VNCSharedFBInfoShmIdTagType = 2, } VNCSharedFBInfoTagType; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 fbSize; uint32 tagType; uint32 tagLength; /* Followed by tag data */ } #include "vmware_pack_end.h" VNCSharedFBInfoHeader; /* * Video YUV Overlay and ZYUV Overlay */ #define VNC_NUM_ZYUVOVERLAY_STREAMS 32 typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 id; /* stream id */ uint32 colorKey; uint32 dataSize; uint8 dataCompress; /* VNCZYUVOverlayCompress values */ uint8 srcFormat; /* VNCZYUVOverlaySourceFormat values */ uint16 srcWidth; uint16 srcHeight; } #include "vmware_pack_end.h" VNCZYUVOverlay; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; } #include "vmware_pack_end.h" VNCCursorPosition; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 windowId; } #include "vmware_pack_end.h" VNCUnityWindowRect; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 windowId; uint16 numRectangles; uint8 _padding[2]; /* Followed by numRectangles VNCRectangle structures */ } #include "vmware_pack_end.h" VNCUnityWindowRegion; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 windowId; uint16 titleLength; uint8 _padding[2]; /* Followed by window title, length specified by titleLength */ } #include "vmware_pack_end.h" VNCUnityWindowTitle; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 count; /* Followed by count of window ids(uint32)*/ } #include "vmware_pack_end.h" VNCUnityZOrder; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 windowId; uint32 state; /* UNITY_WINDOW_STATE_* values */ } #include "vmware_pack_end.h" VNCUnityWindowState; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 windowId; uint32 attr; /* UnityWindowAttribute values */ uint32 value; } #include "vmware_pack_end.h" VNCUnityWindowAttr; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 windowId; uint32 type; /* UnityWindowType values */ } #include "vmware_pack_end.h" VNCUnityWindowType; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 windowId; uint32 iconType; /* UnityIconType values */ } #include "vmware_pack_end.h" VNCUnityWindowIcon; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 windowId; int32 desktopId; } #include "vmware_pack_end.h" VNCUnityWindowDesktop; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; int32 desktopId; } #include "vmware_pack_end.h" VNCUnityActiveDesktop; /* * The cursor state bits: visibility, absolute mouse, etc. */ typedef enum { VNCCursorVisibleStateFlag = 0x01, VNCCursorAbsoluteStateFlag = 0x02, VNCCursorWarpedStateFlag = 0x04 } VNCCursorStateFlags; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint16 state; /* VNCCursorStateFlag values */ } #include "vmware_pack_end.h" VNCCursorState; typedef #include "vmware_pack_begin.h" struct { uint16 absoluteMouse; uint16 _unused; uint16 width; uint16 height; uint32 encoding; } #include "vmware_pack_end.h" VNCPointerTypeChange; typedef enum { VNCTypematicOnInfoFlag = 1, } VNCTypematicInfoFlags; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint16 state; /* VNCTypematicInfoFlags values */ uint32 period; uint32 delay; } #include "vmware_pack_end.h" VNCTypematicInfo; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint32 leds; } #include "vmware_pack_end.h" VNCLEDState; typedef #include "vmware_pack_begin.h" struct { /* * The VNCModeChange encoding always leaves bytesPerLine set to 0 * (it was the x and y values of the rectangle header). * * VNCModeChange2 repurposes these initial 32 bits in the rectangle * header for the bytes per line in the shared framebuffer. */ uint32 bytesPerLine; uint16 width; uint16 height; uint32 encoding; VNCPixelFormat format; } #include "vmware_pack_end.h" VNCModeChange; typedef enum VNCCursorType { VNCColorCursor = 0, VNCAlphaCursor = 1, } VNCCursorType; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint8 type; /* VNCCursorType value */ uint8 _padding; } #include "vmware_pack_end.h" VNCDefineCursorHeader; /* * General VM state information */ typedef enum VNCVMStateFlags { VNCVMFullScreenStateFlag = 0x1, VNCVMDirectFullScreenStateFlag = 0x2, } VNCVMStateInfo; typedef #include "vmware_pack_begin.h" struct { VNCRectangleHeader header; uint16 state; /* VNCVMStateFlags value */ } #include "vmware_pack_end.h" VNCVMState; typedef #include "vmware_pack_begin.h" struct { uint8 id; uint8 vmwid; uint16 len; } #include "vmware_pack_end.h" VNCVMWMessageHeader; /* * Flag bits for the 16-bit VMWPointerEvent flags mask. */ typedef enum VMWPointerEventFlags { VMWPointerButton0Flag = 0x01, VMWPointerButton1Flag = 0x02, VMWPointerButton2Flag = 0x04, VMWPointerButton3Flag = 0x08, VMWPointerGrabFlag = 0x10, VMWPointerUngrabFlag = 0x20 } VMWPointerEventFlags; typedef #include "vmware_pack_begin.h" struct { VNCVMWMessageHeader header; int32 x; int32 y; int32 dx; int32 dy; int16 dz; int16 flags; } #include "vmware_pack_end.h" VMWPointerEvent; typedef #include "vmware_pack_begin.h" struct { VNCVMWMessageHeader header; VScancode keycode; uint8 down; uint8 _padding; } #include "vmware_pack_end.h" VMWKeyEvent; /* * VNC Protocol Messages */ #define VNC_MSG_ID(name) VNC##name##ID /* * Server->Client Messages */ #define VNC_SERVER_MESSAGES \ VNC_MSG_ENTRY( FramebufferUpdate, 0 )\ VNC_MSG_ENTRY( SetColorMapEntries, 1 )\ VNC_MSG_ENTRY( RingBell, 2 )\ VNC_MSG_ENTRY( ServerCutText, 3 )\ \ VNC_MSG_ENTRY( VMWSrvMessage, VNC_VMW_SRVMSG_ID ) /* * VMware Server extension sub-messages */ #define VNC_VMW_SERVER_MESSAGES \ // none yet /* * Client->Server Messages */ #define VNC_CLIENT_MESSAGES \ VNC_MSG_ENTRY( SetPixelFormat, 0 )\ VNC_MSG_ENTRY( FixColorMapEntries, 1 )\ VNC_MSG_ENTRY( SetEncodings, 2 )\ VNC_MSG_ENTRY( UpdateRequest, 3 )\ VNC_MSG_ENTRY( KeyEvent, 4 )\ VNC_MSG_ENTRY( PointerEvent, 5 )\ VNC_MSG_ENTRY( ClientCutText, 6 )\ \ VNC_MSG_ENTRY( VMWCliMessage, VNC_VMW_CLIMSG_ID ) /* * VMware Client extension sub-messages */ #define VNC_VMW_CLIENT_MESSAGES \ VNC_MSG_ENTRY( VMWKeyEvent, 0 )\ VNC_MSG_ENTRY( VMWPointerEvent, 1 ) #define VNC_MSG_ENTRY(name, val) VNC_MSG_ID(name) = val, typedef enum { VNC_CLIENT_MESSAGES } VNCClientMessageID; typedef enum { VNC_VMW_CLIENT_MESSAGES } VNCVMWClientMessageID; typedef enum { VNC_SERVER_MESSAGES } VNCServerMessageID; //typedef enum { // VNC_VMW_SERVER_MESSAGES //} VNCVMWServerMessageID; #undef VNC_MSG_ENTRY /* * VNC Server->Client Rectangle Encodings * * Encodings are sent on the wire from the client. The encoding list here * includes all of the encodings declared in version 3.8 of the RFB spec * (June 2007, available from http://www.realvnc.com) as well as a * number of VMware-specific extensions (see notes below). * * We also define a set of VNC capability bits of type VNCCapBit; the * bits are 1:1 mapped to encodings, and are useful since encodings * themselves are not bitwise exclusive, and hence we can't mask them * together easily. */ /* Standard Rectangle Encodings */ #define VNC_STD_RECT_ENCODINGS \ VNC_ENC_ENTRY( RawRect, 0x0 )\ VNC_ENC_ENTRY( CopyRect, 0x00000001 )\ VNC_ENC_ENTRY( RRERect, 0x00000002 )\ VNC_ENC_ENTRY( CoRRERect, 0x00000004 )\ VNC_ENC_ENTRY( HextileRect, 0x00000005 )\ VNC_ENC_ENTRY( ZlibRect, 0x00000006 )\ VNC_ENC_ENTRY( TightRect, 0x00000007 )\ VNC_ENC_ENTRY( ZlibHexRect, 0x00000008 )\ VNC_ENC_ENTRY( TRLERect, 0x0000000f )\ VNC_ENC_ENTRY( ZRLERect, 0x00000010 )\ VNC_ENC_ENTRY( ZYWRLERect, 0x00000011 )\ /* Standard "Pseudo-encodings" (from RFB 3.8) */ \ #define VNC_STD_PSEUDO_ENCODINGS \ VNC_ENC_ENTRY( Cursor, 0xffffff11 )\ VNC_ENC_ENTRY( DesktopSize, 0xffffff21 )\ #define VNC_STD_ENCODINGS VNC_STD_RECT_ENCODINGS VNC_STD_PSEUDO_ENCODINGS /* QEMU VNC Extensions */ #define VNC_QEMU_PSEUDO_ENCODINGS \ VNC_ENC_ENTRY( PointerTypeChange, 0xfffffeff )\ #define VNC_QEMU_ENCODINGS VNC_QEMU_PSEUDO_ENCODINGS #define VNC_VMW_ENC_ENTRY(name, val) VNC_ENC_ENTRY(name, val + VNC_VMW_ENC_BASE) /* VMware Rectangle Encodings */ #define VNC_VMW_RECT_ENCODINGS \ VNC_VMW_ENC_ENTRY( ROPFillRect, 0 )\ VNC_VMW_ENC_ENTRY( SharedFBRect, 1 )\ VNC_VMW_ENC_ENTRY( SeekableZRLERect, 16 )\ VNC_VMW_ENC_ENTRY( ZYUVOverlayRect, 17 )\ VNC_VMW_ENC_ENTRY( YUVOverlayRect, 18 ) /* VMware Pseudo Encodings */ #define VNC_VMW_PSEUDO_CURSOR_ENCODINGS \ VNC_VMW_ENC_ENTRY( DefineCursor, 100)\ VNC_VMW_ENC_ENTRY( CursorState, 101)\ VNC_VMW_ENC_ENTRY( CursorPosition, 102) #define VNC_VMW_PSEUDO_ENCODINGS \ VNC_VMW_PSEUDO_CURSOR_ENCODINGS \ VNC_VMW_ENC_ENTRY( TypematicInfo, 103)\ VNC_VMW_ENC_ENTRY( LEDState, 104)\ VNC_VMW_ENC_ENTRY( ModeChange, 105)\ VNC_VMW_ENC_ENTRY( VMState, 106)\ VNC_VMW_ENC_ENTRY( SharedFBInfo, 107)\ VNC_VMW_ENC_ENTRY( UnityWindowRect, 108)\ VNC_VMW_ENC_ENTRY( UnityWindowRegion, 109)\ VNC_VMW_ENC_ENTRY( UnityWindowTitle, 110)\ VNC_VMW_ENC_ENTRY( UnityZOrder, 111)\ VNC_VMW_ENC_ENTRY( ModeChange2, 112)\ VNC_VMW_ENC_ENTRY( UnityWindowState, 113)\ VNC_VMW_ENC_ENTRY( ServerPush, 114)\ VNC_VMW_ENC_ENTRY( UnityWindowAttr, 115)\ VNC_VMW_ENC_ENTRY( UnityWindowType, 116)\ VNC_VMW_ENC_ENTRY( UnityWindowIcon, 117)\ VNC_VMW_ENC_ENTRY( UnityWindowDesktop, 118)\ VNC_VMW_ENC_ENTRY( UnityActiveDesktop, 119) #define VNC_VMW_ENCODINGS \ VNC_VMW_RECT_ENCODINGS VNC_VMW_PSEUDO_ENCODINGS #define VNC_ENCODINGS \ VNC_STD_ENCODINGS VNC_QEMU_ENCODINGS VNC_VMW_ENCODINGS #define VNC_ENC_ENTRY(name, val) VNC##name##Enc = val, typedef enum { VNC_ENCODINGS } VNCEncoding; #undef VNC_ENC_ENTRY #define VNC_ENC_ENTRY(name, val) VNC##name##Cap, typedef enum { VNC_ENCODINGS VNCMaxCap, VNCInvalidCap = VNCMaxCap } VNCCapBit; #undef VNC_ENC_ENTRY #endif // _VNC_H_