- added instructions how to update the online documentation
[bochs-mirror.git] / gui / rfb.h
blob26f01ec4a3ff7a22f0e2ee1071e320b3ea9a1fca
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: rfb.h,v 1.6 2008/02/05 22:57:41 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (C) 2002 MandrakeSoft S.A.
6 //
7 // MandrakeSoft S.A.
8 // 43, rue d'Aboukir
9 // 75002 Paris - France
10 // http://www.linux-mandrake.com/
11 // http://www.mandrakesoft.com/
13 // This library is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU Lesser General Public
15 // License as published by the Free Software Foundation; either
16 // version 2 of the License, or (at your option) any later version.
18 // This library is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 // This file includes the rfb spec header and the port numbers
29 // Define the RFB types
30 typedef Bit32u U32;
31 typedef Bit16u U16;
32 typedef Bit8u U8;
33 typedef Bit32s S32;
34 typedef Bit16s S16;
35 typedef Bit8s S8;
37 // Port range
38 #define BX_RFB_PORT_MIN 5900
39 #define BX_RFB_PORT_MAX 5949
42 // RFB Protocol definitions.
43 // Please refer to the specification document
44 // http://www.realvnc.com/docs/rfbproto.pdf
46 typedef struct {
47 U16 xPosition;
48 U16 yPosition;
49 U16 width;
50 U16 height;
51 U32 encodingType;
52 } rfbRectangle;
54 #define rfbRectangleSize (sizeof(rfbRectangle))
57 typedef struct {
58 U8 bitsPerPixel;
59 U8 depth;
60 U8 bigEndianFlag;
61 U8 trueColourFlag;
62 U16 redMax;
63 U16 greenMax;
64 U16 blueMax;
65 U8 redShift;
66 U8 greenShift;
67 U8 blueShift;
68 U8 padding[3];
69 } rfbPixelFormat;
71 #define rfbPixelFormatSize (sizeof(rfbPixelFormat))
74 #define rfbProtocolVersionFormat "RFB %03d.%03d\n"
75 #define rfbServerProtocolMajorVersion 3
76 #define rfbServerProtocolMinorVersion 3
78 typedef char rfbProtocolVersionMessage[12 + 1]; // Add 1 for null byte
79 #define rfbProtocolVersionMessageSize (sizeof(rfbProtocolVersionMessage) - 1) // Real Message Length
82 #define rfbSecurityConnFailed 0
83 #define rfbSecurityNone 1
84 #define rfbSecurityVncAuth 2
86 #define rfbSecurityVncAuthOK 0
87 #define rfbSecurityVncAuthFailed 1
88 #define rfbSecurityVncAuthTooMany 2 // No longer used (3.7)
91 typedef struct {
92 U8 sharedFlag;
93 } rfbClientInitMessage;
95 #define rfbClientInitMessageSize (sizeof(rfbClientInitMessage))
98 typedef struct {
99 U16 framebufferWidth;
100 U16 framebufferHeight;
101 rfbPixelFormat serverPixelFormat;
102 U32 nameLength;
103 // U8[] nameString;
104 } rfbServerInitMessage;
106 #define rfbServerInitMessageSize (sizeof(rfbServerInitMessage))
108 // Client to Server message types
109 #define rfbSetPixelFormat 0
110 #define rfbFixColourMapEntries 1
111 #define rfbSetEncodings 2
112 #define rfbFramebufferUpdateRequest 3
113 #define rfbKeyEvent 4
114 #define rfbPointerEvent 5
115 #define rfbClientCutText 6
118 // Client to Server messages
120 typedef struct {
121 U8 messageType;
122 U8 padding[3];
123 rfbPixelFormat pixelFormat;
124 } rfbSetPixelFormatMessage;
126 #define rfbSetPixelFormatMessageSize (sizeof(rfbSetPixelFormatMessage))
129 typedef struct {
130 U8 messageType;
131 U8 padding;
132 U16 firstColour;
133 U16 numberOfColours;
134 } rfbFixColourMapEntriesMessage;
136 #define rfbFixColourMapEntriesMessageSize (sizeof(rfbFixColourMapEntriesMessage))
139 typedef struct {
140 U8 messageType;
141 U8 padding;
142 U16 numberOfEncodings;
143 } rfbSetEncodingsMessage;
145 #define rfbSetEncodingsMessageSize (sizeof(rfbSetEncodingsMessage))
148 typedef struct {
149 U8 messageType;
150 U8 incremental;
151 U16 xPosition;
152 U16 yPosition;
153 U16 width;
154 U16 height;
155 } rfbFramebufferUpdateRequestMessage;
157 #define rfbFramebufferUpdateRequestMessageSize (sizeof(rfbFramebufferUpdateRequestMessage))
160 typedef struct {
161 U8 messageType;
162 U8 downFlag;
163 U8 padding[2];
164 U32 key;
165 } rfbKeyEventMessage;
167 #define rfbKeyEventMessageSize (sizeof(rfbKeyEventMessage))
170 typedef struct {
171 U8 messageType;
172 U8 buttonMask;
173 U16 xPosition;
174 U16 yPosition;
175 } rfbPointerEventMessage;
177 #define rfbPointerEventMessageSize (sizeof(rfbPointerEventMessage))
179 #define rfbButton1Mask 1
180 #define rfbButton2Mask 2
181 #define rfbButton3Mask 4
184 typedef struct {
185 U8 messageType;
186 U8 padding[3];
187 U32 length;
188 // U8[] text;
189 } rfbClientCutTextMessage;
191 #define rfbClientCutTextMessageSize (sizeof(rfbClientCutTextMessage))
193 // Fill in correct names
194 typedef union {
195 rfbSetPixelFormatMessage spf;
196 rfbFixColourMapEntriesMessage fcme;
197 rfbSetEncodingsMessage se;
198 rfbFramebufferUpdateRequestMessage fur;
199 rfbKeyEventMessage ke;
200 rfbPointerEventMessage pe;
201 rfbClientCutTextMessage cct;
202 } rfbClientToServerMessage;
205 // Server to Client message types
206 #define rfbFramebufferUpdate 0
207 #define rfbSetColourMapEntries 1
208 #define rfbBell 2
209 #define rfbServerCutText 3
211 // Encoding types
212 #define rfbEncodingRaw 0
213 #define rfbEncodingCopyRect 1
214 #define rfbEncodingRRE 2
215 #define rfbEncodingCoRRE 4
216 #define rfbEncodingHextile 5
217 #define rfbEncodingZRLE 16
218 #define rfbEncodingCursor 0xffffff11
219 #define rfbEncodingDesktopSize 0xffffff21
220 #define rfbEncodingZlib 6
221 #define rfbEncodingTight 7
222 #define rfbEncodingZlibHex 8
223 #define rfbEncodingTightOption00 0xffffff00 // to 0xffffffff except 0xffffff11 and 0xffffff21
224 #define rfbEncodingTightOption01 0xffffff01
225 #define rfbEncodingTightOption02 0xffffff02
226 #define rfbEncodingTightOption03 0xffffff03
227 #define rfbEncodingTightOption04 0xffffff04
228 #define rfbEncodingTightOption05 0xffffff05
229 #define rfbEncodingTightOption06 0xffffff06
230 #define rfbEncodingTightOption07 0xffffff07
231 #define rfbEncodingTightOption08 0xffffff08
232 #define rfbEncodingTightOption09 0xffffff09
233 #define rfbEncodingTightOption0a 0xffffff0a
234 #define rfbEncodingTightOption0b 0xffffff0b
235 #define rfbEncodingTightOption0c 0xffffff0c
236 #define rfbEncodingTightOption0d 0xffffff0d
237 #define rfbEncodingTightOption0e 0xffffff0e
238 #define rfbEncodingTightOption0f 0xffffff0f
239 #define rfbEncodingTightOption10 0xffffff10
240 #define rfbEncodingTightOption12 0xffffff12
241 #define rfbEncodingTightOption13 0xffffff13
242 #define rfbEncodingTightOption14 0xffffff14
243 #define rfbEncodingTightOption15 0xffffff15
244 #define rfbEncodingTightOption16 0xffffff16
245 #define rfbEncodingTightOption17 0xffffff17
246 #define rfbEncodingTightOption18 0xffffff18
247 #define rfbEncodingTightOption19 0xffffff19
248 #define rfbEncodingTightOption1a 0xffffff1a
249 #define rfbEncodingTightOption1b 0xffffff1b
250 #define rfbEncodingTightOption1c 0xffffff1c
251 #define rfbEncodingTightOption1d 0xffffff1d
252 #define rfbEncodingTightOption1e 0xffffff1e
253 #define rfbEncodingTightOption1f 0xffffff1f
254 #define rfbEncodingTightOption20 0xffffff20
256 typedef struct {
257 U32 id;
258 const char *name;
259 } rfbEncodingType;
261 rfbEncodingType rfbEncodings[] = {
262 {rfbEncodingRaw, "Raw"},
263 {rfbEncodingCopyRect, "CopyRect"},
264 {rfbEncodingRRE, "RRE"},
265 {rfbEncodingCoRRE, "CoRRE"},
266 {rfbEncodingHextile, "Hextile"},
267 {rfbEncodingZRLE, "ZRLE"},
268 {rfbEncodingCursor, "Cursor"},
269 {rfbEncodingDesktopSize, "DesktopSize"},
270 {rfbEncodingZlib, "Zlib"},
271 {rfbEncodingTight, "Tight"},
272 {rfbEncodingZlibHex, "ZlibHex"},
273 {rfbEncodingTightOption00, "TightOption00"},
274 {rfbEncodingTightOption01, "TightOption01"},
275 {rfbEncodingTightOption02, "TightOption02"},
276 {rfbEncodingTightOption03, "TightOption03"},
277 {rfbEncodingTightOption04, "TightOption04"},
278 {rfbEncodingTightOption05, "TightOption05"},
279 {rfbEncodingTightOption06, "TightOption06"},
280 {rfbEncodingTightOption07, "TightOption07"},
281 {rfbEncodingTightOption08, "TightOption08"},
282 {rfbEncodingTightOption09, "TightOption09"},
283 {rfbEncodingTightOption0a, "TightOption0a"},
284 {rfbEncodingTightOption0b, "TightOption0b"},
285 {rfbEncodingTightOption0c, "TightOption0c"},
286 {rfbEncodingTightOption0d, "TightOption0d"},
287 {rfbEncodingTightOption0e, "TightOption0e"},
288 {rfbEncodingTightOption0f, "TightOption0f"},
289 {rfbEncodingTightOption10, "TightOption10"},
290 {rfbEncodingTightOption12, "TightOption12"},
291 {rfbEncodingTightOption13, "TightOption13"},
292 {rfbEncodingTightOption14, "TightOption14"},
293 {rfbEncodingTightOption15, "TightOption15"},
294 {rfbEncodingTightOption16, "TightOption16"},
295 {rfbEncodingTightOption17, "TightOption17"},
296 {rfbEncodingTightOption18, "TightOption18"},
297 {rfbEncodingTightOption19, "TightOption19"},
298 {rfbEncodingTightOption1a, "TightOption1a"},
299 {rfbEncodingTightOption1b, "TightOption1b"},
300 {rfbEncodingTightOption1c, "TightOption1c"},
301 {rfbEncodingTightOption1d, "TightOption1d"},
302 {rfbEncodingTightOption1e, "TightOption1e"},
303 {rfbEncodingTightOption1f, "TightOption1f"},
304 {rfbEncodingTightOption20, "TightOption20"},
307 #define rfbEncodingsCount (sizeof(rfbEncodings) / sizeof(rfbEncodingType))
309 // Server To Client Messages
311 typedef struct {
312 U8 messageType;
313 U8 padding;
314 U16 numberOfRectangles;
315 } rfbFramebufferUpdateMessage;
317 #define rfbFramebufferUpdateMessageSize (sizeof(rfbFramebufferUpdateMessage))
319 typedef struct {
320 rfbRectangle r;
321 } rfbFramebufferUpdateRectHeader;
323 #define rfbFramebufferUpdateRectHeaderSize (sizeof(rfbFramebufferUpdateRectHeader))
325 typedef struct {
326 U16 srcXPosition;
327 U16 srcYPosition;
328 } rfbCopyRect;
330 #define rfbCopyRectSize (sizeof(rfbCopyRect))
333 /* typedef struct { */
334 /* U32 numberOfSubrectangles; */
335 /* PIXEL backgroundPixelValue; */
336 /* } rfbRREHeader; */
338 /* #define rfbRREHeaderSize (sizeof(rfbRREHeader)) */
341 /* typedef struct { */
342 /* U32 numberOfSubrectangles; */
343 /* PIXEL backgroundPixelValue; */
344 /* } rfbCoRRERectangle; */
346 /* #define rfbCoRRERectangleSize (sizeof(rfbCoRRERectangle)) */
349 #define rfbHextileRaw (1 << 0)
350 #define rfbHextileBackgroundSpecified (1 << 1)
351 #define rfbHextileForegroundSpecified (1 << 2)
352 #define rfbHextileAnySubrects (1 << 3)
353 #define rfbHextileSubrectsColoured (1 << 4)
355 #define rfbHextilePackXY(x,y) (((x) << 4) | (y))
356 #define rfbHextilePackWH(w,h) ((((w)-1) << 4) | ((h)-1))
357 #define rfbHextileExtractX(byte) ((byte) >> 4)
358 #define rfbHextileExtractY(byte) ((byte) & 0xf)
359 #define rfbHextileExtractW(byte) (((byte) >> 4) + 1)
360 #define rfbHextileExtractH(byte) (((byte) & 0xf) + 1)
363 typedef struct {
364 U8 messageType;
365 U8 padding;
366 U16 firstColour;
367 U16 numberOfColours;
368 } rfbSetColourMapEntriesMessage;
370 #define rfbSetColourMapEntriesMessageSize (sizeof(rfbSetColourMapEntriesMessage))
374 typedef struct {
375 U8 messageType;
376 } rfbBellMessage;
378 #define rfbBellMessageSize (sizeof(rfbBellMessage))
382 typedef struct {
383 U8 messageType;
384 U8 padding[3];
385 U32 length;
386 // U8[] text;
387 } rfbServerCutTextMessage;
389 #define rfbServerCutTextMessageSize (sizeof(rfbServerCutTextMessage))
391 // Fill in correct names
392 typedef union {
393 rfbFramebufferUpdateMessage fu;
394 rfbBellMessage b;
395 rfbServerCutTextMessage sct;
396 } rfbServerToClientMessage;