LibVNCServer/LibVNCClient
rfb.h
Go to the documentation of this file.
1 #ifndef RFB_H
2 #define RFB_H
12 /*
13  * Copyright (C) 2005 Rohit Kumar <rokumar@novell.com>,
14  * Johannes E. Schindelin <johannes.schindelin@gmx.de>
15  * Copyright (C) 2002 RealVNC Ltd.
16  * OSXvnc Copyright (C) 2001 Dan McGuirk <mcguirk@incompleteness.net>.
17  * Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge.
18  * All Rights Reserved.
19  *
20  * This is free software; you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License as published by
22  * the Free Software Foundation; either version 2 of the License, or
23  * (at your option) any later version.
24  *
25  * This software is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this software; if not, write to the Free Software
32  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
33  * USA.
34  */
35 
36 #if(defined __cplusplus)
37 extern "C"
38 {
39 #endif
40 
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <rfb/rfbproto.h>
45 
46 #if defined(ANDROID) || defined(LIBVNCSERVER_HAVE_ANDROID)
47 #include <arpa/inet.h>
48 #include <sys/select.h>
49 #endif
50 
51 #ifdef LIBVNCSERVER_HAVE_SYS_TYPES_H
52 #include <sys/types.h>
53 #endif
54 
55 #ifdef WIN32
56 typedef UINT32 in_addr_t;
57 #include <winsock2.h>
58 #ifdef LIBVNCSERVER_HAVE_WS2TCPIP_H
59 #undef socklen_t
60 #include <ws2tcpip.h>
61 #endif
62 #ifdef _MSC_VER
63 #pragma warning(disable:4996)
64 #endif
65 #endif
66 
67 #include <rfb/threading.h>
68 
69 /* if you use pthreads, but don't define LIBVNCSERVER_HAVE_LIBPTHREAD, the structs
70  get all mixed up. So this gives a linker error reminding you to compile
71  the library and your application (at least the parts including rfb.h)
72  with the same support for pthreads. */
73 #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
74 #ifdef LIBVNCSERVER_HAVE_LIBZ
75 #define rfbInitServer rfbInitServerWithPthreadsAndZRLE
76 #else
77 #define rfbInitServer rfbInitServerWithPthreadsButWithoutZRLE
78 #endif
79 #else
80 #ifdef LIBVNCSERVER_HAVE_LIBZ
81 #define rfbInitServer rfbInitServerWithoutPthreadsButWithZRLE
82 #else
83 #define rfbInitServer rfbInitServerWithoutPthreadsAndZRLE
84 #endif
85 #endif
86 
87 struct _rfbClientRec;
88 struct _rfbScreenInfo;
89 struct rfbCursor;
90 
95 };
96 
101 };
102 
103 typedef void (*rfbKbdAddEventProcPtr) (rfbBool down, rfbKeySym keySym, struct _rfbClientRec* cl);
104 typedef void (*rfbKbdReleaseAllKeysProcPtr) (struct _rfbClientRec* cl);
105 typedef void (*rfbPtrAddEventProcPtr) (int buttonMask, int x, int y, struct _rfbClientRec* cl);
106 typedef void (*rfbSetXCutTextProcPtr) (char* str,int len, struct _rfbClientRec* cl);
107 #ifdef LIBVNCSERVER_HAVE_LIBZ
108 typedef void (*rfbSetXCutTextUTF8ProcPtr) (char* str,int len, struct _rfbClientRec* cl);
109 #endif
110 typedef struct rfbCursor* (*rfbGetCursorProcPtr) (struct _rfbClientRec* pScreen);
111 typedef rfbBool (*rfbSetTranslateFunctionProcPtr)(struct _rfbClientRec* cl);
112 typedef rfbBool (*rfbPasswordCheckProcPtr)(struct _rfbClientRec* cl,const char* encryptedPassWord,int len);
113 typedef enum rfbNewClientAction (*rfbNewClientHookPtr)(struct _rfbClientRec* cl);
114 typedef void (*rfbDisplayHookPtr)(struct _rfbClientRec* cl);
115 typedef void (*rfbDisplayFinishedHookPtr)(struct _rfbClientRec* cl, int result);
117 typedef int (*rfbGetKeyboardLedStateHookPtr)(struct _rfbScreenInfo* screen);
118 typedef rfbBool (*rfbXvpHookPtr)(struct _rfbClientRec* cl, uint8_t, uint8_t);
119 typedef int (*rfbSetDesktopSizeHookPtr)(int width, int height, int numScreens, struct rfbExtDesktopScreen* extDesktopScreens, struct _rfbClientRec* cl);
120 typedef int (*rfbNumberOfExtDesktopScreensPtr)(struct _rfbClientRec* cl);
121 typedef rfbBool (*rfbGetExtDesktopScreenPtr)(int seqnumber, struct rfbExtDesktopScreen *extDesktopScreen, struct _rfbClientRec* cl);
127 typedef void (*rfbSetSingleWindowProcPtr) (struct _rfbClientRec* cl, int x, int y);
132 typedef void (*rfbSetServerInputProcPtr) (struct _rfbClientRec* cl, int status);
137 typedef int (*rfbFileTransferPermitted) (struct _rfbClientRec* cl);
139 typedef void (*rfbSetTextChat) (struct _rfbClientRec* cl, int length, char *string);
140 
141 typedef struct {
142  uint32_t count;
144  union {
145  uint8_t* bytes;
146  uint16_t* shorts;
147  } data;
148 } rfbColourMap;
149 
154 typedef struct _rfbSecurity {
155  uint8_t type;
156  void (*handler)(struct _rfbClientRec* cl);
157  struct _rfbSecurity* next;
159 
164 typedef struct _rfbProtocolExtension {
167  rfbBool (*newClient)(struct _rfbClientRec* client, void** data);
170  rfbBool (*init)(struct _rfbClientRec* client, void* data);
176  rfbBool (*enablePseudoEncoding)(struct _rfbClientRec* client,
177  void** data, int encodingNumber);
179  rfbBool (*handleMessage)(struct _rfbClientRec* client,
180  void* data,
181  const rfbClientToServerMsg* message);
182  void (*close)(struct _rfbClientRec* client, void* data);
183  void (*usage)(void);
185  int (*processArgument)(int argc, char *argv[]);
186  struct _rfbProtocolExtension* next;
188 
189 typedef struct _rfbExtensionData {
191  void* data;
192  struct _rfbExtensionData* next;
194 
201 typedef struct _rfbScreenInfo
202 {
204  struct _rfbScreenInfo *scaledScreenNext;
206 
207  int width;
209  int height;
210  int depth;
213 
216 
222  void* screenData;
223 
224  /* additions by libvncserver */
225 
228  const char* desktopName;
229  char thisHost[255];
230 
232  int port;
234  int maxSock;
235  int maxFd;
236 #ifdef WIN32
237  struct fd_set allFds;
238 #else
239  fd_set allFds;
240 #endif
241 
242  enum rfbSocketState socketState;
245 
246  int udpPort;
248  struct _rfbClientRec* udpClient;
249  rfbBool udpSockConnected;
250  struct sockaddr_in udpRemoteAddr;
251 
253 
254  /* http stuff */
257  int httpPort;
258  char* httpDir;
261 
267 
273 #ifdef TODELETE
274  char* screen;
275 #endif
279  struct _rfbClientRec* clientHead;
280  struct _rfbClientRec* pointerClient;
283  /* cursor */
284  int cursorX, cursorY,underCursorBufferLen;
287  struct rfbCursor* cursor;
288 
293  char* frameBuffer;
298  rfbGetCursorProcPtr getCursorPtr;
304 
309 
312 
313 #if defined(LIBVNCSERVER_HAVE_LIBPTHREAD) || defined(LIBVNCSERVER_HAVE_WIN32THREADS)
314  MUTEX(cursorMutex);
315  rfbBool backgroundLoop;
316 #endif
317 
320 
325 
326  in_addr_t listenInterface;
328 
331 
334 
338 
341 
346  char *sslkeyfile;
347  char *sslcertfile;
348  int ipv6port;
350  /* We have an additional IPv6 listen socket since there are systems that
351  don't support dual binding sockets under *any* circumstances, for
352  instance OpenBSD */
365  float fdQuota;
366 #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
367  pthread_t listener_thread;
368  int pipe_notify_listener_thread[2];
369 #elif defined(LIBVNCSERVER_HAVE_WIN32THREADS)
370  uintptr_t listener_thread;
371 #endif
372 #ifdef LIBVNCSERVER_HAVE_LIBZ
373  rfbSetXCutTextUTF8ProcPtr setXCutTextUTF8;
374 #endif
375 } rfbScreenInfo, *rfbScreenInfoPtr;
376 
377 
382 typedef void (*rfbTranslateFnType)(char *table, rfbPixelFormat *in,
383  rfbPixelFormat *out,
384  char *iptr, char *optr,
385  int bytesBetweenInputLines,
386  int width, int height);
387 
388 
389 /* region stuff */
390 
391 struct sraRegion;
392 typedef struct sraRegion* sraRegionPtr;
393 
394 /*
395  * Per-client structure.
396  */
397 
398 typedef void (*ClientGoneHookPtr)(struct _rfbClientRec* cl);
399 typedef void (*ClientFramebufferUpdateRequestHookPtr)(struct _rfbClientRec* cl, rfbFramebufferUpdateRequestMsg* furMsg);
400 
401 typedef struct _rfbFileTransferData {
402  int fd;
404  int fileSize;
407  int sending;
409 
410 
411 typedef struct _rfbStatList {
412  uint32_t type;
413  uint32_t sentCount;
414  uint32_t bytesSent;
415  uint32_t bytesSentIfRaw;
416  uint32_t rcvdCount;
417  uint32_t bytesRcvd;
418  uint32_t bytesRcvdIfRaw;
419  struct _rfbStatList *Next;
420 } rfbStatList;
421 
422 typedef struct _rfbSslCtx rfbSslCtx;
423 typedef struct _wsCtx wsCtx;
424 
425 typedef struct _rfbClientRec {
426 
428  rfbScreenInfoPtr screen;
429 
431  rfbScreenInfoPtr scaledScreen;
434 
435 
442  void* clientData;
444 
446  char *host;
447 
448  /* RFB protocol minor version number */
451 
452 #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
453  pthread_t client_thread;
454 #elif defined(LIBVNCSERVER_HAVE_WIN32THREADS)
455  uintptr_t client_thread;
456 #endif
457 
458  /* Note that the RFB_INITIALISATION_SHARED state is provided to support
459  clients that under some circumstances do not send a ClientInit message.
460  In particular the Mac OS X built-in VNC client (with protocolMinorVersion
461  == 889) is one of those. However, it only requires this support under
462  special circumstances that can only be determined during the initial
463  authentication. If the right conditions are met this state will be
464  set (see the auth.c file) when rfbProcessClientInitMessage is called.
465 
466  If the state is RFB_INITIALISATION_SHARED we should not expect to receive
467  any ClientInit message, but instead should proceed to the next stage
468  of initialisation as though an implicit ClientInit message was received
469  with a shared-flag of true. (There is currently no corresponding
470  RFB_INITIALISATION_NOTSHARED state to represent an implicit ClientInit
471  message with a shared-flag of false because no known existing client
472  requires such support at this time.)
473 
474  Note that software using LibVNCServer to provide a VNC server will only
475  ever have a chance to see the state field set to
476  RFB_INITIALISATION_SHARED if the software is multi-threaded and manages
477  to examine the state field during the extremely brief window after the
478  'None' authentication type selection has been received from the built-in
479  OS X VNC client and before the rfbProcessClientInitMessage function is
480  called -- control cannot return to the caller during this brief window
481  while the state field is set to RFB_INITIALISATION_SHARED. */
482 
484  enum {
491  /* Ephemeral internal-use states that will never be seen by software
492  * using LibVNCServer to provide services: */
493 
495  RFB_SHUTDOWN
496  } state;
497 
503  int correMaxWidth, correMaxHeight;
504 
506 
507  /* The following member is only used during VNC authentication */
508  uint8_t authChallenge[CHALLENGESIZE];
509 
510  /* The following members represent the update needed to get the client's
511  framebuffer from its present state to the current state of our
512  framebuffer.
513 
514  If the client does not accept CopyRect encoding then the update is
515  simply represented as the region of the screen which has been modified
516  (modifiedRegion).
517 
518  If the client does accept CopyRect encoding, then the update consists of
519  two parts. First we have a single copy from one region of the screen to
520  another (the destination of the copy is copyRegion), and second we have
521  the region of the screen which has been modified in some other way
522  (modifiedRegion).
523 
524  Although the copy is of a single region, this region may have many
525  rectangles. When sending an update, the copyRegion is always sent
526  before the modifiedRegion. This is because the modifiedRegion may
527  overlap parts of the screen which are in the source of the copy.
528 
529  In fact during normal processing, the modifiedRegion may even overlap
530  the destination copyRegion. Just before an update is sent we remove
531  from the copyRegion anything in the modifiedRegion. */
532 
534  int copyDX, copyDY;
537 
544 
551  struct timeval startDeferring;
552  struct timeval startPtrDeferring;
553  int lastPtrX;
554  int lastPtrY;
556 
563 
570 #define UPDATE_BUF_SIZE 32768
571 
572  char updateBuf[UPDATE_BUF_SIZE];
573  int ublen;
574 
575  /* statistics */
576  struct _rfbStatList *statEncList;
577  struct _rfbStatList *statMsgList;
580 
581 #ifdef LIBVNCSERVER_HAVE_LIBZ
582  /* zlib encoding -- necessary compression state info per client */
583 
584  struct z_stream_s compStream;
585  rfbBool compStreamInited;
586  uint32_t zlibCompressLevel;
587 #endif
588 #if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG)
590  int tightQualityLevel;
591 
592 #ifdef LIBVNCSERVER_HAVE_LIBJPEG
593  /* tight encoding -- preserve zlib streams' state for each client */
594  z_stream zsStruct[4];
595  rfbBool zsActive[4];
596  int zsLevel[4];
597  int tightCompressLevel;
598 #endif
599 #endif
600 
601  /* Ultra Encoding support */
603  char *lzoWrkMem;
604 
606 
618  int cursorX,cursorY;
624  struct _rfbClientRec *prev;
625  struct _rfbClientRec *next;
626 
627 #if defined(LIBVNCSERVER_HAVE_LIBPTHREAD) || defined(LIBVNCSERVER_HAVE_WIN32THREADS)
633  int refCount;
634  MUTEX(refCountMutex);
635  COND(deleteCond);
636 
637  MUTEX(outputMutex);
638  MUTEX(updateMutex);
639  COND(updateCond);
640 #endif
641 
642 #ifdef LIBVNCSERVER_HAVE_LIBZ
643  void* zrleData;
644  int zywrleLevel;
645  int zywrleBuf[rfbZRLETileWidth * rfbZRLETileHeight];
646 #endif
647 
651 
653 
657 
659 #if defined(LIBVNCSERVER_HAVE_LIBPTHREAD) || defined(LIBVNCSERVER_HAVE_WIN32THREADS)
660 #define LIBVNCSERVER_SEND_MUTEX
661  MUTEX(sendMutex);
662 #endif
663 
664  /* buffers to hold pixel data before and after encoding.
665  per-client for thread safety */
668  char *afterEncBuf;
671 #if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG)
672  uint32_t tightEncoding; /* rfbEncodingTight or rfbEncodingTightPng */
673 #ifdef LIBVNCSERVER_HAVE_LIBJPEG
674  /* TurboVNC Encoding support (extends TightVNC) */
675  int turboSubsampLevel;
676  int turboQualityLevel; /* 1-100 scale */
677 #endif
678 #endif
681  char *wspath; /* Requests path component */
682 #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
683  int pipe_notify_client_thread[2];
684 #endif
685 
691 
695 
696 #ifdef LIBVNCSERVER_HAVE_LIBZ
697  rfbBool enableExtendedClipboard;
698  uint32_t extClipboardUserCap;
699  uint32_t extClipboardMaxUnsolicitedSize;
700  char *extClipboardData;
701  int extClipboardDataSize;
702 
703 #ifdef LIBVNCSERVER_HAVE_LIBJPEG
704  /* Tight encoding internal variables, stored per-client for thread safety */
705  rfbBool tightUsePixelFormat24;
706  void *tightTJ;
707  int tightPngDstDataLen;
708 #endif
709 #endif
710 } rfbClientRec, *rfbClientPtr;
711 
717 #define FB_UPDATE_PENDING(cl) \
718  (((cl)->enableCursorShapeUpdates && (cl)->cursorWasChanged) || \
719  (((cl)->enableCursorShapeUpdates == FALSE && \
720  ((cl)->cursorX != (cl)->screen->cursorX || \
721  (cl)->cursorY != (cl)->screen->cursorY))) || \
722  ((cl)->useNewFBSize && (cl)->newFBSizePending) || \
723  ((cl)->enableCursorPosUpdates && (cl)->cursorWasMoved) || \
724  !sraRgnEmpty((cl)->copyRegion) || !sraRgnEmpty((cl)->modifiedRegion))
725 
726 /*
727  * Macros for endian swapping.
728  */
729 
730 #define Swap16(s) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff))
731 
732 #define Swap24(l) ((((l) & 0xff) << 16) | (((l) >> 16) & 0xff) | \
733  (((l) & 0x00ff00)))
734 
735 #define Swap32(l) ((((l) >> 24) & 0x000000ff)| \
736  (((l) & 0x00ff0000) >> 8) | \
737  (((l) & 0x0000ff00) << 8) | \
738  (((l) & 0x000000ff) << 24))
739 
740 
741 extern char rfbEndianTest;
742 
743 #define Swap16IfLE(s) (rfbEndianTest ? Swap16(s) : (s))
744 #define Swap24IfLE(l) (rfbEndianTest ? Swap24(l) : (l))
745 #define Swap32IfLE(l) (rfbEndianTest ? Swap32(l) : (l))
746 
747 /* UltraVNC uses some windows structures unmodified, so the viewer expects LittleEndian Data */
748 #define Swap16IfBE(s) (rfbEndianTest ? (s) : Swap16(s))
749 #define Swap24IfBE(l) (rfbEndianTest ? (l) : Swap24(l))
750 #define Swap32IfBE(l) (rfbEndianTest ? (l) : Swap32(l))
751 
752 /* sockets.c */
753 
754 extern int rfbMaxClientWait;
755 
756 extern void rfbInitSockets(rfbScreenInfoPtr rfbScreen);
757 extern void rfbShutdownSockets(rfbScreenInfoPtr rfbScreen);
758 extern void rfbDisconnectUDPSock(rfbScreenInfoPtr rfbScreen);
759 extern void rfbCloseClient(rfbClientPtr cl);
760 extern int rfbReadExact(rfbClientPtr cl, char *buf, int len);
761 extern int rfbReadExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout);
762 extern int rfbPeekExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout);
763 extern int rfbWriteExact(rfbClientPtr cl, const char *buf, int len);
764 extern int rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec);
765 extern rfbSocket rfbConnect(rfbScreenInfoPtr rfbScreen, char* host, int port);
766 extern rfbSocket rfbConnectToTcpAddr(char* host, int port);
767 extern rfbSocket rfbListenOnTCPPort(int port, in_addr_t iface);
768 extern rfbSocket rfbListenOnTCP6Port(int port, const char* iface);
769 extern rfbSocket rfbListenOnUDPPort(int port, in_addr_t iface);
770 extern int rfbStringToAddr(char* string,in_addr_t* addr);
772 
773 #ifdef LIBVNCSERVER_WITH_WEBSOCKETS
774 /* websockets.c */
775 
776 extern rfbBool webSocketsCheck(rfbClientPtr cl);
777 extern rfbBool webSocketCheckDisconnect(rfbClientPtr cl);
778 extern int webSocketsEncode(rfbClientPtr cl, const char *src, int len, char **dst);
779 extern int webSocketsDecode(rfbClientPtr cl, char *dst, int len);
780 extern rfbBool webSocketsHasDataInBuffer(rfbClientPtr cl);
781 #endif
782 
783 /* rfbserver.c */
784 
785 /* Routines to iterate over the client list in a thread-safe way.
786  Only a single iterator can be in use at a time process-wide. */
787 typedef struct rfbClientIterator *rfbClientIteratorPtr;
788 
789 extern void rfbClientListInit(rfbScreenInfoPtr rfbScreen);
790 extern rfbClientIteratorPtr rfbGetClientIterator(rfbScreenInfoPtr rfbScreen);
791 extern rfbClientPtr rfbClientIteratorNext(rfbClientIteratorPtr iterator);
793 extern void rfbIncrClientRef(rfbClientPtr cl);
794 extern void rfbDecrClientRef(rfbClientPtr cl);
795 
796 extern void rfbNewClientConnection(rfbScreenInfoPtr rfbScreen,rfbSocket sock);
797 extern rfbClientPtr rfbNewClient(rfbScreenInfoPtr rfbScreen,rfbSocket sock);
798 extern rfbClientPtr rfbNewUDPClient(rfbScreenInfoPtr rfbScreen);
799 extern rfbClientPtr rfbReverseConnection(rfbScreenInfoPtr rfbScreen,char *host, int port);
800 extern void rfbClientConnectionGone(rfbClientPtr cl);
801 extern void rfbProcessClientMessage(rfbClientPtr cl);
802 extern void rfbClientConnFailed(rfbClientPtr cl, const char *reason);
803 extern void rfbNewUDPConnection(rfbScreenInfoPtr rfbScreen,rfbSocket sock);
804 extern void rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen);
805 extern rfbBool rfbSendFramebufferUpdate(rfbClientPtr cl, sraRegionPtr updateRegion);
806 extern rfbBool rfbSendRectEncodingRaw(rfbClientPtr cl, int x,int y,int w,int h);
807 extern rfbBool rfbSendUpdateBuf(rfbClientPtr cl);
808 extern void rfbSendServerCutText(rfbScreenInfoPtr rfbScreen,char *str, int len);
809 #ifdef LIBVNCSERVER_HAVE_LIBZ
810 extern void rfbSendServerCutTextUTF8(rfbScreenInfoPtr rfbScreen,char *str, int len, char *fallbackLatin1Str, int latin1Len);
811 #endif
812 extern rfbBool rfbSendCopyRegion(rfbClientPtr cl,sraRegionPtr reg,int dx,int dy);
813 extern rfbBool rfbSendLastRectMarker(rfbClientPtr cl);
814 extern rfbBool rfbSendNewFBSize(rfbClientPtr cl, int w, int h);
815 extern rfbBool rfbSendExtDesktopSize(rfbClientPtr cl, int w, int h);
816 extern rfbBool rfbSendSetColourMapEntries(rfbClientPtr cl, int firstColour, int nColours);
817 extern void rfbSendBell(rfbScreenInfoPtr rfbScreen);
818 
819 extern char *rfbProcessFileTransferReadBuffer(rfbClientPtr cl, uint32_t length);
820 extern rfbBool rfbSendFileTransferChunk(rfbClientPtr cl);
821 extern rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer);
822 extern rfbBool rfbSendFileTransferMessage(rfbClientPtr cl, uint8_t contentType, uint8_t contentParam, uint32_t size, uint32_t length, const char *buffer);
823 extern char *rfbProcessFileTransferReadBuffer(rfbClientPtr cl, uint32_t length);
824 extern rfbBool rfbProcessFileTransfer(rfbClientPtr cl, uint8_t contentType, uint8_t contentParam, uint32_t size, uint32_t length);
825 
826 void rfbGotXCutText(rfbScreenInfoPtr rfbScreen, char *str, int len);
827 
828 /* translate.c */
829 
831 
832 extern void rfbTranslateNone(char *table, rfbPixelFormat *in,
833  rfbPixelFormat *out,
834  char *iptr, char *optr,
835  int bytesBetweenInputLines,
836  int width, int height);
837 extern rfbBool rfbSetTranslateFunction(rfbClientPtr cl);
838 extern rfbBool rfbSetClientColourMap(rfbClientPtr cl, int firstColour, int nColours);
839 extern void rfbSetClientColourMaps(rfbScreenInfoPtr rfbScreen, int firstColour, int nColours);
840 
841 /* httpd.c */
842 
843 extern void rfbHttpInitSockets(rfbScreenInfoPtr rfbScreen);
844 extern void rfbHttpShutdownSockets(rfbScreenInfoPtr rfbScreen);
845 extern void rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen);
846 
847 
848 
849 /* auth.c */
850 
851 extern void rfbAuthNewClient(rfbClientPtr cl);
852 extern void rfbProcessClientSecurityType(rfbClientPtr cl);
853 extern void rfbAuthProcessClientMessage(rfbClientPtr cl);
856 
857 /* rre.c */
858 
859 extern rfbBool rfbSendRectEncodingRRE(rfbClientPtr cl, int x,int y,int w,int h);
860 
861 
862 /* corre.c */
863 
864 extern rfbBool rfbSendRectEncodingCoRRE(rfbClientPtr cl, int x,int y,int w,int h);
865 
866 
867 /* hextile.c */
868 
869 extern rfbBool rfbSendRectEncodingHextile(rfbClientPtr cl, int x, int y, int w,
870  int h);
871 
872 /* ultra.c */
873 
874 /* Set maximum ultra rectangle size in pixels. Always allow at least
875  * two scan lines.
876  */
877 #define ULTRA_MAX_RECT_SIZE (128*256)
878 #define ULTRA_MAX_SIZE(min) ((( min * 2 ) > ULTRA_MAX_RECT_SIZE ) ? \
879  ( min * 2 ) : ULTRA_MAX_RECT_SIZE )
880 
881 extern rfbBool rfbSendRectEncodingUltra(rfbClientPtr cl, int x,int y,int w,int h);
882 
883 
884 #ifdef LIBVNCSERVER_HAVE_LIBZ
885 /* zlib.c */
886 
890 #define VNC_ENCODE_ZLIB_MIN_COMP_SIZE (17)
891 
892 /* Set maximum zlib rectangle size in pixels. Always allow at least
893  * two scan lines.
894  */
895 #define ZLIB_MAX_RECT_SIZE (128*256)
896 #define ZLIB_MAX_SIZE(min) ((( min * 2 ) > ZLIB_MAX_RECT_SIZE ) ? \
897  ( min * 2 ) : ZLIB_MAX_RECT_SIZE )
898 
899 extern rfbBool rfbSendRectEncodingZlib(rfbClientPtr cl, int x, int y, int w,
900  int h);
901 
902 #ifdef LIBVNCSERVER_HAVE_LIBJPEG
903 /* tight.c */
904 
905 #define TIGHT_DEFAULT_COMPRESSION 6
906 #define TURBO_DEFAULT_SUBSAMP 0
907 
908 extern int rfbNumCodedRectsTight(rfbClientPtr cl, int x,int y,int w,int h);
909 
910 extern rfbBool rfbSendRectEncodingTight(rfbClientPtr cl, int x,int y,int w,int h);
911 extern rfbBool rfbSendTightHeader(rfbClientPtr cl, int x, int y, int w, int h);
912 extern rfbBool rfbSendCompressedDataTight(rfbClientPtr cl, char *buf, int compressedLen);
913 
914 #if defined(LIBVNCSERVER_HAVE_LIBPNG)
915 extern rfbBool rfbSendRectEncodingTightPng(rfbClientPtr cl, int x,int y,int w,int h);
916 #endif
917 
918 #endif
919 #endif
920 
921 
922 /* cursor.c */
923 
924 typedef struct rfbCursor {
927  unsigned char *source;
928  unsigned char *mask;
929  unsigned short width, height, xhot, yhot;
930  unsigned short foreRed, foreGreen, foreBlue;
931  unsigned short backRed, backGreen, backBlue;
932  unsigned char *richSource;
933  unsigned char *alphaSource;
935 } rfbCursor, *rfbCursorPtr;
936 extern unsigned char rfbReverseByte[0x100];
937 
938 extern rfbBool rfbSendCursorShape(rfbClientPtr cl/*, rfbScreenInfoPtr pScreen*/);
939 extern rfbBool rfbSendCursorPos(rfbClientPtr cl);
940 extern void rfbConvertLSBCursorBitmapOrMask(int width,int height,unsigned char* bitmap);
941 extern rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskString);
942 extern char* rfbMakeMaskForXCursor(int width,int height,char* cursorString);
943 extern char* rfbMakeMaskFromAlphaSource(int width,int height,unsigned char* alphaSource);
944 extern void rfbMakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
945 extern void rfbMakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
946 extern void rfbFreeCursor(rfbCursorPtr cursor);
947 extern void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c);
948 
950 extern void rfbDefaultPtrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl);
951 
952 /* zrle.c */
953 #ifdef LIBVNCSERVER_HAVE_LIBZ
954 extern rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w,int h);
955 #endif
956 
957 /* stats.c */
958 
959 extern void rfbResetStats(rfbClientPtr cl);
960 extern void rfbPrintStats(rfbClientPtr cl);
961 
962 /* font.c */
963 
964 typedef struct rfbFontData {
965  unsigned char* data;
971  int* metaData;
972 } rfbFontData,* rfbFontDataPtr;
973 
974 int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,unsigned char c,rfbPixel colour);
975 void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,const char* string,rfbPixel colour);
977 int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,unsigned char c,int x1,int y1,int x2,int y2,rfbPixel colour,rfbPixel backColour);
978 void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,const char* string,int x1,int y1,int x2,int y2,rfbPixel colour,rfbPixel backColour);
979 int rfbWidthOfString(rfbFontDataPtr font,const char* string);
980 int rfbWidthOfChar(rfbFontDataPtr font,unsigned char c);
981 void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int* y2);
983 void rfbWholeFontBBox(rfbFontDataPtr font,int *x1, int *y1, int *x2, int *y2);
984 
986 rfbFontDataPtr rfbLoadConsoleFont(char *filename);
988 void rfbFreeFont(rfbFontDataPtr font);
989 
990 /* draw.c */
991 
992 void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col);
993 void rfbDrawPixel(rfbScreenInfoPtr s,int x,int y,rfbPixel col);
994 void rfbDrawLine(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,rfbPixel col);
995 
996 /* selbox.c */
997 
1002 typedef void (*SelectionChangedHookPtr)(int _index);
1003 extern int rfbSelectBox(rfbScreenInfoPtr rfbScreen,
1004  rfbFontDataPtr font, char** list,
1005  int x1, int y1, int x2, int y2,
1006  rfbPixel foreColour, rfbPixel backColour,
1007  int border,SelectionChangedHookPtr selChangedHook);
1008 
1009 /* cargs.c */
1010 
1011 extern void rfbUsage(void);
1012 extern void rfbPurgeArguments(int* argc,int* position,int count,char *argv[]);
1013 extern rfbBool rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]);
1014 extern rfbBool rfbProcessSizeArguments(int* width,int* height,int* bpp,int* argc, char *argv[]);
1015 
1016 /* main.c */
1017 
1018 extern void rfbLogEnable(int enabled);
1019 typedef void (*rfbLogProc)(const char *format, ...);
1021 extern void rfbLogPerror(const char *str);
1022 
1023 void rfbScheduleCopyRect(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2,int dx,int dy);
1024 void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,int dy);
1025 
1026 void rfbDoCopyRect(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2,int dx,int dy);
1027 void rfbDoCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,int dx,int dy);
1028 
1029 void rfbMarkRectAsModified(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2);
1030 void rfbMarkRegionAsModified(rfbScreenInfoPtr rfbScreen,sraRegionPtr modRegion);
1031 void rfbDoNothingWithClient(rfbClientPtr cl);
1032 enum rfbNewClientAction defaultNewClientHook(rfbClientPtr cl);
1035 struct _rfbProtocolExtension* rfbGetExtensionIterator(void);
1038  void* data);
1039 rfbBool rfbDisableExtension(rfbClientPtr cl, rfbProtocolExtension* extension);
1040 void* rfbGetExtensionClientData(rfbClientPtr cl, rfbProtocolExtension* extension);
1041 
1043 rfbBool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len);
1044 
1045 /* functions to make a vnc server */
1046 extern rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
1047  int width,int height,int bitsPerSample,int samplesPerPixel,
1048  int bytesPerPixel);
1049 extern void rfbInitServer(rfbScreenInfoPtr rfbScreen);
1050 extern void rfbShutdownServer(rfbScreenInfoPtr rfbScreen,rfbBool disconnectClients);
1051 extern void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen,char *framebuffer,
1052  int width,int height, int bitsPerSample,int samplesPerPixel,
1053  int bytesPerPixel);
1054 
1055 extern void rfbScreenCleanup(rfbScreenInfoPtr screenInfo);
1056 extern void rfbSetServerVersionIdentity(rfbScreenInfoPtr screen, char *fmt, ...);
1057 
1058 /* functions to accept/refuse a client that has been put on hold
1059  by a NewClientHookPtr function. Must not be called in other
1060  situations. */
1061 extern void rfbStartOnHoldClient(rfbClientPtr cl);
1062 extern void rfbRefuseOnHoldClient(rfbClientPtr cl);
1063 
1064 /* call one of these two functions to service the vnc clients.
1065  usec are the microseconds the select on the fds waits.
1066  if you are using the event loop, set this to some value > 0, so the
1067  server doesn't get a high load just by listening.
1068  rfbProcessEvents() returns TRUE if an update was pending. */
1069 
1070 extern void rfbRunEventLoop(rfbScreenInfoPtr screenInfo, long usec, rfbBool runInBackground);
1071 extern rfbBool rfbProcessEvents(rfbScreenInfoPtr screenInfo,long usec);
1072 extern rfbBool rfbIsActive(rfbScreenInfoPtr screenInfo);
1073 
1084 
1085 /* Statistics */
1086 extern char *messageNameServer2Client(uint32_t type, char *buf, int len);
1087 extern char *messageNameClient2Server(uint32_t type, char *buf, int len);
1088 extern char *encodingName(uint32_t enc, char *buf, int len);
1089 
1090 extern rfbStatList *rfbStatLookupEncoding(rfbClientPtr cl, uint32_t type);
1091 extern rfbStatList *rfbStatLookupMessage(rfbClientPtr cl, uint32_t type);
1092 
1093 /* Each call to rfbStatRecord* adds one to the rect count for that type */
1094 extern void rfbStatRecordEncodingSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw);
1095 extern void rfbStatRecordEncodingSentAdd(rfbClientPtr cl, uint32_t type, int byteCount); /* Specifically for tight encoding */
1096 extern void rfbStatRecordEncodingRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw);
1097 extern void rfbStatRecordMessageSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw);
1098 extern void rfbStatRecordMessageRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw);
1099 extern void rfbResetStats(rfbClientPtr cl);
1100 extern void rfbPrintStats(rfbClientPtr cl);
1101 
1102 extern int rfbStatGetSentBytes(rfbClientPtr cl);
1103 extern int rfbStatGetSentBytesIfRaw(rfbClientPtr cl);
1104 extern int rfbStatGetRcvdBytes(rfbClientPtr cl);
1105 extern int rfbStatGetRcvdBytesIfRaw(rfbClientPtr cl);
1106 extern int rfbStatGetMessageCountSent(rfbClientPtr cl, uint32_t type);
1107 extern int rfbStatGetMessageCountRcvd(rfbClientPtr cl, uint32_t type);
1108 extern int rfbStatGetEncodingCountSent(rfbClientPtr cl, uint32_t type);
1109 extern int rfbStatGetEncodingCountRcvd(rfbClientPtr cl, uint32_t type);
1110 
1112 extern void rfbSetProtocolVersion(rfbScreenInfoPtr rfbScreen, int major_, int minor_);
1113 
1115 extern rfbBool rfbSendTextChatMessage(rfbClientPtr cl, uint32_t length, char *buffer);
1116 
1117 
1118 /*
1119  * Additions for Qt event loop integration
1120  * Original idea taken from vino.
1121  */
1122 rfbBool rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen);
1123 rfbBool rfbUpdateClient(rfbClientPtr cl);
1124 
1125 
1126 #if(defined __cplusplus)
1127 }
1128 #endif
1129 
1304 #endif
int y
Definition: SDLvncviewer.c:34
int x
Definition: SDLvncviewer.c:34
rfbLogProc rfbErr
Definition: rfb.h:1020
void rfbSetCursor(rfbScreenInfoPtr rfbScreen, rfbCursorPtr c)
void rfbPurgeArguments(int *argc, int *position, int count, char *argv[])
rfbBool(* rfbGetExtDesktopScreenPtr)(int seqnumber, struct rfbExtDesktopScreen *extDesktopScreen, struct _rfbClientRec *cl)
Definition: rfb.h:121
struct rfbClientIterator * rfbClientIteratorPtr
Definition: rfb.h:787
void rfbDoCopyRect(rfbScreenInfoPtr rfbScreen, int x1, int y1, int x2, int y2, int dx, int dy)
void rfbFreeFont(rfbFontDataPtr font)
free a dynamically loaded font
void(* rfbSetXCutTextProcPtr)(char *str, int len, struct _rfbClientRec *cl)
Definition: rfb.h:106
rfbClientIteratorPtr rfbGetClientIterator(rfbScreenInfoPtr rfbScreen)
int rfbStatGetMessageCountSent(rfbClientPtr cl, uint32_t type)
void rfbFreeCursor(rfbCursorPtr cursor)
void rfbHttpCheckFds(rfbScreenInfoPtr rfbScreen)
void rfbDisconnectUDPSock(rfbScreenInfoPtr rfbScreen)
rfbBool rfbSendRectEncodingRaw(rfbClientPtr cl, int x, int y, int w, int h)
rfbBool rfbSetTranslateFunction(rfbClientPtr cl)
rfbBool(* rfbSetTranslateFunctionProcPtr)(struct _rfbClientRec *cl)
Definition: rfb.h:111
int rfbStatGetSentBytesIfRaw(rfbClientPtr cl)
void rfbStartOnHoldClient(rfbClientPtr cl)
void rfbRunEventLoop(rfbScreenInfoPtr screenInfo, long usec, rfbBool runInBackground)
enum rfbNewClientAction defaultNewClientHook(rfbClientPtr cl)
rfbClientPtr rfbNewUDPClient(rfbScreenInfoPtr rfbScreen)
int rfbDrawCharWithClip(rfbScreenInfoPtr rfbScreen, rfbFontDataPtr font, int x, int y, unsigned char c, int x1, int y1, int x2, int y2, rfbPixel colour, rfbPixel backColour)
if colour==backColour, background is transparent
rfbBool rfbProcessFileTransfer(rfbClientPtr cl, uint8_t contentType, uint8_t contentParam, uint32_t size, uint32_t length)
struct _wsCtx wsCtx
Definition: rfb.h:423
rfbBool rfbDisableExtension(rfbClientPtr cl, rfbProtocolExtension *extension)
void rfbCloseClient(rfbClientPtr cl)
void rfbMarkRegionAsModified(rfbScreenInfoPtr rfbScreen, sraRegionPtr modRegion)
void rfbUnregisterProtocolExtension(rfbProtocolExtension *extension)
void rfbRegisterTightVNCFileTransferExtension(void)
Register the TightVNC-1.3.x file transfer extension.
rfbBool rfbSendFileTransferChunk(rfbClientPtr cl)
rfbBool rfbSendUpdateBuf(rfbClientPtr cl)
rfbSocket rfbListenOnTCPPort(int port, in_addr_t iface)
int rfbCheckFds(rfbScreenInfoPtr rfbScreen, long usec)
int rfbReadExact(rfbClientPtr cl, char *buf, int len)
#define rfbInitServer
Definition: rfb.h:83
int rfbStatGetEncodingCountRcvd(rfbClientPtr cl, uint32_t type)
rfbBool rfbSendRectEncodingCoRRE(rfbClientPtr cl, int x, int y, int w, int h)
char * rfbProcessFileTransferReadBuffer(rfbClientPtr cl, uint32_t length)
int rfbDrawChar(rfbScreenInfoPtr rfbScreen, rfbFontDataPtr font, int x, int y, unsigned char c, rfbPixel colour)
void rfbRefuseOnHoldClient(rfbClientPtr cl)
void rfbMarkRectAsModified(rfbScreenInfoPtr rfbScreen, int x1, int y1, int x2, int y2)
void rfbResetStats(rfbClientPtr cl)
char * rfbMakeMaskForXCursor(int width, int height, char *cursorString)
int(* rfbGetKeyboardLedStateHookPtr)(struct _rfbScreenInfo *screen)
support the capability to view the caps/num/scroll states of the X server
Definition: rfb.h:117
rfbBool rfbSetNonBlocking(rfbSocket sock)
void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen, sraRegionPtr copyRegion, int dx, int dy)
void rfbGotXCutText(rfbScreenInfoPtr rfbScreen, char *str, int len)
rfbBool rfbSendTextChatMessage(rfbClientPtr cl, uint32_t length, char *buffer)
send a TextChat message to a client
rfbFontDataPtr rfbLoadConsoleFont(char *filename)
dynamically load a linux console font (4096 bytes, 256 glyphs a 8x16
void rfbSetProtocolVersion(rfbScreenInfoPtr rfbScreen, int major_, int minor_)
Set which version you want to advertise 3.3, 3.6, 3.7 and 3.8 are currently supported.
int rfbSelectBox(rfbScreenInfoPtr rfbScreen, rfbFontDataPtr font, char **list, int x1, int y1, int x2, int y2, rfbPixel foreColour, rfbPixel backColour, int border, SelectionChangedHookPtr selChangedHook)
void rfbMakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen, rfbCursorPtr cursor)
void rfbNewClientConnection(rfbScreenInfoPtr rfbScreen, rfbSocket sock)
void rfbDrawStringWithClip(rfbScreenInfoPtr rfbScreen, rfbFontDataPtr font, int x, int y, const char *string, int x1, int y1, int x2, int y2, rfbPixel colour, rfbPixel backColour)
char rfbEndianTest
rfbBool rfbSendFramebufferUpdate(rfbClientPtr cl, sraRegionPtr updateRegion)
void rfbScheduleCopyRect(rfbScreenInfoPtr rfbScreen, int x1, int y1, int x2, int y2, int dx, int dy)
void rfbReleaseClientIterator(rfbClientIteratorPtr iterator)
void rfbDoNothingWithClient(rfbClientPtr cl)
int rfbWidthOfString(rfbFontDataPtr font, const char *string)
void(* SelectionChangedHookPtr)(int _index)
this opens a modal select box.
Definition: rfb.h:1002
void rfbHttpInitSockets(rfbScreenInfoPtr rfbScreen)
void rfbWholeFontBBox(rfbFontDataPtr font, int *x1, int *y1, int *x2, int *y2)
this returns the smallest box enclosing any character of font.
rfbBool rfbSendSetColourMapEntries(rfbClientPtr cl, int firstColour, int nColours)
void(* ClientGoneHookPtr)(struct _rfbClientRec *cl)
Definition: rfb.h:398
void rfbTranslateNone(char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height)
rfbSocketState
Definition: rfb.h:97
void rfbClientConnectionGone(rfbClientPtr cl)
rfbBool rfbProcessArguments(rfbScreenInfoPtr rfbScreen, int *argc, char *argv[])
rfbBool rfbSendLastRectMarker(rfbClientPtr cl)
rfbBool rfbSetClientColourMap(rfbClientPtr cl, int firstColour, int nColours)
rfbStatList * rfbStatLookupEncoding(rfbClientPtr cl, uint32_t type)
void rfbUnregisterSecurityHandler(rfbSecurityHandler *handler)
struct sraRegion * sraRegionPtr
Definition: rfb.h:392
void rfbClientConnFailed(rfbClientPtr cl, const char *reason)
void rfbStatRecordMessageRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw)
rfbBool rfbSendRectEncodingRRE(rfbClientPtr cl, int x, int y, int w, int h)
rfbBool rfbProcessSizeArguments(int *width, int *height, int *bpp, int *argc, char *argv[])
rfbClientPtr rfbReverseConnection(rfbScreenInfoPtr rfbScreen, char *host, int port)
void rfbProcessClientMessage(rfbClientPtr cl)
int rfbStatGetRcvdBytes(rfbClientPtr cl)
void rfbConvertLSBCursorBitmapOrMask(int width, int height, unsigned char *bitmap)
void rfbShutdownServer(rfbScreenInfoPtr rfbScreen, rfbBool disconnectClients)
void rfbStatRecordEncodingSentAdd(rfbClientPtr cl, uint32_t type, int byteCount)
void rfbDrawLine(rfbScreenInfoPtr s, int x1, int y1, int x2, int y2, rfbPixel col)
void rfbAuthProcessClientMessage(rfbClientPtr cl)
void rfbDefaultPtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl)
cursor handling for the pointer
void rfbFillRect(rfbScreenInfoPtr s, int x1, int y1, int x2, int y2, rfbPixel col)
void(* ClientFramebufferUpdateRequestHookPtr)(struct _rfbClientRec *cl, rfbFramebufferUpdateRequestMsg *furMsg)
Definition: rfb.h:399
void rfbLogPerror(const char *str)
int rfbStringToAddr(char *string, in_addr_t *addr)
struct _rfbProtocolExtension * rfbGetExtensionIterator(void)
rfbBool rfbEnableExtension(rfbClientPtr cl, rfbProtocolExtension *extension, void *data)
void rfbScreenCleanup(rfbScreenInfoPtr screenInfo)
rfbBool rfbSendCursorPos(rfbClientPtr cl)
void(* rfbDisplayHookPtr)(struct _rfbClientRec *cl)
Definition: rfb.h:114
void rfbSetServerVersionIdentity(rfbScreenInfoPtr screen, char *fmt,...)
rfbBool rfbUpdateClient(rfbClientPtr cl)
int rfbWidthOfChar(rfbFontDataPtr font, unsigned char c)
rfbScreenInfoPtr rfbGetScreen(int *argc, char **argv, int width, int height, int bitsPerSample, int samplesPerPixel, int bytesPerPixel)
rfbBool rfbSendRectEncodingUltra(rfbClientPtr cl, int x, int y, int w, int h)
rfbBool rfbSendCursorShape(rfbClientPtr cl)
rfbLogProc rfbLog
unsigned char rfbReverseByte[0x100]
void rfbRegisterProtocolExtension(rfbProtocolExtension *extension)
rfbStatList * rfbStatLookupMessage(rfbClientPtr cl, uint32_t type)
void rfbIncrClientRef(rfbClientPtr cl)
char * rfbMakeMaskFromAlphaSource(int width, int height, unsigned char *alphaSource)
rfbBool rfbSendFileTransferMessage(rfbClientPtr cl, uint8_t contentType, uint8_t contentParam, uint32_t size, uint32_t length, const char *buffer)
void rfbNewUDPConnection(rfbScreenInfoPtr rfbScreen, rfbSocket sock)
void(* rfbSetSingleWindowProcPtr)(struct _rfbClientRec *cl, int x, int y)
If x==1 and y==1 then set the whole display else find the window underneath x and y and set the frame...
Definition: rfb.h:127
rfbBool rfbIsActive(rfbScreenInfoPtr screenInfo)
void rfbUnregisterTightVNCFileTransferExtension(void)
Unregister the TightVNC-1.3.x file transfer extension.
char * encodingName(uint32_t enc, char *buf, int len)
rfbBool rfbSendDirContent(rfbClientPtr cl, int length, char *buffer)
int(* rfbNumberOfExtDesktopScreensPtr)(struct _rfbClientRec *cl)
Definition: rfb.h:120
rfbBool rfbProcessEvents(rfbScreenInfoPtr screenInfo, long usec)
rfbSocket rfbListenOnTCP6Port(int port, const char *iface)
char * messageNameClient2Server(uint32_t type, char *buf, int len)
rfbBool(* rfbPasswordCheckProcPtr)(struct _rfbClientRec *cl, const char *encryptedPassWord, int len)
Definition: rfb.h:112
void * rfbGetExtensionClientData(rfbClientPtr cl, rfbProtocolExtension *extension)
rfbBool rfbSendRectEncodingHextile(rfbClientPtr cl, int x, int y, int w, int h)
void rfbDoCopyRegion(rfbScreenInfoPtr rfbScreen, sraRegionPtr copyRegion, int dx, int dy)
rfbClientPtr rfbClientIteratorNext(rfbClientIteratorPtr iterator)
void rfbReleaseExtensionIterator(void)
void rfbAuthNewClient(rfbClientPtr cl)
void(* rfbSetServerInputProcPtr)(struct _rfbClientRec *cl, int status)
Status determines if the X11 server permits input from the local user status==0 or 1.
Definition: rfb.h:132
void(* rfbPtrAddEventProcPtr)(int buttonMask, int x, int y, struct _rfbClientRec *cl)
Definition: rfb.h:105
int rfbMaxClientWait
enum rfbNewClientAction(* rfbNewClientHookPtr)(struct _rfbClientRec *cl)
Definition: rfb.h:113
int rfbStatGetEncodingCountSent(rfbClientPtr cl, uint32_t type)
void rfbDecrClientRef(rfbClientPtr cl)
rfbSocket rfbConnect(rfbScreenInfoPtr rfbScreen, char *host, int port)
void rfbDrawPixel(rfbScreenInfoPtr s, int x, int y, rfbPixel col)
rfbSocket rfbConnectToTcpAddr(char *host, int port)
rfbBool rfbEconomicTranslate
struct _rfbSslCtx rfbSslCtx
Definition: rfb.h:422
void rfbDrawString(rfbScreenInfoPtr rfbScreen, rfbFontDataPtr font, int x, int y, const char *string, rfbPixel colour)
int rfbWriteExact(rfbClientPtr cl, const char *buf, int len)
void rfbSetClientColourMaps(rfbScreenInfoPtr rfbScreen, int firstColour, int nColours)
rfbBool rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
void rfbStatRecordMessageSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw)
int rfbStatGetSentBytes(rfbClientPtr cl)
void(* rfbTranslateFnType)(char *table, rfbPixelFormat *in, rfbPixelFormat *out, char *iptr, char *optr, int bytesBetweenInputLines, int width, int height)
rfbTranslateFnType is the type of translation functions.
Definition: rfb.h:382
void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen, char *framebuffer, int width, int height, int bitsPerSample, int samplesPerPixel, int bytesPerPixel)
void rfbHttpShutdownSockets(rfbScreenInfoPtr rfbScreen)
void(* rfbKbdReleaseAllKeysProcPtr)(struct _rfbClientRec *cl)
Definition: rfb.h:104
void rfbMakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen, rfbCursorPtr cursor)
void rfbClientListInit(rfbScreenInfoPtr rfbScreen)
void rfbLogEnable(int enabled)
rfbBool(* rfbXvpHookPtr)(struct _rfbClientRec *cl, uint8_t, uint8_t)
Definition: rfb.h:118
void rfbPrintStats(rfbClientPtr cl)
rfbClientPtr rfbNewClient(rfbScreenInfoPtr rfbScreen, rfbSocket sock)
rfbBool rfbSendExtDesktopSize(rfbClientPtr cl, int w, int h)
void(* rfbKbdAddEventProcPtr)(rfbBool down, rfbKeySym keySym, struct _rfbClientRec *cl)
Definition: rfb.h:103
void rfbProcessClientSecurityType(rfbClientPtr cl)
rfbBool rfbSendNewFBSize(rfbClientPtr cl, int w, int h)
int(* rfbSetDesktopSizeHookPtr)(int width, int height, int numScreens, struct rfbExtDesktopScreen *extDesktopScreens, struct _rfbClientRec *cl)
Definition: rfb.h:119
int rfbReadExactTimeout(rfbClientPtr cl, char *buf, int len, int timeout)
int rfbStatGetMessageCountRcvd(rfbClientPtr cl, uint32_t type)
int rfbPeekExactTimeout(rfbClientPtr cl, char *buf, int len, int timeout)
rfbCursorPtr rfbMakeXCursor(int width, int height, char *cursorString, char *maskString)
char * messageNameServer2Client(uint32_t type, char *buf, int len)
void(* rfbSetTextChat)(struct _rfbClientRec *cl, int length, char *string)
Handle the textchat messages.
Definition: rfb.h:139
void rfbUsage(void)
void(* rfbDisplayFinishedHookPtr)(struct _rfbClientRec *cl, int result)
Definition: rfb.h:115
void(* rfbLogProc)(const char *format,...)
Definition: rfb.h:1019
rfbBool rfbCheckPasswordByList(rfbClientPtr cl, const char *response, int len)
to check against plain passwords
void rfbStatRecordEncodingRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw)
rfbSocket rfbListenOnUDPPort(int port, in_addr_t iface)
void rfbFontBBox(rfbFontDataPtr font, unsigned char c, int *x1, int *y1, int *x2, int *y2)
rfbNewClientAction
Definition: rfb.h:91
void rfbSendServerCutText(rfbScreenInfoPtr rfbScreen, char *str, int len)
void rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen)
void rfbRegisterSecurityHandler(rfbSecurityHandler *handler)
void rfbSendBell(rfbScreenInfoPtr rfbScreen)
void rfbShutdownSockets(rfbScreenInfoPtr rfbScreen)
rfbBool rfbSendCopyRegion(rfbClientPtr cl, sraRegionPtr reg, int dx, int dy)
void rfbStatRecordEncodingSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw)
int rfbStatGetRcvdBytesIfRaw(rfbClientPtr cl)
int(* rfbFileTransferPermitted)(struct _rfbClientRec *cl)
Permit the server to allow or deny filetransfers.
Definition: rfb.h:137
void rfbInitSockets(rfbScreenInfoPtr rfbScreen)
@ RFB_SOCKET_READY
Definition: rfb.h:99
@ RFB_SOCKET_INIT
Definition: rfb.h:98
@ RFB_SOCKET_SHUTDOWN
Definition: rfb.h:100
@ RFB_CLIENT_ACCEPT
Definition: rfb.h:92
@ RFB_CLIENT_REFUSE
Definition: rfb.h:94
@ RFB_CLIENT_ON_HOLD
Definition: rfb.h:93
#define UPDATE_BUF_SIZE
UPDATE_BUF_SIZE must be big enough to send at least one whole line of the framebuffer.
Definition: rfb.h:570
int8_t rfbBool
Definition: rfbproto.h:108
uint32_t rfbKeySym
Definition: rfbproto.h:122
uint32_t rfbPixel
Definition: rfbproto.h:123
#define rfbZRLETileHeight
Definition: rfbproto.h:951
#define rfbZRLETileWidth
Definition: rfbproto.h:950
#define CHALLENGESIZE
Definition: rfbproto.h:1555
#define rfbSocket
Definition: rfbproto.h:104
struct sraRegion sraRegion
Definition: rfbregion.h:18
rfbBool compStreamInitedLZO
Definition: rfb.h:602
struct _rfbClientRec * prev
Definition: rfb.h:624
rfbBool enableServerIdentity
client supports ServerIdentity encoding
Definition: rfb.h:610
char * translateLookupTable
Definition: rfb.h:561
rfbBool readyForSetColourMapEntries
Definition: rfb.h:500
struct _rfbClientRec * next
Definition: rfb.h:625
char * zrleBeforeBuf
for threaded zrle
Definition: rfb.h:655
char * host
Definition: rfb.h:446
ClientFramebufferUpdateRequestHookPtr clientFramebufferUpdateRequestHook
clientFramebufferUpdateRequestHook is called when a client requests a frame buffer update.
Definition: rfb.h:690
rfbSslCtx * sslctx
Definition: rfb.h:679
rfbBool enableCursorShapeUpdates
client supports cursor shape updates
Definition: rfb.h:613
rfbBool PalmVNC
how did the client tell us it wanted the screen changed? Ultra style or palm style?
Definition: rfb.h:433
void * clientData
private data.
Definition: rfb.h:442
rfbBool cursorWasChanged
cursor shape update should be sent
Definition: rfb.h:616
rfbBool onHold
Definition: rfb.h:499
sraRegionPtr requestedRegion
As part of the FramebufferUpdateRequest, a client can express interest in a subrectangle of the whole...
Definition: rfb.h:543
int afterEncBufLen
Definition: rfb.h:670
int ublen
Definition: rfb.h:573
char * beforeEncBuf
for thread safety for rfbSendFBUpdate()
Definition: rfb.h:666
char * wspath
Definition: rfb.h:681
int afterEncBufSize
Definition: rfb.h:669
int progressiveSliceY
if progressive updating is on, this variable holds the current y coordinate of the progressive slice.
Definition: rfb.h:650
rfbBool enableCursorPosUpdates
client supports cursor position updates
Definition: rfb.h:614
int protocolMajorVersion
Definition: rfb.h:449
rfbBool enableSupportedEncodings
client supports SupportedEncodings encoding
Definition: rfb.h:609
rfbExtensionData * extensions
Definition: rfb.h:652
int rawBytesEquivalent
Definition: rfb.h:578
rfbBool useExtDesktopSize
Definition: rfb.h:692
rfbTranslateFnType translateFn
translateFn points to the translation function which is used to copy and translate a rectangle from t...
Definition: rfb.h:560
int lastPtrButtons
Definition: rfb.h:555
rfbBool useRichCursorEncoding
rfbEncodingRichCursor is preferred
Definition: rfb.h:615
int preferredEncoding
Definition: rfb.h:502
rfbBool cursorWasMoved
cursor position update should be sent
Definition: rfb.h:617
rfbBool newFBSizePending
framebuffer size was changed
Definition: rfb.h:622
char * lzoWrkMem
Definition: rfb.h:603
rfbBool useNewFBSize
client supports NewFBSize encoding
Definition: rfb.h:621
ClientGoneHookPtr clientGoneHook
Definition: rfb.h:443
struct _rfbStatList * statEncList
Definition: rfb.h:576
int copyDX
Definition: rfb.h:534
sraRegionPtr modifiedRegion
Definition: rfb.h:536
rfbScreenInfoPtr scaledScreen
points to a scaled version of the screen buffer in cl->scaledScreenList
Definition: rfb.h:431
struct _rfbStatList * statMsgList
Definition: rfb.h:577
int lastPtrX
Definition: rfb.h:553
wsCtx * wsctx
Definition: rfb.h:680
int lastPtrY
Definition: rfb.h:554
rfbSocket sock
Definition: rfb.h:445
rfbBool useCopyRect
Definition: rfb.h:501
sraRegionPtr copyRegion
the destination region of the copy
Definition: rfb.h:533
rfbBool enableLastRectEncoding
client supports LastRect encoding
Definition: rfb.h:612
int cursorX
Definition: rfb.h:618
rfbFileTransferData fileTransfer
Definition: rfb.h:605
rfbBool enableKeyboardLedState
client supports KeyboardState encoding
Definition: rfb.h:611
void * paletteHelper
Definition: rfb.h:656
int lastKeyboardLedState
keep track of last value so we can send change events
Definition: rfb.h:607
int bytesSent
Definition: rfb.h:579
char * afterEncBuf
Definition: rfb.h:668
int correMaxHeight
Definition: rfb.h:503
int requestedDesktopSizeChange
Definition: rfb.h:693
int lastDesktopSizeChangeError
Definition: rfb.h:694
@ RFB_AUTHENTICATION
authenticating
Definition: rfb.h:487
@ RFB_SECURITY_TYPE
negotiating security (RFB v.3.7)
Definition: rfb.h:486
@ RFB_INITIALISATION
sending initialisation messages
Definition: rfb.h:488
@ RFB_PROTOCOL_VERSION
establishing protocol version
Definition: rfb.h:485
@ RFB_INITIALISATION_SHARED
sending initialisation messages with implicit shared-flag already true
Definition: rfb.h:494
@ RFB_NORMAL
normal protocol messages
Definition: rfb.h:489
rfbBool reverseConnection
Definition: rfb.h:498
rfbBool enableSupportedMessages
client supports SupportedMessages encoding
Definition: rfb.h:608
int beforeEncBufSize
Definition: rfb.h:667
int protocolMinorVersion
Definition: rfb.h:450
rfbScreenInfoPtr screen
back pointer to the screen
Definition: rfb.h:428
rfbBool viewOnly
Definition: rfb.h:505
rfbPixelFormat format
Definition: rfb.h:562
uint8_t * bytes
Definition: rfb.h:145
uint16_t * shorts
Definition: rfb.h:146
uint32_t count
Definition: rfb.h:142
rfbBool is16
is the data format short?
Definition: rfb.h:143
Definition: rfb.h:924
unsigned short yhot
metrics
Definition: rfb.h:929
rfbBool cleanupSource
Definition: rfb.h:926
rfbBool cleanupMask
Definition: rfb.h:926
unsigned char * mask
points to bits
Definition: rfb.h:928
unsigned short backRed
Definition: rfb.h:931
unsigned short backBlue
device-independent colour
Definition: rfb.h:931
unsigned short width
Definition: rfb.h:929
unsigned short foreRed
Definition: rfb.h:930
unsigned short height
Definition: rfb.h:929
unsigned short foreGreen
Definition: rfb.h:930
unsigned short backGreen
Definition: rfb.h:931
unsigned short foreBlue
device-independent colour
Definition: rfb.h:930
unsigned char * source
points to bits
Definition: rfb.h:927
rfbBool cleanupRichSource
Definition: rfb.h:926
rfbBool cleanup
set this to true if LibVNCServer has to free this cursor
Definition: rfb.h:926
unsigned short xhot
Definition: rfb.h:929
unsigned char * richSource
source bytes for a rich cursor
Definition: rfb.h:932
rfbBool alphaPreMultiplied
if richSource already has alpha applied
Definition: rfb.h:934
unsigned char * alphaSource
source for alpha blending info
Definition: rfb.h:933
rfbProtocolExtension * extension
Definition: rfb.h:190
struct _rfbExtensionData * next
Definition: rfb.h:192
void * data
Definition: rfb.h:191
int compressionEnabled
Definition: rfb.h:403
int * metaData
metaData is a 256*5 array: for each character (offset,width,height,x,y)
Definition: rfb.h:971
unsigned char * data
Definition: rfb.h:965
Protocol extension handling.
Definition: rfb.h:164
struct _rfbProtocolExtension * next
Definition: rfb.h:186
int * pseudoEncodings
if pseudoEncodings is not NULL, it contains a 0 terminated list of the pseudo encodings handled by th...
Definition: rfb.h:173
Per-screen (framebuffer) structure.
Definition: rfb.h:202
rfbBool httpInitDone
Definition: rfb.h:255
void * authPasswdData
Definition: rfb.h:263
char * httpDir
Definition: rfb.h:258
rfbKbdReleaseAllKeysProcPtr kbdReleaseAllKeys
Definition: rfb.h:295
rfbSocket httpListen6Sock
Definition: rfb.h:355
rfbBool httpEnableProxyConnect
Definition: rfb.h:256
rfbPtrAddEventProcPtr ptrAddEvent
Definition: rfb.h:296
int maxFd
Definition: rfb.h:235
rfbSocket listenSock
Definition: rfb.h:233
int width
Definition: rfb.h:207
rfbGetCursorProcPtr getCursorPtr
Definition: rfb.h:298
in_addr_t listenInterface
Definition: rfb.h:326
int deferUpdateTime
this is the amount of milliseconds to wait at least before sending an update.
Definition: rfb.h:272
rfbBool ignoreSIGPIPE
if TRUE, an ignoring signal handler is installed for SIGPIPE
Definition: rfb.h:319
rfbSetSingleWindowProcPtr setSingleWindow
Definition: rfb.h:300
char * sslcertfile
Definition: rfb.h:347
int maxRectsPerUpdate
send only this many rectangles in one update
Definition: rfb.h:269
char * listen6Interface
Definition: rfb.h:349
rfbKbdAddEventProcPtr kbdAddEvent
Definition: rfb.h:294
rfbSocket udpSock
Definition: rfb.h:247
rfbXvpHookPtr xvpHook
xvpHook is called to handle an xvp client message
Definition: rfb.h:345
int protocolMajorVersion
What does the server tell the new clients which version it supports.
Definition: rfb.h:336
rfbNumberOfExtDesktopScreensPtr numberOfExtDesktopScreensHook
Optional hooks to query ExtendedDesktopSize screen information.
Definition: rfb.h:360
int scaledScreenRefCount
Definition: rfb.h:205
int port
Definition: rfb.h:232
rfbPixel whitePixel
Definition: rfb.h:215
rfbGetKeyboardLedStateHookPtr getKeyboardLedStateHook
These hooks are called to pass keyboard state back to the client.
Definition: rfb.h:311
rfbDisplayFinishedHookPtr displayFinishedHook
displayFinishedHook is called just after a frame buffer update
Definition: rfb.h:343
int maxSock
Definition: rfb.h:234
char * sslkeyfile
Definition: rfb.h:346
rfbSetServerInputProcPtr setServerInput
Definition: rfb.h:301
rfbDisplayHookPtr displayHook
displayHook is called just before a frame buffer update
Definition: rfb.h:308
rfbBool dontConvertRichCursorToXCursor
Definition: rfb.h:286
struct _rfbClientRec * clientHead
Definition: rfb.h:279
rfbSocket inetdSock
Definition: rfb.h:243
struct rfbCursor * cursor
Definition: rfb.h:287
int sizeInBytes
Definition: rfb.h:212
rfbGetExtDesktopScreenPtr getExtDesktopScreenHook
Definition: rfb.h:361
rfbSetTranslateFunctionProcPtr setTranslateFunction
Definition: rfb.h:299
struct _rfbScreenInfo * scaledScreenNext
this structure has children that are scaled versions of this screen
Definition: rfb.h:204
int progressiveSliceHeight
if not zero, only a slice of this height is processed every time an update should be sent.
Definition: rfb.h:324
rfbSetXCutTextProcPtr setXCutText
Definition: rfb.h:297
rfbSetDesktopSizeHookPtr setDesktopSizeHook
hook to let client set resolution
Definition: rfb.h:357
int maxClientWait
Definition: rfb.h:252
int paddedWidthInBytes
Definition: rfb.h:208
rfbBool dontDisconnect
Definition: rfb.h:278
rfbPixelFormat serverFormat
Definition: rfb.h:226
char * frameBuffer
the frameBuffer has to be supplied by the serving process.
Definition: rfb.h:293
rfbPasswordCheckProcPtr passwordCheck
Definition: rfb.h:262
rfbSetTextChat setTextChat
Definition: rfb.h:303
int cursorX
Definition: rfb.h:284
struct _rfbClientRec * pointerClient
"Mutex" for pointer events
Definition: rfb.h:280
int udpPort
Definition: rfb.h:246
float fdQuota
This value between 0 and 1.0 defines which fraction of the maximum number of file descriptors LibVNCS...
Definition: rfb.h:365
int deferPtrUpdateTime
Definition: rfb.h:327
char * versionString
rfbEncodingServerIdentity
Definition: rfb.h:333
const char * desktopName
Definition: rfb.h:228
rfbBool permitFileTransfer
command line authorization of file transfers
Definition: rfb.h:340
rfbPixel blackPixel
Definition: rfb.h:214
rfbBool autoPort
Definition: rfb.h:231
int httpPort
Definition: rfb.h:257
rfbColourMap colourMap
set this if rfbServerFormat.trueColour==FALSE
Definition: rfb.h:227
int depth
Definition: rfb.h:210
char * underCursorBuffer
Definition: rfb.h:285
int height
Definition: rfb.h:209
rfbBool handleEventsEagerly
handle as many input events as possible (default off)
Definition: rfb.h:330
rfbSocket httpListenSock
Definition: rfb.h:259
rfbBool inetdInitDone
Definition: rfb.h:244
rfbSocket httpSock
Definition: rfb.h:260
int ipv6port
The port to listen on when using IPv6.
Definition: rfb.h:348
void * screenData
some screen specific data can be put into a struct where screenData points to.
Definition: rfb.h:222
fd_set allFds
Definition: rfb.h:239
int authPasswdFirstViewOnly
If rfbAuthPasswdData is given a list, this is the first view only password.
Definition: rfb.h:266
int protocolMinorVersion
Definition: rfb.h:337
rfbNewClientHookPtr newClientHook
newClientHook is called just after a new client is created
Definition: rfb.h:306
int http6Port
Definition: rfb.h:354
rfbBool alwaysShared
Definition: rfb.h:276
rfbFileTransferPermitted getFileTransferPermission
Definition: rfb.h:302
int bitsPerPixel
Definition: rfb.h:211
rfbSocket listen6Sock
Definition: rfb.h:353
rfbBool neverShared
Definition: rfb.h:277
struct _rfbClientRec * udpClient
Definition: rfb.h:248
Security handling (RFB protocol version 3.7)
Definition: rfb.h:154
uint8_t type
Definition: rfb.h:155
struct _rfbSecurity * next
Definition: rfb.h:157
uint32_t bytesSent
Definition: rfb.h:414
uint32_t bytesSentIfRaw
Definition: rfb.h:415
uint32_t sentCount
Definition: rfb.h:413
uint32_t bytesRcvd
Definition: rfb.h:417
uint32_t rcvdCount
Definition: rfb.h:416
struct _rfbStatList * Next
Definition: rfb.h:419
uint32_t type
Definition: rfb.h:412
uint32_t bytesRcvdIfRaw
Definition: rfb.h:418
#define MUTEX(mutex)
Definition: threading.h:84
#define COND(cond)
Definition: threading.h:89
rfbClient * client
Definition: vnc2mpg.c:358
char * filename
Definition: vnc2mpg.c:360
#define height
Definition: vncev.c:19
#define width
Definition: vncev.c:18