tcp.c revision d65680efa46fa49e8bf14e67b29b782510ff934c
/* -*- c-basic-offset: 8 -*-
rdesktop: A Remote Desktop Protocol client.
Protocol services - TCP layer
Copyright (C) Matthew Chapman 1999-2007
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.
*/
/*
* Sun GPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Sun elects to use only
* the General Public License version 2 (GPLv2) at this time for any software where
* a choice of GPL license versions is made available with the language indicating
* that GPLv2 or any later version may be used, or where a choice of which version
* of the GPL is applied is otherwise unspecified.
*/
#ifndef _WIN32
#include <unistd.h> /* select read write close */
#include <netdb.h> /* gethostbyname */
#include <errno.h> /* errno */
#endif
#include "rdesktop.h"
#ifdef _WIN32
#define socklen_t int
#define TCP_STRERROR "tcp error"
#else
#endif
#ifndef INADDR_NONE
#define INADDR_NONE ((unsigned long) -1)
#endif
#ifdef WITH_SCARD
#define STREAM_COUNT 8
#else
#define STREAM_COUNT 1
#endif
static int g_sock;
int g_tcp_port_rdp = TCP_PORT_RDP;
/* wait till socket is ready to write or timeout */
static RD_BOOL
{
int sel_count;
if (sel_count > 0)
{
return True;
}
return False;
}
/* Initialise TCP transport data packet */
{
static int cur_stream_id = 0;
#ifdef WITH_SCARD
#endif
{
}
#ifdef WITH_SCARD
#endif
return result;
}
/* Send TCP transport data packet */
void
{
#ifdef WITH_SCARD
#endif
{
if (sent <= 0)
{
{
sent = 0;
}
else
{
return;
}
}
}
#ifdef WITH_SCARD
#endif
}
/* Receive a message on the TCP layer */
{
int rcvd = 0;
if (s == NULL)
{
/* read into "new" stream */
{
}
s = &g_in;
}
else
{
/* append to existing stream */
if (new_length > s->size)
{
s->size = new_length;
}
}
while (length > 0)
{
/* User quit */
return NULL;
if (rcvd < 0)
{
{
rcvd = 0;
}
else
{
return NULL;
}
}
else if (rcvd == 0)
{
error("Connection closed\n");
return NULL;
}
}
return s;
}
/* Establish a connection on the TCP layer */
tcp_connect(char *server)
{
int i;
#ifdef IPv6
int n;
char tcp_port_rdp_s[10];
{
return False;
}
g_sock = -1;
while (res)
{
if (!(g_sock < 0))
{
break;
g_sock = -1;
}
}
if (g_sock == -1)
{
return False;
}
#else /* no IPv6 support */
struct sockaddr_in servaddr;
{
}
{
return False;
}
{
return False;
}
{
return False;
}
#endif /* IPv6 */
option_value = 1;
option_len = sizeof(option_value);
/* receive buffer must be a least 16 K */
{
{
option_len = sizeof(option_value);
}
}
for (i = 0; i < STREAM_COUNT; i++)
{
}
return True;
}
/* Disconnect on the TCP layer */
void
tcp_disconnect(void)
{
}
char *
{
static char ipaddr[32];
struct sockaddr_in sockaddr;
{
}
else
return ipaddr;
}
/* reset the state of the tcp layer */
/* Support for Session Directory */
void
tcp_reset_state(void)
{
int i;
/* Clear the incoming stream */
/* Clear the outgoing stream(s) */
for (i = 0; i < STREAM_COUNT; i++)
{
}
}