From f0a91c444d87bd09961185d888f87799ab817790 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Wed, 31 Jul 2013 23:03:38 -0700 Subject: [PATCH] xorg driver, add xrdp connection --- xorg/server/module/Makefile | 2 +- xorg/server/module/rdp.h | 8 ++ xorg/server/module/rdpClientCon.c | 175 ++++++++++++++++++++++++++++++ xorg/server/module/rdpClientCon.h | 38 +++++++ xorg/server/xrdpdev/xrdpdev.c | 16 +++ 5 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 xorg/server/module/rdpClientCon.c create mode 100644 xorg/server/module/rdpClientCon.h diff --git a/xorg/server/module/Makefile b/xorg/server/module/Makefile index 6cb1893f..d30b2ba9 100644 --- a/xorg/server/module/Makefile +++ b/xorg/server/module/Makefile @@ -5,7 +5,7 @@ rdpPolyRectangle.o rdpPolyArc.o rdpFillPolygon.o rdpPolyFillRect.o \ rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o rdpImageText8.o \ rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o rdpPushPixels.o \ rdpCursor.o rdpMain.o rdpRandR.o rdpMisc.o rdpReg.o \ -rdpComposite.o rdpGlyphs.o rdpPixmap.o rdpInput.o +rdpComposite.o rdpGlyphs.o rdpPixmap.o rdpInput.o rdpClientCon.o CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1 diff --git a/xorg/server/module/rdp.h b/xorg/server/module/rdp.h index 085e114f..0cc5d6ee 100644 --- a/xorg/server/module/rdp.h +++ b/xorg/server/module/rdp.h @@ -33,6 +33,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define PixelDPI 100 #define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10)) +#define RDPMIN(_val1, _val2) ((_val1) < (_val2) ? (_val1) : (_val2)) +#define RDPMAX(_val1, _val2) ((_val1) < (_val2) ? (_val2) : (_val1)) + +/* defined in rdpClientCon.h */ +typedef struct _rdpClientCon rdpClientCon; + /* move this to common header */ struct _rdpRec { @@ -73,6 +79,8 @@ struct _rdpRec RRGetPanningProcPtr rrGetPanning; RRSetPanningProcPtr rrSetPanning; + int listen_sck; + rdpClientCon *clientCon; }; typedef struct _rdpRec rdpRec; typedef struct _rdpRec * rdpPtr; diff --git a/xorg/server/module/rdpClientCon.c b/xorg/server/module/rdpClientCon.c new file mode 100644 index 00000000..5a5a4551 --- /dev/null +++ b/xorg/server/module/rdpClientCon.c @@ -0,0 +1,175 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Client connection to xrdp + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include "rdp.h" +#include "rdpDraw.h" +#include "rdpClientCon.h" +#include "rdpMisc.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +#define LTOUI32(_in) ((unsigned int)(_in)) + +/******************************************************************************/ +static int +rdpClientConGotConnection(ScreenPtr pScreen, rdpPtr dev) +{ + LLOGLN(0, ("rdpClientConGotConnection:")); + return 0; +} + +/******************************************************************************/ +static int +rdpClientConGotData(ScreenPtr pScreen, rdpPtr dev, rdpClientCon *clientCon) +{ + LLOGLN(0, ("rdpClientConGotData:")); + return 0; +} + +/******************************************************************************/ +static int +rdpClientConGotControlConnection(ScreenPtr pScreen, rdpPtr dev, + rdpClientCon *clientCon) +{ + LLOGLN(0, ("rdpClientConGotControlConnection:")); + return 0; +} + +/******************************************************************************/ +static int +rdpClientConGotControlData(ScreenPtr pScreen, rdpPtr dev, + rdpClientCon *clientCon) +{ + LLOGLN(0, ("rdpClientConGotControlData:")); + return 0; +} + +/******************************************************************************/ +int +rdpClientConCheck(ScreenPtr pScreen) +{ + rdpPtr dev; + rdpClientCon *clientCon; + fd_set rfds; + struct timeval time; + int max; + int sel; + int count; + + LLOGLN(10, ("rdpClientConCheck:")); + dev = rdpGetDevFromScreen(pScreen); + time.tv_sec = 0; + time.tv_usec = 0; + FD_ZERO(&rfds); + count = 0; + max = 0; + if (dev->listen_sck > 0) + { + count++; + FD_SET(LTOUI32(dev->listen_sck), &rfds); + max = RDPMAX(dev->listen_sck, max); + } + clientCon = dev->clientCon; + while (clientCon != NULL) + { + if (clientCon->sck > 0) + { + count++; + FD_SET(LTOUI32(clientCon->sck), &rfds); + max = RDPMAX(clientCon->sck, max); + } + if (clientCon->sckControl > 0) + { + count++; + FD_SET(LTOUI32(clientCon->sckControl), &rfds); + max = RDPMAX(clientCon->sckControl, max); + } + if (clientCon->sckControlListener > 0) + { + count++; + FD_SET(LTOUI32(clientCon->sckControlListener), &rfds); + max = RDPMAX(clientCon->sckControlListener, max); + } + clientCon = clientCon->next; + } + if (count < 1) + { + sel = 0; + } + else + { + sel = select(max + 1, &rfds, 0, 0, &time); + } + if (sel < 1) + { + LLOGLN(10, ("rdpClientConCheck: no select")); + return 0; + } + if (dev->listen_sck > 0) + { + if (FD_ISSET(LTOUI32(dev->listen_sck), &rfds)) + { + rdpClientConGotConnection(pScreen, dev); + } + } + clientCon = dev->clientCon; + while (clientCon != NULL) + { + if (clientCon->sck > 0) + { + if (FD_ISSET(LTOUI32(clientCon->sck), &rfds)) + { + rdpClientConGotData(pScreen, dev, clientCon); + } + } + if (clientCon->sckControlListener > 0) + { + if (FD_ISSET(LTOUI32(clientCon->sckControlListener), &rfds)) + { + rdpClientConGotControlConnection(pScreen, dev, clientCon); + } + } + if (clientCon->sckControl > 0) + { + if (FD_ISSET(LTOUI32(clientCon->sckControl), &rfds)) + { + rdpClientConGotControlData(pScreen, dev, clientCon); + } + } + clientCon = clientCon->next; + } + return 0; +} diff --git a/xorg/server/module/rdpClientCon.h b/xorg/server/module/rdpClientCon.h new file mode 100644 index 00000000..fad17b68 --- /dev/null +++ b/xorg/server/module/rdpClientCon.h @@ -0,0 +1,38 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Client connection to xrdp + +*/ + +#ifndef _RDPCLIENTCON_H +#define _RDPCLIENTCON_H + +struct _rdpClientCon +{ + int sck; + int sckControlListener; + int sckControl; + struct _rdpClientCon *next; +}; + +int +rdpClientConCheck(ScreenPtr pScreen); + +#endif diff --git a/xorg/server/xrdpdev/xrdpdev.c b/xorg/server/xrdpdev/xrdpdev.c index a4fffffc..a22c27fa 100644 --- a/xorg/server/xrdpdev/xrdpdev.c +++ b/xorg/server/xrdpdev/xrdpdev.c @@ -48,6 +48,7 @@ This is the main driver file #include "rdpComposite.h" #include "rdpGlyphs.h" #include "rdpPixmap.h" +#include "rdpClientCon.h" #define XRDP_DRIVER_NAME "XRDPDEV" #define XRDP_NAME "XRDPDEV" @@ -393,6 +394,19 @@ rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg) return 0; } +/******************************************************************************/ +static void +rdpBlockHandler1(pointer blockData, OSTimePtr pTimeout, pointer pReadmask) +{ +} + +/******************************************************************************/ +static void +rdpWakeupHandler1(pointer blockData, int result, pointer pReadmask) +{ + rdpClientConCheck((ScreenPtr)blockData); +} + /*****************************************************************************/ static Bool rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) @@ -518,6 +532,8 @@ rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) ps->Glyphs = rdpGlyphs; } + RegisterBlockAndWakeupHandlers(rdpBlockHandler1, rdpWakeupHandler1, pScreen); + g_timer = TimerSet(g_timer, 0, 10, rdpDeferredRandR, pScreen); LLOGLN(0, ("rdpScreenInit: out"));