From 896ca2036c35b89a7f63e1adefe5e3724bf4d40d Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Tue, 19 Jul 2011 13:40:34 +0200 Subject: tightPng: Add initial tightPng encoding support. http://wiki.qemu.org/VNC_Tight_PNG Signed-off-by: Joel Martin Signed-off-by: Christian Beier --- rfb/rfb.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'rfb/rfb.h') diff --git a/rfb/rfb.h b/rfb/rfb.h index c16336d..e79b68b 100644 --- a/rfb/rfb.h +++ b/rfb/rfb.h @@ -542,7 +542,9 @@ typedef struct _rfbClientRec { struct z_stream_s compStream; rfbBool compStreamInited; uint32_t zlibCompressLevel; - /** the quality level is also used by ZYWRLE */ +#endif +#if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG) + /** the quality level is also used by ZYWRLE and TightPng */ int tightQualityLevel; #ifdef LIBVNCSERVER_HAVE_LIBJPEG @@ -550,6 +552,8 @@ typedef struct _rfbClientRec { z_stream zsStruct[4]; rfbBool zsActive[4]; int zsLevel[4]; +#endif +#if defined(LIBVNCSERVER_HAVE_LIBJPEG) || defined(LIBVNCSERVER_HAVE_LIBPNG) int tightCompressLevel; #endif #endif @@ -624,6 +628,9 @@ typedef struct _rfbClientRec { char *afterEncBuf; int afterEncBufSize; int afterEncBufLen; +#if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG) + uint32_t tightEncoding; /* rfbEncodingTight or rfbEncodingTightPng */ +#endif } rfbClientRec, *rfbClientPtr; /** @@ -800,7 +807,7 @@ extern rfbBool rfbSendRectEncodingUltra(rfbClientPtr cl, int x,int y,int w,int h extern rfbBool rfbSendRectEncodingZlib(rfbClientPtr cl, int x, int y, int w, int h); -#ifdef LIBVNCSERVER_HAVE_LIBJPEG +#if defined(LIBVNCSERVER_HAVE_LIBJPEG) || defined(LIBVNCSERVER_HAVE_LIBPNG) /* tight.c */ #define TIGHT_DEFAULT_COMPRESSION 6 @@ -808,7 +815,13 @@ extern rfbBool rfbSendRectEncodingZlib(rfbClientPtr cl, int x, int y, int w, extern rfbBool rfbTightDisableGradient; extern int rfbNumCodedRectsTight(rfbClientPtr cl, int x,int y,int w,int h); + +#if defined(LIBVNCSERVER_HAVE_LIBJPEG) extern rfbBool rfbSendRectEncodingTight(rfbClientPtr cl, int x,int y,int w,int h); +#endif +#if defined(LIBVNCSERVER_HAVE_LIBPNG) +extern rfbBool rfbSendRectEncodingTightPng(rfbClientPtr cl, int x,int y,int w,int h); +#endif #endif #endif -- cgit v1.2.1 From 6fac22a74b5020387a6961e4cc197b5fa4743f96 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Tue, 16 Aug 2011 14:02:31 +0200 Subject: websockets: Initial WebSockets support. Has a bug: WebSocket client disconnects are not detected. rfbSendFramebufferUpdate is doing a MSG_PEEK recv to determine if enough data is available which prevents a disconnect from being detected. Otherwise it's working pretty well. [jes: moved added struct members to the end for binary compatibility with previous LibVNCServer versions, removed an unused variable] Signed-off-by: Johannes Schindelin --- rfb/rfb.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'rfb/rfb.h') diff --git a/rfb/rfb.h b/rfb/rfb.h index e79b68b..1a46e9a 100644 --- a/rfb/rfb.h +++ b/rfb/rfb.h @@ -631,6 +631,19 @@ typedef struct _rfbClientRec { #if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG) uint32_t tightEncoding; /* rfbEncodingTight or rfbEncodingTightPng */ #endif + +#ifdef LIBVNCSERVER_WITH_WEBSOCKETS + rfbBool webSockets; + rfbBool webSocketsSSL; + rfbBool webSocketsBase64; + + char encodeBuf[UPDATE_BUF_SIZE*2 + 2]; /* UTF-8 could double it + framing */ + + char decodeBuf[8192]; /* TODO: what makes sense? */ + int dblen; + char carryBuf[3]; /* For base64 carry-over */ + int carrylen; +#endif } rfbClientRec, *rfbClientPtr; /** @@ -683,6 +696,7 @@ extern void rfbDisconnectUDPSock(rfbScreenInfoPtr rfbScreen); extern void rfbCloseClient(rfbClientPtr cl); extern int rfbReadExact(rfbClientPtr cl, char *buf, int len); extern int rfbReadExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout); +extern int rfbPeekExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout); extern int rfbWriteExact(rfbClientPtr cl, const char *buf, int len); extern int rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec); extern int rfbConnect(rfbScreenInfoPtr rfbScreen, char* host, int port); @@ -692,6 +706,14 @@ extern int rfbListenOnUDPPort(int port, in_addr_t iface); extern int rfbStringToAddr(char* string,in_addr_t* addr); extern rfbBool rfbSetNonBlocking(int sock); +#ifdef LIBVNCSERVER_WITH_WEBSOCKETS +/* websockets.c */ + +extern rfbBool webSocketsCheck(rfbClientPtr cl); +extern int webSocketsEncode(rfbClientPtr cl, const char *src, int len); +extern int webSocketsDecode(rfbClientPtr cl, char *dst, int len); +#endif + /* rfbserver.c */ /* Routines to iterate over the client list in a thread-safe way. -- cgit v1.2.1 From 4aa35863676335917d2a25a7952031f0fba66dfb Mon Sep 17 00:00:00 2001 From: Gernot Tenchio Date: Tue, 16 Aug 2011 14:02:35 +0200 Subject: websockets: Add encryption support [jes: moved out GnuTLS and OpenSSL support, added a dummy support, to separate changes better, and to keep things compiling] Signed-off-by: Johannes Schindelin --- rfb/rfb.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'rfb/rfb.h') diff --git a/rfb/rfb.h b/rfb/rfb.h index 1a46e9a..b6fb7c0 100644 --- a/rfb/rfb.h +++ b/rfb/rfb.h @@ -368,6 +368,10 @@ typedef struct _rfbScreenInfo rfbDisplayFinishedHookPtr displayFinishedHook; /** xvpHook is called to handle an xvp client message */ rfbXvpHookPtr xvpHook; +#ifdef LIBVNCSERVER_WITH_WEBSOCKETS + char *sslkeyfile; + char *sslcertfile; +#endif } rfbScreenInfo, *rfbScreenInfoPtr; @@ -414,6 +418,8 @@ typedef struct _rfbStatList { struct _rfbStatList *Next; } rfbStatList; +typedef struct _rfbSslCtx rfbSslCtx; + typedef struct _rfbClientRec { /** back pointer to the screen */ @@ -637,8 +643,9 @@ typedef struct _rfbClientRec { rfbBool webSocketsSSL; rfbBool webSocketsBase64; - char encodeBuf[UPDATE_BUF_SIZE*2 + 2]; /* UTF-8 could double it + framing */ + rfbSslCtx *sslctx; + char encodeBuf[UPDATE_BUF_SIZE*2 + 2]; /* UTF-8 could double it + framing */ char decodeBuf[8192]; /* TODO: what makes sense? */ int dblen; char carryBuf[3]; /* For base64 carry-over */ -- cgit v1.2.1 From 297072a691970fb7e2cd379b62f52f30d5988592 Mon Sep 17 00:00:00 2001 From: Gernot Tenchio Date: Tue, 16 Aug 2011 14:02:39 +0200 Subject: websockets: Add wspath member to rfbClientRec Added wspath member to rfbClientRec which holds the path component of the initial websocket request. Signed-off-by: Johannes Schindelin --- rfb/rfb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'rfb/rfb.h') diff --git a/rfb/rfb.h b/rfb/rfb.h index b6fb7c0..9239b35 100644 --- a/rfb/rfb.h +++ b/rfb/rfb.h @@ -645,6 +645,7 @@ typedef struct _rfbClientRec { rfbSslCtx *sslctx; + char *wspath; /* Requests path component */ char encodeBuf[UPDATE_BUF_SIZE*2 + 2]; /* UTF-8 could double it + framing */ char decodeBuf[8192]; /* TODO: what makes sense? */ int dblen; -- cgit v1.2.1 From 1408866c864cac3b1bbf37eb9fdc8d303f37957d Mon Sep 17 00:00:00 2001 From: Gernot Tenchio Date: Thu, 25 Aug 2011 10:58:19 +0200 Subject: websockets: Initial HyBi support --- rfb/rfb.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'rfb/rfb.h') diff --git a/rfb/rfb.h b/rfb/rfb.h index 9239b35..1f29e63 100644 --- a/rfb/rfb.h +++ b/rfb/rfb.h @@ -419,6 +419,7 @@ typedef struct _rfbStatList { } rfbStatList; typedef struct _rfbSslCtx rfbSslCtx; +typedef struct _wsCtx wsCtx; typedef struct _rfbClientRec { @@ -640,17 +641,10 @@ typedef struct _rfbClientRec { #ifdef LIBVNCSERVER_WITH_WEBSOCKETS rfbBool webSockets; - rfbBool webSocketsSSL; rfbBool webSocketsBase64; - rfbSslCtx *sslctx; - + wsCtx *wsctx; char *wspath; /* Requests path component */ - char encodeBuf[UPDATE_BUF_SIZE*2 + 2]; /* UTF-8 could double it + framing */ - char decodeBuf[8192]; /* TODO: what makes sense? */ - int dblen; - char carryBuf[3]; /* For base64 carry-over */ - int carrylen; #endif } rfbClientRec, *rfbClientPtr; @@ -718,7 +712,7 @@ extern rfbBool rfbSetNonBlocking(int sock); /* websockets.c */ extern rfbBool webSocketsCheck(rfbClientPtr cl); -extern int webSocketsEncode(rfbClientPtr cl, const char *src, int len); +extern int webSocketsEncode(rfbClientPtr cl, const char *src, int len, char **dst); extern int webSocketsDecode(rfbClientPtr cl, char *dst, int len); #endif -- cgit v1.2.1 From 55234a37fd0f865261c09b602b94444d42f35daa Mon Sep 17 00:00:00 2001 From: Gernot Tenchio Date: Thu, 25 Aug 2011 12:12:17 +0200 Subject: websockets: Move Hixie disconnect hack to websockets.c Move the hixie disconnect hack to websockets.c. Removed the remaining websockets vars from rfbClientPtr, so all websockets stuff is hidden behind an opaque pointer. --- rfb/rfb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'rfb/rfb.h') diff --git a/rfb/rfb.h b/rfb/rfb.h index 1f29e63..11d1447 100644 --- a/rfb/rfb.h +++ b/rfb/rfb.h @@ -640,8 +640,6 @@ typedef struct _rfbClientRec { #endif #ifdef LIBVNCSERVER_WITH_WEBSOCKETS - rfbBool webSockets; - rfbBool webSocketsBase64; rfbSslCtx *sslctx; wsCtx *wsctx; char *wspath; /* Requests path component */ @@ -712,6 +710,7 @@ extern rfbBool rfbSetNonBlocking(int sock); /* websockets.c */ extern rfbBool webSocketsCheck(rfbClientPtr cl); +extern rfbBool webSocketCheckDisconnect(rfbClientPtr cl); extern int webSocketsEncode(rfbClientPtr cl, const char *src, int len, char **dst); extern int webSocketsDecode(rfbClientPtr cl, char *dst, int len); #endif -- cgit v1.2.1