diff options
Diffstat (limited to 'nchan.c')
-rw-r--r-- | nchan.c | 88 |
1 files changed, 32 insertions, 56 deletions
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: nchan.c,v 1.41 2002/01/14 13:41:13 markus Exp $"); | 26 | RCSID("$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) */ | ||
67 | chan_event_fn *chan_rcvd_oclose = NULL; | ||
68 | chan_event_fn *chan_read_failed = NULL; | ||
69 | chan_event_fn *chan_ibuf_empty = NULL; | ||
70 | /* events concerning the OUTPUT from channel for socket (ostate) */ | ||
71 | chan_event_fn *chan_rcvd_ieof = NULL; | ||
72 | chan_event_fn *chan_write_failed = NULL; | ||
73 | chan_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 | } |
136 | static void | 128 | void |
137 | chan_read_failed_12(Channel *c) | 129 | chan_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 | } |
151 | static void | 143 | void |
152 | chan_ibuf_empty1(Channel *c) | 144 | chan_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 | } |
215 | static void | 207 | void |
216 | chan_obuf_empty1(Channel *c) | 208 | chan_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 | } |
309 | static void | 301 | static void |
310 | chan_ibuf_empty2(Channel *c) | ||
311 | { | ||
312 | chan_ibuf_empty1(c); | ||
313 | } | ||
314 | static void | ||
315 | chan_rcvd_eof2(Channel *c) | 302 | chan_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 | } |
337 | static void | 324 | static void |
338 | chan_obuf_empty2(Channel *c) | ||
339 | { | ||
340 | chan_obuf_empty1(c); | ||
341 | } | ||
342 | static void | ||
343 | chan_send_eof2(Channel *c) | 325 | chan_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 | ||
378 | void | 360 | void |
361 | chan_rcvd_ieof(Channel *c) | ||
362 | { | ||
363 | if (compat20) | ||
364 | chan_rcvd_eof2(c); | ||
365 | else | ||
366 | chan_rcvd_ieof1(c); | ||
367 | } | ||
368 | void | ||
369 | chan_rcvd_oclose(Channel *c) | ||
370 | { | ||
371 | if (compat20) | ||
372 | chan_rcvd_close2(c); | ||
373 | else | ||
374 | chan_rcvd_oclose1(c); | ||
375 | } | ||
376 | void | ||
377 | chan_write_failed(Channel *c) | ||
378 | { | ||
379 | if (compat20) | ||
380 | chan_write_failed2(c); | ||
381 | else | ||
382 | chan_write_failed1(c); | ||
383 | } | ||
384 | |||
385 | void | ||
379 | chan_mark_dead(Channel *c) | 386 | chan_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 | ||
434 | void | ||
435 | chan_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 */ | ||
443 | void | ||
444 | chan_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 */ |
466 | static void | 442 | static void |
467 | chan_shutdown_write(Channel *c) | 443 | chan_shutdown_write(Channel *c) |