2006-05-26 17:10:14 +04:00
|
|
|
/*
|
|
|
|
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-2006
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @file scp.c
|
|
|
|
* @brief scp (sesman control protocol) common code
|
|
|
|
* scp (sesman control protocol) common code
|
|
|
|
* This code controls which version is being used and starts the appropriate process
|
|
|
|
* @author Jay Sorg, Simone Fedele
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sesman.h"
|
|
|
|
|
2006-07-14 00:15:21 +04:00
|
|
|
extern int thread_sck;
|
|
|
|
|
2006-05-26 17:10:14 +04:00
|
|
|
/******************************************************************************/
|
2006-07-14 00:15:21 +04:00
|
|
|
void* DEFAULT_CC
|
|
|
|
scp_process_start(void* sck)
|
2006-05-26 17:10:14 +04:00
|
|
|
{
|
2006-10-15 17:08:08 +04:00
|
|
|
struct SCP_CONNECTION scon;
|
|
|
|
struct SCP_SESSION* sdata;
|
2006-05-26 17:10:14 +04:00
|
|
|
|
2006-07-14 00:15:21 +04:00
|
|
|
/* making a local copy of the socket (it's on the stack) */
|
|
|
|
/* probably this is just paranoia */
|
2006-10-15 17:08:08 +04:00
|
|
|
scon.in_sck = thread_sck;
|
|
|
|
LOG_DBG("started scp thread on socket %d", scon.in_sck);
|
2006-07-14 00:15:21 +04:00
|
|
|
|
|
|
|
/* unlocking thread_sck */
|
|
|
|
lock_socket_release();
|
2006-05-26 17:10:14 +04:00
|
|
|
|
2006-10-15 17:08:08 +04:00
|
|
|
make_stream(scon.in_s);
|
|
|
|
make_stream(scon.out_s);
|
2006-05-26 17:10:14 +04:00
|
|
|
|
2006-10-15 17:08:08 +04:00
|
|
|
init_stream(scon.in_s, 8192);
|
|
|
|
init_stream(scon.out_s, 8192);
|
|
|
|
|
|
|
|
switch (scp_vXs_accept(&scon, &(sdata)))
|
2006-05-26 17:10:14 +04:00
|
|
|
{
|
2006-10-15 17:08:08 +04:00
|
|
|
case SCP_SERVER_STATE_OK:
|
|
|
|
if (sdata->version == 0)
|
2006-05-26 17:10:14 +04:00
|
|
|
{
|
|
|
|
/* starts processing an scp v0 connection */
|
2006-10-15 17:08:08 +04:00
|
|
|
scp_v0_process(&scon, sdata);
|
2006-05-26 17:10:14 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-15 17:08:08 +04:00
|
|
|
//scp_v1_process();
|
2006-05-26 17:10:14 +04:00
|
|
|
}
|
2006-10-16 15:25:47 +04:00
|
|
|
break;
|
2006-10-15 17:08:08 +04:00
|
|
|
|
|
|
|
case SCP_SERVER_STATE_VERSION_ERR:
|
|
|
|
/* an unknown scp version was requested, so we shut down the */
|
|
|
|
/* connection (and log the fact) */
|
|
|
|
log_message(LOG_LEVEL_WARNING,"unknown protocol version specified. connection refused.");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCP_SERVER_STATE_NETWORK_ERR:
|
|
|
|
log_message(LOG_LEVEL_WARNING,"libscp network error.");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCP_SERVER_STATE_SEQUENCE_ERR:
|
|
|
|
log_message(LOG_LEVEL_WARNING,"libscp sequence error.");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCP_SERVER_STATE_INTERNAL_ERR:
|
|
|
|
/* internal error occurred (eg. malloc() error, ecc.) */
|
|
|
|
log_message(LOG_LEVEL_ERROR, "libscp internal error occurred.");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
log_message(LOG_LEVEL_ALWAYS, "unknown return from scp_vXs_accept()");
|
2006-05-26 17:10:14 +04:00
|
|
|
}
|
2006-10-15 17:08:08 +04:00
|
|
|
|
|
|
|
g_tcp_close(scon.in_sck);
|
|
|
|
free_stream(scon.in_s);
|
|
|
|
free_stream(scon.out_s);
|
2006-07-14 00:15:21 +04:00
|
|
|
return 0;
|
2006-05-26 17:10:14 +04:00
|
|
|
}
|
|
|
|
|