summaryrefslogtreecommitdiff
path: root/channels.h
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-01-26 13:26:22 +1100
committerDamien Miller <djm@mindrot.org>2010-01-26 13:26:22 +1100
commite1537f951fa87e4d070adda82b474b25cf4902ec (patch)
tree3c9d794dcf7fca1d880ffd9db24b20038d3f800b /channels.h
parentf589fd1ea8c352e6bf819733ecd505119a694c51 (diff)
- djm@cvs.openbsd.org 2010/01/26 01:28:35
[channels.c channels.h clientloop.c clientloop.h mux.c nchan.c ssh.c] rewrite ssh(1) multiplexing code to a more sensible protocol. The new multiplexing code uses channels for the listener and accepted control sockets to make the mux master non-blocking, so no stalls when processing messages from a slave. avoid use of fatal() in mux master protocol parsing so an errant slave process cannot take down a running master. implement requesting of port-forwards over multiplexed sessions. Any port forwards requested by the slave are added to those the master has established. add support for stdio forwarding ("ssh -W host:port ...") in mux slaves. document master/slave mux protocol so that other tools can use it to control a running ssh(1). Note: there are no guarantees that this protocol won't be incompatibly changed (though it is versioned). feedback Salvador Fandino, dtucker@ channel changes ok markus@
Diffstat (limited to 'channels.h')
-rw-r--r--channels.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/channels.h b/channels.h
index 79ebe047a..cc71885f4 100644
--- a/channels.h
+++ b/channels.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.h,v 1.102 2010/01/11 01:39:46 dtucker Exp $ */ 1/* $OpenBSD: channels.h,v 1.103 2010/01/26 01:28:35 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -53,7 +53,9 @@
53#define SSH_CHANNEL_CONNECTING 12 53#define SSH_CHANNEL_CONNECTING 12
54#define SSH_CHANNEL_DYNAMIC 13 54#define SSH_CHANNEL_DYNAMIC 13
55#define SSH_CHANNEL_ZOMBIE 14 /* Almost dead. */ 55#define SSH_CHANNEL_ZOMBIE 14 /* Almost dead. */
56#define SSH_CHANNEL_MAX_TYPE 15 56#define SSH_CHANNEL_MUX_LISTENER 15 /* Listener for mux conn. */
57#define SSH_CHANNEL_MUX_CLIENT 16 /* Conn. to mux slave */
58#define SSH_CHANNEL_MAX_TYPE 17
57 59
58struct Channel; 60struct Channel;
59typedef struct Channel Channel; 61typedef struct Channel Channel;
@@ -81,6 +83,9 @@ struct channel_connect {
81 struct addrinfo *ai, *aitop; 83 struct addrinfo *ai, *aitop;
82}; 84};
83 85
86/* Callbacks for mux channels back into client-specific code */
87typedef int mux_callback_fn(struct Channel *);
88
84struct Channel { 89struct Channel {
85 int type; /* channel type/state */ 90 int type; /* channel type/state */
86 int self; /* my own channel identifier */ 91 int self; /* my own channel identifier */
@@ -92,7 +97,7 @@ struct Channel {
92 int wfd; /* write fd */ 97 int wfd; /* write fd */
93 int efd; /* extended fd */ 98 int efd; /* extended fd */
94 int sock; /* sock fd */ 99 int sock; /* sock fd */
95 int ctl_fd; /* control fd (client sharing) */ 100 int ctl_chan; /* control channel (multiplexed connections) */
96 int isatty; /* rfd is a tty */ 101 int isatty; /* rfd is a tty */
97 int wfd_isatty; /* wfd is a tty */ 102 int wfd_isatty; /* wfd is a tty */
98 int client_tty; /* (client) TTY has been requested */ 103 int client_tty; /* (client) TTY has been requested */
@@ -142,6 +147,10 @@ struct Channel {
142 147
143 /* non-blocking connect */ 148 /* non-blocking connect */
144 struct channel_connect connect_ctx; 149 struct channel_connect connect_ctx;
150
151 /* multiplexing protocol hook, called for each packet received */
152 mux_callback_fn *mux_rcb;
153 void *mux_ctx;
145}; 154};
146 155
147#define CHAN_EXTENDED_IGNORE 0 156#define CHAN_EXTENDED_IGNORE 0
@@ -172,6 +181,7 @@ struct Channel {
172#define CHAN_CLOSE_RCVD 0x02 181#define CHAN_CLOSE_RCVD 0x02
173#define CHAN_EOF_SENT 0x04 182#define CHAN_EOF_SENT 0x04
174#define CHAN_EOF_RCVD 0x08 183#define CHAN_EOF_RCVD 0x08
184#define CHAN_LOCAL 0x10
175 185
176#define CHAN_RBUF 16*1024 186#define CHAN_RBUF 16*1024
177 187
@@ -243,7 +253,7 @@ void channel_clear_adm_permitted_opens(void);
243void channel_print_adm_permitted_opens(void); 253void channel_print_adm_permitted_opens(void);
244int channel_input_port_forward_request(int, int); 254int channel_input_port_forward_request(int, int);
245Channel *channel_connect_to(const char *, u_short, char *, char *); 255Channel *channel_connect_to(const char *, u_short, char *, char *);
246Channel *channel_connect_stdio_fwd(const char*, u_short); 256Channel *channel_connect_stdio_fwd(const char*, u_short, int, int);
247Channel *channel_connect_by_listen_address(u_short, char *, char *); 257Channel *channel_connect_by_listen_address(u_short, char *, char *);
248int channel_request_remote_forwarding(const char *, u_short, 258int channel_request_remote_forwarding(const char *, u_short,
249 const char *, u_short); 259 const char *, u_short);