Lines Matching +full:send +full:- +full:empty
35 #include "openbsd-compat/sys-queue.h"
52 * 1.3: strict request-ack-protocol:
53 * CLOSE ->
54 * <- CLOSE_CONFIRM
57 * IEOF ->
58 * <- OCLOSE
59 * <- IEOF
60 * OCLOSE ->
65 * See the debugging output from 'ssh -v' and 'sshd -d' of
66 * ssh-1.2.27 as an example.
95 if (c->istate > CHAN_INPUT_CLOSED || next > CHAN_INPUT_CLOSED) in chan_set_istate()
96 fatal("chan_set_istate: bad state %d -> %d", c->istate, next); in chan_set_istate()
97 debug2("channel %d: input %s -> %s", c->self, istates[c->istate], in chan_set_istate()
99 c->istate = next; in chan_set_istate()
105 if (c->ostate > CHAN_OUTPUT_CLOSED || next > CHAN_OUTPUT_CLOSED) in chan_set_ostate()
106 fatal("chan_set_ostate: bad state %d -> %d", c->ostate, next); in chan_set_ostate()
107 debug2("channel %d: output %s -> %s", c->self, ostates[c->ostate], in chan_set_ostate()
109 c->ostate = next; in chan_set_ostate()
115 debug2("channel %d: read failed", c->self); in chan_read_failed()
116 switch (c->istate) { in chan_read_failed()
123 c->self, c->istate); in chan_read_failed()
131 debug2("channel %d: ibuf empty", c->self); in chan_ibuf_empty()
132 if (sshbuf_len(c->input)) { in chan_ibuf_empty()
133 error("channel %d: chan_ibuf_empty for non empty buffer", in chan_ibuf_empty()
134 c->self); in chan_ibuf_empty()
137 switch (c->istate) { in chan_ibuf_empty()
139 if (!(c->flags & (CHAN_CLOSE_SENT|CHAN_LOCAL))) in chan_ibuf_empty()
145 c->self, c->istate); in chan_ibuf_empty()
153 debug2("channel %d: obuf empty", c->self); in chan_obuf_empty()
154 if (sshbuf_len(c->output)) { in chan_obuf_empty()
155 error("channel %d: chan_obuf_empty for non empty buffer", in chan_obuf_empty()
156 c->self); in chan_obuf_empty()
159 switch (c->ostate) { in chan_obuf_empty()
166 c->self, c->ostate); in chan_obuf_empty()
174 debug2("channel %d: rcvd eow", c->self); in chan_rcvd_eow()
175 switch (c->istate) { in chan_rcvd_eow()
188 debug2("channel %d: send eof", c->self); in chan_send_eof2()
189 switch (c->istate) { in chan_send_eof2()
191 if (!c->have_remote_id) in chan_send_eof2()
192 fatal_f("channel %d: no remote_id", c->self); in chan_send_eof2()
194 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in chan_send_eof2()
196 fatal_fr(r, "send CHANNEL_EOF"); in chan_send_eof2()
197 c->flags |= CHAN_EOF_SENT; in chan_send_eof2()
200 error("channel %d: cannot send eof for istate %d", in chan_send_eof2()
201 c->self, c->istate); in chan_send_eof2()
211 debug2("channel %d: send_close2", c->self); in chan_send_close2()
212 if (c->ostate != CHAN_OUTPUT_CLOSED || in chan_send_close2()
213 c->istate != CHAN_INPUT_CLOSED) { in chan_send_close2()
214 error("channel %d: cannot send close for istate/ostate %d/%d", in chan_send_close2()
215 c->self, c->istate, c->ostate); in chan_send_close2()
216 } else if (c->flags & CHAN_CLOSE_SENT) { in chan_send_close2()
217 error("channel %d: already sent close", c->self); in chan_send_close2()
219 if (!c->have_remote_id) in chan_send_close2()
220 fatal_f("channel %d: no remote_id", c->self); in chan_send_close2()
221 debug2("channel %d: send close for remote id %u", c->self, in chan_send_close2()
222 c->remote_id); in chan_send_close2()
224 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in chan_send_close2()
226 fatal_fr(r, "send CHANNEL_EOF"); in chan_send_close2()
227 c->flags |= CHAN_CLOSE_SENT; in chan_send_close2()
236 debug2("channel %d: send eow", c->self); in chan_send_eow2()
237 if (c->ostate == CHAN_OUTPUT_CLOSED) { in chan_send_eow2()
239 c->self); in chan_send_eow2()
242 if (!(ssh->compat & SSH_NEW_OPENSSH)) in chan_send_eow2()
244 if (!c->have_remote_id) in chan_send_eow2()
245 fatal_f("channel %d: no remote_id", c->self); in chan_send_eow2()
247 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in chan_send_eow2()
251 fatal_fr(r, "send CHANNEL_EOF"); in chan_send_eow2()
259 debug2("channel %d: rcvd eof", c->self); in chan_rcvd_ieof()
260 c->flags |= CHAN_EOF_RCVD; in chan_rcvd_ieof()
261 if (c->ostate == CHAN_OUTPUT_OPEN) in chan_rcvd_ieof()
263 if (c->ostate == CHAN_OUTPUT_WAIT_DRAIN && in chan_rcvd_ieof()
264 sshbuf_len(c->output) == 0 && in chan_rcvd_ieof()
272 debug2("channel %d: rcvd close", c->self); in chan_rcvd_oclose()
273 if (!(c->flags & CHAN_LOCAL)) { in chan_rcvd_oclose()
274 if (c->flags & CHAN_CLOSE_RCVD) in chan_rcvd_oclose()
276 c->self); in chan_rcvd_oclose()
277 c->flags |= CHAN_CLOSE_RCVD; in chan_rcvd_oclose()
279 if (c->type == SSH_CHANNEL_LARVAL) { in chan_rcvd_oclose()
285 switch (c->ostate) { in chan_rcvd_oclose()
294 switch (c->istate) { in chan_rcvd_oclose()
301 if (!(c->flags & CHAN_LOCAL)) in chan_rcvd_oclose()
312 debug2("channel %d: write failed", c->self); in chan_write_failed()
313 switch (c->ostate) { in chan_write_failed()
317 if (strcmp(c->ctype, "session") == 0) in chan_write_failed()
323 c->self, c->ostate); in chan_write_failed()
331 c->type = SSH_CHANNEL_ZOMBIE; in chan_mark_dead()
337 if (c->type == SSH_CHANNEL_ZOMBIE) { in chan_is_dead()
338 debug2("channel %d: zombie", c->self); in chan_is_dead()
341 if (c->istate != CHAN_INPUT_CLOSED || c->ostate != CHAN_OUTPUT_CLOSED) in chan_is_dead()
343 if ((ssh->compat & SSH_BUG_EXTEOF) && in chan_is_dead()
344 c->extended_usage == CHAN_EXTENDED_WRITE && in chan_is_dead()
345 c->efd != -1 && in chan_is_dead()
346 sshbuf_len(c->extended) > 0) { in chan_is_dead()
348 c->self, c->efd, sshbuf_len(c->extended)); in chan_is_dead()
351 if (c->flags & CHAN_LOCAL) { in chan_is_dead()
352 debug2("channel %d: is dead (local)", c->self); in chan_is_dead()
355 if (!(c->flags & CHAN_CLOSE_SENT)) { in chan_is_dead()
360 if (c->flags & CHAN_CLOSE_RCVD) { in chan_is_dead()
362 c->self); in chan_is_dead()
367 if ((c->flags & CHAN_CLOSE_SENT) && in chan_is_dead()
368 (c->flags & CHAN_CLOSE_RCVD)) { in chan_is_dead()
369 debug2("channel %d: is dead", c->self); in chan_is_dead()
379 sshbuf_reset(c->output); in chan_shutdown_write()
380 if (c->type == SSH_CHANNEL_LARVAL) in chan_shutdown_write()
384 c->self, c->istate, c->ostate, c->sock, c->wfd, c->efd, in chan_shutdown_write()
386 if (c->sock != -1) { in chan_shutdown_write()
387 if (shutdown(c->sock, SHUT_WR) == -1) { in chan_shutdown_write()
389 "fd %d [i%d o%d]: %.100s", c->self, c->sock, in chan_shutdown_write()
390 c->istate, c->ostate, strerror(errno)); in chan_shutdown_write()
393 if (channel_close_fd(ssh, c, &c->wfd) < 0) { in chan_shutdown_write()
395 "fd %d [i%d o%d]: %.100s", c->self, c->wfd, in chan_shutdown_write()
396 c->istate, c->ostate, strerror(errno)); in chan_shutdown_write()
404 if (c->type == SSH_CHANNEL_LARVAL) in chan_shutdown_read()
407 c->self, c->istate, c->ostate, c->sock, c->rfd, c->efd, in chan_shutdown_read()
409 if (c->sock != -1) { in chan_shutdown_read()
413 * HP-UX may return ENOTCONN also. in chan_shutdown_read()
415 if (shutdown(c->sock, SHUT_RD) == -1 && errno != ENOTCONN) { in chan_shutdown_read()
417 "fd %d [i%d o%d]: %.100s", c->self, c->sock, in chan_shutdown_read()
418 c->istate, c->ostate, strerror(errno)); in chan_shutdown_read()
421 if (channel_close_fd(ssh, c, &c->rfd) < 0) { in chan_shutdown_read()
423 "fd %d [i%d o%d]: %.100s", c->self, c->rfd, in chan_shutdown_read()
424 c->istate, c->ostate, strerror(errno)); in chan_shutdown_read()
432 if (c->type == SSH_CHANNEL_LARVAL || c->efd == -1) in chan_shutdown_extended_read()
434 if (c->extended_usage != CHAN_EXTENDED_READ && in chan_shutdown_extended_read()
435 c->extended_usage != CHAN_EXTENDED_IGNORE) in chan_shutdown_extended_read()
438 c->self, c->istate, c->ostate, c->sock, c->rfd, c->efd, in chan_shutdown_extended_read()
440 if (channel_close_fd(ssh, c, &c->efd) < 0) { in chan_shutdown_extended_read()
442 "extended fd %d [i%d o%d]: %.100s", c->self, c->efd, in chan_shutdown_extended_read()
443 c->istate, c->ostate, strerror(errno)); in chan_shutdown_extended_read()