67 #include <sys/timeb.h>
70 #include <rfb/rfbconfig.h>
72 #ifdef LIBVNCSERVER_HAVE_LIBZ
80 #if LIBVNCSERVER_HAVE_ENDIAN_H
82 # if __BYTE_ORDER == __BIG_ENDIAN
83 # define LIBVNCSERVER_WORDS_BIGENDIAN 1
89 #define strncasecmp _strnicmp
92 #define rfbMax(a,b) (((a)>(b))?(a):(b))
94 #define rfbSocket SOCKET
95 #define RFB_INVALID_SOCKET INVALID_SOCKET
96 #define _rfbCloseSocket closesocket
98 #ifdef LIBVNCSERVER_HAVE_SYS_TIME_H
101 #ifdef LIBVNCSERVER_HAVE_NETINET_IN_H
102 #include <netinet/in.h>
104 #define rfbSocket int
106 #define RFB_INVALID_SOCKET (-1)
107 #define _rfbCloseSocket close
114 #define rfbCloseSocket(s) \
116 if (s != RFB_INVALID_SOCKET) { \
117 _rfbCloseSocket(s); \
118 s = RFB_INVALID_SOCKET; \
125 #ifdef LIBVNCSERVER_NEED_INADDR_T
126 typedef uint32_t in_addr_t;
130 #define INADDR_NONE ((in_addr_t) 0xffffffff)
133 #define MAX_ENCODINGS 64
154 #define sz_rfbRectangle 8
209 #define sz_rfbPixelFormat 16
212 #define rfbPFFullColors 0
213 #define rfbPF256Colors 1
214 #define rfbPF64Colors 2
215 #define rfbPF8Colors 3
216 #define rfbPF8GreyColors 4
217 #define rfbPF4GreyColors 5
218 #define rfbPF2GreyColors 6
252 #define rfbProtocolVersionFormat "RFB %03d.%03d\n"
253 #define rfbProtocolMajorVersion 3
254 #define rfbProtocolMinorVersion 8
261 #define sz_rfbProtocolVersionMsg 12
276 #define rfbSecTypeInvalid 0
277 #define rfbSecTypeNone 1
278 #define rfbSecTypeVncAuth 2
290 #define rfbConnFailed 0
301 #define rfbVeNCrypt 19
304 #define rfbUltraMSLogonI 0x70
305 #define rfbUltraMSLogonII 0x71
306 #define rfbMSLogon 0xfffffffa
308 #define rfbVeNCryptPlain 256
309 #define rfbVeNCryptTLSNone 257
310 #define rfbVeNCryptTLSVNC 258
311 #define rfbVeNCryptTLSPlain 259
312 #define rfbVeNCryptX509None 260
313 #define rfbVeNCryptX509VNC 261
314 #define rfbVeNCryptX509Plain 262
315 #define rfbVeNCryptX509SASL 263
316 #define rfbVeNCryptTLSSASL 264
340 #define rfbVncAuthOK 0
341 #define rfbVncAuthFailed 1
342 #define rfbVncAuthTooMany 2
359 #define sz_rfbClientInitMsg 1
378 #define sz_rfbServerInitMsg (8 + sz_rfbPixelFormat)
404 #define rfbFramebufferUpdate 0
405 #define rfbSetColourMapEntries 1
407 #define rfbServerCutText 3
409 #define rfbResizeFrameBuffer 4
410 #define rfbPalmVNCReSizeFrameBuffer 0xF
414 #define rfbSetPixelFormat 0
415 #define rfbFixColourMapEntries 1
416 #define rfbSetEncodings 2
417 #define rfbFramebufferUpdateRequest 3
418 #define rfbKeyEvent 4
419 #define rfbPointerEvent 5
420 #define rfbClientCutText 6
422 #define rfbFileTransfer 7
424 #define rfbSetScale 8
426 #define rfbSetServerInput 9
430 #define rfbTextChat 11
433 #define rfbPalmVNCSetScaleFactor 0xF
437 #define rfbSetDesktopSize 251
438 #define rfbQemuEvent 255
449 #define rfbEncodingRaw 0
450 #define rfbEncodingCopyRect 1
451 #define rfbEncodingRRE 2
452 #define rfbEncodingCoRRE 4
453 #define rfbEncodingHextile 5
454 #define rfbEncodingZlib 6
455 #define rfbEncodingTight 7
456 #define rfbEncodingTightPng 0xFFFFFEFC
457 #define rfbEncodingZlibHex 8
458 #define rfbEncodingUltra 9
459 #define rfbEncodingTRLE 15
460 #define rfbEncodingZRLE 16
461 #define rfbEncodingZYWRLE 17
463 #define rfbEncodingH264 0x48323634
466 #define rfbEncodingCache 0xFFFF0000
467 #define rfbEncodingCacheEnable 0xFFFF0001
468 #define rfbEncodingXOR_Zlib 0xFFFF0002
469 #define rfbEncodingXORMonoColor_Zlib 0xFFFF0003
470 #define rfbEncodingXORMultiColor_Zlib 0xFFFF0004
471 #define rfbEncodingSolidColor 0xFFFF0005
472 #define rfbEncodingXOREnable 0xFFFF0006
473 #define rfbEncodingCacheZip 0xFFFF0007
474 #define rfbEncodingSolMonoZip 0xFFFF0008
475 #define rfbEncodingUltraZip 0xFFFF0009
478 #define rfbEncodingXvp 0xFFFFFECB
492 #define rfbEncodingFineQualityLevel0 0xFFFFFE00
493 #define rfbEncodingFineQualityLevel100 0xFFFFFE64
494 #define rfbEncodingSubsamp1X 0xFFFFFD00
495 #define rfbEncodingSubsamp4X 0xFFFFFD01
496 #define rfbEncodingSubsamp2X 0xFFFFFD02
497 #define rfbEncodingSubsampGray 0xFFFFFD03
498 #define rfbEncodingSubsamp8X 0xFFFFFD04
499 #define rfbEncodingSubsamp16X 0xFFFFFD05
501 #define rfbEncodingCompressLevel0 0xFFFFFF00
502 #define rfbEncodingCompressLevel1 0xFFFFFF01
503 #define rfbEncodingCompressLevel2 0xFFFFFF02
504 #define rfbEncodingCompressLevel3 0xFFFFFF03
505 #define rfbEncodingCompressLevel4 0xFFFFFF04
506 #define rfbEncodingCompressLevel5 0xFFFFFF05
507 #define rfbEncodingCompressLevel6 0xFFFFFF06
508 #define rfbEncodingCompressLevel7 0xFFFFFF07
509 #define rfbEncodingCompressLevel8 0xFFFFFF08
510 #define rfbEncodingCompressLevel9 0xFFFFFF09
512 #define rfbEncodingXCursor 0xFFFFFF10
513 #define rfbEncodingRichCursor 0xFFFFFF11
514 #define rfbEncodingPointerPos 0xFFFFFF18
516 #define rfbEncodingLastRect 0xFFFFFF20
517 #define rfbEncodingNewFBSize 0xFFFFFF21
518 #define rfbEncodingExtDesktopSize 0xFFFFFECC
520 #define rfbEncodingQualityLevel0 0xFFFFFFE0
521 #define rfbEncodingQualityLevel1 0xFFFFFFE1
522 #define rfbEncodingQualityLevel2 0xFFFFFFE2
523 #define rfbEncodingQualityLevel3 0xFFFFFFE3
524 #define rfbEncodingQualityLevel4 0xFFFFFFE4
525 #define rfbEncodingQualityLevel5 0xFFFFFFE5
526 #define rfbEncodingQualityLevel6 0xFFFFFFE6
527 #define rfbEncodingQualityLevel7 0xFFFFFFE7
528 #define rfbEncodingQualityLevel8 0xFFFFFFE8
529 #define rfbEncodingQualityLevel9 0xFFFFFFE9
531 #define rfbEncodingQemuExtendedKeyEvent 0xFFFFFEFE
532 #define rfbEncodingExtendedClipboard 0xC0A1E5CE
535 #define rfbEncodingKeyboardLedState 0xFFFE0000
536 #define rfbEncodingSupportedMessages 0xFFFE0001
537 #define rfbEncodingSupportedEncodings 0xFFFE0002
538 #define rfbEncodingServerIdentity 0xFFFE0003
564 #define sz_rfbFramebufferUpdateMsg 4
579 #define sz_rfbFramebufferUpdateRectHeader (sz_rfbRectangle + 4)
589 uint8_t client2server[32];
590 uint8_t server2client[32];
593 #define sz_rfbSupportedMessages 64
620 #define rfbKeyboardMaskShift 1
621 #define rfbKeyboardMaskCapsLock 2
622 #define rfbKeyboardMaskControl 4
623 #define rfbKeyboardMaskAlt 8
624 #define rfbKeyboardMaskMeta 16
625 #define rfbKeyboardMaskSuper 32
626 #define rfbKeyboardMaskHyper 64
627 #define rfbKeyboardMaskNumLock 128
628 #define rfbKeyboardMaskScrollLock 256
629 #define rfbKeyboardMaskAltGraph 512
641 #define sz_rfbCopyRect 4
655 #define sz_rfbRREHeader 4
673 #define sz_rfbCoRRERectangle 4
715 #define rfbHextileRaw (1 << 0)
716 #define rfbHextileBackgroundSpecified (1 << 1)
717 #define rfbHextileForegroundSpecified (1 << 2)
718 #define rfbHextileAnySubrects (1 << 3)
719 #define rfbHextileSubrectsColoured (1 << 4)
721 #define rfbHextilePackXY(x,y) (((x) << 4) | (y))
722 #define rfbHextilePackWH(w,h) ((((w)-1) << 4) | ((h)-1))
723 #define rfbHextileExtractX(byte) ((byte) >> 4)
724 #define rfbHextileExtractY(byte) ((byte) & 0xf)
725 #define rfbHextileExtractW(byte) (((byte) >> 4) + 1)
726 #define rfbHextileExtractH(byte) (((byte) & 0xf) + 1)
739 #define sz_rfbZlibHeader 4
741 #ifdef LIBVNCSERVER_HAVE_LIBZ
880 #define rfbTightExplicitFilter 0x04
881 #define rfbTightFill 0x08
882 #define rfbTightJpeg 0x09
883 #define rfbTightNoZlib 0x0A
884 #define rfbTightPng 0x0A
885 #define rfbTightMaxSubencoding 0x0A
888 #define rfbTightFilterCopy 0x00
889 #define rfbTightFilterPalette 0x01
890 #define rfbTightFilterGradient 0x02
922 #define sz_rfbXCursorColors 6
948 #define sz_rfbZRLEHeader 4
950 #define rfbZRLETileWidth 64
951 #define rfbZRLETileHeight 64
964 #define rfbHextileZlibRaw (1 << 5)
965 #define rfbHextileZlibHex (1 << 6)
966 #define rfbHextileZlibMono (1 << 7)
989 #define sz_rfbSetColourMapEntriesMsg 6
1001 #define sz_rfbBellMsg 1
1017 #define sz_rfbServerCutTextMsg 8
1026 typedef struct _rfbFileTransferMsg {
1037 #define sz_rfbFileTransferMsg 12
1039 #define rfbFileTransferVersion 2
1042 #define rfbDirContentRequest 1
1043 #define rfbDirPacket 2
1045 #define rfbFileTransferRequest 3
1046 #define rfbFileHeader 4
1047 #define rfbFilePacket 5
1048 #define rfbEndOfFile 6
1049 #define rfbAbortFileTransfer 7
1050 #define rfbFileTransferOffer 8
1051 #define rfbFileAcceptHeader 9
1052 #define rfbCommand 10
1053 #define rfbCommandReturn 11
1054 #define rfbFileChecksums 12
1055 #define rfbFileTransferAccess 14
1058 #define rfbRDirContent 1
1059 #define rfbRDrivesList 2
1060 #define rfbRDirRecursiveList 3
1061 #define rfbRDirRecursiveSize 4
1064 #define rfbADirectory 1
1066 #define rfbADrivesList 3
1067 #define rfbADirCreate 4
1068 #define rfbADirDelete 5
1069 #define rfbAFileCreate 6
1070 #define rfbAFileDelete 7
1071 #define rfbAFileRename 8
1072 #define rfbADirRename 9
1073 #define rfbADirRecursiveListItem 10
1074 #define rfbADirRecursiveSize 11
1077 #define rfbCDirCreate 1
1078 #define rfbCDirDelete 2
1079 #define rfbCFileCreate 3
1080 #define rfbCFileDelete 4
1081 #define rfbCFileRename 5
1082 #define rfbCDirRename 6
1085 #define rfbRErrorUnknownCmd 1
1086 #define rfbRErrorCmd 0xFFFFFFFF
1088 #define sz_rfbBlockSize 8192
1089 #define rfbZipDirectoryPrefix "!UVNCDIR-\0"
1090 #define sz_rfbZipDirectoryPrefix 9
1091 #define rfbDirPrefix "[ "
1092 #define rfbDirSuffix " ]"
1102 typedef struct _rfbTextChatMsg {
1110 #define sz_rfbTextChatMsg 8
1112 #define rfbTextMaxSize 4096
1113 #define rfbTextChatOpen 0xFFFFFFFF
1114 #define rfbTextChatClose 0xFFFFFFFE
1115 #define rfbTextChatFinished 0xFFFFFFFD
1146 #define sz_rfbXvpMsg (4)
1149 #define rfbXvp_Fail 0
1150 #define rfbXvp_Init 1
1152 #define rfbXvp_Shutdown 2
1153 #define rfbXvp_Reboot 3
1154 #define rfbXvp_Reset 4
1180 #define sz_rfbExtDesktopSizeMsg (4)
1181 #define sz_rfbExtDesktopScreen (16)
1184 #define rfbExtDesktopSize_GenericChange 0
1185 #define rfbExtDesktopSize_ClientRequestedChange 1
1186 #define rfbExtDesktopSize_OtherClientRequestedChange 2
1189 #define rfbExtDesktopSize_Success 0
1190 #define rfbExtDesktopSize_ResizeProhibited 1
1191 #define rfbExtDesktopSize_OutOfResources 2
1192 #define rfbExtDesktopSize_InvalidScreenLayout 3
1212 #define sz_rfbSetDesktopSizeMsg (8)
1220 typedef struct _rfbResizeFrameBufferMsg {
1227 #define sz_rfbResizeFrameBufferMsg 6
1249 #define sz_rfbPalmVNCReSizeFrameBufferMsg (12)
1284 #define sz_rfbCacheRect 2
1308 #define sz_rfbSetPixelFormatMsg (sz_rfbPixelFormat + 4)
1329 #define sz_rfbFixColourMapEntriesMsg 6
1345 #define sz_rfbSetEncodingsMsg 4
1363 #define sz_rfbFramebufferUpdateRequestMsg 10
1404 #define sz_rfbKeyEventMsg 8
1415 #define sz_rfbQemuExtendedKeyEventMsg 12
1429 #define rfbButton1Mask 1
1430 #define rfbButton2Mask 2
1431 #define rfbButton3Mask 4
1432 #define rfbButton4Mask 8
1433 #define rfbButton5Mask 16
1435 #define rfbWheelUpMask rfbButton4Mask
1436 #define rfbWheelDownMask rfbButton5Mask
1438 #define sz_rfbPointerEventMsg 6
1454 #define rfbExtendedClipboard_Text 1
1455 #define rfbExtendedClipboard_RTF 2
1456 #define rfbExtendedClipboard_HTML 4
1457 #define rfbExtendedClipboard_DIB 8
1458 #define rfbExtendedClipboard_Files 16
1459 #define rfbExtendedClipboard_Caps (1 << 24)
1460 #define rfbExtendedClipboard_Request (1 << 25)
1461 #define rfbExtendedClipboard_Peek (1 << 26)
1462 #define rfbExtendedClipboard_Notify (1 << 27)
1463 #define rfbExtendedClipboard_Provide (1 << 28)
1464 #define sz_rfbClientCutTextMsg 8
1473 typedef struct _rfbSetScaleMsg {
1479 #define sz_rfbSetScaleMsg 4
1495 #define sz_rfbPalmVNCSetScaleFactorMsg (4)
1503 typedef struct _rfbSetServerInputMsg {
1509 #define sz_rfbSetServerInputMsg 4
1516 typedef struct _rfbSetSWMsg {
1523 #define sz_rfbSetSWMsg 6
1555 #define CHALLENGESIZE 16
char * rfbDecryptPasswdFromFile(char *fname)
int rfbEncryptAndStorePasswd(char *passwd, char *fname)
char rfbProtocolVersionMsg[13]
void rfbRandomBytes(unsigned char *bytes)
void rfbEncryptBytes(unsigned char *bytes, char *passwd)
uint16_t framebufferHeigth
uint16_t framebufferWidth
uint16_t framebufferWidth
uint16_t framebufferHeight
rfbFramebufferUpdateRequestMsg fur
rfbPalmVNCSetScaleFactorMsg pssf
rfbFixColourMapEntriesMsg fcme
rfbResizeFrameBufferMsg rsfb
rfbSetColourMapEntriesMsg scme
rfbPalmVNCReSizeFrameBufferMsg prsfb
rfbFramebufferUpdateMsg fu