removing unused files

This commit is contained in:
ilsimo 2007-05-06 21:08:45 +00:00
parent f22b5b42a7
commit a53a1b72b8
12 changed files with 0 additions and 1996 deletions

View File

@ -1,37 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp.h
* @brief libscp main header
* @author Simone Fedele
*
*/
#ifndef LIBSCP_H
#define LIBSCP_H
#include "libscp_types.h"
#include "libscp_vX.h"
#include "libscp_v0.h"
#include "libscp_v1s.h"
#include "libscp_v1c.h"
#endif

View File

@ -1,130 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_types.h
* @brief libscp data types definitions
* @author Simone Fedele
*
*/
#ifndef LIBSCP_TYPES_H
#define LIBSCP_TYPES_H
#include "os_calls.h"
#include "parse.h"
#include "arch.h"
#include "log.h"
//sesman requires its own tcp streaming functions for threading safety
#include "tcp.h"
#define SCP_SID tui32
#define SCP_DISPLAY tui16
#define SCP_RESOURCE_SHARING_REQUEST_YES 0x01
#define SCP_RESOURCE_SHARING_REQUEST_NO 0x00
#define SCP_SESSION_TYPE_XVNC 0x00
#define SCP_SESSION_TYPE_XRDP 0x01
#define SCP_ADDRESS_TYPE_IPV4 0x00
#define SCP_ADDRESS_TYPE_IPV6 0x01
#define SCP_COMMAND_SET_DEFAULT 0x0000
#define SCP_COMMAND_SET_MANAGE 0x0001
#define SCP_COMMAND_SET_RSR 0x0002
#define SCP_SERVER_MAX_LIST_SIZE 100
#define free_session(s) {g_free((s)->username); g_free((s)->password); g_free((s)->hostname); g_free(s);}
struct SCP_CONNECTION
{
int in_sck;
struct stream* in_s;
struct stream* out_s;
};
struct SCP_SESSION
{
tui8 type;
tui32 version;
tui16 height;
tui16 width;
tui8 bpp;
tui8 rsr;
char locale[18];
char* username;
char* password;
char* hostname;
tui8 addr_type;
tui32 ipv4addr; //htons
tui32 ipv6addr; //should be 128bit
tui16 display;
char* errstr;
};
struct SCP_DISCONNECTED_SESSION
{
tui32 SID;
tui8 type;
tui16 height;
tui16 width;
tui8 bpp;
tui8 idle_days;
tui8 idle_hours;
tui8 idle_minutes;
};
enum SCP_CLIENT_STATES_E
{
SCP_CLIENT_STATE_OK,
SCP_CLIENT_STATE_NETWORK_ERR,
SCP_CLIENT_STATE_VERSION_ERR,
SCP_CLIENT_STATE_SEQUENCE_ERR,
SCP_CLIENT_STATE_SIZE_ERR,
SCP_CLIENT_STATE_INTERNAL_ERR,
SCP_CLIENT_STATE_SESSION_LIST,
SCP_CLIENT_STATE_LIST_OK,
SCP_CLIENT_STATE_RESEND_CREDENTIALS,
SCP_CLIENT_STATE_CONNECTION_DENIED,
SCP_CLIENT_STATE_PWD_CHANGE_REQ,
SCP_CLIENT_STATE_RECONNECT_SINGLE,
SCP_CLIENT_STATE_SELECTION_CANCEL,
SCP_CLIENT_STATE_END
};
enum SCP_SERVER_STATES_E
{
SCP_SERVER_STATE_OK,
SCP_SERVER_STATE_VERSION_ERR,
SCP_SERVER_STATE_NETWORK_ERR,
SCP_SERVER_STATE_SEQUENCE_ERR,
SCP_SERVER_STATE_INTERNAL_ERR,
SCP_SERVER_STATE_SESSION_TYPE_ERR,
SCP_SERVER_STATE_SIZE_ERR,
SCP_SERVER_STATE_SELECTION_CANCEL,
/*SCP_SERVER_STATE_FORCE_NEW,*/
SCP_SERVER_STATE_START_MANAGE,
SCP_SERVER_STATE_END
};
#endif

View File

@ -1,247 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_v0.c
* @brief libscp version 0 code
* @author Simone Fedele
*
*/
#include "libscp_v0.h"
#include "os_calls.h"
/* client API */
/******************************************************************************/
enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
{
tui32 version;
tui32 size;
tui16 sz;
init_stream(c->in_s, c->in_s->size);
init_stream(c->out_s, c->in_s->size);
g_tcp_set_non_blocking(c->in_sck);
g_tcp_set_no_delay(c->in_sck);
s_push_layer(c->out_s, channel_hdr, 8);
if (s->type==SCP_SESSION_TYPE_XVNC)
{
out_uint16_be(c->out_s, 0); // code
}
else if (s->type==SCP_SESSION_TYPE_XRDP)
{
out_uint16_be(c->out_s, 10); // code
}
else
{
return SCP_CLIENT_STATE_INTERNAL_ERR;
}
sz = g_strlen(s->username);
out_uint16_be(c->out_s, sz);
out_uint8a(c->out_s, s->username, sz);
sz = g_strlen(s->password);
out_uint16_be(c->out_s,sz);
out_uint8a(c->out_s, s->password, sz);
out_uint16_be(c->out_s, s->width);
out_uint16_be(c->out_s, s->height);
out_uint16_be(c->out_s, s->bpp);
s_mark_end(c->out_s);
s_pop_layer(c->out_s, channel_hdr);
out_uint32_be(c->out_s, 0); // version
out_uint32_be(c->out_s, c->out_s->end - c->out_s->data); // size
if (0!=tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (0 != version)
{
return SCP_CLIENT_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size < 14)
{
return SCP_CLIENT_STATE_SIZE_ERR;
}
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, sz);
if (3!=sz)
{
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, sz);
if (1!=sz)
{
return SCP_CLIENT_STATE_CONNECTION_DENIED;
}
in_uint16_be(c->in_s, sz);
s->display=sz;
return SCP_CLIENT_STATE_END;
}
/* server API */
/******************************************************************************/
enum SCP_SERVER_STATES_E scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
{
tui32 version=0;
tui32 size;
struct SCP_SESSION* session=0;
tui16 sz;
tui32 code=0;
if (!skipVchk)
{
if (0==tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
in_uint32_be(c->in_s, version);
if (version != 0)
{
return SCP_SERVER_STATE_VERSION_ERR;
}
}
else
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
}
in_uint32_be(c->in_s, size);
init_stream(c->in_s, 8196);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, size-8))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, code);
if (code == 0 || code == 10)
{
session = g_malloc(sizeof(struct SCP_SESSION),1);
if (0 == session)
{
return SCP_SERVER_STATE_INTERNAL_ERR;
}
session->version=version;
if (code == 0)
{
session->type=SCP_SESSION_TYPE_XVNC;
}
else
{
session->type=SCP_SESSION_TYPE_XRDP;
}
/* reading username */
in_uint16_be(c->in_s, sz);
session->username=g_malloc(sz+1,0);
if (0==session->username)
{
g_free(session);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
session->username[sz]='\0';
in_uint8a(c->in_s, session->username, sz);
/* reading password */
in_uint16_be(c->in_s, sz);
session->password=g_malloc(sz+1,0);
if (0==session->password)
{
g_free(session->username);
g_free(session);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
session->password[sz]='\0';
in_uint8a(c->in_s, session->password, sz);
in_uint16_be(c->in_s, session->width);
in_uint16_be(c->in_s, session->height);
in_uint16_be(c->in_s, sz);
session->bpp=(unsigned char)sz;
}
else
{
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
(*s)=session;
return SCP_SERVER_STATE_OK;
}
/******************************************************************************/
enum SCP_SERVER_STATES_E scp_v0s_allow_connection(struct SCP_CONNECTION* c, SCP_DISPLAY d)
{
out_uint32_be(c->out_s, 0); /* version */
out_uint32_be(c->out_s, 14); /* size */
out_uint16_be(c->out_s, 3); /* cmd */
out_uint16_be(c->out_s, 1); /* data */
out_uint16_be(c->out_s, d); /* data */
s_mark_end(c->out_s);
if (0!=tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
return SCP_SERVER_STATE_OK;
}
/******************************************************************************/
enum SCP_SERVER_STATES_E scp_v0s_deny_connection(struct SCP_CONNECTION* c)
{
out_uint32_be(c->out_s, 0); /* version */
out_uint32_be(c->out_s, 14); /* size */
out_uint16_be(c->out_s, 3); /* cmd */
out_uint16_be(c->out_s, 0); /* data */
out_uint16_be(c->out_s, 0); /* data */
s_mark_end(c->out_s);
if (0!=tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
return SCP_SERVER_STATE_OK;
}

View File

@ -1,72 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_v0.h
* @brief libscp version 0 declarations
* @author Simone Fedele
*
*/
#ifndef LIBSCP_V0_H
#define LIBSCP_V0_H
#include "libscp_types.h"
/* client API */
/**
*
* @brief connects to sesman using scp v0
* @param c connection descriptor
* @param s session descriptor
* @param d display
*
*/
enum SCP_CLIENT_STATES_E scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
/* server API */
/**
*
* @brief processes the stream using scp version 0
* @param c connection descriptor
* @param s session descriptor
* @param skipVchk if set to !0 skips the version control (to be used after
* scp_vXs_accept() )
*
*/
enum SCP_SERVER_STATES_E scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk);
/**
*
* @brief allows the connection to TS, returning the display port
* @param c connection descriptor
*
*/
enum SCP_SERVER_STATES_E scp_v0s_allow_connection(struct SCP_CONNECTION* c, SCP_DISPLAY d);
/**
*
* @brief denies the connection to TS
* @param c connection descriptor
*
*/
enum SCP_SERVER_STATES_E scp_v0s_deny_connection(struct SCP_CONNECTION* c);
#endif

View File

@ -1,447 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_v1c.c
* @brief libscp version 1 client api code
* @author Simone Fedele
*
*/
#include "libscp_v1c.h"
#include <stdlib.h>
#include <stdio.h>
static enum SCP_CLIENT_STATES_E _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
/* client API */
/* 001 */
enum SCP_CLIENT_STATES_E scp_v1c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
{
tui8 sz;
tui32 size;
init_stream(c->out_s, c->out_s->size);
init_stream(c->in_s, c->in_s->size);
size=19+17+4+ g_strlen(s->hostname) + g_strlen(s->username) + g_strlen(s->password);
if (s->addr_type==SCP_ADDRESS_TYPE_IPV4)
{
size=size+4;
}
else
{
size=size+16;
}
/* sending request */
/* header */
out_uint32_be(c->out_s, 1); /* version */
out_uint32_be(c->out_s, size);
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT);
out_uint16_be(c->out_s, 1);
/* body */
out_uint8(c->out_s, s->type);
out_uint16_be(c->out_s, s->height);
out_uint16_be(c->out_s, s->width);
out_uint8(c->out_s, s->bpp);
out_uint8(c->out_s, s->rsr);
out_uint8p(c->out_s, s->locale, 17);
out_uint8(c->out_s, s->addr_type);
if (s->addr_type==SCP_ADDRESS_TYPE_IPV4)
{
out_uint32_be(c->out_s, s->ipv4addr);
}
else
{
#warning ipv6 address needed
}
sz=g_strlen(s->hostname);
out_uint8(c->out_s, sz);
out_uint8p(c->out_s, s->hostname, sz);
sz=g_strlen(s->username);
out_uint8(c->out_s, sz);
out_uint8p(c->out_s, s->username, sz);
sz=g_strlen(s->password);
out_uint8(c->out_s, sz);
out_uint8p(c->out_s, s->password, sz);
if (0!=tcp_force_send(c->in_sck, c->out_s->data, size))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
/* wait for response */
return _scp_v1c_check_response(c, s);
}
/* 004 */
enum SCP_CLIENT_STATES_E scp_v1c_resend_credentials(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
{
tui8 sz;
tui32 size;
init_stream(c->out_s, c->out_s->size);
init_stream(c->in_s, c->in_s->size);
size=12+2+g_strlen(s->username)+g_strlen(s->password);
/* sending request */
/* header */
out_uint32_be(c->out_s, 1); /* version */
out_uint32_be(c->out_s, size);
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT);
out_uint16_be(c->out_s, 4);
/* body */
sz=g_strlen(s->username);
out_uint8(c->out_s, sz);
out_uint8p(c->out_s, s->username, sz);
sz=g_strlen(s->password);
out_uint8(c->out_s, sz);
out_uint8p(c->out_s, s->password, sz);
if (0!=tcp_force_send(c->in_sck, c->out_s->data, size))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
/* wait for response */
return _scp_v1c_check_response(c, s);
}
/* 021 */ enum SCP_CLIENT_STATES_E scp_v1c_pwd_change(struct SCP_CONNECTION* c, char* newpass);
/* 022 */ enum SCP_CLIENT_STATES_E scp_v1c_pwd_change_cancel(struct SCP_CONNECTION* c);
/* 041 */
enum SCP_CLIENT_STATES_E
scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount, struct SCP_DISCONNECTED_SESSION** s)
{
tui32 version=1;
tui32 size=12;
tui16 cmd=41;
tui32 sescnt=0; /* total session number */
tui32 sestmp=0; /* additional total session number */
tui8 pktcnt=0; /* packet session count */
tui32 totalcnt=0; /* session counter */
tui8 continued=0; /* continue flag */
int firstpkt=1; /* "first packet" flag */
int idx;
struct SCP_DISCONNECTED_SESSION* ds=0;
init_stream(c->out_s, c->out_s->size);
/* we request session list */
out_uint32_be(c->out_s, version); /* version */
out_uint32_be(c->out_s, size); /* size */
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT); /* cmdset */
out_uint16_be(c->out_s, cmd); /* cmd */
if (0!=tcp_force_send(c->in_sck, c->out_s->data, size))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
do
{
/* then we wait for server response */
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version!=1)
{
return SCP_CLIENT_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size<12)
{
return SCP_CLIENT_STATE_SIZE_ERR;
}
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, size-8))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd!=SCP_COMMAND_SET_DEFAULT)
{
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd!=42)
{
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
if (firstpkt)
{
firstpkt = 0;
in_uint32_be(c->in_s, sescnt);
sestmp = sescnt;
ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION)*sescnt, 0);
if (ds == 0)
{
return SCP_CLIENT_STATE_INTERNAL_ERR;
}
}
else
{
in_uint32_be(c->in_s, sestmp);
}
in_uint8(c->in_s, continued);
in_uint8(c->in_s, pktcnt);
for (idx=0; idx<pktcnt; idx++)
{
in_uint32_be(c->in_s, (ds[totalcnt]).SID); /* session id */
in_uint8(c->in_s, (ds[totalcnt]).type);
in_uint16_be(c->in_s, (ds[totalcnt]).height);
in_uint16_be(c->in_s, (ds[totalcnt]).width);
in_uint8(c->in_s, (ds[totalcnt]).bpp);
in_uint8(c->in_s, (ds[totalcnt]).idle_days);
in_uint8(c->in_s, (ds[totalcnt]).idle_hours);
in_uint8(c->in_s, (ds[totalcnt]).idle_minutes);
totalcnt++;
}
}
while (continued);
printf("fine\n");
/* return data... */
(*scount) = sescnt;
(*s) = ds;
return SCP_CLIENT_STATE_LIST_OK;
}
/* 043 */
enum SCP_CLIENT_STATES_E
scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s, SCP_SID sid)
{
tui32 version = 1;
tui32 size = 16;
tui16 cmd = 43;
init_stream(c->out_s, c->out_s->size);
/* sending our selection */
out_uint32_be(c->out_s, version); /* version */
out_uint32_be(c->out_s, size); /* size */
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT); /* cmdset */
out_uint16_be(c->out_s, cmd); /* cmd */
out_uint32_be(c->out_s, sid);
if (0!=tcp_force_send(c->in_sck, c->out_s->data, size))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
/* waiting for response.... */
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version!=1)
{
return SCP_CLIENT_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size<12)
{
return SCP_CLIENT_STATE_SIZE_ERR;
}
init_stream(c->in_s, c->in_s->size);
/* read the rest of the packet */
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, size-8))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != SCP_COMMAND_SET_DEFAULT)
{
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != 46)
{
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
/* session display */
in_uint16_be(c->in_s, (s->display));
/*we don't need to return any data other than the display */
/*because we already sent that */
return SCP_CLIENT_STATE_OK;
}
/* 044 */
enum SCP_CLIENT_STATES_E
scp_v1c_select_session_cancel(struct SCP_CONNECTION* c)
{
tui32 version = 1;
tui32 size = 12;
tui16 cmd = 44;
init_stream(c->out_s, c->out_s->size);
/* sending our selection */
out_uint32_be(c->out_s, version); /* version */
out_uint32_be(c->out_s, size); /* size */
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT); /* cmdset */
out_uint16_be(c->out_s, cmd); /* cmd */
if (0!=tcp_force_send(c->in_sck, c->out_s->data, size))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
return SCP_CLIENT_STATE_END;
}
static enum SCP_CLIENT_STATES_E _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
{
tui32 version;
tui32 size;
tui16 cmd;
tui16 dim;
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version!=1)
{
return SCP_CLIENT_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
init_stream(c->in_s, c->in_s->size);
/* read the rest of the packet */
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, size-8))
{
return SCP_CLIENT_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd!=SCP_COMMAND_SET_DEFAULT)
{
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd)
if (cmd==2) /* connection denied */
{
in_uint16_be(c->in_s, dim);
if (s->errstr!=0)
{
g_free(s->errstr);
}
s->errstr=g_malloc(dim+1,0);
if (s->errstr==0)
{
return SCP_CLIENT_STATE_INTERNAL_ERR;
}
in_uint8a(c->in_s, s->errstr, dim);
(s->errstr)[dim]='\0';
return SCP_CLIENT_STATE_CONNECTION_DENIED;
}
else if (cmd==3) /* resend usr/pwd */
{
in_uint16_be(c->in_s, dim);
if (s->errstr!=0)
{
g_free(s->errstr);
}
s->errstr=g_malloc(dim+1,0);
if (s->errstr==0)
{
return SCP_CLIENT_STATE_INTERNAL_ERR;
}
in_uint8a(c->in_s, s->errstr, dim);
(s->errstr)[dim]='\0';
return SCP_CLIENT_STATE_RESEND_CREDENTIALS;
}
else if (cmd==20) /* password change */
{
in_uint16_be(c->in_s, dim);
if (s->errstr!=0)
{
g_free(s->errstr);
}
s->errstr=g_malloc(dim+1,0);
if (s->errstr==0)
{
return SCP_CLIENT_STATE_INTERNAL_ERR;
}
in_uint8a(c->in_s, s->errstr, dim);
(s->errstr)[dim]='\0';
return SCP_CLIENT_STATE_PWD_CHANGE_REQ;
}
else if (cmd==30) /* display */
{
in_uint16_be(c->in_s, s->display);
return SCP_CLIENT_STATE_OK;
}
//else if (cmd==31) /* there's a disconnected session */
//{
// return SCP_CLIENT_STATE_RECONNECT_SINGLE;
//}
//else if (cmd==33) /* display of a disconnected session */
//{
// return SCP_CLIENT_STATE_RECONNECT;
//}
else if (cmd==40) /* session list */
{
return SCP_CLIENT_STATE_SESSION_LIST;
}
return SCP_CLIENT_STATE_SEQUENCE_ERR;
}

View File

@ -1,64 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_v1c.h
* @brief libscp version 1 client api declarations
* @author Simone Fedele
*
*/
#ifndef LIBSCP_V1C_H
#define LIBSCP_V1C_H
#include "libscp_types.h"
/* client API */
/* 001 */
enum SCP_CLIENT_STATES_E
scp_v1c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
/* 004 */
enum SCP_CLIENT_STATES_E
scp_v1c_resend_credentials(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
/* 021 */
enum SCP_CLIENT_STATES_E
scp_v1c_pwd_change(struct SCP_CONNECTION* c, char* newpass);
/* 022 */
enum SCP_CLIENT_STATES_E
scp_v1c_pwd_change_cancel(struct SCP_CONNECTION* c);
/* 041 */
enum SCP_CLIENT_STATES_E
scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
struct SCP_DISCONNECTED_SESSION** s);
/* 043 */
enum SCP_CLIENT_STATES_E
scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
SCP_SID sid);
/* 044 */
enum SCP_CLIENT_STATES_E
scp_v1c_select_session_cancel(struct SCP_CONNECTION* c);
#endif

View File

@ -1,599 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_v1s.c
* @brief libscp version 1 server api code
* @author Simone Fedele
*
*/
#ifndef LIBSCP_V1S_C
#define LIBSCP_V1S_C
#include "libscp_v1s.h"
/* server API */
enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
{
struct SCP_SESSION* session;
tui32 version;
tui32 size;
tui16 cmdset;
tui16 cmd;
tui8 sz;
if (!skipVchk)
{
if (0==tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
in_uint32_be(c->in_s, version);
if (version != 1)
{
return SCP_SERVER_STATE_VERSION_ERR;
}
}
else
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
}
else
{
version=1;
}
in_uint32_be(c->in_s, size);
if (size<12)
{
return SCP_SERVER_STATE_SIZE_ERR;
}
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
/* reading command set */
in_uint16_be(c->in_s, cmdset);
/* if we are starting a management session */
if (cmdset==SCP_COMMAND_SET_MANAGE)
{
return SCP_SERVER_STATE_START_MANAGE;
}
/* if we started with resource sharing... */
if (cmdset==SCP_COMMAND_SET_RSR)
{
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
/* reading command */
in_uint16_be(c->in_s, cmd);
if (cmd != 1)
{
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
session = g_malloc(sizeof(struct SCP_SESSION),1);
if (0 == session)
{
return SCP_SERVER_STATE_INTERNAL_ERR;
}
session->version=1;
in_uint8(c->in_s, session->type);
if ((session->type != SCP_SESSION_TYPE_XVNC) && (session->type != SCP_SESSION_TYPE_XRDP))
{
g_free(session);
return SCP_SERVER_STATE_SESSION_TYPE_ERR;
}
in_uint16_be(c->in_s,session->height);
in_uint16_be(c->in_s, session->width);
in_uint8(c->in_s, session->bpp);
in_uint8(c->in_s, session->rsr);
in_uint8a(c->in_s, session->locale, 17);
session->locale[17]='\0';
in_uint8(c->in_s, session->addr_type);
if (session->addr_type==SCP_ADDRESS_TYPE_IPV4)
{
in_uint32_be(c->in_s, session->ipv4addr);
}
else if (session->addr_type==SCP_ADDRESS_TYPE_IPV6)
{
#warning how to handle ipv6 addresses?
}
/* reading hostname */
in_uint8(c->in_s, sz);
session->hostname=g_malloc(sz+1,1);
if (0==session->hostname)
{
g_free(session);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
session->hostname[sz]='\0';
in_uint8a(c->in_s, session->hostname, sz);
/* reading username */
in_uint8(c->in_s, sz);
session->username=g_malloc(sz+1,1);
if (0==session->username)
{
g_free(session->hostname);
g_free(session);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
session->username[sz]='\0';
in_uint8a(c->in_s, session->username, sz);
/* reading password */
in_uint8(c->in_s, sz);
session->password=g_malloc(sz+1,1);
if (0==session->password)
{
g_free(session->username);
g_free(session->hostname);
g_free(session);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
session->password[sz]='\0';
in_uint8a(c->in_s, session->password, sz);
/* returning the struct */
(*s)=session;
return SCP_SERVER_STATE_OK;
}
enum SCP_SERVER_STATES_E
scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason)
{
int rlen;
init_stream(c->out_s,c->out_s->size);
/* forcing message not to exceed 64k */
rlen = g_strlen(reason);
if (rlen > 65535)
{
rlen = 65535;
}
out_uint32_be(c->out_s, 1);
/* packet size: 4 + 4 + 2 + 2 + 2 + strlen(reason)*/
/* version + size + cmdset + cmd + msglen + msg */
out_uint32_be(c->out_s, rlen+14);
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT);
out_uint16_be(c->out_s, 2);
out_uint16_be(c->out_s, rlen)
out_uint8p(c->out_s, reason, rlen);
if (0!=tcp_force_send(c->in_sck, c->out_s->data, rlen+14))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
return SCP_SERVER_STATE_END;
}
enum SCP_SERVER_STATES_E
scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char* reason)
{
tui8 sz;
char *ubuf;
char *pbuf;
tui32 version;
tui32 size;
tui16 cmdset;
tui16 cmd;
int rlen;
init_stream(c->in_s, c->in_s->size);
init_stream(c->out_s, c->out_s->size);
/* forcing message not to exceed 64k */
rlen = g_strlen(reason);
if (rlen > 65535)
{
rlen = 65535;
}
/* send password request */
version=1;
size=12;
cmdset=0;
cmd=3;
out_uint32_be(c->out_s, version); /* version */
out_uint32_be(c->out_s, 14+rlen); /* size */
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT); /* cmdset */
out_uint16_be(c->out_s, cmd); /* cmd */
out_uint16_be(c->out_s, rlen);
out_uint8p(c->out_s, reason, rlen);
if (0!=tcp_force_send(c->in_sck, c->out_s->data, 14+rlen))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
/* receive password & username */
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version!=1)
{
return SCP_SERVER_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size<12)
{
return SCP_SERVER_STATE_SIZE_ERR;
}
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmdset);
if (cmdset != SCP_COMMAND_SET_DEFAULT)
{
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != 4)
{
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
/* reading username */
in_uint8(c->in_s, sz);
ubuf=g_malloc(sz+1,1);
if (0==ubuf)
{
return SCP_SERVER_STATE_INTERNAL_ERR;
}
ubuf[sz]='\0';
in_uint8a(c->in_s, ubuf, sz);
/* reading password */
in_uint8(c->in_s, sz);
pbuf=g_malloc(sz+1,1);
if (0==pbuf)
{
g_free(ubuf);
return SCP_SERVER_STATE_INTERNAL_ERR;
}
pbuf[sz]='\0';
in_uint8a(c->in_s, pbuf, sz);
/* replacing username and password */
g_free(s->username);
g_free(s->password);
s->username=ubuf;
s->password=pbuf;
return SCP_SERVER_STATE_OK;
}
/* 020 */
enum SCP_SERVER_STATES_E
scp_v1s_request_pwd_change(struct SCP_CONNECTION* c, char* reason, char* npw)
{
return SCP_SERVER_STATE_INTERNAL_ERR;
}
/* 023 */
enum SCP_SERVER_STATES_E
scp_v1s_pwd_change_error(struct SCP_CONNECTION* c, char* error, int retry, char* npw)
{
return SCP_SERVER_STATE_INTERNAL_ERR;
}
/* 030 */
enum SCP_SERVER_STATES_E
scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d)
{
/* send password request */
tui32 version=1;
tui32 size=14;
tui16 cmd=30;
init_stream(c->out_s, c->out_s->size);
out_uint32_be(c->out_s, version); /* version */
out_uint32_be(c->out_s, size); /* size */
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT); /* cmdset */
out_uint16_be(c->out_s, cmd); /* cmd */
out_uint16_be(c->out_s, d); /* display */
if (0!=tcp_force_send(c->in_sck, c->out_s->data, 14))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
return SCP_SERVER_STATE_OK;
}
/* 032 */
enum SCP_SERVER_STATES_E
scp_v1s_connection_error(struct SCP_CONNECTION* c, char* error)
{
return SCP_SERVER_STATE_INTERNAL_ERR;
return SCP_SERVER_STATE_END;
}
/* 040 */
enum SCP_SERVER_STATES_E
scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNECTED_SESSION* ds, SCP_SID* sid)
{
tui32 version=1;
tui32 size=12;
tui16 cmd=40;
int pktcnt;
int idx;
int sidx;
int pidx;
struct SCP_DISCONNECTED_SESSION* cds;
/* first we send a notice that we have some disconnected sessions */
init_stream(c->out_s, c->out_s->size);
out_uint32_be(c->out_s, version); /* version */
out_uint32_be(c->out_s, size); /* size */
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT); /* cmdset */
out_uint16_be(c->out_s, cmd); /* cmd */
if (0!=tcp_force_send(c->in_sck, c->out_s->data, size))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
/* then we wait for client ack */
#warning maybe this message could say if the session should be resized on
#warning server side or client side
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version!=1)
{
return SCP_SERVER_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size<12)
{
return SCP_SERVER_STATE_SIZE_ERR;
}
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != SCP_COMMAND_SET_DEFAULT)
{
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != 41)
{
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
/* calculating the number of packets to send */
pktcnt=sescnt/SCP_SERVER_MAX_LIST_SIZE;
if ((sescnt%SCP_SERVER_MAX_LIST_SIZE)!=0)
{
pktcnt++;
}
for (idx=0; idx<pktcnt; idx++)
{
/* ok, we send session session list */
init_stream(c->out_s, c->out_s->size);
/* size: ver+size+cmdset+cmd+sescnt+continue+count */
size=4+4+2+2+4+1+1;
/* header */
cmd=42;
s_push_layer(c->out_s, channel_hdr, 8);
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT);
out_uint16_be(c->out_s, cmd);
/* session count */
out_uint32_be(c->out_s, sescnt);
/* setting the continue flag */
if ((idx+1)*SCP_SERVER_MAX_LIST_SIZE >= sescnt)
{
out_uint8(c->out_s, 0);
/* setting session count for this packet */
pidx=sescnt-(idx*SCP_SERVER_MAX_LIST_SIZE);
out_uint8(c->out_s, pidx);
}
else
{
out_uint8(c->out_s, 1);
/* setting session count for this packet */
pidx=SCP_SERVER_MAX_LIST_SIZE;
out_uint8(c->out_s, pidx);
}
/* adding session descriptors */
for (sidx=0; sidx<pidx; sidx++)
{
/* shortcut to the current session to send */
cds=ds+((idx)*SCP_SERVER_MAX_LIST_SIZE)+sidx;
/* session data */
out_uint32_be(c->out_s, cds->SID); /* session id */
out_uint8(c->out_s, cds->type);
out_uint16_be(c->out_s, cds->height);
out_uint16_be(c->out_s, cds->width);
out_uint8(c->out_s, cds->bpp);
out_uint8(c->out_s, cds->idle_days);
out_uint8(c->out_s, cds->idle_hours);
out_uint8(c->out_s, cds->idle_minutes);
size = size + 13;
}
s_pop_layer(c->out_s, channel_hdr);
out_uint32_be(c->out_s, version);
out_uint32_be(c->out_s, size);
if (0!=tcp_force_send(c->in_sck, c->out_s->data, size))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
}
/* we get the response */
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, (8)))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version!=1)
{
return SCP_SERVER_STATE_VERSION_ERR;
}
in_uint32_be(c->in_s, size);
if (size<12)
{
return SCP_SERVER_STATE_SIZE_ERR;
}
/* rest of the packet */
init_stream(c->in_s, c->in_s->size);
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, (size-8)))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd != SCP_COMMAND_SET_DEFAULT)
{
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
in_uint16_be(c->in_s, cmd);
if (cmd == 43)
{
/* select session */
in_uint32_be(c->in_s, (*sid));
/* checking sid value */
for (idx=0; idx<sescnt; idx++)
{
/* the sid is valid */
if (ds[idx].SID==(*sid))
{
/* ok, session selected */
return SCP_SERVER_STATE_OK;
}
}
/* if we got here, the requested sid wasn't one from the list we sent */
/* we should kill the connection */
return SCP_CLIENT_STATE_INTERNAL_ERR;
}
else if (cmd == 44)
{
/* cancel connection */
return SCP_SERVER_STATE_SELECTION_CANCEL;
}
// else if (cmd == 45)
// {
// /* force new connection */
// return SCP_SERVER_STATE_FORCE_NEW;
// }
else
{
/* wrong response */
return SCP_SERVER_STATE_SEQUENCE_ERR;
}
return SCP_SERVER_STATE_OK;
}
/* 046 was: 031 struct SCP_DISCONNECTED_SESSION* ds, */
enum SCP_SERVER_STATES_E
scp_v1s_reconnect_session(struct SCP_CONNECTION* c, SCP_DISPLAY d)
{
tui32 version = 1;
tui32 size = 14;
tui16 cmd = 46;
/* ok, we send session data and display */
init_stream(c->out_s, c->out_s->size);
/* header */
out_uint32_be(c->out_s, version);
out_uint32_be(c->out_s, size);
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT);
out_uint16_be(c->out_s, cmd);
/* session data */
out_uint16_be(c->out_s, d); /* session display */
/*out_uint8(c->out_s, ds->type);
out_uint16_be(c->out_s, ds->height);
out_uint16_be(c->out_s, ds->width);
out_uint8(c->out_s, ds->bpp);
out_uint8(c->out_s, ds->idle_days);
out_uint8(c->out_s, ds->idle_hours);
out_uint8(c->out_s, ds->idle_minutes);*/
/* these last three are not really needed... */
if (0!=tcp_force_send(c->in_sck, c->out_s->data, size))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
return SCP_SERVER_STATE_OK;
}
#endif

View File

@ -1,87 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_v1s.h
* @brief libscp version 1 server api declarations
* @author Simone Fedele
*
*/
#ifndef LIBSCP_V1S_H
#define LIBSCP_V1S_H
#include "libscp_types.h"
/* server API */
/**
*
* @brief processes the stream using scp version 1
* @param c connection descriptor
* @param s pointer to session descriptor pointer
* @param skipVchk if set to !0 skips the version control (to be used after
* scp_vXs_accept() )
*
* this function places in *s the address of a newely allocated SCP_SESSION structure
* that should be free()d
*/
enum SCP_SERVER_STATES_E
scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk);
/**
*
* @brief denies connection to sesman
* @param c connection descriptor
* @param reason pointer to a string containinge the reason for denying connection
*
*/
/* 002 */
enum SCP_SERVER_STATES_E
scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason);
enum SCP_SERVER_STATES_E
scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char* reason);
/* 020 */
enum SCP_SERVER_STATES_E
scp_v1s_request_pwd_change(struct SCP_CONNECTION* c, char* reason, char* npw);
/* 023 */
enum SCP_SERVER_STATES_E
scp_v1s_pwd_change_error(struct SCP_CONNECTION* c, char* error, int retry, char* npw);
/* 030 */
enum SCP_SERVER_STATES_E
scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d);
/* 032 */
enum SCP_SERVER_STATES_E
scp_v1s_connection_error(struct SCP_CONNECTION* c, char* error);
/* 040 */
enum SCP_SERVER_STATES_E
scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt,
struct SCP_DISCONNECTED_SESSION* ds, SCP_SID* sid);
/* 046 was: 031 struct SCP_DISCONNECTED_SESSION* ds, */
enum SCP_SERVER_STATES_E
scp_v1s_reconnect_session(struct SCP_CONNECTION* c, SCP_DISPLAY d);
#endif

View File

@ -1,53 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_vX.c
* @brief libscp version neutral code
* @author Simone Fedele
*
*/
#include "libscp_vX.h"
/* server API */
enum SCP_SERVER_STATES_E scp_vXs_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
{
tui32 version;
/* reading version and packet size */
if (0!=tcp_force_recv(c->in_sck, c->in_s->data, 8))
{
return SCP_SERVER_STATE_NETWORK_ERR;
}
in_uint32_be(c->in_s, version);
if (version == 0)
{
return scp_v0s_accept(c, s, 1);
}
else if (version == 1)
{
return scp_v1s_accept(c, s, 1);
}
return SCP_SERVER_STATE_VERSION_ERR;
}

View File

@ -1,48 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_vX.h
* @brief libscp version neutral code header
* @author Simone Fedele
*
*/
#ifndef LIBSCP_VX_H
#define LIBSCP_VX_H
#include "libscp_types.h"
#include "libscp_v0.h"
#include "libscp_v1s.h"
/* server API */
/**
*
* @brief version neutral server accept function
* @param c connection descriptor
* @param s session descriptor pointer address.
* it will return a newely allocated descriptor.
* It this memory needs to be g_free()d
*
*/
enum SCP_SERVER_STATES_E scp_vXs_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s);
#endif

View File

@ -1,145 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file tcp.c
* @brief Tcp stream funcions
* @author Jay Sorg, Simone Fedele
*
*/
#include "sesman.h"
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
/*****************************************************************************/
int DEFAULT_CC
tcp_force_recv(int sck, char* data, int len)
{
int rcvd;
#ifndef LIBSCP_CLIENT
int block;
block = lock_fork_critical_section_start();
#endif
while (len > 0)
{
rcvd = g_tcp_recv(sck, data, len, 0);
if (rcvd == -1)
{
if (g_tcp_last_error_would_block(sck))
{
g_sleep(1);
}
else
{
#ifndef LIBSCP_CLIENT
lock_fork_critical_section_end(block);
#endif
return 1;
}
}
else if (rcvd == 0)
{
#ifndef LIBSCP_CLIENT
lock_fork_critical_section_end(block);
#endif
return 1;
}
else
{
data += rcvd;
len -= rcvd;
}
}
#ifndef LIBSCP_CLIENT
lock_fork_critical_section_end(block);
#endif
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
tcp_force_send(int sck, char* data, int len)
{
int sent;
#ifndef LIBSCP_CLIENT
int block;
block = lock_fork_critical_section_start();
#endif
while (len > 0)
{
sent = g_tcp_send(sck, data, len, 0);
if (sent == -1)
{
if (g_tcp_last_error_would_block(sck))
{
g_sleep(1);
}
else
{
#ifndef LIBSCP_CLIENT
lock_fork_critical_section_end(block);
#endif
return 1;
}
}
else if (sent == 0)
{
#ifndef LIBSCP_CLIENT
lock_fork_critical_section_end(block);
#endif
return 1;
}
else
{
data += sent;
len -= sent;
}
}
#ifndef LIBSCP_CLIENT
lock_fork_critical_section_end(block);
#endif
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
tcp_bind(int sck, char* addr, char* port)
{
struct sockaddr_in s;
memset(&s, 0, sizeof(struct sockaddr_in));
s.sin_family = AF_INET;
s.sin_port = htons(atoi(port));
s.sin_addr.s_addr = inet_addr(addr);
return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
}

View File

@ -1,67 +0,0 @@
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file tcp.h
* @brief Tcp stream functions declarations
* @author Jay Sorg, Simone Fedele
*
*/
#ifndef TCP_H
#define TCP_H
/**
*
* @brief Force receiving data from tcp stream
* @param sck The socket to read from
* @param data Data buffer
* @param len Data buffer size
* @return 0 on success, 1 on error
*
*/
int DEFAULT_CC
tcp_force_recv(int sck, char* data, int len);
/**
*
* @brief Force sending data to tcp stream
* @param sck the socket to write to
* @param data Data buffer
* @param len Data buffer size
* @return 0 on success, 1 on error
*
*/
int DEFAULT_CC
tcp_force_send(int sck, char* data, int len);
/**
*
* @brief Binds the listening socket
* @param sck Listening socket
* @param addr Listening address
* @param port Listening port
* @return 0 on success, -1 on error
*
*/
int DEFAULT_CC
tcp_bind(int sck, char* addr, char* port);
#endif