mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-11 16:23:55 -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:
36
sshchan.h
36
sshchan.h
@ -40,7 +40,7 @@ struct Channel {
|
||||
#define chan_send_eof(ch) ((ch)->vt->send_eof(ch))
|
||||
#define chan_set_input_wanted(ch, wanted) \
|
||||
((ch)->vt->set_input_wanted(ch, wanted))
|
||||
#define chan_log_close_msg(ch) ((ch)->vt->send_eof(ch))
|
||||
#define chan_log_close_msg(ch) ((ch)->vt->log_close_msg(ch))
|
||||
#define chan_want_close(ch, leof, reof) ((ch)->vt->want_close(ch, leof, reof))
|
||||
|
||||
/*
|
||||
@ -56,4 +56,38 @@ void chan_remotely_opened_failure(Channel *chan, const char *errtext);
|
||||
* closing until both directions have had an EOF */
|
||||
int chan_no_eager_close(Channel *, int, int);
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* This structure is owned by an SSH connection layer, and identifies
|
||||
* the connection layer's end of the channel, for the Channel
|
||||
* implementation to talk back to.
|
||||
*/
|
||||
|
||||
struct SshChannelVtable {
|
||||
int (*write)(SshChannel *c, const void *, int);
|
||||
void (*write_eof)(SshChannel *c);
|
||||
void (*unclean_close)(SshChannel *c, const char *err);
|
||||
void (*unthrottle)(SshChannel *c, int bufsize);
|
||||
Conf *(*get_conf)(SshChannel *c);
|
||||
void (*window_override_removed)(SshChannel *c);
|
||||
void (*x11_sharing_handover)(SshChannel *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);
|
||||
};
|
||||
|
||||
struct SshChannel {
|
||||
const struct SshChannelVtable *vt;
|
||||
};
|
||||
|
||||
#define sshfwd_write(c, buf, len) ((c)->vt->write(c, buf, len))
|
||||
#define sshfwd_write_eof(c) ((c)->vt->write_eof(c))
|
||||
#define sshfwd_unclean_close(c, err) ((c)->vt->unclean_close(c, err))
|
||||
#define sshfwd_unthrottle(c, bufsize) ((c)->vt->unthrottle(c, bufsize))
|
||||
#define sshfwd_get_conf(c) ((c)->vt->get_conf(c))
|
||||
#define sshfwd_window_override_removed(c) ((c)->vt->window_override_removed(c))
|
||||
#define sshfwd_x11_sharing_handover(c, cs, ch, pa, pp, e, pmaj, pmin, d, l) \
|
||||
((c)->vt->x11_sharing_handover(c, cs, ch, pa, pp, e, pmaj, pmin, d, l))
|
||||
|
||||
#endif /* PUTTY_SSHCHAN_H */
|
||||
|
Reference in New Issue
Block a user