]> git.sesse.net Git - rdpsrv/commitdiff
Give up X server for now, connect to VNC on localhost instead.
authorSteinar H. Gunderson <sesse@samfundet.no>
Fri, 4 Feb 2005 15:49:23 +0000 (15:49 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Fri, 4 Feb 2005 15:49:23 +0000 (15:49 +0000)
proto.h
rdpsrv.c
tcp.c
util.c

diff --git a/proto.h b/proto.h
index fa4108823abe21da194fecc47f4df55a0b142b4a..00ab7a0bc194868ef397fd2a3cb9e6afedfe8d18 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -119,6 +119,7 @@ STREAM tcp_init(uint32 maxlen);
 void tcp_send(STREAM s);
 STREAM tcp_recv(STREAM s, uint32 length);
 BOOL tcp_recv_connect(int server_sock);
+int tcp_connect(char *server, int port);
 void tcp_disconnect(void);
 /* xclip.c */
 void ui_clip_format_announce(uint8 * data, uint32 length);
index e97515b53d965d29f04594b7f678aeb80de7e98a..7c6b1f60a7dbeba7ca3118a9b6afc70d23890b90 100644 (file)
--- a/rdpsrv.c
+++ b/rdpsrv.c
@@ -104,10 +104,13 @@ void handle_input_pdu(STREAM s)
 
 int serve_client()
 {
+       // connect to VNC
+       int vnc_sock = tcp_connect("127.0.0.1", 5901);
+       
        if (!mcs_recv_connect_initial())
                error("MCS_CONNECT_INITIAL recv failed");
        mcs_send_connect_response();
-       
+
        for ( ;; ) {
                uint8 type, data_pdu_type;
                STREAM s;
diff --git a/tcp.c b/tcp.c
index fef986eafabd56c8d70ca9bfb5829ddfcbf872ba..30aecadf668f726d7467d2c4cafd476ed8d9dcfb 100644 (file)
--- a/tcp.c
+++ b/tcp.c
@@ -132,6 +132,99 @@ tcp_recv(STREAM s, uint32 length)
        return s;
 }
 
+/* Establish a connection on the TCP layer */
+int
+tcp_connect(char *server, int port)
+{
+        int true_value = 1;
+       int sock;
+
+#ifdef IPv6
+
+        int n;
+        struct addrinfo hints, *res, *ressave;
+        char tcp_port_rdp_s[10];
+
+        snprintf(tcp_port_rdp_s, 10, "%d", tcp_port_rdp);
+
+        memset(&hints, 0, sizeof(struct addrinfo));
+        hints.ai_family = AF_UNSPEC;
+        hints.ai_socktype = SOCK_STREAM;
+
+        n = getaddrinfo(server, tcp_port_rdp_s, &hints, &res);
+
+        if (n < 0)
+        {
+                error("getaddrinfo: %s\n", gai_strerror(n));
+                return -1;
+        }
+
+        ressave = res;
+        sock = -1;
+        while (res)
+        {
+                sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+                if (!(sock < 0))
+                {
+                        if (connect(sock, res->ai_addr, res->ai_addrlen) == 0)
+                                break;
+                        close(sock);
+                        sock = -1;
+                }
+                res = res->ai_next;
+        }
+        freeaddrinfo(ressave);
+
+        if (sock == -1)
+        {
+                error("%s: unable to connect\n", server);
+                return -1;
+        }
+
+#else /* no IPv6 support */
+
+        struct hostent *nslookup;
+        struct sockaddr_in servaddr;
+
+        if ((nslookup = gethostbyname(server)) != NULL)
+        {
+                memcpy(&servaddr.sin_addr, nslookup->h_addr, sizeof(servaddr.sin_addr));
+        }
+        else if ((servaddr.sin_addr.s_addr = inet_addr(server)) == INADDR_NONE)
+        {
+                error("%s: unable to resolve host\n", server);
+                return -1;
+        }
+
+        if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+        {
+                error("socket: %s\n", strerror(errno));
+                return -1;
+        }
+
+        servaddr.sin_family = AF_INET;
+        servaddr.sin_port = htons(port);
+
+        if (connect(sock, (struct sockaddr *) &servaddr, sizeof(struct sockaddr)) < 0)
+        {
+                error("connect: %s\n", strerror(errno));
+                close(sock);
+                return -1;
+        }
+
+#endif /* IPv6 */
+
+        setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *) &true_value, sizeof(true_value));
+
+        in.size = 4096;
+        in.data = (uint8 *) xmalloc(in.size);
+
+        out.size = 4096;
+        out.data = (uint8 *) xmalloc(out.size);
+
+        return sock;
+}
+
 /* Establish a connection on the TCP layer */
 BOOL
 tcp_recv_connect(int server_sock)
diff --git a/util.c b/util.c
index 44aefe7074989eb32ff554698ad592b61723ac50..3c2e4bd6db69fbe35ffe39f5e1bfab2cf2529fc7 100644 (file)
--- a/util.c
+++ b/util.c
@@ -27,7 +27,6 @@
 #include <sys/time.h>           /* gettimeofday */
 #include <sys/times.h>          /* times */
 #include <errno.h>
-#include <X11/Xlib.h>           /* Window */
 #include "rdesktop.h"
 
 #ifdef EGD_SOCKET