2007-05-07 01:02:25 +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.
|
2010-07-04 11:36:06 +04:00
|
|
|
Copyright (C) Jay Sorg 2005-2010
|
2007-05-07 01:02:25 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @file libscp_v0.c
|
|
|
|
* @brief libscp version 0 code
|
|
|
|
* @author Simone Fedele
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libscp_v0.h"
|
|
|
|
|
|
|
|
#include "os_calls.h"
|
2008-07-30 14:58:30 +04:00
|
|
|
|
|
|
|
extern struct log_config* s_log;
|
|
|
|
|
2007-05-07 01:02:25 +04:00
|
|
|
/* client API */
|
|
|
|
/******************************************************************************/
|
2009-08-19 11:27:35 +04:00
|
|
|
enum SCP_CLIENT_STATES_E
|
|
|
|
scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
|
|
|
tui32 version;
|
|
|
|
tui32 size;
|
|
|
|
tui16 sz;
|
|
|
|
|
|
|
|
init_stream(c->in_s, c->in_s->size);
|
|
|
|
init_stream(c->out_s, c->in_s->size);
|
|
|
|
|
2012-05-27 19:17:39 +04:00
|
|
|
LOG_DBG("[v0:%d] starting connection", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
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);
|
|
|
|
|
2008-07-30 14:58:30 +04:00
|
|
|
/* code */
|
|
|
|
if (s->type == SCP_SESSION_TYPE_XVNC)
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2008-07-30 14:58:30 +04:00
|
|
|
out_uint16_be(c->out_s, 0);
|
2007-05-07 01:02:25 +04:00
|
|
|
}
|
2008-07-30 14:58:30 +04:00
|
|
|
else if (s->type == SCP_SESSION_TYPE_XRDP)
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2008-07-30 14:58:30 +04:00
|
|
|
out_uint16_be(c->out_s, 10);
|
2007-05-07 01:02:25 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
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);
|
|
|
|
|
2008-07-30 14:58:30 +04:00
|
|
|
/* version */
|
|
|
|
out_uint32_be(c->out_s, 0);
|
|
|
|
/* size */
|
|
|
|
out_uint32_be(c->out_s, c->out_s->end - c->out_s->data);
|
2007-05-07 01:02:25 +04:00
|
|
|
|
|
|
|
if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_CLIENT_STATE_NETWORK_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_CLIENT_STATE_NETWORK_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
in_uint32_be(c->in_s, version);
|
|
|
|
if (0 != version)
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_CLIENT_STATE_VERSION_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
in_uint32_be(c->in_s, size);
|
|
|
|
if (size < 14)
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: packet size error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_CLIENT_STATE_SIZE_ERR;
|
|
|
|
}
|
|
|
|
|
2008-07-30 14:58:30 +04:00
|
|
|
/* getting payload */
|
2007-05-07 01:02:25 +04:00
|
|
|
init_stream(c->in_s, c->in_s->size);
|
|
|
|
if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_CLIENT_STATE_NETWORK_ERR;
|
|
|
|
}
|
|
|
|
|
2008-07-30 14:58:30 +04:00
|
|
|
/* check code */
|
2007-05-07 01:02:25 +04:00
|
|
|
in_uint16_be(c->in_s, sz);
|
2008-07-30 14:58:30 +04:00
|
|
|
if (3 != sz)
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
|
|
|
}
|
|
|
|
|
2008-07-30 14:58:30 +04:00
|
|
|
/* message payload */
|
2007-05-07 01:02:25 +04:00
|
|
|
in_uint16_be(c->in_s, sz);
|
2008-07-30 14:58:30 +04:00
|
|
|
if (1 != sz)
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: connection denied", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_CLIENT_STATE_CONNECTION_DENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
in_uint16_be(c->in_s, sz);
|
2008-07-30 14:58:30 +04:00
|
|
|
s->display = sz;
|
2007-05-07 01:02:25 +04:00
|
|
|
|
2012-05-27 19:17:39 +04:00
|
|
|
LOG_DBG("[v0:%d] connection terminated", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_CLIENT_STATE_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* server API */
|
|
|
|
/******************************************************************************/
|
2009-08-19 11:27:35 +04:00
|
|
|
enum SCP_SERVER_STATES_E
|
|
|
|
scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2008-07-30 14:58:30 +04:00
|
|
|
tui32 version = 0;
|
2007-05-07 01:02:25 +04:00
|
|
|
tui32 size;
|
2008-07-30 14:58:30 +04:00
|
|
|
struct SCP_SESSION* session = 0;
|
2007-05-07 01:02:25 +04:00
|
|
|
tui16 sz;
|
2008-07-30 14:58:30 +04:00
|
|
|
tui32 code = 0;
|
|
|
|
char buf[257];
|
2007-05-07 01:02:25 +04:00
|
|
|
|
|
|
|
if (!skipVchk)
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
LOG_DBG("[v0:%d] starting connection", __LINE__);
|
2009-08-19 11:27:35 +04:00
|
|
|
if (0 == scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2009-08-19 11:27:35 +04:00
|
|
|
c->in_s->end = c->in_s->data + 8;
|
2007-05-07 01:02:25 +04:00
|
|
|
in_uint32_be(c->in_s, version);
|
|
|
|
if (version != 0)
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_VERSION_ERR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_NETWORK_ERR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
in_uint32_be(c->in_s, size);
|
|
|
|
|
|
|
|
init_stream(c->in_s, 8196);
|
2009-08-19 11:27:35 +04:00
|
|
|
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_NETWORK_ERR;
|
|
|
|
}
|
2009-08-19 11:27:35 +04:00
|
|
|
c->in_s->end = c->in_s->data + (size - 8);
|
2007-05-07 01:02:25 +04:00
|
|
|
|
|
|
|
in_uint16_be(c->in_s, code);
|
|
|
|
|
|
|
|
if (code == 0 || code == 10)
|
|
|
|
{
|
2009-08-19 11:27:35 +04:00
|
|
|
session = scp_session_create();
|
2007-05-07 01:02:25 +04:00
|
|
|
if (0 == session)
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_INTERNAL_ERR;
|
|
|
|
}
|
|
|
|
|
2008-07-30 14:58:30 +04:00
|
|
|
scp_session_set_version(session, version);
|
2007-05-07 01:02:25 +04:00
|
|
|
if (code == 0)
|
|
|
|
{
|
2008-07-30 14:58:30 +04:00
|
|
|
scp_session_set_type(session, SCP_SESSION_TYPE_XVNC);
|
2007-05-07 01:02:25 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-30 14:58:30 +04:00
|
|
|
scp_session_set_type(session, SCP_SESSION_TYPE_XRDP);
|
2007-05-07 01:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* reading username */
|
|
|
|
in_uint16_be(c->in_s, sz);
|
2008-07-30 14:58:30 +04:00
|
|
|
buf[sz]='\0';
|
|
|
|
in_uint8a(c->in_s, buf, sz);
|
|
|
|
if (0 != scp_session_set_username(session, buf))
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2008-07-30 14:58:30 +04:00
|
|
|
scp_session_destroy(session);
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting username", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_INTERNAL_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reading password */
|
|
|
|
in_uint16_be(c->in_s, sz);
|
2008-07-30 14:58:30 +04:00
|
|
|
buf[sz]='\0';
|
|
|
|
in_uint8a(c->in_s, buf, sz);
|
|
|
|
if (0 != scp_session_set_password(session, buf))
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2008-07-30 14:58:30 +04:00
|
|
|
scp_session_destroy(session);
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting password", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_INTERNAL_ERR;
|
|
|
|
}
|
|
|
|
|
2008-07-30 14:58:30 +04:00
|
|
|
/* width */
|
|
|
|
in_uint16_be(c->in_s, sz);
|
|
|
|
scp_session_set_width(session, sz);
|
|
|
|
/* height */
|
2007-05-07 01:02:25 +04:00
|
|
|
in_uint16_be(c->in_s, sz);
|
2008-07-30 14:58:30 +04:00
|
|
|
scp_session_set_height(session, sz);
|
|
|
|
/* bpp */
|
|
|
|
in_uint16_be(c->in_s, sz);
|
|
|
|
scp_session_set_bpp(session, (tui8)sz);
|
2009-08-19 11:27:35 +04:00
|
|
|
if (s_check_rem(c->in_s, 2))
|
|
|
|
{
|
|
|
|
/* reading domain */
|
|
|
|
in_uint16_be(c->in_s, sz);
|
|
|
|
if (sz > 0)
|
|
|
|
{
|
|
|
|
in_uint8a(c->in_s, buf, sz);
|
|
|
|
buf[sz] = '\0';
|
|
|
|
scp_session_set_domain(session, buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (s_check_rem(c->in_s, 2))
|
|
|
|
{
|
|
|
|
/* reading program */
|
|
|
|
in_uint16_be(c->in_s, sz);
|
|
|
|
if (sz > 0)
|
|
|
|
{
|
|
|
|
in_uint8a(c->in_s, buf, sz);
|
|
|
|
buf[sz] = '\0';
|
|
|
|
scp_session_set_program(session, buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (s_check_rem(c->in_s, 2))
|
|
|
|
{
|
|
|
|
/* reading directory */
|
|
|
|
in_uint16_be(c->in_s, sz);
|
|
|
|
if (sz > 0)
|
|
|
|
{
|
|
|
|
in_uint8a(c->in_s, buf, sz);
|
|
|
|
buf[sz] = '\0';
|
|
|
|
scp_session_set_directory(session, buf);
|
|
|
|
}
|
|
|
|
}
|
2010-11-04 14:14:03 +03:00
|
|
|
if (s_check_rem(c->in_s, 2))
|
|
|
|
{
|
|
|
|
/* reading client IP address */
|
|
|
|
in_uint16_be(c->in_s, sz);
|
|
|
|
if (sz > 0)
|
|
|
|
{
|
|
|
|
in_uint8a(c->in_s, buf, sz);
|
|
|
|
buf[sz] = '\0';
|
|
|
|
scp_session_set_client_ip(session, buf);
|
|
|
|
}
|
|
|
|
}
|
2007-05-07 01:02:25 +04:00
|
|
|
}
|
2012-05-31 18:57:17 +04:00
|
|
|
if (code == SCP_GW_AUTHENTICATION)
|
|
|
|
{
|
|
|
|
/* g_writeln("Command is SCP_GW_AUTHENTICATION"); */
|
|
|
|
session = scp_session_create();
|
|
|
|
if (0 == session)
|
|
|
|
{
|
|
|
|
/* until syslog merge log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);*/
|
|
|
|
return SCP_SERVER_STATE_INTERNAL_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
scp_session_set_version(session, version);
|
|
|
|
scp_session_set_type(session, SCP_GW_AUTHENTICATION);
|
|
|
|
/* reading username */
|
|
|
|
in_uint16_be(c->in_s, sz);
|
|
|
|
buf[sz]='\0';
|
|
|
|
in_uint8a(c->in_s, buf, sz);
|
|
|
|
/* g_writeln("Received user name: %s",buf); */
|
|
|
|
if (0 != scp_session_set_username(session, buf))
|
|
|
|
{
|
|
|
|
scp_session_destroy(session);
|
|
|
|
/* until syslog merge log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting username", __LINE__);*/
|
|
|
|
return SCP_SERVER_STATE_INTERNAL_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reading password */
|
|
|
|
in_uint16_be(c->in_s, sz);
|
|
|
|
buf[sz]='\0';
|
|
|
|
in_uint8a(c->in_s, buf, sz);
|
|
|
|
/* g_writeln("Received password: %s",buf); */
|
|
|
|
if (0 != scp_session_set_password(session, buf))
|
|
|
|
{
|
|
|
|
scp_session_destroy(session);
|
|
|
|
/* until syslog merge log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting password", __LINE__); */
|
|
|
|
return SCP_SERVER_STATE_INTERNAL_ERR;
|
|
|
|
}
|
|
|
|
}
|
2007-05-07 01:02:25 +04:00
|
|
|
else
|
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_SEQUENCE_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*s)=session;
|
|
|
|
return SCP_SERVER_STATE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2009-08-19 11:27:35 +04:00
|
|
|
enum SCP_SERVER_STATES_E
|
|
|
|
scp_v0s_allow_connection(struct SCP_CONNECTION* c, SCP_DISPLAY d)
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
2008-07-30 14:58:30 +04:00
|
|
|
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_NETWORK_ERR;
|
|
|
|
}
|
|
|
|
|
2012-05-27 19:17:39 +04:00
|
|
|
LOG_DBG("[v0:%d] connection terminated (allowed)", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
2009-08-19 11:27:35 +04:00
|
|
|
enum SCP_SERVER_STATES_E
|
|
|
|
scp_v0s_deny_connection(struct SCP_CONNECTION* c)
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
|
|
|
out_uint32_be(c->out_s, 0); /* version */
|
|
|
|
out_uint32_be(c->out_s, 14); /* size */
|
|
|
|
out_uint16_be(c->out_s, 3); /* cmd */
|
2012-05-31 18:57:17 +04:00
|
|
|
out_uint16_be(c->out_s, 0); /* data = 0 - means NOT ok*/
|
|
|
|
out_uint16_be(c->out_s, 0); /* reserved for display number*/
|
2007-05-07 01:02:25 +04:00
|
|
|
s_mark_end(c->out_s);
|
|
|
|
|
2008-07-30 14:58:30 +04:00
|
|
|
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2012-05-27 19:17:39 +04:00
|
|
|
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_NETWORK_ERR;
|
|
|
|
}
|
|
|
|
|
2012-05-27 19:17:39 +04:00
|
|
|
LOG_DBG("[v0:%d] connection terminated (denied)", __LINE__);
|
2007-05-07 01:02:25 +04:00
|
|
|
return SCP_SERVER_STATE_OK;
|
|
|
|
}
|
2012-05-31 18:57:17 +04:00
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
enum SCP_SERVER_STATES_E
|
|
|
|
scp_v0s_replyauthentication(struct SCP_CONNECTION* c, unsigned short int value)
|
|
|
|
{
|
|
|
|
out_uint32_be(c->out_s, 0); /* version */
|
|
|
|
out_uint32_be(c->out_s, 14); /* size */
|
|
|
|
/* cmd SCP_GW_AUTHENTICATION means authentication reply */
|
|
|
|
out_uint16_be(c->out_s, SCP_GW_AUTHENTICATION);
|
|
|
|
out_uint16_be(c->out_s, value); /* reply code */
|
|
|
|
out_uint16_be(c->out_s, 0); /* dummy data */
|
|
|
|
s_mark_end(c->out_s);
|
|
|
|
|
|
|
|
/* g_writeln("Total number of bytes that will be sent %d",c->out_s->end - c->out_s->data);*/
|
|
|
|
if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
|
|
|
|
{
|
|
|
|
/* until syslog merge log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); */
|
|
|
|
return SCP_SERVER_STATE_NETWORK_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* until syslog merge LOG_DBG(s_log, "[v0:%d] connection terminated (scp_v0s_deny_authentication)", __LINE__);*/
|
|
|
|
return SCP_SERVER_STATE_OK;
|
|
|
|
}
|