summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--channels.c7
-rw-r--r--channels.h20
-rw-r--r--nchan.c88
4 files changed, 48 insertions, 72 deletions
diff --git a/ChangeLog b/ChangeLog
index 3338ab0dc..dc251c6a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -176,6 +176,9 @@
176 - markus@cvs.openbsd.org 2002/01/14 13:41:13 176 - markus@cvs.openbsd.org 2002/01/14 13:41:13
177 [nchan.c] 177 [nchan.c]
178 remove duplicated code; ok provos@ 178 remove duplicated code; ok provos@
179 - markus@cvs.openbsd.org 2002/01/14 13:55:55
180 [channels.c channels.h nchan.c]
181 remove function pointers for events, remove chan_init*; ok provos@
179 182
18020020121 18320020121
181 - (djm) Rework ssh-rand-helper: 184 - (djm) Rework ssh-rand-helper:
@@ -7323,4 +7326,4 @@
7323 - Wrote replacements for strlcpy and mkdtemp 7326 - Wrote replacements for strlcpy and mkdtemp
7324 - Released 1.0pre1 7327 - Released 1.0pre1
7325 7328
7326$Id: ChangeLog,v 1.1772 2002/01/22 12:28:28 djm Exp $ 7329$Id: ChangeLog,v 1.1773 2002/01/22 12:28:45 djm Exp $
diff --git a/channels.c b/channels.c
index db3bda66a..473c5efe4 100644
--- a/channels.c
+++ b/channels.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include "includes.h" 41#include "includes.h"
42RCSID("$OpenBSD: channels.c,v 1.158 2002/01/09 17:26:35 markus Exp $"); 42RCSID("$OpenBSD: channels.c,v 1.159 2002/01/14 13:55:55 markus Exp $");
43 43
44#include "ssh.h" 44#include "ssh.h"
45#include "ssh1.h" 45#include "ssh1.h"
@@ -217,7 +217,6 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
217 217
218 /* Do initial allocation if this is the first call. */ 218 /* Do initial allocation if this is the first call. */
219 if (channels_alloc == 0) { 219 if (channels_alloc == 0) {
220 chan_init();
221 channels_alloc = 10; 220 channels_alloc = 10;
222 channels = xmalloc(channels_alloc * sizeof(Channel *)); 221 channels = xmalloc(channels_alloc * sizeof(Channel *));
223 for (i = 0; i < channels_alloc; i++) 222 for (i = 0; i < channels_alloc; i++)
@@ -246,7 +245,9 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
246 buffer_init(&c->input); 245 buffer_init(&c->input);
247 buffer_init(&c->output); 246 buffer_init(&c->output);
248 buffer_init(&c->extended); 247 buffer_init(&c->extended);
249 chan_init_iostates(c); 248 c->ostate = CHAN_OUTPUT_OPEN;
249 c->istate = CHAN_INPUT_OPEN;
250 c->flags = 0;
250 channel_register_fds(c, rfd, wfd, efd, extusage, nonblock); 251 channel_register_fds(c, rfd, wfd, efd, extusage, nonblock);
251 c->self = found; 252 c->self = found;
252 c->type = type; 253 c->type = type;
diff --git a/channels.h b/channels.h
index a857db11e..9f97488b2 100644
--- a/channels.h
+++ b/channels.h
@@ -32,7 +32,7 @@
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35/* RCSID("$OpenBSD: channels.h,v 1.57 2002/01/13 21:31:20 markus Exp $"); */ 35/* RCSID("$OpenBSD: channels.h,v 1.58 2002/01/14 13:55:55 markus Exp $"); */
36 36
37#ifndef CHANNEL_H 37#ifndef CHANNEL_H
38#define CHANNEL_H 38#define CHANNEL_H
@@ -215,19 +215,15 @@ void auth_input_open_request(int, u_int32_t, void *);
215 215
216int chan_is_dead(Channel *, int); 216int chan_is_dead(Channel *, int);
217void chan_mark_dead(Channel *); 217void chan_mark_dead(Channel *);
218void chan_init_iostates(Channel *);
219void chan_init(void);
220 218
221typedef void chan_event_fn(Channel *); 219/* channel events */
222 220
223/* for the input state */ 221void chan_rcvd_oclose(Channel *);
224extern chan_event_fn *chan_rcvd_oclose; 222void chan_read_failed(Channel *);
225extern chan_event_fn *chan_read_failed; 223void chan_ibuf_empty(Channel *);
226extern chan_event_fn *chan_ibuf_empty;
227 224
228/* for the output state */ 225void chan_rcvd_ieof(Channel *);
229extern chan_event_fn *chan_rcvd_ieof; 226void chan_write_failed(Channel *);
230extern chan_event_fn *chan_write_failed; 227void chan_obuf_empty(Channel *);
231extern chan_event_fn *chan_obuf_empty;
232 228
233#endif 229#endif
diff --git a/nchan.c b/nchan.c
index 9ecf42105..ebb8e6858 100644
--- a/nchan.c
+++ b/nchan.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: nchan.c,v 1.41 2002/01/14 13:41:13 markus Exp $"); 26RCSID("$OpenBSD: nchan.c,v 1.42 2002/01/14 13:55:55 markus Exp $");
27 27
28#include "ssh1.h" 28#include "ssh1.h"
29#include "ssh2.h" 29#include "ssh2.h"
@@ -63,14 +63,6 @@ RCSID("$OpenBSD: nchan.c,v 1.41 2002/01/14 13:41:13 markus Exp $");
63/* 63/*
64 * EVENTS update channel input/output states execute ACTIONS 64 * EVENTS update channel input/output states execute ACTIONS
65 */ 65 */
66/* events concerning the INPUT from socket for channel (istate) */
67chan_event_fn *chan_rcvd_oclose = NULL;
68chan_event_fn *chan_read_failed = NULL;
69chan_event_fn *chan_ibuf_empty = NULL;
70/* events concerning the OUTPUT from channel for socket (ostate) */
71chan_event_fn *chan_rcvd_ieof = NULL;
72chan_event_fn *chan_write_failed = NULL;
73chan_event_fn *chan_obuf_empty = NULL;
74/* 66/*
75 * ACTIONS: should never update the channel states 67 * ACTIONS: should never update the channel states
76 */ 68 */
@@ -133,8 +125,8 @@ chan_rcvd_oclose1(Channel *c)
133 return; 125 return;
134 } 126 }
135} 127}
136static void 128void
137chan_read_failed_12(Channel *c) 129chan_read_failed(Channel *c)
138{ 130{
139 debug("channel %d: read failed", c->self); 131 debug("channel %d: read failed", c->self);
140 switch (c->istate) { 132 switch (c->istate) {
@@ -148,8 +140,8 @@ chan_read_failed_12(Channel *c)
148 break; 140 break;
149 } 141 }
150} 142}
151static void 143void
152chan_ibuf_empty1(Channel *c) 144chan_ibuf_empty(Channel *c)
153{ 145{
154 debug("channel %d: ibuf empty", c->self); 146 debug("channel %d: ibuf empty", c->self);
155 if (buffer_len(&c->input)) { 147 if (buffer_len(&c->input)) {
@@ -212,8 +204,8 @@ chan_write_failed1(Channel *c)
212 break; 204 break;
213 } 205 }
214} 206}
215static void 207void
216chan_obuf_empty1(Channel *c) 208chan_obuf_empty(Channel *c)
217{ 209{
218 debug("channel %d: obuf empty", c->self); 210 debug("channel %d: obuf empty", c->self);
219 if (buffer_len(&c->output)) { 211 if (buffer_len(&c->output)) {
@@ -307,11 +299,6 @@ chan_rcvd_close2(Channel *c)
307 } 299 }
308} 300}
309static void 301static void
310chan_ibuf_empty2(Channel *c)
311{
312 chan_ibuf_empty1(c);
313}
314static void
315chan_rcvd_eof2(Channel *c) 302chan_rcvd_eof2(Channel *c)
316{ 303{
317 debug("channel %d: rcvd eof", c->self); 304 debug("channel %d: rcvd eof", c->self);
@@ -335,11 +322,6 @@ chan_write_failed2(Channel *c)
335 } 322 }
336} 323}
337static void 324static void
338chan_obuf_empty2(Channel *c)
339{
340 chan_obuf_empty1(c);
341}
342static void
343chan_send_eof2(Channel *c) 325chan_send_eof2(Channel *c)
344{ 326{
345 debug("channel %d: send eof", c->self); 327 debug("channel %d: send eof", c->self);
@@ -376,6 +358,31 @@ chan_send_close2(Channel *c)
376/* shared */ 358/* shared */
377 359
378void 360void
361chan_rcvd_ieof(Channel *c)
362{
363 if (compat20)
364 chan_rcvd_eof2(c);
365 else
366 chan_rcvd_ieof1(c);
367}
368void
369chan_rcvd_oclose(Channel *c)
370{
371 if (compat20)
372 chan_rcvd_close2(c);
373 else
374 chan_rcvd_oclose1(c);
375}
376void
377chan_write_failed(Channel *c)
378{
379 if (compat20)
380 chan_write_failed2(c);
381 else
382 chan_write_failed1(c);
383}
384
385void
379chan_mark_dead(Channel *c) 386chan_mark_dead(Channel *c)
380{ 387{
381 c->type = SSH_CHANNEL_ZOMBIE; 388 c->type = SSH_CHANNEL_ZOMBIE;
@@ -431,37 +438,6 @@ chan_is_dead(Channel *c, int send)
431 return 0; 438 return 0;
432} 439}
433 440
434void
435chan_init_iostates(Channel *c)
436{
437 c->ostate = CHAN_OUTPUT_OPEN;
438 c->istate = CHAN_INPUT_OPEN;
439 c->flags = 0;
440}
441
442/* init */
443void
444chan_init(void)
445{
446 if (compat20) {
447 chan_rcvd_oclose = chan_rcvd_close2;
448 chan_read_failed = chan_read_failed_12;
449 chan_ibuf_empty = chan_ibuf_empty2;
450
451 chan_rcvd_ieof = chan_rcvd_eof2;
452 chan_write_failed = chan_write_failed2;
453 chan_obuf_empty = chan_obuf_empty2;
454 } else {
455 chan_rcvd_oclose = chan_rcvd_oclose1;
456 chan_read_failed = chan_read_failed_12;
457 chan_ibuf_empty = chan_ibuf_empty1;
458
459 chan_rcvd_ieof = chan_rcvd_ieof1;
460 chan_write_failed = chan_write_failed1;
461 chan_obuf_empty = chan_obuf_empty1;
462 }
463}
464
465/* helper */ 441/* helper */
466static void 442static void
467chan_shutdown_write(Channel *c) 443chan_shutdown_write(Channel *c)