• Home
  • Raw
  • Download

Lines Matching refs:c

89 chan_set_istate(Channel *c, u_int next)  in chan_set_istate()  argument
91 if (c->istate > CHAN_INPUT_CLOSED || next > CHAN_INPUT_CLOSED) in chan_set_istate()
92 fatal("chan_set_istate: bad state %d -> %d", c->istate, next); in chan_set_istate()
93 debug2("channel %d: input %s -> %s", c->self, istates[c->istate], in chan_set_istate()
95 c->istate = next; in chan_set_istate()
99 chan_set_ostate(Channel *c, u_int next) in chan_set_ostate() argument
101 if (c->ostate > CHAN_OUTPUT_CLOSED || next > CHAN_OUTPUT_CLOSED) in chan_set_ostate()
102 fatal("chan_set_ostate: bad state %d -> %d", c->ostate, next); in chan_set_ostate()
103 debug2("channel %d: output %s -> %s", c->self, ostates[c->ostate], in chan_set_ostate()
105 c->ostate = next; in chan_set_ostate()
109 chan_read_failed(struct ssh *ssh, Channel *c) in chan_read_failed() argument
111 debug2("channel %d: read failed", c->self); in chan_read_failed()
112 switch (c->istate) { in chan_read_failed()
114 chan_shutdown_read(ssh, c); in chan_read_failed()
115 chan_set_istate(c, CHAN_INPUT_WAIT_DRAIN); in chan_read_failed()
119 c->self, c->istate); in chan_read_failed()
125 chan_ibuf_empty(struct ssh *ssh, Channel *c) in chan_ibuf_empty() argument
127 debug2("channel %d: ibuf empty", c->self); in chan_ibuf_empty()
128 if (sshbuf_len(c->input)) { in chan_ibuf_empty()
130 c->self); in chan_ibuf_empty()
133 switch (c->istate) { in chan_ibuf_empty()
135 if (!(c->flags & (CHAN_CLOSE_SENT|CHAN_LOCAL))) in chan_ibuf_empty()
136 chan_send_eof2(ssh, c); in chan_ibuf_empty()
137 chan_set_istate(c, CHAN_INPUT_CLOSED); in chan_ibuf_empty()
141 c->self, c->istate); in chan_ibuf_empty()
147 chan_obuf_empty(struct ssh *ssh, Channel *c) in chan_obuf_empty() argument
149 debug2("channel %d: obuf empty", c->self); in chan_obuf_empty()
150 if (sshbuf_len(c->output)) { in chan_obuf_empty()
152 c->self); in chan_obuf_empty()
155 switch (c->ostate) { in chan_obuf_empty()
157 chan_shutdown_write(ssh, c); in chan_obuf_empty()
158 chan_set_ostate(c, CHAN_OUTPUT_CLOSED); in chan_obuf_empty()
162 c->self, c->ostate); in chan_obuf_empty()
168 chan_rcvd_eow(struct ssh *ssh, Channel *c) in chan_rcvd_eow() argument
170 debug2("channel %d: rcvd eow", c->self); in chan_rcvd_eow()
171 switch (c->istate) { in chan_rcvd_eow()
173 chan_shutdown_read(ssh, c); in chan_rcvd_eow()
174 chan_set_istate(c, CHAN_INPUT_CLOSED); in chan_rcvd_eow()
180 chan_send_eof2(struct ssh *ssh, Channel *c) in chan_send_eof2() argument
184 debug2("channel %d: send eof", c->self); in chan_send_eof2()
185 switch (c->istate) { in chan_send_eof2()
187 if (!c->have_remote_id) in chan_send_eof2()
189 __func__, c->self); in chan_send_eof2()
191 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in chan_send_eof2()
194 c->flags |= CHAN_EOF_SENT; in chan_send_eof2()
198 c->self, c->istate); in chan_send_eof2()
204 chan_send_close2(struct ssh *ssh, Channel *c) in chan_send_close2() argument
208 debug2("channel %d: send close", c->self); in chan_send_close2()
209 if (c->ostate != CHAN_OUTPUT_CLOSED || in chan_send_close2()
210 c->istate != CHAN_INPUT_CLOSED) { in chan_send_close2()
212 c->self, c->istate, c->ostate); in chan_send_close2()
213 } else if (c->flags & CHAN_CLOSE_SENT) { in chan_send_close2()
214 error("channel %d: already sent close", c->self); in chan_send_close2()
216 if (!c->have_remote_id) in chan_send_close2()
218 __func__, c->self); in chan_send_close2()
220 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in chan_send_close2()
223 c->flags |= CHAN_CLOSE_SENT; in chan_send_close2()
228 chan_send_eow2(struct ssh *ssh, Channel *c) in chan_send_eow2() argument
232 debug2("channel %d: send eow", c->self); in chan_send_eow2()
233 if (c->ostate == CHAN_OUTPUT_CLOSED) { in chan_send_eow2()
235 c->self); in chan_send_eow2()
240 if (!c->have_remote_id) in chan_send_eow2()
241 fatal("%s: channel %d: no remote_id", __func__, c->self); in chan_send_eow2()
243 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in chan_send_eow2()
253 chan_rcvd_ieof(struct ssh *ssh, Channel *c) in chan_rcvd_ieof() argument
255 debug2("channel %d: rcvd eof", c->self); in chan_rcvd_ieof()
256 c->flags |= CHAN_EOF_RCVD; in chan_rcvd_ieof()
257 if (c->ostate == CHAN_OUTPUT_OPEN) in chan_rcvd_ieof()
258 chan_set_ostate(c, CHAN_OUTPUT_WAIT_DRAIN); in chan_rcvd_ieof()
259 if (c->ostate == CHAN_OUTPUT_WAIT_DRAIN && in chan_rcvd_ieof()
260 sshbuf_len(c->output) == 0 && in chan_rcvd_ieof()
261 !CHANNEL_EFD_OUTPUT_ACTIVE(c)) in chan_rcvd_ieof()
262 chan_obuf_empty(ssh, c); in chan_rcvd_ieof()
266 chan_rcvd_oclose(struct ssh *ssh, Channel *c) in chan_rcvd_oclose() argument
268 debug2("channel %d: rcvd close", c->self); in chan_rcvd_oclose()
269 if (!(c->flags & CHAN_LOCAL)) { in chan_rcvd_oclose()
270 if (c->flags & CHAN_CLOSE_RCVD) in chan_rcvd_oclose()
272 c->self); in chan_rcvd_oclose()
273 c->flags |= CHAN_CLOSE_RCVD; in chan_rcvd_oclose()
275 if (c->type == SSH_CHANNEL_LARVAL) { in chan_rcvd_oclose()
277 chan_set_ostate(c, CHAN_OUTPUT_CLOSED); in chan_rcvd_oclose()
278 chan_set_istate(c, CHAN_INPUT_CLOSED); in chan_rcvd_oclose()
281 switch (c->ostate) { in chan_rcvd_oclose()
287 chan_set_ostate(c, CHAN_OUTPUT_WAIT_DRAIN); in chan_rcvd_oclose()
290 switch (c->istate) { in chan_rcvd_oclose()
292 chan_shutdown_read(ssh, c); in chan_rcvd_oclose()
293 chan_shutdown_extended_read(ssh, c); in chan_rcvd_oclose()
294 chan_set_istate(c, CHAN_INPUT_CLOSED); in chan_rcvd_oclose()
297 if (!(c->flags & CHAN_LOCAL)) in chan_rcvd_oclose()
298 chan_send_eof2(ssh, c); in chan_rcvd_oclose()
299 chan_shutdown_extended_read(ssh, c); in chan_rcvd_oclose()
300 chan_set_istate(c, CHAN_INPUT_CLOSED); in chan_rcvd_oclose()
306 chan_write_failed(struct ssh *ssh, Channel *c) in chan_write_failed() argument
308 debug2("channel %d: write failed", c->self); in chan_write_failed()
309 switch (c->ostate) { in chan_write_failed()
312 chan_shutdown_write(ssh, c); in chan_write_failed()
313 if (strcmp(c->ctype, "session") == 0) in chan_write_failed()
314 chan_send_eow2(ssh, c); in chan_write_failed()
315 chan_set_ostate(c, CHAN_OUTPUT_CLOSED); in chan_write_failed()
319 c->self, c->ostate); in chan_write_failed()
325 chan_mark_dead(struct ssh *ssh, Channel *c) in chan_mark_dead() argument
327 c->type = SSH_CHANNEL_ZOMBIE; in chan_mark_dead()
331 chan_is_dead(struct ssh *ssh, Channel *c, int do_send) in chan_is_dead() argument
333 if (c->type == SSH_CHANNEL_ZOMBIE) { in chan_is_dead()
334 debug2("channel %d: zombie", c->self); in chan_is_dead()
337 if (c->istate != CHAN_INPUT_CLOSED || c->ostate != CHAN_OUTPUT_CLOSED) in chan_is_dead()
340 c->extended_usage == CHAN_EXTENDED_WRITE && in chan_is_dead()
341 c->efd != -1 && in chan_is_dead()
342 sshbuf_len(c->extended) > 0) { in chan_is_dead()
344 c->self, c->efd, sshbuf_len(c->extended)); in chan_is_dead()
347 if (c->flags & CHAN_LOCAL) { in chan_is_dead()
348 debug2("channel %d: is dead (local)", c->self); in chan_is_dead()
351 if (!(c->flags & CHAN_CLOSE_SENT)) { in chan_is_dead()
353 chan_send_close2(ssh, c); in chan_is_dead()
356 if (c->flags & CHAN_CLOSE_RCVD) { in chan_is_dead()
358 c->self); in chan_is_dead()
363 if ((c->flags & CHAN_CLOSE_SENT) && in chan_is_dead()
364 (c->flags & CHAN_CLOSE_RCVD)) { in chan_is_dead()
365 debug2("channel %d: is dead", c->self); in chan_is_dead()
373 chan_shutdown_write(struct ssh *ssh, Channel *c) in chan_shutdown_write() argument
375 sshbuf_reset(c->output); in chan_shutdown_write()
376 if (c->type == SSH_CHANNEL_LARVAL) in chan_shutdown_write()
380 c->self, __func__, c->istate, c->ostate, c->sock, c->wfd, c->efd, in chan_shutdown_write()
381 channel_format_extended_usage(c)); in chan_shutdown_write()
382 if (c->sock != -1) { in chan_shutdown_write()
383 if (shutdown(c->sock, SHUT_WR) == -1) { in chan_shutdown_write()
385 "fd %d [i%d o%d]: %.100s", c->self, __func__, in chan_shutdown_write()
386 c->sock, c->istate, c->ostate, in chan_shutdown_write()
390 if (channel_close_fd(ssh, &c->wfd) < 0) { in chan_shutdown_write()
393 c->self, __func__, c->wfd, c->istate, c->ostate, in chan_shutdown_write()
400 chan_shutdown_read(struct ssh *ssh, Channel *c) in chan_shutdown_read() argument
402 if (c->type == SSH_CHANNEL_LARVAL) in chan_shutdown_read()
405 c->self, __func__, c->istate, c->ostate, c->sock, c->rfd, c->efd, in chan_shutdown_read()
406 channel_format_extended_usage(c)); in chan_shutdown_read()
407 if (c->sock != -1) { in chan_shutdown_read()
413 if (shutdown(c->sock, SHUT_RD) == -1 && errno != ENOTCONN) { in chan_shutdown_read()
416 c->self, __func__, c->sock, c->istate, c->ostate, in chan_shutdown_read()
420 if (channel_close_fd(ssh, &c->rfd) < 0) { in chan_shutdown_read()
423 c->self, __func__, c->rfd, c->istate, c->ostate, in chan_shutdown_read()
430 chan_shutdown_extended_read(struct ssh *ssh, Channel *c) in chan_shutdown_extended_read() argument
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, __func__, c->istate, c->ostate, c->sock, c->rfd, c->efd, in chan_shutdown_extended_read()
439 channel_format_extended_usage(c)); in chan_shutdown_extended_read()
440 if (channel_close_fd(ssh, &c->efd) < 0) { in chan_shutdown_extended_read()
443 c->self, __func__, c->efd, c->istate, c->ostate, in chan_shutdown_extended_read()