diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | channels.c | 7 | ||||
-rw-r--r-- | channels.h | 20 | ||||
-rw-r--r-- | nchan.c | 88 |
4 files changed, 48 insertions, 72 deletions
@@ -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 | ||
180 | 20020121 | 183 | 20020121 |
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" |
42 | RCSID("$OpenBSD: channels.c,v 1.158 2002/01/09 17:26:35 markus Exp $"); | 42 | RCSID("$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 | ||
216 | int chan_is_dead(Channel *, int); | 216 | int chan_is_dead(Channel *, int); |
217 | void chan_mark_dead(Channel *); | 217 | void chan_mark_dead(Channel *); |
218 | void chan_init_iostates(Channel *); | ||
219 | void chan_init(void); | ||
220 | 218 | ||
221 | typedef void chan_event_fn(Channel *); | 219 | /* channel events */ |
222 | 220 | ||
223 | /* for the input state */ | 221 | void chan_rcvd_oclose(Channel *); |
224 | extern chan_event_fn *chan_rcvd_oclose; | 222 | void chan_read_failed(Channel *); |
225 | extern chan_event_fn *chan_read_failed; | 223 | void chan_ibuf_empty(Channel *); |
226 | extern chan_event_fn *chan_ibuf_empty; | ||
227 | 224 | ||
228 | /* for the output state */ | 225 | void chan_rcvd_ieof(Channel *); |
229 | extern chan_event_fn *chan_rcvd_ieof; | 226 | void chan_write_failed(Channel *); |
230 | extern chan_event_fn *chan_write_failed; | 227 | void chan_obuf_empty(Channel *); |
231 | extern chan_event_fn *chan_obuf_empty; | ||
232 | 228 | ||
233 | #endif | 229 | #endif |
@@ -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) |