diff options
-rw-r--r-- | design.txt | 35 | ||||
-rw-r--r-- | readme.txt | 6 | ||||
-rw-r--r-- | xrdp/os_calls.c | 32 | ||||
-rw-r--r-- | xrdp/xrdp.h | 4 | ||||
-rw-r--r-- | xrdp/xrdp_process.c | 5 | ||||
-rw-r--r-- | xrdp/xrdp_types.h | 1 |
6 files changed, 77 insertions, 6 deletions
diff --git a/design.txt b/design.txt new file mode 100644 index 00000000..3e154870 --- /dev/null +++ b/design.txt @@ -0,0 +1,35 @@ + +This document is intended to explain xrdp server design. + +Many connections, all capable of running different moduals +one connection could be using a vnc connection +one could be running a custom app made for xrdp +one could be running a X11 session +clients control the screen size and color depth + +all controlled by a cofiguaration file. + +you can create a lib or use a lib with your executable that talks +to xrdp server. + +------ ---------- +-xrdp---linked-------mylib.so- session 1 +------ ---------- + | + | ------------------------- + |----unix socket--myapp linked to libxrdp- session 2 + | ------------------------- + | + | ----------- + |----linked-------mylib2.so- session 3 + ----------- + +Any of the above sessions can repeat or have different session +numbers or not even be used. +If a session is disconnected, all that changes is the rdp connection +is lost, the session remains. + +For X11, start the XServer after the user is +authenticated. First check for the next available X11 display, +create a user session, start the XServer and set the DISPLAY enviromenet +variable. @@ -6,6 +6,10 @@ Credits Mark from up 19.9 was the first to work with rdp server code. To use this run make the ./xrdp, then connect with rdesktop or mstsc. -Only tested with linux and i386. +Tested with linux and i386. +I've got it compiling in windows with borland free tools. + +xrdp directory is the main server code +design.txt is an attempt to expain the project design Jay diff --git a/xrdp/os_calls.c b/xrdp/os_calls.c index 2b55bec0..164c93f3 100644 --- a/xrdp/os_calls.c +++ b/xrdp/os_calls.c @@ -30,6 +30,7 @@ #include <netinet/in.h> #include <netinet/tcp.h> #include <sys/socket.h> +#include <sys/un.h> #include <sys/time.h> #include <sys/types.h> #endif @@ -242,6 +243,15 @@ int g_tcp_socket(void) } /*****************************************************************************/ +int g_tcp_local_socket(void) +{ + int rv; + + rv = socket(PF_LOCAL, SOCK_STREAM, 0); + return rv; +} + +/*****************************************************************************/ void g_tcp_close(int sck) { #ifdef _WIN32 @@ -280,6 +290,17 @@ int g_tcp_bind(int sck, char* port) } /*****************************************************************************/ +int g_tcp_local_bind(int sck, char* port) +{ + struct sockaddr_un s; + + memset(&s, 0, sizeof(struct sockaddr_un)); + s.sun_family = AF_UNIX; + strcpy(s.sun_path, port); + return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_un)); +} + +/*****************************************************************************/ int g_tcp_listen(int sck) { return listen(sck, 2); @@ -323,16 +344,21 @@ int g_tcp_last_error_would_block(int sck) } /*****************************************************************************/ -int g_tcp_select(int sck) +int g_tcp_select(int sck1, int sck2) { fd_set rfds; struct timeval time; + int max; time.tv_sec = 0; time.tv_usec = 0; FD_ZERO(&rfds); - FD_SET(((unsigned int)sck), &rfds); - return select(sck + 1, &rfds, 0, 0, &time); + FD_SET(((unsigned int)sck1), &rfds); + FD_SET(((unsigned int)sck2), &rfds); + max = sck1; + if (sck2 > max) + max = sck2; + return select(max + 1, &rfds, 0, 0, &time); } /*****************************************************************************/ diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 47cc710d..d5f5f6f6 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -51,15 +51,17 @@ void g_memset(void* ptr, int val, int size); void g_memcpy(void* d_ptr, const void* s_ptr, int size); int g_getchar(void); int g_tcp_socket(void); +int g_tcp_local_socket(void); void g_tcp_close(int sck); int g_tcp_set_non_blocking(int sck); int g_tcp_bind(int sck, char* port); +int g_tcp_local_bind(int sck, char* port); int g_tcp_listen(int sck); int g_tcp_accept(int sck); int g_tcp_recv(int sck, void* ptr, int len, int flags); int g_tcp_send(int sck, void* ptr, int len, int flags); int g_tcp_last_error_would_block(int sck); -int g_tcp_select(int sck); +int g_tcp_select(int sck1, int sck2); int g_is_term(void); void g_set_term(int in_val); void g_sleep(int msecs); diff --git a/xrdp/xrdp_process.c b/xrdp/xrdp_process.c index 8694f19d..f488cdbe 100644 --- a/xrdp/xrdp_process.c +++ b/xrdp/xrdp_process.c @@ -59,7 +59,7 @@ int xrdp_process_main_loop(struct xrdp_process* self) { while (!g_is_term() && !self->term) { - i = g_tcp_select(self->sck); + i = g_tcp_select(self->sck, self->app_sck); if (i == 1) { init_stream(s, 8192); @@ -105,6 +105,9 @@ int xrdp_process_main_loop(struct xrdp_process* self) xrdp_wm_init(self->wm); } } + else if (i == 2) + { + } else if (i == 0) g_sleep(10); else diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index d8763a2b..bf80cb92 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -336,6 +336,7 @@ struct xrdp_process /* create these when up and running */ struct xrdp_orders* orders; struct xrdp_wm* wm; + int app_sck; }; /* rdp listener */ |