added use of libscp
This commit is contained in:
parent
831ef476b7
commit
b1eface57f
12
vnc/Makefile
12
vnc/Makefile
@ -1,5 +1,7 @@
|
|||||||
# libvnc makefile
|
# libvnc makefile
|
||||||
VNCOBJ = vnc.o os_calls.o d3des.o
|
LIBSCPOBJ = libscp_v0.o tcp.o
|
||||||
|
|
||||||
|
VNCOBJ = vnc.o os_calls.o d3des.o $(LIBSCPOBJ)
|
||||||
|
|
||||||
DESTDIR = /usr/local/xrdp
|
DESTDIR = /usr/local/xrdp
|
||||||
CFGDIR = /etc/xrdp
|
CFGDIR = /etc/xrdp
|
||||||
@ -10,7 +12,7 @@ DOCDIR = /usr/doc/xrdp
|
|||||||
DEFINES =
|
DEFINES =
|
||||||
|
|
||||||
CFLAGS = -Wall -O2 -I../common -fPIC $(DEFINES)
|
CFLAGS = -Wall -O2 -I../common -fPIC $(DEFINES)
|
||||||
C_OS_FLAGS = $(CFLAGS) -c
|
C_OS_FLAGS = $(CFLAGS) -c -g
|
||||||
LDFLAGS = -shared
|
LDFLAGS = -shared
|
||||||
LIBS = -ldl
|
LIBS = -ldl
|
||||||
CC = gcc
|
CC = gcc
|
||||||
@ -34,3 +36,9 @@ install:
|
|||||||
|
|
||||||
installdeb:
|
installdeb:
|
||||||
install libvnc.so $(DESTDIRDEB)/usr/lib/xrdp/libvnc.so
|
install libvnc.so $(DESTDIRDEB)/usr/lib/xrdp/libvnc.so
|
||||||
|
|
||||||
|
libscp_v0.o:
|
||||||
|
$(CC) $(C_OS_FLAGS) ../sesman/libscp_v0.c
|
||||||
|
|
||||||
|
tcp.o:
|
||||||
|
$(CC) $(C_OS_FLAGS) -DLIBSCP_CLIENT ../sesman/tcp.c
|
111
vnc/vnc.c
111
vnc/vnc.c
@ -904,11 +904,10 @@ lib_mod_connect(struct vnc* v)
|
|||||||
int error;
|
int error;
|
||||||
int i;
|
int i;
|
||||||
int check_sec_result;
|
int check_sec_result;
|
||||||
int version;
|
|
||||||
int size;
|
struct SCP_SESSION scp_s;
|
||||||
int code;
|
struct SCP_CONNECTION scp_c;
|
||||||
int ok;
|
enum SCP_CLIENT_STATES_E scp_e;
|
||||||
int display;
|
|
||||||
|
|
||||||
v->server_msg(v, "started connecting", 0);
|
v->server_msg(v, "started connecting", 0);
|
||||||
check_sec_result = 1;
|
check_sec_result = 1;
|
||||||
@ -927,82 +926,66 @@ lib_mod_connect(struct vnc* v)
|
|||||||
/* if port = -1, use sesman to get port / desktop */
|
/* if port = -1, use sesman to get port / desktop */
|
||||||
if (g_strncmp(v->port, "-1", 2) == 0)
|
if (g_strncmp(v->port, "-1", 2) == 0)
|
||||||
{
|
{
|
||||||
display = 0;
|
scp_s.type=SCP_SESSION_TYPE_XVNC;
|
||||||
|
scp_s.display=0;
|
||||||
|
scp_s.height=v->server_height;
|
||||||
|
scp_s.width=v->server_width;
|
||||||
|
scp_s.bpp=v->server_bpp;
|
||||||
|
scp_s.username=g_strdup(v->username);
|
||||||
|
scp_s.password=g_strdup(v->password);
|
||||||
|
|
||||||
error = 0;
|
error = 0;
|
||||||
init_stream(s, 8192);
|
init_stream(s, 8192);
|
||||||
v->sck = g_tcp_socket();
|
scp_c.in_sck=g_tcp_socket();
|
||||||
v->sck_closed = 0;
|
make_stream((scp_c.in_s));
|
||||||
|
make_stream((scp_c.out_s));
|
||||||
|
init_stream((scp_c.in_s), 8192);
|
||||||
|
init_stream((scp_c.out_s), 8192);
|
||||||
v->server_msg(v, "connecting to sesman", 0);
|
v->server_msg(v, "connecting to sesman", 0);
|
||||||
if (g_tcp_connect(v->sck, v->ip, "3350") == 0)
|
v->sck_closed = 0;
|
||||||
|
if (g_tcp_connect(scp_c.in_sck, v->ip, "3350") == 0)
|
||||||
{
|
{
|
||||||
g_tcp_set_non_blocking(v->sck);
|
error=1;
|
||||||
g_tcp_set_no_delay(v->sck);
|
scp_e=scp_v0c_connect(&scp_c, &scp_s);
|
||||||
s_push_layer(s, channel_hdr, 8);
|
switch (scp_e)
|
||||||
out_uint16_be(s, 0); // code
|
|
||||||
i = g_strlen(v->username);
|
|
||||||
out_uint16_be(s, i);
|
|
||||||
out_uint8a(s, v->username, i);
|
|
||||||
i = g_strlen(v->password);
|
|
||||||
out_uint16_be(s, i);
|
|
||||||
out_uint8a(s, v->password, i);
|
|
||||||
out_uint16_be(s, v->server_width);
|
|
||||||
out_uint16_be(s, v->server_height);
|
|
||||||
out_uint16_be(s, v->server_bpp);
|
|
||||||
s_mark_end(s);
|
|
||||||
s_pop_layer(s, channel_hdr);
|
|
||||||
out_uint32_be(s, 0); // version
|
|
||||||
out_uint32_be(s, s->end - s->data); // size
|
|
||||||
v->server_msg(v, "sending login info to sesman", 0);
|
|
||||||
error = lib_send(v, s->data, s->end - s->data);
|
|
||||||
if (error == 0)
|
|
||||||
{
|
{
|
||||||
init_stream(s, 8192);
|
case SCP_CLIENT_STATE_CONNECTION_DENIED:
|
||||||
v->server_msg(v, "receiving sesman header", 0);
|
v->server_msg(v, "error - sesman returned no", 0);
|
||||||
error = lib_recv(v, s->data, 8);
|
break;
|
||||||
}
|
case SCP_CLIENT_STATE_VERSION_ERR:
|
||||||
if (error == 0)
|
v->server_msg(v, "error - libscp version error", 0);
|
||||||
{
|
break;
|
||||||
in_uint32_be(s, version);
|
case SCP_CLIENT_STATE_SIZE_ERR:
|
||||||
in_uint32_be(s, size);
|
v->server_msg(v, "error - libscp size error", 0);
|
||||||
init_stream(s, 8192);
|
break;
|
||||||
v->server_msg(v, "receiving sesman data", 0);
|
case SCP_CLIENT_STATE_NETWORK_ERR:
|
||||||
error = lib_recv(v, s->data, size - 8);
|
v->server_msg(v, "error - libscp network error", 0);
|
||||||
}
|
break;
|
||||||
if (error == 0)
|
case SCP_CLIENT_STATE_SEQUENCE_ERR:
|
||||||
{
|
v->server_msg(v, "error - libscp sequence error", 0);
|
||||||
if (version == 0)
|
break;
|
||||||
{
|
case SCP_CLIENT_STATE_END:
|
||||||
in_uint16_be(s, code);
|
v->server_msg(v, "error - sesman returned ok", 0);
|
||||||
if (code == 3)
|
error=0;
|
||||||
{
|
break;
|
||||||
in_uint16_be(s, ok);
|
default:
|
||||||
if (ok)
|
v->server_msg(v, "error - unknown error", 0);
|
||||||
{
|
|
||||||
in_uint16_be(s, display);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
in_uint8s(s, 2);
|
|
||||||
v->server_msg(v, "error - sesman returned no", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v->server_msg(v, "error - connecting to sesman", 0);
|
v->server_msg(v, "error - connecting to sesman", 0);
|
||||||
}
|
}
|
||||||
g_tcp_close(v->sck);
|
g_tcp_close(scp_c.in_sck);
|
||||||
if (error != 0 || display == 0)
|
if (error != 0 || scp_s.display == 0)
|
||||||
{
|
{
|
||||||
v->server_msg(v, "error - connection failed", 0);
|
v->server_msg(v, "error - connection failed", 0);
|
||||||
free_stream(s);
|
free_stream(s);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
v->server_msg(v, "sesman started a session", 0);
|
v->server_msg(v, "sesman started a session", 0);
|
||||||
g_sprintf(con_port, "%d", 5900 + display);
|
g_sprintf(con_port, "%d", 5900 + scp_s.display);
|
||||||
v->vnc_desktop = display;
|
v->vnc_desktop = scp_s.display;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include "os_calls.h"
|
#include "os_calls.h"
|
||||||
#include "d3des.h"
|
#include "d3des.h"
|
||||||
|
|
||||||
|
#include "../sesman/libscp.h"
|
||||||
|
|
||||||
struct vnc
|
struct vnc
|
||||||
{
|
{
|
||||||
int size; /* size of this struct */
|
int size; /* size of this struct */
|
||||||
@ -38,7 +40,7 @@ struct vnc
|
|||||||
int (*mod_signal)(struct vnc* v);
|
int (*mod_signal)(struct vnc* v);
|
||||||
int (*mod_end)(struct vnc* v);
|
int (*mod_end)(struct vnc* v);
|
||||||
int (*mod_set_param)(struct vnc* v, char* name, char* value);
|
int (*mod_set_param)(struct vnc* v, char* name, char* value);
|
||||||
long mod_dumby[100 - 6]; /* align, 100 minus the number of mod
|
long mod_dumby[100 - 6]; /* align, 100 minus the number of mod
|
||||||
functions above */
|
functions above */
|
||||||
/* server functions */
|
/* server functions */
|
||||||
int (*server_begin_update)(struct vnc* v);
|
int (*server_begin_update)(struct vnc* v);
|
||||||
@ -79,7 +81,7 @@ struct vnc
|
|||||||
int (*server_get_channel_id)(struct vnc* v, char* name);
|
int (*server_get_channel_id)(struct vnc* v, char* name);
|
||||||
int (*server_send_to_channel)(struct vnc* v, int channel_id,
|
int (*server_send_to_channel)(struct vnc* v, int channel_id,
|
||||||
char* data, int data_len);
|
char* data, int data_len);
|
||||||
long server_dumby[100 - 24]; /* align, 100 minus the number of server
|
long server_dumby[100 - 24]; /* align, 100 minus the number of server
|
||||||
functions above */
|
functions above */
|
||||||
/* common */
|
/* common */
|
||||||
long handle; /* pointer to self as long */
|
long handle; /* pointer to self as long */
|
||||||
|
Loading…
Reference in New Issue
Block a user