summaryrefslogtreecommitdiff
path: root/nchan.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2002-01-22 23:28:45 +1100
committerDamien Miller <djm@mindrot.org>2002-01-22 23:28:45 +1100
commit5144df92616ff8ed4fa3aa709651333c09d850b4 (patch)
tree125fe86f2f84288a5736b2cfe180dc61297d6a63 /nchan.c
parent472d05716adc8e06076551febe5ead3b1e3a67dc (diff)
- markus@cvs.openbsd.org 2002/01/14 13:55:55
[channels.c channels.h nchan.c] remove function pointers for events, remove chan_init*; ok provos@
Diffstat (limited to 'nchan.c')
-rw-r--r--nchan.c88
1 files changed, 32 insertions, 56 deletions
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)