parent
0a7dc2b687
commit
71e7fc734d
@ -0,0 +1,37 @@
|
||||
/*
|
||||
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 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
|
@ -0,0 +1,117 @@
|
||||
/*
|
||||
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 libscp_types.h
|
||||
* @brief libscp data types definitions
|
||||
* @author Simone Fedele
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LIBSCP_TYPES_H
|
||||
#define LIBSCP_TYPES_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "os_calls.h"
|
||||
#include "parse.h"
|
||||
#include "arch.h"
|
||||
|
||||
//#warning sesman requires its own tcp streaming functions for threading safety
|
||||
#include "tcp.h"
|
||||
|
||||
#define SCP_SID uint32_t
|
||||
#define SCP_DISPLAY uint16_t
|
||||
|
||||
//#warning this should be an INT16 on every platform...
|
||||
//typedef unsigned int SCP_DISPLAY_PORT; --> uint16_t is it portable?
|
||||
|
||||
#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
|
||||
|
||||
struct SCP_CONNECTION
|
||||
{
|
||||
int in_sck;
|
||||
struct stream* in_s;
|
||||
struct stream* out_s;
|
||||
};
|
||||
|
||||
struct SCP_SESSION
|
||||
{
|
||||
unsigned char type;
|
||||
uint32_t version;
|
||||
uint16_t height;
|
||||
uint16_t width;
|
||||
unsigned char bpp;
|
||||
unsigned char rsr;
|
||||
char locale[18];
|
||||
char* username;
|
||||
char* password;
|
||||
char* hostname;
|
||||
unsigned char addr_type;
|
||||
uint32_t ipv4addr; //htons
|
||||
uint32_t ipv6addr; //should be 128bit
|
||||
uint16_t display;
|
||||
char* errstr;
|
||||
};
|
||||
|
||||
struct SCP_DISCONNECTED_SESSION
|
||||
{
|
||||
uint32_t SID;
|
||||
unsigned char type;
|
||||
uint16_t height;
|
||||
uint16_t width;
|
||||
unsigned char bpp;
|
||||
unsigned char idle_days;
|
||||
unsigned char idle_hours;
|
||||
unsigned char idle_minutes;
|
||||
};
|
||||
|
||||
enum SCP_CLIENT_STATES_E
|
||||
{
|
||||
SCP_CLIENT_STATE_OK,
|
||||
SCP_CLIENT_STATE_NETWORK_ERR
|
||||
};
|
||||
|
||||
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_START_MANAGE,
|
||||
SCP_SERVER_STATE_END
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,188 @@
|
||||
/*
|
||||
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 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, SCP_DISPLAY* d)
|
||||
{
|
||||
uint16_t 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);
|
||||
|
||||
out_uint16_be(c->out_s, 10); // code
|
||||
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;
|
||||
}
|
||||
|
||||
return SCP_CLIENT_STATE_OK;
|
||||
}
|
||||
|
||||
/* server API */
|
||||
/******************************************************************************/
|
||||
enum SCP_SERVER_STATES_E scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
{
|
||||
uint32_t version=0;
|
||||
uint32_t size;
|
||||
struct SCP_SESSION* session=0;
|
||||
uint16_t sz;
|
||||
uint32_t 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;
|
||||
|
||||
g_printf("session %x\n",session);
|
||||
|
||||
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) 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) 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;
|
||||
}
|
||||
|
||||
//reset_stream(c->in_s);
|
||||
//reset_stream(c->out_s);
|
||||
(*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;
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
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 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, SCP_DISPLAY* d);
|
||||
|
||||
/* 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
|
@ -0,0 +1,31 @@
|
||||
#include "scp.h"
|
||||
|
||||
#ifndef SCP_V1C_H
|
||||
#define SCP_V1C_H
|
||||
|
||||
enum SCP_CLIENY_STATES_E
|
||||
{
|
||||
SCP_CLIENT_STATE_NO,
|
||||
SCP_CLIENT_STATE_WRONGPWD,
|
||||
SCP_CLIENT_STATE_PWDCHG_REQ,
|
||||
SCP_CLIENT_STATE_PWDCHG_CANCEL,
|
||||
SCP_CLIENT_STATE_,
|
||||
|
||||
};
|
||||
|
||||
/* client API */
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
/* 001 */ SCP_CLIENT_STATES_E scp_v1c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s);
|
||||
ritorna errore: o il display
|
||||
|
||||
/* 021 */ SCP_CLIENT_STATES_E scp_v1c_pwd_change(struct SCP_CONNECTION* c, char* newpass);
|
||||
/* 022 */ SCP_CLIENT_STATES_E scp_v1c_pwd_change_cancel(struct SCP_CONNECTION* c);
|
||||
|
||||
/* ... */ SCP_CLIENT_STATES_E scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount, struct SCP_DISCONNECTED_SESSION** s);
|
||||
/* 041 */ SCP_CLIENT_STATES_E scp_v1c_select_session(struct SCP_CONNECTION* c, SCP_SID sid);
|
||||
/* 042 */ SCP_CLIENT_STATES_E scp_v1c_select_session_cancel(struct SCP_CONNECTION* c);
|
||||
|
||||
#endif
|
@ -0,0 +1,227 @@
|
||||
|
||||
#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;
|
||||
uint32_t version;
|
||||
uint32_t size;
|
||||
uint16_t cmdset;
|
||||
uint16_t cmd;
|
||||
unsigned char 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;
|
||||
}
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
if (size<12)
|
||||
{
|
||||
return SCP_SERVER_STATE_SIZE_ERR;
|
||||
}
|
||||
|
||||
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 != 0)
|
||||
{
|
||||
return SCP_SERVER_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
session = g_malloc(sizeof(struct SCP_SESSION),1);
|
||||
if (0 == session) return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
|
||||
in_uint8(c->in_s, session->type);
|
||||
if ((session->type != SCP_SESSION_TYPE_XVNC) && (session->type != SCP_SESSION_TYPE_XRDP))
|
||||
{
|
||||
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) 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) 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) return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
session->password[sz]='\0';
|
||||
in_uint8a(c->in_s, session->password, sz);
|
||||
|
||||
//leggo lo stream e ritorno la struttura
|
||||
*s=session;
|
||||
|
||||
return SCP_SERVER_STATE_OK;
|
||||
}
|
||||
|
||||
enum SCP_SERVER_STATES_E scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason)
|
||||
{
|
||||
int rlen;
|
||||
|
||||
/* 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, char** pwd, char** user)
|
||||
{
|
||||
unsigned char sz;
|
||||
uint32_t version;
|
||||
uint32_t size;
|
||||
uint16_t cmdset;
|
||||
uint16_t cmd;
|
||||
|
||||
version=1;
|
||||
size=12;
|
||||
cmdset=0;
|
||||
cmd=3;
|
||||
|
||||
/* send password request */
|
||||
out_uint32_be(c->out_s, 1); /* version */
|
||||
out_uint32_be(c->out_s, 12); /* size */
|
||||
out_uint16_be(c->out_s, SCP_COMMAND_SET_DEFAULT); /* cmdset */
|
||||
out_uint16_be(c->out_s, 3); /* cmd */
|
||||
|
||||
if (0!=tcp_force_send(c->in_sck, c->out_s->data, 12))
|
||||
{
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
/* receive password & username */
|
||||
#warning check cmd seq
|
||||
/* tcp_force_recv()
|
||||
in_uint32_be()
|
||||
in_uint32_be
|
||||
in_uint16_be
|
||||
in_uint16_be*/
|
||||
|
||||
/* reading username */
|
||||
in_uint8(c->in_s, sz);
|
||||
(*user)=g_malloc(sz+1,1);
|
||||
if (0==(*user)) return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
(*user)[sz]='\0';
|
||||
in_uint8a(c->in_s, (*user), sz);
|
||||
|
||||
/* reading password */
|
||||
in_uint8(c->in_s, sz);
|
||||
(*pwd)=g_malloc(sz+1,1);
|
||||
if (0==(*pwd)) return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
(*pwd)[sz]='\0';
|
||||
in_uint8a(c->in_s, (*pwd), sz);
|
||||
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
/* 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* s, 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* s, SCP_DISPLAY d)
|
||||
{
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
/* 031 */
|
||||
enum SCP_SERVER_STATES_E scp_v1s_reconnect_session(struct SCP_CONNECTION* s, SCP_DISPLAY d)
|
||||
{
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
/* 032 */
|
||||
enum SCP_SERVER_STATES_E scp_v1s_connection_error(struct SCP_CONNECTION* s, char* error)
|
||||
{
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
/* 040 */
|
||||
enum SCP_SERVER_STATES_E scp_v1s_list_sessions(struct SCP_CONNECTION* s, int sescnt, struct SCP_DISCONNECTED_SESSION** ds, SCP_SID* sid)
|
||||
{
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,20 @@
|
||||
|
||||
#ifndef LIBSCP_V1S_H
|
||||
#define LIBSCP_V1S_H
|
||||
|
||||
#include "libscp_types.h"
|
||||
//#include "os_calls.h"
|
||||
//#include "tcp.h"
|
||||
|
||||
/* server API */
|
||||
/* ... */ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk);
|
||||
/* 002 */ enum SCP_SERVER_STATES_E scp_v1s_deny_connection(struct SCP_CONNECTION* c, 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* s, char* error, int retry, char* npw);
|
||||
/* 030 */ enum SCP_SERVER_STATES_E scp_v1s_connect_new_session(struct SCP_CONNECTION* s, SCP_DISPLAY d);
|
||||
/* 031 */ enum SCP_SERVER_STATES_E scp_v1s_reconnect_session(struct SCP_CONNECTION* s, SCP_DISPLAY d);
|
||||
/* 032 */ enum SCP_SERVER_STATES_E scp_v1s_connection_error(struct SCP_CONNECTION* s, char* error);
|
||||
/* 040 */ enum SCP_SERVER_STATES_E scp_v1s_list_sessions(struct SCP_CONNECTION* s, int sescnt, struct SCP_DISCONNECTED_SESSION** ds, SCP_SID* sid);
|
||||
|
||||
#endif
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
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 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)
|
||||
{
|
||||
uint32_t 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;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
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 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
|
Loading…
Reference in new issue