1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-03 20:42:48 -05:00

Put a layer of abstraction in front of struct ssh_channel.

Clients outside ssh.c - all implementations of Channel - will now not
see the ssh_channel data type itself, but only a subobject of the
interface type SshChannel. All the sshfwd_* functions have become
methods in that interface type's vtable (though, wrapped in the usual
kind of macros, the call sites look identical).

This paves the way for me to split up the SSH-1 and SSH-2 connection
layers and have each one lay out its channel bookkeeping structure as
it sees fit; as long as they each provide an implementation of the
sshfwd_ method family, the types behind that need not look different.

A minor good effect of this is that the sshfwd_ methods are no longer
global symbols, so they don't have to be stubbed in Unix Pageant to
get it to compile.
This commit is contained in:
Simon Tatham
2018-09-14 13:47:13 +01:00
parent d437e5402e
commit aa08e6ca91
8 changed files with 110 additions and 69 deletions

23
ssh.h
View File

@ -9,19 +9,6 @@
struct ssh_channel;
extern int sshfwd_write(struct ssh_channel *c, const void *, int);
extern void sshfwd_write_eof(struct ssh_channel *c);
extern void sshfwd_unclean_close(struct ssh_channel *c, const char *err);
extern void sshfwd_unthrottle(struct ssh_channel *c, int bufsize);
Conf *sshfwd_get_conf(struct ssh_channel *c);
void sshfwd_window_override_removed(struct ssh_channel *c);
void sshfwd_x11_sharing_handover(struct ssh_channel *c,
ssh_sharing_connstate *share_cs,
share_channel *share_chan,
const char *peer_addr, int peer_port,
int endian, int protomajor, int protominor,
const void *initial_data, int initial_len);
/*
* Buffer management constants. There are several of these for
* various different purposes:
@ -734,12 +721,12 @@ void logevent(Frontend *, const char *);
struct PortForwarding;
/* Allocate and register a new channel for port forwarding */
struct ssh_channel *ssh_send_port_open(Ssh ssh, const char *hostname, int port,
const char *org, Channel *chan);
SshChannel *ssh_send_port_open(Ssh ssh, const char *hostname, int port,
const char *org, Channel *chan);
/* Exports from portfwd.c */
extern char *pfd_connect(Channel **chan_ret, char *hostname, int port,
struct ssh_channel *c, Conf *conf, int addressfamily);
SshChannel *c, Conf *conf, int addressfamily);
struct PortListener;
/* desthost == NULL indicates dynamic (SOCKS) port forwarding */
extern char *pfl_listen(char *desthost, int destport, char *srcaddr,
@ -813,7 +800,7 @@ extern struct X11Display *x11_setup_display(const char *display, Conf *);
void x11_free_display(struct X11Display *disp);
struct X11FakeAuth *x11_invent_fake_auth(tree234 *t, int authtype);
void x11_free_fake_auth(struct X11FakeAuth *auth);
Channel *x11_new_channel(tree234 *authtree, struct ssh_channel *c,
Channel *x11_new_channel(tree234 *authtree, SshChannel *c,
const char *peeraddr, int peerport,
int connection_sharing_possible);
char *x11_display(const char *display);
@ -845,7 +832,7 @@ void x11_get_auth_from_authfile(struct X11Display *display,
int x11_identify_auth_proto(ptrlen protoname);
void *x11_dehexify(ptrlen hex, int *outlen);
Channel *agentf_new(struct ssh_channel *c);
Channel *agentf_new(SshChannel *c);
Bignum copybn(Bignum b);
Bignum bn_power_2(int n);