summaryrefslogtreecommitdiff
path: root/nchan.c
diff options
context:
space:
mode:
Diffstat (limited to 'nchan.c')
-rw-r--r--nchan.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/nchan.c b/nchan.c
index 2935df320..3138cdd19 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.48 2003/04/08 20:21:29 itojun Exp $"); 26RCSID("$OpenBSD: nchan.c,v 1.49 2003/08/29 10:04:36 markus Exp $");
27 27
28#include "ssh1.h" 28#include "ssh1.h"
29#include "ssh2.h" 29#include "ssh2.h"
@@ -83,7 +83,7 @@ chan_set_istate(Channel *c, u_int next)
83{ 83{
84 if (c->istate > CHAN_INPUT_CLOSED || next > CHAN_INPUT_CLOSED) 84 if (c->istate > CHAN_INPUT_CLOSED || next > CHAN_INPUT_CLOSED)
85 fatal("chan_set_istate: bad state %d -> %d", c->istate, next); 85 fatal("chan_set_istate: bad state %d -> %d", c->istate, next);
86 debug("channel %d: input %s -> %s", c->self, istates[c->istate], 86 debug2("channel %d: input %s -> %s", c->self, istates[c->istate],
87 istates[next]); 87 istates[next]);
88 c->istate = next; 88 c->istate = next;
89} 89}
@@ -92,7 +92,7 @@ chan_set_ostate(Channel *c, u_int next)
92{ 92{
93 if (c->ostate > CHAN_OUTPUT_CLOSED || next > CHAN_OUTPUT_CLOSED) 93 if (c->ostate > CHAN_OUTPUT_CLOSED || next > CHAN_OUTPUT_CLOSED)
94 fatal("chan_set_ostate: bad state %d -> %d", c->ostate, next); 94 fatal("chan_set_ostate: bad state %d -> %d", c->ostate, next);
95 debug("channel %d: output %s -> %s", c->self, ostates[c->ostate], 95 debug2("channel %d: output %s -> %s", c->self, ostates[c->ostate],
96 ostates[next]); 96 ostates[next]);
97 c->ostate = next; 97 c->ostate = next;
98} 98}
@@ -104,7 +104,7 @@ chan_set_ostate(Channel *c, u_int next)
104static void 104static void
105chan_rcvd_oclose1(Channel *c) 105chan_rcvd_oclose1(Channel *c)
106{ 106{
107 debug("channel %d: rcvd oclose", c->self); 107 debug2("channel %d: rcvd oclose", c->self);
108 switch (c->istate) { 108 switch (c->istate) {
109 case CHAN_INPUT_WAIT_OCLOSE: 109 case CHAN_INPUT_WAIT_OCLOSE:
110 chan_set_istate(c, CHAN_INPUT_CLOSED); 110 chan_set_istate(c, CHAN_INPUT_CLOSED);
@@ -128,7 +128,7 @@ chan_rcvd_oclose1(Channel *c)
128void 128void
129chan_read_failed(Channel *c) 129chan_read_failed(Channel *c)
130{ 130{
131 debug("channel %d: read failed", c->self); 131 debug2("channel %d: read failed", c->self);
132 switch (c->istate) { 132 switch (c->istate) {
133 case CHAN_INPUT_OPEN: 133 case CHAN_INPUT_OPEN:
134 chan_shutdown_read(c); 134 chan_shutdown_read(c);
@@ -143,7 +143,7 @@ chan_read_failed(Channel *c)
143void 143void
144chan_ibuf_empty(Channel *c) 144chan_ibuf_empty(Channel *c)
145{ 145{
146 debug("channel %d: ibuf empty", c->self); 146 debug2("channel %d: ibuf empty", c->self);
147 if (buffer_len(&c->input)) { 147 if (buffer_len(&c->input)) {
148 error("channel %d: chan_ibuf_empty for non empty buffer", 148 error("channel %d: chan_ibuf_empty for non empty buffer",
149 c->self); 149 c->self);
@@ -169,7 +169,7 @@ chan_ibuf_empty(Channel *c)
169static void 169static void
170chan_rcvd_ieof1(Channel *c) 170chan_rcvd_ieof1(Channel *c)
171{ 171{
172 debug("channel %d: rcvd ieof", c->self); 172 debug2("channel %d: rcvd ieof", c->self);
173 switch (c->ostate) { 173 switch (c->ostate) {
174 case CHAN_OUTPUT_OPEN: 174 case CHAN_OUTPUT_OPEN:
175 chan_set_ostate(c, CHAN_OUTPUT_WAIT_DRAIN); 175 chan_set_ostate(c, CHAN_OUTPUT_WAIT_DRAIN);
@@ -186,7 +186,7 @@ chan_rcvd_ieof1(Channel *c)
186static void 186static void
187chan_write_failed1(Channel *c) 187chan_write_failed1(Channel *c)
188{ 188{
189 debug("channel %d: write failed", c->self); 189 debug2("channel %d: write failed", c->self);
190 switch (c->ostate) { 190 switch (c->ostate) {
191 case CHAN_OUTPUT_OPEN: 191 case CHAN_OUTPUT_OPEN:
192 chan_shutdown_write(c); 192 chan_shutdown_write(c);
@@ -207,7 +207,7 @@ chan_write_failed1(Channel *c)
207void 207void
208chan_obuf_empty(Channel *c) 208chan_obuf_empty(Channel *c)
209{ 209{
210 debug("channel %d: obuf empty", c->self); 210 debug2("channel %d: obuf empty", c->self);
211 if (buffer_len(&c->output)) { 211 if (buffer_len(&c->output)) {
212 error("channel %d: chan_obuf_empty for non empty buffer", 212 error("channel %d: chan_obuf_empty for non empty buffer",
213 c->self); 213 c->self);
@@ -229,7 +229,7 @@ chan_obuf_empty(Channel *c)
229static void 229static void
230chan_send_ieof1(Channel *c) 230chan_send_ieof1(Channel *c)
231{ 231{
232 debug("channel %d: send ieof", c->self); 232 debug2("channel %d: send ieof", c->self);
233 switch (c->istate) { 233 switch (c->istate) {
234 case CHAN_INPUT_OPEN: 234 case CHAN_INPUT_OPEN:
235 case CHAN_INPUT_WAIT_DRAIN: 235 case CHAN_INPUT_WAIT_DRAIN:
@@ -246,7 +246,7 @@ chan_send_ieof1(Channel *c)
246static void 246static void
247chan_send_oclose1(Channel *c) 247chan_send_oclose1(Channel *c)
248{ 248{
249 debug("channel %d: send oclose", c->self); 249 debug2("channel %d: send oclose", c->self);
250 switch (c->ostate) { 250 switch (c->ostate) {
251 case CHAN_OUTPUT_OPEN: 251 case CHAN_OUTPUT_OPEN:
252 case CHAN_OUTPUT_WAIT_DRAIN: 252 case CHAN_OUTPUT_WAIT_DRAIN:
@@ -268,7 +268,7 @@ chan_send_oclose1(Channel *c)
268static void 268static void
269chan_rcvd_close2(Channel *c) 269chan_rcvd_close2(Channel *c)
270{ 270{
271 debug("channel %d: rcvd close", c->self); 271 debug2("channel %d: rcvd close", c->self);
272 if (c->flags & CHAN_CLOSE_RCVD) 272 if (c->flags & CHAN_CLOSE_RCVD)
273 error("channel %d: protocol error: close rcvd twice", c->self); 273 error("channel %d: protocol error: close rcvd twice", c->self);
274 c->flags |= CHAN_CLOSE_RCVD; 274 c->flags |= CHAN_CLOSE_RCVD;
@@ -301,7 +301,7 @@ chan_rcvd_close2(Channel *c)
301static void 301static void
302chan_rcvd_eof2(Channel *c) 302chan_rcvd_eof2(Channel *c)
303{ 303{
304 debug("channel %d: rcvd eof", c->self); 304 debug2("channel %d: rcvd eof", c->self);
305 c->flags |= CHAN_EOF_RCVD; 305 c->flags |= CHAN_EOF_RCVD;
306 if (c->ostate == CHAN_OUTPUT_OPEN) 306 if (c->ostate == CHAN_OUTPUT_OPEN)
307 chan_set_ostate(c, CHAN_OUTPUT_WAIT_DRAIN); 307 chan_set_ostate(c, CHAN_OUTPUT_WAIT_DRAIN);
@@ -309,7 +309,7 @@ chan_rcvd_eof2(Channel *c)
309static void 309static void
310chan_write_failed2(Channel *c) 310chan_write_failed2(Channel *c)
311{ 311{
312 debug("channel %d: write failed", c->self); 312 debug2("channel %d: write failed", c->self);
313 switch (c->ostate) { 313 switch (c->ostate) {
314 case CHAN_OUTPUT_OPEN: 314 case CHAN_OUTPUT_OPEN:
315 case CHAN_OUTPUT_WAIT_DRAIN: 315 case CHAN_OUTPUT_WAIT_DRAIN:
@@ -325,7 +325,7 @@ chan_write_failed2(Channel *c)
325static void 325static void
326chan_send_eof2(Channel *c) 326chan_send_eof2(Channel *c)
327{ 327{
328 debug("channel %d: send eof", c->self); 328 debug2("channel %d: send eof", c->self);
329 switch (c->istate) { 329 switch (c->istate) {
330 case CHAN_INPUT_WAIT_DRAIN: 330 case CHAN_INPUT_WAIT_DRAIN:
331 packet_start(SSH2_MSG_CHANNEL_EOF); 331 packet_start(SSH2_MSG_CHANNEL_EOF);
@@ -342,7 +342,7 @@ chan_send_eof2(Channel *c)
342static void 342static void
343chan_send_close2(Channel *c) 343chan_send_close2(Channel *c)
344{ 344{
345 debug("channel %d: send close", c->self); 345 debug2("channel %d: send close", c->self);
346 if (c->ostate != CHAN_OUTPUT_CLOSED || 346 if (c->ostate != CHAN_OUTPUT_CLOSED ||
347 c->istate != CHAN_INPUT_CLOSED) { 347 c->istate != CHAN_INPUT_CLOSED) {
348 error("channel %d: cannot send close for istate/ostate %d/%d", 348 error("channel %d: cannot send close for istate/ostate %d/%d",
@@ -398,13 +398,13 @@ int
398chan_is_dead(Channel *c, int send) 398chan_is_dead(Channel *c, int send)
399{ 399{
400 if (c->type == SSH_CHANNEL_ZOMBIE) { 400 if (c->type == SSH_CHANNEL_ZOMBIE) {
401 debug("channel %d: zombie", c->self); 401 debug2("channel %d: zombie", c->self);
402 return 1; 402 return 1;
403 } 403 }
404 if (c->istate != CHAN_INPUT_CLOSED || c->ostate != CHAN_OUTPUT_CLOSED) 404 if (c->istate != CHAN_INPUT_CLOSED || c->ostate != CHAN_OUTPUT_CLOSED)
405 return 0; 405 return 0;
406 if (!compat20) { 406 if (!compat20) {
407 debug("channel %d: is dead", c->self); 407 debug2("channel %d: is dead", c->self);
408 return 1; 408 return 1;
409 } 409 }
410 if ((datafellows & SSH_BUG_EXTEOF) && 410 if ((datafellows & SSH_BUG_EXTEOF) &&
@@ -421,7 +421,7 @@ chan_is_dead(Channel *c, int send)
421 } else { 421 } else {
422 /* channel would be dead if we sent a close */ 422 /* channel would be dead if we sent a close */
423 if (c->flags & CHAN_CLOSE_RCVD) { 423 if (c->flags & CHAN_CLOSE_RCVD) {
424 debug("channel %d: almost dead", 424 debug2("channel %d: almost dead",
425 c->self); 425 c->self);
426 return 1; 426 return 1;
427 } 427 }
@@ -429,7 +429,7 @@ chan_is_dead(Channel *c, int send)
429 } 429 }
430 if ((c->flags & CHAN_CLOSE_SENT) && 430 if ((c->flags & CHAN_CLOSE_SENT) &&
431 (c->flags & CHAN_CLOSE_RCVD)) { 431 (c->flags & CHAN_CLOSE_RCVD)) {
432 debug("channel %d: is dead", c->self); 432 debug2("channel %d: is dead", c->self);
433 return 1; 433 return 1;
434 } 434 }
435 return 0; 435 return 0;
@@ -443,10 +443,10 @@ chan_shutdown_write(Channel *c)
443 if (compat20 && c->type == SSH_CHANNEL_LARVAL) 443 if (compat20 && c->type == SSH_CHANNEL_LARVAL)
444 return; 444 return;
445 /* shutdown failure is allowed if write failed already */ 445 /* shutdown failure is allowed if write failed already */
446 debug("channel %d: close_write", c->self); 446 debug2("channel %d: close_write", c->self);
447 if (c->sock != -1) { 447 if (c->sock != -1) {
448 if (shutdown(c->sock, SHUT_WR) < 0) 448 if (shutdown(c->sock, SHUT_WR) < 0)
449 debug("channel %d: chan_shutdown_write: " 449 debug2("channel %d: chan_shutdown_write: "
450 "shutdown() failed for fd%d: %.100s", 450 "shutdown() failed for fd%d: %.100s",
451 c->self, c->sock, strerror(errno)); 451 c->self, c->sock, strerror(errno));
452 } else { 452 } else {
@@ -461,7 +461,7 @@ chan_shutdown_read(Channel *c)
461{ 461{
462 if (compat20 && c->type == SSH_CHANNEL_LARVAL) 462 if (compat20 && c->type == SSH_CHANNEL_LARVAL)
463 return; 463 return;
464 debug("channel %d: close_read", c->self); 464 debug2("channel %d: close_read", c->self);
465 if (c->sock != -1) { 465 if (c->sock != -1) {
466 /* 466 /*
467 * shutdown(sock, SHUT_READ) may return ENOTCONN if the 467 * shutdown(sock, SHUT_READ) may return ENOTCONN if the