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
|
|
|
|
|
2003-01-12 18:26:10 +03:00
|
|
|
#ifndef DONE_TYPEDEFS
|
|
|
|
#define DONE_TYPEDEFS
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
typedef struct conf_tag Conf;
|
2003-01-12 18:26:10 +03:00
|
|
|
typedef struct backend_tag Backend;
|
|
|
|
typedef struct terminal_tag Terminal;
|
|
|
|
#endif
|
|
|
|
|
2000-10-23 15:55:11 +04:00
|
|
|
typedef struct SockAddr_tag *SockAddr;
|
2001-03-13 13:22:45 +03:00
|
|
|
/* pay attention to levels of indirection */
|
|
|
|
typedef struct socket_function_table **Socket;
|
|
|
|
typedef struct plug_function_table **Plug;
|
|
|
|
|
|
|
|
struct socket_function_table {
|
2001-05-06 18:35:20 +04:00
|
|
|
Plug(*plug) (Socket s, Plug p);
|
|
|
|
/* 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 */
|
2001-03-13 13:22:45 +03:00
|
|
|
void (*close) (Socket s);
|
2003-01-10 21:33:35 +03:00
|
|
|
int (*write) (Socket s, const char *data, int len);
|
|
|
|
int (*write_oob) (Socket s, const char *data, int len);
|
2011-09-13 15:44:03 +04:00
|
|
|
void (*write_eof) (Socket s);
|
2001-03-13 13:22:45 +03:00
|
|
|
void (*flush) (Socket s);
|
2002-03-23 20:47:21 +03:00
|
|
|
void (*set_private_ptr) (Socket s, void *ptr);
|
|
|
|
void *(*get_private_ptr) (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 */
|
2003-05-04 18:18:18 +04:00
|
|
|
const char *(*socket_error) (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;
|
|
|
|
typedef Socket (*accept_fn_t)(accept_ctx_t ctx, Plug plug);
|
|
|
|
|
2001-03-13 13:22:45 +03:00
|
|
|
struct plug_function_table {
|
2005-01-16 17:29:34 +03:00
|
|
|
void (*log)(Plug p, int type, SockAddr addr, int port,
|
|
|
|
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.
|
|
|
|
*/
|
2001-03-13 13:22:45 +03:00
|
|
|
int (*closing)
|
2003-05-04 18:18:18 +04: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()) */
|
2001-03-13 13:22:45 +03:00
|
|
|
int (*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.
|
|
|
|
*/
|
2001-08-25 21:09:23 +04:00
|
|
|
void (*sent) (Plug p, int bufsize);
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2013-11-17 18:03:55 +04: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 */
|
2002-03-23 20:47:21 +03:00
|
|
|
Socket new_connection(SockAddr addr, char *hostname,
|
|
|
|
int port, int privport,
|
2004-06-20 21:07:38 +04:00
|
|
|
int oobinline, int nodelay, int keepalive,
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
Plug plug, Conf *conf);
|
2003-01-12 18:26:10 +03:00
|
|
|
Socket new_listener(char *srcaddr, int port, Plug plug, int local_host_only,
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
Conf *conf, int addressfamily);
|
2003-01-12 18:26:10 +03:00
|
|
|
SockAddr name_lookup(char *host, int port, char **canonicalname,
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
Conf *conf, int addressfamily);
|
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()) */
|
2003-06-06 14:42:14 +04:00
|
|
|
Socket platform_new_connection(SockAddr addr, char *hostname,
|
|
|
|
int port, int privport,
|
2004-06-20 21:07:38 +04:00
|
|
|
int oobinline, int nodelay, int keepalive,
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
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
|
|
|
|
2004-12-30 19:45:11 +03:00
|
|
|
SockAddr sk_namelookup(const char *host, char **canonicalname, int address_family);
|
2003-01-12 18:26:10 +03:00
|
|
|
SockAddr sk_nonamelookup(const char *host);
|
2001-09-08 02:39:01 +04:00
|
|
|
void sk_getaddr(SockAddr addr, char *buf, int buflen);
|
2013-07-27 22:35:48 +04:00
|
|
|
int sk_hostname_is_local(const char *name);
|
2002-12-18 15:18:54 +03:00
|
|
|
int sk_address_is_local(SockAddr addr);
|
2012-10-17 00:15:51 +04:00
|
|
|
int sk_address_is_special_local(SockAddr addr);
|
2002-04-27 19:01:18 +04:00
|
|
|
int sk_addrtype(SockAddr addr);
|
|
|
|
void sk_addrcopy(SockAddr addr, char *buf);
|
2000-10-23 15:55:11 +04:00
|
|
|
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. */
|
|
|
|
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() */
|
2001-05-06 18:35:20 +04:00
|
|
|
Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
|
2004-06-20 21:07:38 +04:00
|
|
|
int nodelay, int keepalive, Plug p);
|
2001-03-13 13:22:45 +03:00
|
|
|
|
2004-12-30 19:45:11 +03:00
|
|
|
Socket sk_newlistener(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
|
|
|
|
|
|
|
/*
|
|
|
|
* Each socket abstraction contains a `void *' private field in
|
|
|
|
* which the client can keep state.
|
2001-03-13 13:22:45 +03:00
|
|
|
*
|
|
|
|
* This is perhaps unnecessary now that we have the notion of a plug,
|
|
|
|
* but there is some existing code that uses it, so it stays.
|
2000-10-23 15:55:11 +04:00
|
|
|
*/
|
2002-03-23 20:47:21 +03:00
|
|
|
#define sk_set_private_ptr(s, ptr) (((*s)->set_private_ptr) (s, ptr))
|
|
|
|
#define sk_get_private_ptr(s) (((*s)->get_private_ptr) (s))
|
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.
|
|
|
|
*/
|
2003-05-04 18:18:18 +04: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
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
Socket new_error_socket(const char *errmsg, Plug plug);
|
|
|
|
|
2001-03-13 13:22:45 +03:00
|
|
|
/********** SSL stuff **********/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This section is subject to change, but you get the general idea
|
|
|
|
* of what it will eventually look like.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct certificate *Certificate;
|
|
|
|
typedef struct our_certificate *Our_Certificate;
|
|
|
|
/* to be defined somewhere else, somehow */
|
|
|
|
|
|
|
|
typedef struct ssl_client_socket_function_table **SSL_Client_Socket;
|
|
|
|
typedef struct ssl_client_plug_function_table **SSL_Client_Plug;
|
|
|
|
|
|
|
|
struct ssl_client_socket_function_table {
|
|
|
|
struct socket_function_table base;
|
|
|
|
void (*renegotiate) (SSL_Client_Socket s);
|
2001-05-06 18:35:20 +04:00
|
|
|
/* renegotiate the cipher spec */
|
2001-03-13 13:22:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ssl_client_plug_function_table {
|
|
|
|
struct plug_function_table base;
|
|
|
|
int (*refuse_cert) (SSL_Client_Plug p, Certificate cert[]);
|
2001-05-06 18:35:20 +04:00
|
|
|
/* do we accept this certificate chain? If not, why not? */
|
|
|
|
/* cert[0] is the server's certificate, cert[] is NULL-terminated */
|
|
|
|
/* the last certificate may or may not be the root certificate */
|
|
|
|
Our_Certificate(*client_cert) (SSL_Client_Plug p);
|
|
|
|
/* the server wants us to identify ourselves */
|
|
|
|
/* may return NULL if we want anonymity */
|
2001-03-13 13:22:45 +03:00
|
|
|
};
|
|
|
|
|
2001-05-06 18:35:20 +04:00
|
|
|
SSL_Client_Socket sk_ssl_client_over(Socket s, /* pre-existing (tcp) connection */
|
|
|
|
SSL_Client_Plug p);
|
2001-03-13 13:22:45 +03:00
|
|
|
|
|
|
|
#define sk_renegotiate(s) (((*s)->renegotiate) (s))
|
2000-10-24 14:47:49 +04:00
|
|
|
|
|
|
|
#endif
|