File: rfb.h

package info (click to toggle)
bochs 2.3-2etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 14,116 kB
  • ctags: 16,927
  • sloc: cpp: 130,524; ansic: 18,822; sh: 7,922; makefile: 3,836; yacc: 1,056; asm: 463; perl: 381; lex: 280; csh: 3
file content (397 lines) | stat: -rw-r--r-- 11,496 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
/////////////////////////////////////////////////////////////////////////
// $Id: rfb.h,v 1.4 2004/04/08 17:36:26 cbothamy Exp $
/////////////////////////////////////////////////////////////////////////
//
//  Copyright (C) 2002  MandrakeSoft S.A.
//
//    MandrakeSoft S.A.
//    43, rue d'Aboukir
//    75002 Paris - France
//    http://www.linux-mandrake.com/
//    http://www.mandrakesoft.com/
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
//
// This file includes the rfb spec header and the port numbers

// Define the RFB types
typedef Bit32u         U32;
typedef Bit16u         U16;
typedef Bit8u          U8;
typedef Bit32s         S32;
typedef Bit16s         S16;
typedef Bit8s          S8;

// Port range
#define BX_RFB_PORT_MIN 5900
#define BX_RFB_PORT_MAX 5949


// RFB Protocol definitions. 
// Please refer to the specification document 
// http://www.realvnc.com/docs/rfbproto.pdf

typedef struct {
    U16 xPosition;
    U16 yPosition;
    U16 width;
    U16 height;
    U32 encodingType;
} rfbRectangle;

#define rfbRectangleSize (sizeof(rfbRectangle))


typedef struct {
    U8  bitsPerPixel;
    U8  depth;
    U8  bigEndianFlag;
    U8  trueColourFlag;
    U16 redMax;
    U16 greenMax;
    U16 blueMax;
    U8  redShift;
    U8  greenShift;
    U8  blueShift;
    U8  padding[3];
} rfbPixelFormat;

#define rfbPixelFormatSize (sizeof(rfbPixelFormat))


#define rfbProtocolVersionFormat "RFB %03d.%03d\n"
#define rfbServerProtocolMajorVersion 3
#define rfbServerProtocolMinorVersion 3

typedef char rfbProtocolVersionMessage[12 + 1]; // Add 1 for null byte
#define rfbProtocolVersionMessageSize (sizeof(rfbProtocolVersionMessage) - 1) // Real Message Length


#define rfbSecurityConnFailed 0
#define rfbSecurityNone 1
#define rfbSecurityVncAuth 2

#define rfbSecurityVncAuthOK 0
#define rfbSecurityVncAuthFailed 1
#define rfbSecurityVncAuthTooMany 2 // No longer used (3.7)


typedef struct {
    U8 sharedFlag;
} rfbClientInitMessage;

#define rfbClientInitMessageSize (sizeof(rfbClientInitMessage))


typedef struct {
    U16            framebufferWidth;
    U16            framebufferHeight;
    rfbPixelFormat serverPixelFormat;
    U32            nameLength;
    // U8[]        nameString;
} rfbServerInitMessage;

#define rfbServerInitMessageSize (sizeof(rfbServerInitMessage))

// Client to Server message types
#define rfbSetPixelFormat 0
#define rfbFixColourMapEntries 1
#define rfbSetEncodings 2
#define rfbFramebufferUpdateRequest 3
#define rfbKeyEvent 4
#define rfbPointerEvent 5
#define rfbClientCutText 6


// Client to Server messages

typedef struct {
	U8             messageType;
	U8             padding[3];
	rfbPixelFormat pixelFormat;
} rfbSetPixelFormatMessage;

#define rfbSetPixelFormatMessageSize (sizeof(rfbSetPixelFormatMessage))


typedef struct {
    U8  messageType;
    U8  padding;
    U16 firstColour;
    U16 numberOfColours;
} rfbFixColourMapEntriesMessage;

#define rfbFixColourMapEntriesMessageSize (sizeof(rfbFixColourMapEntriesMessage))


typedef struct {
	U8  messageType;
	U8  padding;
	U16 numberOfEncodings;
} rfbSetEncodingsMessage;

#define rfbSetEncodingsMessageSize (sizeof(rfbSetEncodingsMessage))


typedef struct {
	U8  messageType;
	U8  incremental;
	U16 xPosition;
	U16 yPosition;
	U16 width;
	U16 height;
} rfbFramebufferUpdateRequestMessage;

#define rfbFramebufferUpdateRequestMessageSize (sizeof(rfbFramebufferUpdateRequestMessage))


typedef struct {
	U8  messageType;
	U8  downFlag;
	U8  padding[2];
	U32 key;
} rfbKeyEventMessage;

#define rfbKeyEventMessageSize (sizeof(rfbKeyEventMessage))


typedef struct {
	U8  messageType;
	U8  buttonMask;
	U16 xPosition;
	U16 yPosition;
} rfbPointerEventMessage;

#define rfbPointerEventMessageSize (sizeof(rfbPointerEventMessage)) 

#define rfbButton1Mask 1
#define rfbButton2Mask 2
#define rfbButton3Mask 4


typedef struct {
	U8  messageType;
	U8  padding[3];
	U32 length;
	// U8[]  text;
} rfbClientCutTextMessage;

#define rfbClientCutTextMessageSize (sizeof(rfbClientCutTextMessage))

// Fill in correct names
typedef union {
	rfbSetPixelFormatMessage           spf;
	rfbFixColourMapEntriesMessage      fcme;
	rfbSetEncodingsMessage             se;
	rfbFramebufferUpdateRequestMessage fur;
	rfbKeyEventMessage                 ke;
	rfbPointerEventMessage             pe;
	rfbClientCutTextMessage            cct;
} rfbClientToServerMessage;


// Server to Client message types
#define rfbFramebufferUpdate   0
#define rfbSetColourMapEntries 1
#define rfbBell                2
#define rfbServerCutText       3

// Encoding types
#define rfbEncodingRaw         0
#define rfbEncodingCopyRect    1
#define rfbEncodingRRE         2
#define rfbEncodingCoRRE       4
#define rfbEncodingHextile     5
#define rfbEncodingZRLE       16
#define rfbEncodingCursor      0xffffff11
#define rfbEncodingDesktopSize 0xffffff21
#define rfbEncodingZlib        6
#define rfbEncodingTight       7
#define rfbEncodingZlibHex     8
#define rfbEncodingTightOption00 0xffffff00  // to 0xffffffff except 0xffffff11 and 0xffffff21
#define rfbEncodingTightOption01 0xffffff01
#define rfbEncodingTightOption02 0xffffff02  
#define rfbEncodingTightOption03 0xffffff03  
#define rfbEncodingTightOption04 0xffffff04  
#define rfbEncodingTightOption05 0xffffff05  
#define rfbEncodingTightOption06 0xffffff06  
#define rfbEncodingTightOption07 0xffffff07  
#define rfbEncodingTightOption08 0xffffff08  
#define rfbEncodingTightOption09 0xffffff09  
#define rfbEncodingTightOption0a 0xffffff0a  
#define rfbEncodingTightOption0b 0xffffff0b  
#define rfbEncodingTightOption0c 0xffffff0c  
#define rfbEncodingTightOption0d 0xffffff0d  
#define rfbEncodingTightOption0e 0xffffff0e  
#define rfbEncodingTightOption0f 0xffffff0f  
#define rfbEncodingTightOption10 0xffffff10  
#define rfbEncodingTightOption12 0xffffff12  
#define rfbEncodingTightOption13 0xffffff13  
#define rfbEncodingTightOption14 0xffffff14  
#define rfbEncodingTightOption15 0xffffff15  
#define rfbEncodingTightOption16 0xffffff16  
#define rfbEncodingTightOption17 0xffffff17  
#define rfbEncodingTightOption18 0xffffff18  
#define rfbEncodingTightOption19 0xffffff19  
#define rfbEncodingTightOption1a 0xffffff1a  
#define rfbEncodingTightOption1b 0xffffff1b  
#define rfbEncodingTightOption1c 0xffffff1c  
#define rfbEncodingTightOption1d 0xffffff1d  
#define rfbEncodingTightOption1e 0xffffff1e  
#define rfbEncodingTightOption1f 0xffffff1f  
#define rfbEncodingTightOption20 0xffffff20  

typedef struct {
        U32 id;
        char *name;
} rfbEncodingType;

rfbEncodingType rfbEncodings[] = {
        {rfbEncodingRaw, "Raw"},
        {rfbEncodingCopyRect, "CopyRect"},
        {rfbEncodingRRE, "RRE"},
        {rfbEncodingCoRRE, "CoRRE"},
        {rfbEncodingHextile, "Hextile"},
        {rfbEncodingZRLE, "ZRLE"},
        {rfbEncodingCursor, "Cursor"},
        {rfbEncodingDesktopSize, "DesktopSize"},
        {rfbEncodingZlib, "Zlib"},
        {rfbEncodingTight, "Tight"},
        {rfbEncodingZlibHex, "ZlibHex"},
        {rfbEncodingTightOption00, "TightOption00"},
        {rfbEncodingTightOption01, "TightOption01"},
        {rfbEncodingTightOption02, "TightOption02"},
        {rfbEncodingTightOption03, "TightOption03"},
        {rfbEncodingTightOption04, "TightOption04"},
        {rfbEncodingTightOption05, "TightOption05"},
        {rfbEncodingTightOption06, "TightOption06"},
        {rfbEncodingTightOption07, "TightOption07"},
        {rfbEncodingTightOption08, "TightOption08"},
        {rfbEncodingTightOption09, "TightOption09"},
        {rfbEncodingTightOption0a, "TightOption0a"},
        {rfbEncodingTightOption0b, "TightOption0b"},
        {rfbEncodingTightOption0c, "TightOption0c"},
        {rfbEncodingTightOption0d, "TightOption0d"},
        {rfbEncodingTightOption0e, "TightOption0e"},
        {rfbEncodingTightOption0f, "TightOption0f"},
        {rfbEncodingTightOption10, "TightOption10"},
        {rfbEncodingTightOption12, "TightOption12"},
        {rfbEncodingTightOption13, "TightOption13"},
        {rfbEncodingTightOption14, "TightOption14"},
        {rfbEncodingTightOption15, "TightOption15"},
        {rfbEncodingTightOption16, "TightOption16"},
        {rfbEncodingTightOption17, "TightOption17"},
        {rfbEncodingTightOption18, "TightOption18"},
        {rfbEncodingTightOption19, "TightOption19"},
        {rfbEncodingTightOption1a, "TightOption1a"},
        {rfbEncodingTightOption1b, "TightOption1b"},
        {rfbEncodingTightOption1c, "TightOption1c"},
        {rfbEncodingTightOption1d, "TightOption1d"},
        {rfbEncodingTightOption1e, "TightOption1e"},
        {rfbEncodingTightOption1f, "TightOption1f"},
        {rfbEncodingTightOption20, "TightOption20"},
};

#define rfbEncodingsCount (sizeof(rfbEncodings) / sizeof(rfbEncodingType))

// Server To Client Messages

typedef struct {
	U8  messageType;
	U8  padding;
	U16 numberOfRectangles;
} rfbFramebufferUpdateMessage;

#define rfbFramebufferUpdateMessageSize (sizeof(rfbFramebufferUpdateMessage))

typedef struct {
	rfbRectangle r;
} rfbFramebufferUpdateRectHeader;

#define rfbFramebufferUpdateRectHeaderSize (sizeof(rfbFramebufferUpdateRectHeader))

typedef struct {
	U16 srcXPosition;
	U16 srcYPosition;
} rfbCopyRect;

#define rfbCopyRectSize (sizeof(rfbCopyRect))


/* typedef struct { */
/* 	U32   numberOfSubrectangles; */
/* 	PIXEL backgroundPixelValue; */
/* } rfbRREHeader; */

/* #define rfbRREHeaderSize (sizeof(rfbRREHeader)) */


/* typedef struct { */
/* 	U32   numberOfSubrectangles; */
/* 	PIXEL backgroundPixelValue; */
/* } rfbCoRRERectangle; */

/* #define rfbCoRRERectangleSize (sizeof(rfbCoRRERectangle)) */


#define rfbHextileRaw			(1 << 0)
#define rfbHextileBackgroundSpecified	(1 << 1)
#define rfbHextileForegroundSpecified	(1 << 2)
#define rfbHextileAnySubrects		(1 << 3)
#define rfbHextileSubrectsColoured	(1 << 4)

#define rfbHextilePackXY(x,y) (((x) << 4) | (y))
#define rfbHextilePackWH(w,h) ((((w)-1) << 4) | ((h)-1))
#define rfbHextileExtractX(byte) ((byte) >> 4)
#define rfbHextileExtractY(byte) ((byte) & 0xf)
#define rfbHextileExtractW(byte) (((byte) >> 4) + 1)
#define rfbHextileExtractH(byte) (((byte) & 0xf) + 1)


typedef struct {
	U8  messageType;
	U8  padding;
	U16 firstColour;
	U16 numberOfColours;
} rfbSetColourMapEntriesMessage;

#define rfbSetColourMapEntriesMessageSize (sizeof(rfbSetColourMapEntriesMessage))



typedef struct {
	U8 messageType;
} rfbBellMessage;

#define rfbBellMessageSize (sizeof(rfbBellMessage))



typedef struct {
	U8  messageType;
	U8  padding[3];
	U32 length;
	// U8[]  text;
} rfbServerCutTextMessage;

#define rfbServerCutTextMessageSize (sizeof(rfbServerCutTextMessage))

// Fill in correct names
typedef union {
	rfbFramebufferUpdateMessage fu;
	rfbBellMessage              b;
	rfbServerCutTextMessage     sct;
} rfbServerToClientMessage;