2000-10-23 15:55:11 +04:00
|
|
|
/*
|
|
|
|
* Networking abstraction in PuTTY.
|
|
|
|
*
|
|
|
|
* The way this works is: a back end can choose to open any number
|
|
|
|
* of sockets - including zero, which might be necessary in some.
|
2001-03-13 13:22:45 +03:00
|
|
|
* It can register a bunch of callbacks (most notably for when
|
|
|
|
* data is received) for each socket, and it can call the networking
|
|
|
|
* abstraction to send data without having to worry about blocking.
|
|
|
|
* The stuff behind the abstraction takes care of selects and
|
|
|
|
* nonblocking writes and all that sort of painful gubbins.
|
2000-10-23 15:55:11 +04:00
|
|
|
*/
|
|
|
|
|
2000-10-24 14:47:49 +04:00
|
|
|
#ifndef PUTTY_NETWORK_H
|
|
|
|
#define PUTTY_NETWORK_H
|
|
|
|
|
2018-05-24 10:59:01 +03:00
|
|
|
#include "defs.h"
|
2003-01-12 18:26:10 +03:00
|
|
|
|
2018-10-05 09:03:46 +03:00
|
|
|
struct SocketVtable {
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
Plug *(*plug) (Socket *s, Plug *p);
|
2001-05-06 18:35:20 +04:00
|
|
|
/* use a different plug (return the old one) */
|
|
|
|
/* if p is NULL, it doesn't change the plug */
|
|
|
|
/* but it does return the one it's using */
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
void (*close) (Socket *s);
|
|
|
|
int (*write) (Socket *s, const void *data, int len);
|
|
|
|
int (*write_oob) (Socket *s, const void *data, int len);
|
|
|
|
void (*write_eof) (Socket *s);
|
|
|
|
void (*flush) (Socket *s);
|
|
|
|
void (*set_frozen) (Socket *s, int is_frozen);
|
2001-05-06 18:35:20 +04:00
|
|
|
/* ignored by tcp, but vital for ssl */
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
const char *(*socket_error) (Socket *s);
|
|
|
|
char *(*peer_info) (Socket *s);
|
2001-03-13 13:22:45 +03:00
|
|
|
};
|
|
|
|
|
2013-11-17 18:03:55 +04:00
|
|
|
typedef union { void *p; int i; } accept_ctx_t;
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
typedef Socket *(*accept_fn_t)(accept_ctx_t ctx, Plug *plug);
|
2013-11-17 18:03:55 +04:00
|
|
|
|
2018-10-05 09:03:46 +03:00
|
|
|
struct PlugVtable {
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
void (*log)(Plug *p, int type, SockAddr *addr, int port,
|
2005-01-16 17:29:34 +03:00
|
|
|
const char *error_msg, int error_code);
|
|
|
|
/*
|
|
|
|
* Passes the client progress reports on the process of setting
|
|
|
|
* up the connection.
|
|
|
|
*
|
|
|
|
* - type==0 means we are about to try to connect to address
|
|
|
|
* `addr' (error_msg and error_code are ignored)
|
|
|
|
* - type==1 means we have failed to connect to address `addr'
|
|
|
|
* (error_msg and error_code are supplied). This is not a
|
|
|
|
* fatal error - we may well have other candidate addresses
|
|
|
|
* to fall back to. When it _is_ fatal, the closing()
|
|
|
|
* function will be called.
|
2015-11-22 15:15:52 +03:00
|
|
|
* - type==2 means that error_msg contains a line of generic
|
|
|
|
* logging information about setting up the connection. This
|
|
|
|
* will typically be a wodge of standard-error output from a
|
|
|
|
* proxy command, so the receiver should probably prefix it to
|
|
|
|
* indicate this.
|
2005-01-16 17:29:34 +03:00
|
|
|
*/
|
2016-06-03 01:03:24 +03:00
|
|
|
void (*closing)
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
(Plug *p, const char *error_msg, int error_code, int calling_back);
|
2001-05-06 18:35:20 +04:00
|
|
|
/* error_msg is NULL iff it is not an error (ie it closed normally) */
|
|
|
|
/* calling_back != 0 iff there is a Plug function */
|
|
|
|
/* currently running (would cure the fixme in try_send()) */
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
void (*receive) (Plug *p, int urgent, char *data, int len);
|
2001-05-06 18:35:20 +04:00
|
|
|
/*
|
|
|
|
* - urgent==0. `data' points to `len' bytes of perfectly
|
|
|
|
* ordinary data.
|
|
|
|
*
|
|
|
|
* - urgent==1. `data' points to `len' bytes of data,
|
|
|
|
* which were read from before an Urgent pointer.
|
|
|
|
*
|
|
|
|
* - urgent==2. `data' points to `len' bytes of data,
|
|
|
|
* the first of which was the one at the Urgent mark.
|
|
|
|
*/
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
void (*sent) (Plug *p, int bufsize);
|
2001-08-25 21:09:23 +04:00
|
|
|
/*
|
|
|
|
* The `sent' function is called when the pending send backlog
|
|
|
|
* on a socket is cleared or partially cleared. The new backlog
|
|
|
|
* size is passed in the `bufsize' parameter.
|
|
|
|
*/
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
int (*accepting)(Plug *p, accept_fn_t constructor, accept_ctx_t ctx);
|
2001-08-09 00:44:35 +04:00
|
|
|
/*
|
2013-11-17 18:03:55 +04:00
|
|
|
* `accepting' is called only on listener-type sockets, and is
|
|
|
|
* passed a constructor function+context that will create a fresh
|
|
|
|
* Socket describing the connection. It returns nonzero if it
|
|
|
|
* doesn't want the connection for some reason, or 0 on success.
|
2001-08-09 00:44:35 +04:00
|
|
|
*/
|
2001-03-13 13:22:45 +03:00
|
|
|
};
|
2001-01-24 13:11:18 +03:00
|
|
|
|
2002-03-23 20:47:21 +03:00
|
|
|
/* proxy indirection layer */
|
2003-08-07 20:04:33 +04:00
|
|
|
/* NB, control of 'addr' is passed via new_connection, which takes
|
|
|
|
* responsibility for freeing it */
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
Socket *new_connection(SockAddr *addr, const char *hostname,
|
|
|
|
int port, int privport,
|
|
|
|
int oobinline, int nodelay, int keepalive,
|
|
|
|
Plug *plug, Conf *conf);
|
|
|
|
Socket *new_listener(const char *srcaddr, int port, Plug *plug,
|
|
|
|
int local_host_only, Conf *conf, int addressfamily);
|
|
|
|
SockAddr *name_lookup(const char *host, int port, char **canonicalname,
|
|
|
|
Conf *conf, int addressfamily,
|
|
|
|
Frontend *frontend_for_logging,
|
|
|
|
const char *lookup_reason_for_logging);
|
|
|
|
int proxy_for_destination (SockAddr *addr, const char *hostname, int port,
|
2013-11-17 18:05:41 +04:00
|
|
|
Conf *conf);
|
2002-03-23 20:47:21 +03:00
|
|
|
|
2003-06-06 14:42:14 +04:00
|
|
|
/* platform-dependent callback from new_connection() */
|
2003-08-07 20:04:33 +04:00
|
|
|
/* (same caveat about addr as new_connection()) */
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
Socket *platform_new_connection(SockAddr *addr, const char *hostname,
|
|
|
|
int port, int privport,
|
|
|
|
int oobinline, int nodelay, int keepalive,
|
|
|
|
Plug *plug, Conf *conf);
|
2003-06-06 14:42:14 +04:00
|
|
|
|
2002-03-23 20:47:21 +03:00
|
|
|
/* socket functions */
|
2000-10-23 15:55:11 +04:00
|
|
|
|
|
|
|
void sk_init(void); /* called once at program startup */
|
2002-03-06 23:13:22 +03:00
|
|
|
void sk_cleanup(void); /* called just before program exit */
|
2000-10-23 15:55:11 +04:00
|
|
|
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
SockAddr *sk_namelookup(const char *host, char **canonicalname, int address_family);
|
|
|
|
SockAddr *sk_nonamelookup(const char *host);
|
|
|
|
void sk_getaddr(SockAddr *addr, char *buf, int buflen);
|
|
|
|
int sk_addr_needs_port(SockAddr *addr);
|
2013-07-27 22:35:48 +04:00
|
|
|
int sk_hostname_is_local(const char *name);
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
int sk_address_is_local(SockAddr *addr);
|
|
|
|
int sk_address_is_special_local(SockAddr *addr);
|
|
|
|
int sk_addrtype(SockAddr *addr);
|
|
|
|
void sk_addrcopy(SockAddr *addr, char *buf);
|
|
|
|
void sk_addr_free(SockAddr *addr);
|
2008-11-08 19:58:55 +03:00
|
|
|
/* sk_addr_dup generates another SockAddr which contains the same data
|
|
|
|
* as the original one and can be freed independently. May not actually
|
|
|
|
* physically _duplicate_ it: incrementing a reference count so that
|
|
|
|
* one more free is required before it disappears is an acceptable
|
|
|
|
* implementation. */
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
SockAddr *sk_addr_dup(SockAddr *addr);
|
2000-10-23 15:55:11 +04:00
|
|
|
|
2003-08-07 20:04:33 +04:00
|
|
|
/* NB, control of 'addr' is passed via sk_new, which takes responsibility
|
|
|
|
* for freeing it, as for new_connection() */
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
Socket *sk_new(SockAddr *addr, int port, int privport, int oobinline,
|
|
|
|
int nodelay, int keepalive, Plug *p);
|
2001-03-13 13:22:45 +03:00
|
|
|
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug,
|
|
|
|
int local_host_only, int address_family);
|
2001-08-09 00:44:35 +04:00
|
|
|
|
2001-03-13 13:22:45 +03:00
|
|
|
#define sk_plug(s,p) (((*s)->plug) (s, p))
|
|
|
|
#define sk_close(s) (((*s)->close) (s))
|
|
|
|
#define sk_write(s,buf,len) (((*s)->write) (s, buf, len))
|
|
|
|
#define sk_write_oob(s,buf,len) (((*s)->write_oob) (s, buf, len))
|
2011-09-13 15:44:03 +04:00
|
|
|
#define sk_write_eof(s) (((*s)->write_eof) (s))
|
2001-03-13 13:22:45 +03:00
|
|
|
#define sk_flush(s) (((*s)->flush) (s))
|
|
|
|
|
|
|
|
#ifdef DEFINE_PLUG_METHOD_MACROS
|
2005-01-16 17:29:34 +03:00
|
|
|
#define plug_log(p,type,addr,port,msg,code) (((*p)->log) (p, type, addr, port, msg, code))
|
2001-03-13 13:22:45 +03:00
|
|
|
#define plug_closing(p,msg,code,callback) (((*p)->closing) (p, msg, code, callback))
|
|
|
|
#define plug_receive(p,urgent,buf,len) (((*p)->receive) (p, urgent, buf, len))
|
2001-08-25 21:09:23 +04:00
|
|
|
#define plug_sent(p,bufsize) (((*p)->sent) (p, bufsize))
|
2013-11-17 18:03:55 +04:00
|
|
|
#define plug_accepting(p, constructor, ctx) (((*p)->accepting)(p, constructor, ctx))
|
2001-03-13 13:22:45 +03:00
|
|
|
#endif
|
2000-10-23 15:55:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Special error values are returned from sk_namelookup and sk_new
|
|
|
|
* if there's a problem. These functions extract an error message,
|
|
|
|
* or return NULL if there's no problem.
|
|
|
|
*/
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
const char *sk_addr_error(SockAddr *addr);
|
2001-03-13 13:22:45 +03:00
|
|
|
#define sk_socket_error(s) (((*s)->socket_error) (s))
|
|
|
|
|
2001-08-09 00:44:35 +04:00
|
|
|
/*
|
|
|
|
* Set the `frozen' flag on a socket. A frozen socket is one in
|
2001-08-25 21:09:23 +04:00
|
|
|
* which all READABLE notifications are ignored, so that data is
|
|
|
|
* not accepted from the peer until the socket is unfrozen. This
|
|
|
|
* exists for two purposes:
|
|
|
|
*
|
|
|
|
* - Port forwarding: when a local listening port receives a
|
|
|
|
* connection, we do not want to receive data from the new
|
|
|
|
* socket until we have somewhere to send it. Hence, we freeze
|
|
|
|
* the socket until its associated SSH channel is ready; then we
|
|
|
|
* unfreeze it and pending data is delivered.
|
|
|
|
*
|
|
|
|
* - Socket buffering: if an SSH channel (or the whole connection)
|
|
|
|
* backs up or presents a zero window, we must freeze the
|
|
|
|
* associated local socket in order to avoid unbounded buffer
|
|
|
|
* growth.
|
2001-08-09 00:44:35 +04:00
|
|
|
*/
|
2002-03-23 20:47:21 +03:00
|
|
|
#define sk_set_frozen(s, is_frozen) (((*s)->set_frozen) (s, is_frozen))
|
2001-03-13 13:22:45 +03:00
|
|
|
|
2015-05-18 15:57:45 +03:00
|
|
|
/*
|
|
|
|
* Return a (dynamically allocated) string giving some information
|
|
|
|
* about the other end of the socket, suitable for putting in log
|
|
|
|
* files. May be NULL if nothing is available at all.
|
|
|
|
*/
|
|
|
|
#define sk_peer_info(s) (((*s)->peer_info) (s))
|
|
|
|
|
2002-10-30 20:57:31 +03:00
|
|
|
/*
|
|
|
|
* Simple wrapper on getservbyname(), needed by ssh.c. Returns the
|
|
|
|
* port number, in host byte order (suitable for printf and so on).
|
|
|
|
* Returns 0 on failure. Any platform not supporting getservbyname
|
|
|
|
* can just return 0 - this function is not required to handle
|
|
|
|
* numeric port specifications.
|
|
|
|
*/
|
|
|
|
int net_service_lookup(char *service);
|
|
|
|
|
Since r8305, Unix PuTTY has always "upgraded" an X11 display like "localhost:0"
to a Unix-domain socket. This typically works fine when PuTTY is run on the
same machine as the X server, but it's broken multi-hop X forwarding through
OpenSSH; when OpenSSH creates a proxy X server "localhost:10", it only listens
on TCP, not on a Unix-domain socket.
Instead, when deciding on the details of the display, we actively probe to see
if there's a Unix-domain socket we can use instead, and only use it if it's
there, falling back to the specified IP "localhost" if not.
Independently, when looking for local auth details in Xauthority for a
"localhost" TCP display, we prefer a matching Unix-domain entry, but will fall
back to an IP "localhost" entry (which would be unusual, but we don't trust a
Windows X server not to do it) -- this is a generalisation of the special case
added in r2538 (but removed in r8305, as the automatic upgrade masked the need
for it).
(This is now done in platform-independent code, so a side-effect is that
get_hostname() is now part of the networking abstraction on all platforms.)
[originally from svn r8462]
[r2538 == fda998324345ba50a913655754303ce8f0a4cfde]
[r8305 == ca6fc3a4daf51166a15693feffc967bee9e3f59a]
2009-02-24 04:01:23 +03:00
|
|
|
/*
|
|
|
|
* Look up the local hostname; return value needs freeing.
|
|
|
|
* May return NULL.
|
|
|
|
*/
|
|
|
|
char *get_hostname(void);
|
|
|
|
|
2013-11-17 18:03:36 +04:00
|
|
|
/*
|
|
|
|
* Trivial socket implementation which just stores an error. Found in
|
|
|
|
* errsock.c.
|
|
|
|
*/
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
Socket *new_error_socket(const char *errmsg, Plug *plug);
|
2013-11-17 18:03:36 +04:00
|
|
|
|
2018-05-27 17:41:12 +03:00
|
|
|
/*
|
|
|
|
* Trivial plug that does absolutely nothing. Found in nullplug.c.
|
|
|
|
*/
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
extern Plug *nullplug;
|
2018-05-27 17:41:12 +03:00
|
|
|
|
2015-11-22 14:49:14 +03:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
* Functions defined outside the network code, which have to be
|
|
|
|
* declared in this header file rather than the main putty.h because
|
|
|
|
* they use types defined here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Exports from be_misc.c.
|
|
|
|
*/
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
void backend_socket_log(Frontend *frontend, int type, SockAddr *addr, int port,
|
2015-11-22 17:33:28 +03:00
|
|
|
const char *error_msg, int error_code, Conf *conf,
|
|
|
|
int session_started);
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
void log_proxy_stderr(Plug *plug, bufchain *buf, const void *vdata, int len);
|
2015-11-22 14:49:14 +03:00
|
|
|
|
2000-10-24 14:47:49 +04:00
|
|
|
#endif
|