1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-13 17:17:37 -05:00

Dave Hinton's modifications to the network layer interface, which

should make it possible to add SSL support later.

[originally from svn r996]
This commit is contained in:
Simon Tatham
2001-03-13 10:22:45 +00:00
parent 40a68abec5
commit 7b0e082700
7 changed files with 276 additions and 133 deletions

30
raw.c
View File

@ -24,20 +24,17 @@ static void c_write (char *buf, int len) {
from_backend(0, buf, len);
}
static int raw_receive (Socket skt, int urgent, char *data, int len) {
if (urgent==3) {
static int raw_closing (Plug plug, char *error_msg, int error_code, int calling_back) {
sk_close(s);
s = NULL;
if (error_msg) {
/* A socket error has occurred. */
sk_close(s);
s = NULL;
connection_fatal(data);
len = 0;
return 0;
} else if (!len) {
/* Connection has closed. */
sk_close(s);
s = NULL;
return 0;
}
connection_fatal (error_msg);
} /* Otherwise, the remote side closed the connection normally. */
return 0;
}
static int raw_receive (Plug plug, int urgent, char *data, int len) {
c_write(data, len);
return 1;
}
@ -50,6 +47,11 @@ static int raw_receive (Socket skt, int urgent, char *data, int len) {
* Also places the canonical host name into `realhost'.
*/
static char *raw_init (char *host, int port, char **realhost) {
static struct plug_function_table fn_table = {
raw_closing,
raw_receive
}, *fn_table_ptr = &fn_table;
SockAddr addr;
char *err;
@ -66,7 +68,7 @@ static char *raw_init (char *host, int port, char **realhost) {
/*
* Open socket.
*/
s = sk_new(addr, port, 0, 1, raw_receive);
s = sk_new(addr, port, 0, 1, &fn_table_ptr);
if ( (err = sk_socket_error(s)) )
return err;