Lines Matching full:ssh
14 * called by a name other than "ssh" or "Secure Shell".
75 #include "ssh.h"
108 typedef void chan_fn(struct ssh *, Channel *c);
223 static void port_open_helper(struct ssh *ssh, Channel *c, char *rtype);
229 static Channel *rdynamic_connect_prepare(struct ssh *, char *, char *);
230 static int rdynamic_connect_finish(struct ssh *, Channel *);
238 channel_init_channels(struct ssh *ssh) in channel_init_channels() argument
249 ssh->chanctxt = sc; in channel_init_channels()
253 channel_by_id(struct ssh *ssh, int id) in channel_by_id() argument
257 if (id < 0 || (u_int)id >= ssh->chanctxt->channels_alloc) { in channel_by_id()
261 c = ssh->chanctxt->channels[id]; in channel_by_id()
270 channel_by_remote_id(struct ssh *ssh, u_int remote_id) in channel_by_remote_id() argument
275 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_by_remote_id()
276 c = ssh->chanctxt->channels[i]; in channel_by_remote_id()
288 channel_lookup(struct ssh *ssh, int id) in channel_lookup() argument
292 if ((c = channel_by_id(ssh, id)) == NULL) in channel_lookup()
317 channel_add_timeout(struct ssh *ssh, const char *type_pattern, in channel_add_timeout() argument
320 struct ssh_channels *sc = ssh->chanctxt; in channel_add_timeout()
338 channel_clear_timeouts(struct ssh *ssh) in channel_clear_timeouts() argument
340 struct ssh_channels *sc = ssh->chanctxt; in channel_clear_timeouts()
352 lookup_timeout(struct ssh *ssh, const char *type) in lookup_timeout() argument
354 struct ssh_channels *sc = ssh->chanctxt; in lookup_timeout()
372 channel_set_xtype(struct ssh *ssh, int id, const char *xctype) in channel_set_xtype() argument
376 if ((c = channel_by_id(ssh, id)) == NULL) in channel_set_xtype()
382 c->inactive_deadline = lookup_timeout(ssh, c->xctype); in channel_set_xtype()
392 channel_set_used_time(struct ssh *ssh, Channel *c) in channel_set_used_time() argument
394 ssh->chanctxt->lastused = monotime(); in channel_set_used_time()
396 c->lastused = ssh->chanctxt->lastused; in channel_set_used_time()
404 channel_get_expiry(struct ssh *ssh, Channel *c) in channel_get_expiry() argument
406 struct ssh_channels *sc = ssh->chanctxt; in channel_get_expiry()
424 channel_register_fds(struct ssh *ssh, Channel *c, int rfd, int wfd, int efd, in channel_register_fds() argument
485 channel_set_used_time(ssh, NULL); in channel_register_fds()
492 channel_new(struct ssh *ssh, char *ctype, int type, int rfd, int wfd, int efd, in channel_new() argument
496 struct ssh_channels *sc = ssh->chanctxt; in channel_new()
533 channel_register_fds(ssh, c, rfd, wfd, efd, extusage, nonblock, 0); in channel_new()
543 c->inactive_deadline = lookup_timeout(ssh, c->ctype); in channel_new()
551 channel_close_fd(struct ssh *ssh, Channel *c, int *fdp) in channel_close_fd() argument
601 channel_close_fds(struct ssh *ssh, Channel *c) in channel_close_fds() argument
605 channel_close_fd(ssh, c, &c->sock); in channel_close_fds()
607 channel_close_fd(ssh, c, &c->rfd); in channel_close_fds()
609 channel_close_fd(ssh, c, &c->wfd); in channel_close_fds()
611 channel_close_fd(ssh, c, &c->efd); in channel_close_fds()
643 permission_set_get(struct ssh *ssh, int where) in permission_set_get() argument
645 struct ssh_channels *sc = ssh->chanctxt; in permission_set_get()
661 permission_set_get_array(struct ssh *ssh, int who, int where, in permission_set_get_array() argument
664 struct permission_set *pset = permission_set_get(ssh, where); in permission_set_get_array()
682 permission_set_add(struct ssh *ssh, int who, int where, in permission_set_add() argument
690 permission_set_get_array(ssh, who, where, &permp, &npermp); in permission_set_add()
709 mux_remove_remote_forwardings(struct ssh *ssh, Channel *c) in mux_remove_remote_forwardings() argument
711 struct ssh_channels *sc = ssh->chanctxt; in mux_remove_remote_forwardings()
725 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in mux_remove_remote_forwardings()
726 (r = sshpkt_put_cstring(ssh, in mux_remove_remote_forwardings()
728 (r = sshpkt_put_u8(ssh, 0)) != 0 || in mux_remove_remote_forwardings()
729 (r = sshpkt_put_cstring(ssh, in mux_remove_remote_forwardings()
731 (r = sshpkt_put_u32(ssh, perm->listen_port)) != 0 || in mux_remove_remote_forwardings()
732 (r = sshpkt_send(ssh)) != 0) { in mux_remove_remote_forwardings()
741 channel_free(struct ssh *ssh, Channel *c) in channel_free() argument
743 struct ssh_channels *sc = ssh->chanctxt; in channel_free()
767 mux_remove_remote_forwardings(ssh, c); in channel_free()
776 s = channel_open_message(ssh); in channel_free()
781 channel_close_fds(ssh, c); in channel_free()
796 cc->abandon_cb(ssh, c, cc->ctx); in channel_free()
801 c->filter_cleanup(ssh, c->self, c->filter_ctx); in channel_free()
807 channel_free_all(struct ssh *ssh) in channel_free_all() argument
810 struct ssh_channels *sc = ssh->chanctxt; in channel_free_all()
814 channel_free(ssh, sc->channels[i]); in channel_free_all()
840 channel_close_all(struct ssh *ssh) in channel_close_all() argument
844 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) in channel_close_all()
845 if (ssh->chanctxt->channels[i] != NULL) in channel_close_all()
846 channel_close_fds(ssh, ssh->chanctxt->channels[i]); in channel_close_all()
853 channel_stop_listening(struct ssh *ssh) in channel_stop_listening() argument
858 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_stop_listening()
859 c = ssh->chanctxt->channels[i]; in channel_stop_listening()
868 channel_close_fd(ssh, c, &c->sock); in channel_stop_listening()
869 channel_free(ssh, c); in channel_stop_listening()
881 channel_not_very_much_buffered_data(struct ssh *ssh) in channel_not_very_much_buffered_data() argument
884 u_int maxsize = ssh_packet_get_maxsize(ssh); in channel_not_very_much_buffered_data()
887 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_not_very_much_buffered_data()
888 c = ssh->chanctxt->channels[i]; in channel_not_very_much_buffered_data()
902 channel_still_open(struct ssh *ssh) in channel_still_open() argument
907 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_still_open()
908 c = ssh->chanctxt->channels[i]; in channel_still_open()
945 channel_tty_open(struct ssh *ssh) in channel_tty_open() argument
950 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_tty_open()
951 c = ssh->chanctxt->channels[i]; in channel_tty_open()
962 channel_find_open(struct ssh *ssh) in channel_find_open() argument
967 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_find_open()
968 c = ssh->chanctxt->channels[i]; in channel_find_open()
1044 channel_open_message(struct ssh *ssh) in channel_open_message() argument
1057 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_open_message()
1058 c = ssh->chanctxt->channels[i]; in channel_open_message()
1103 open_preamble(struct ssh *ssh, const char *where, Channel *c, const char *type) in open_preamble() argument
1107 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN)) != 0 || in open_preamble()
1108 (r = sshpkt_put_cstring(ssh, type)) != 0 || in open_preamble()
1109 (r = sshpkt_put_u32(ssh, c->self)) != 0 || in open_preamble()
1110 (r = sshpkt_put_u32(ssh, c->local_window)) != 0 || in open_preamble()
1111 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0) { in open_preamble()
1117 channel_send_open(struct ssh *ssh, int id) in channel_send_open() argument
1119 Channel *c = channel_lookup(ssh, id); in channel_send_open()
1127 open_preamble(ssh, __func__, c, c->ctype); in channel_send_open()
1128 if ((r = sshpkt_send(ssh)) != 0) in channel_send_open()
1133 channel_request_start(struct ssh *ssh, int id, char *service, int wantconfirm) in channel_request_start() argument
1135 Channel *c = channel_lookup(ssh, id); in channel_request_start()
1146 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_REQUEST)) != 0 || in channel_request_start()
1147 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in channel_request_start()
1148 (r = sshpkt_put_cstring(ssh, service)) != 0 || in channel_request_start()
1149 (r = sshpkt_put_u8(ssh, wantconfirm)) != 0) { in channel_request_start()
1155 channel_register_status_confirm(struct ssh *ssh, int id, in channel_register_status_confirm() argument
1161 if ((c = channel_lookup(ssh, id)) == NULL) in channel_register_status_confirm()
1172 channel_register_open_confirm(struct ssh *ssh, int id, in channel_register_open_confirm() argument
1175 Channel *c = channel_lookup(ssh, id); in channel_register_open_confirm()
1186 channel_register_cleanup(struct ssh *ssh, int id, in channel_register_cleanup() argument
1189 Channel *c = channel_by_id(ssh, id); in channel_register_cleanup()
1200 channel_cancel_cleanup(struct ssh *ssh, int id) in channel_cancel_cleanup() argument
1202 Channel *c = channel_by_id(ssh, id); in channel_cancel_cleanup()
1213 channel_register_filter(struct ssh *ssh, int id, channel_infilter_fn *ifn, in channel_register_filter() argument
1216 Channel *c = channel_lookup(ssh, id); in channel_register_filter()
1229 channel_set_fds(struct ssh *ssh, int id, int rfd, int wfd, int efd, in channel_set_fds() argument
1232 Channel *c = channel_lookup(ssh, id); in channel_set_fds()
1240 channel_register_fds(ssh, c, rfd, wfd, efd, extusage, nonblock, is_tty); in channel_set_fds()
1242 channel_set_used_time(ssh, c); in channel_set_fds()
1245 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_WINDOW_ADJUST)) != 0 || in channel_set_fds()
1246 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in channel_set_fds()
1247 (r = sshpkt_put_u32(ssh, c->local_window)) != 0 || in channel_set_fds()
1248 (r = sshpkt_send(ssh)) != 0) in channel_set_fds()
1253 channel_pre_listener(struct ssh *ssh, Channel *c) in channel_pre_listener() argument
1259 channel_pre_connecting(struct ssh *ssh, Channel *c) in channel_pre_connecting() argument
1266 channel_pre_open(struct ssh *ssh, Channel *c) in channel_pre_open() argument
1284 chan_obuf_empty(ssh, c); in channel_pre_open()
1312 x11_open_helper(struct ssh *ssh, struct sshbuf *b) in x11_open_helper() argument
1314 struct ssh_channels *sc = ssh->chanctxt; in x11_open_helper()
1379 channel_force_close(struct ssh *ssh, Channel *c, int abandon) in channel_force_close() argument
1383 chan_read_failed(ssh, c); in channel_force_close()
1386 chan_ibuf_empty(ssh, c); in channel_force_close()
1391 chan_write_failed(ssh, c); in channel_force_close()
1394 c->detach_user(ssh, c->self, 1, NULL); in channel_force_close()
1396 channel_close_fd(ssh, c, &c->efd); in channel_force_close()
1405 channel_pre_x11_open(struct ssh *ssh, Channel *c) in channel_pre_x11_open() argument
1407 int ret = x11_open_helper(ssh, c->output); in channel_pre_x11_open()
1413 channel_set_used_time(ssh, c); in channel_pre_x11_open()
1414 channel_pre_open(ssh, c); in channel_pre_x11_open()
1420 channel_force_close(ssh, c, 0); in channel_pre_x11_open()
1425 channel_pre_mux_client(struct ssh *ssh, Channel *c) in channel_pre_mux_client() argument
1434 chan_ibuf_empty(ssh, c); in channel_pre_mux_client()
1436 chan_rcvd_oclose(ssh, c); in channel_pre_mux_client()
1443 chan_obuf_empty(ssh, c); in channel_pre_mux_client()
1695 channel_connect_stdio_fwd(struct ssh *ssh, in channel_connect_stdio_fwd() argument
1703 c = channel_new(ssh, "stdio-forward", SSH_CHANNEL_OPENING, in, out, in channel_connect_stdio_fwd()
1712 channel_register_fds(ssh, c, in, out, -1, 0, 1, 0); in channel_connect_stdio_fwd()
1713 port_open_helper(ssh, c, port_to_connect == PORT_STREAMLOCAL ? in channel_connect_stdio_fwd()
1721 channel_pre_dynamic(struct ssh *ssh, Channel *c) in channel_pre_dynamic() argument
1752 chan_mark_dead(ssh, c); in channel_pre_dynamic()
1762 port_open_helper(ssh, c, "direct-tcpip"); in channel_pre_dynamic()
1768 rdynamic_close(struct ssh *ssh, Channel *c) in rdynamic_close() argument
1771 channel_force_close(ssh, c, 0); in rdynamic_close()
1776 channel_before_prepare_io_rdynamic(struct ssh *ssh, Channel *c) in channel_before_prepare_io_rdynamic() argument
1789 rdynamic_close(ssh, c); in channel_before_prepare_io_rdynamic()
1810 rdynamic_close(ssh, c); in channel_before_prepare_io_rdynamic()
1816 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_DATA)) != 0 || in channel_before_prepare_io_rdynamic()
1817 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in channel_before_prepare_io_rdynamic()
1818 (r = sshpkt_put_stringb(ssh, c->input)) != 0 || in channel_before_prepare_io_rdynamic()
1819 (r = sshpkt_send(ssh)) != 0) { in channel_before_prepare_io_rdynamic()
1826 } else if (rdynamic_connect_finish(ssh, c) < 0) { in channel_before_prepare_io_rdynamic()
1828 rdynamic_close(ssh, c); in channel_before_prepare_io_rdynamic()
1834 channel_post_x11_listener(struct ssh *ssh, Channel *c) in channel_post_x11_listener() argument
1851 channel_close_fd(ssh, c, &c->sock); in channel_post_x11_listener()
1852 chan_mark_dead(ssh, c); in channel_post_x11_listener()
1869 nc = channel_new(ssh, "x11-connection", in channel_post_x11_listener()
1872 open_preamble(ssh, __func__, nc, "x11"); in channel_post_x11_listener()
1873 if ((r = sshpkt_put_cstring(ssh, remote_ipaddr)) != 0 || in channel_post_x11_listener()
1874 (r = sshpkt_put_u32(ssh, remote_port)) != 0) { in channel_post_x11_listener()
1877 if ((r = sshpkt_send(ssh)) != 0) in channel_post_x11_listener()
1883 port_open_helper(struct ssh *ssh, Channel *c, char *rtype) in port_open_helper() argument
1905 open_preamble(ssh, __func__, c, rtype); in port_open_helper()
1908 if ((r = sshpkt_put_cstring(ssh, c->path)) != 0 || in port_open_helper()
1909 (r = sshpkt_put_u32(ssh, c->host_port)) != 0) in port_open_helper()
1913 if ((r = sshpkt_put_cstring(ssh, c->path)) != 0) in port_open_helper()
1917 if ((r = sshpkt_put_cstring(ssh, c->path)) != 0) in port_open_helper()
1921 if ((r = sshpkt_put_cstring(ssh, c->path)) != 0 || in port_open_helper()
1922 (r = sshpkt_put_u32(ssh, local_port)) != 0) in port_open_helper()
1927 if ((r = sshpkt_put_cstring(ssh, "")) != 0) in port_open_helper()
1931 if ((r = sshpkt_put_cstring(ssh, remote_ipaddr)) != 0 || in port_open_helper()
1932 (r = sshpkt_put_u32(ssh, (u_int)remote_port)) != 0) in port_open_helper()
1935 if ((r = sshpkt_send(ssh)) != 0) in port_open_helper()
1942 channel_set_x11_refuse_time(struct ssh *ssh, time_t refuse_time) in channel_set_x11_refuse_time() argument
1944 ssh->chanctxt->x11_refuse_time = refuse_time; in channel_set_x11_refuse_time()
1951 channel_post_port_listener(struct ssh *ssh, Channel *c) in channel_post_port_listener() argument
1994 nc = channel_new(ssh, rtype, nextstate, newsock, newsock, -1, in channel_post_port_listener()
2002 port_open_helper(ssh, nc, rtype); in channel_post_port_listener()
2010 channel_post_auth_listener(struct ssh *ssh, Channel *c) in channel_post_auth_listener() argument
2028 nc = channel_new(ssh, "agent-connection", in channel_post_auth_listener()
2032 open_preamble(ssh, __func__, nc, "auth-agent@openssh.com"); in channel_post_auth_listener()
2033 if ((r = sshpkt_send(ssh)) != 0) in channel_post_auth_listener()
2038 channel_post_connecting(struct ssh *ssh, Channel *c) in channel_post_connecting() argument
2061 channel_set_used_time(ssh, c); in channel_post_connecting()
2065 if ((r = sshpkt_start(ssh, in channel_post_connecting()
2067 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in channel_post_connecting()
2068 (r = sshpkt_put_u32(ssh, c->self)) != 0 || in channel_post_connecting()
2069 (r = sshpkt_put_u32(ssh, c->local_window)) != 0 || in channel_post_connecting()
2070 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0 || in channel_post_connecting()
2071 (r = sshpkt_send(ssh)) != 0) in channel_post_connecting()
2089 rdynamic_close(ssh, c); in channel_post_connecting()
2091 if ((r = sshpkt_start(ssh, in channel_post_connecting()
2093 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in channel_post_connecting()
2094 (r = sshpkt_put_u32(ssh, in channel_post_connecting()
2096 (r = sshpkt_put_cstring(ssh, strerror(err))) != 0 || in channel_post_connecting()
2097 (r = sshpkt_put_cstring(ssh, "")) != 0 || in channel_post_connecting()
2098 (r = sshpkt_send(ssh)) != 0) in channel_post_connecting()
2100 chan_mark_dead(ssh, c); in channel_post_connecting()
2110 channel_handle_rfd(struct ssh *ssh, Channel *c) in channel_handle_rfd() argument
2153 channel_set_used_time(ssh, c); in channel_handle_rfd()
2172 chan_mark_dead(ssh, c); in channel_handle_rfd()
2175 chan_read_failed(ssh, c); in channel_handle_rfd()
2179 channel_set_used_time(ssh, c); in channel_handle_rfd()
2181 if (c->input_filter(ssh, c, buf, len) == -1) { in channel_handle_rfd()
2183 chan_read_failed(ssh, c); in channel_handle_rfd()
2195 channel_handle_wfd(struct ssh *ssh, Channel *c) in channel_handle_wfd() argument
2210 if ((buf = c->output_filter(ssh, c, &data, &dlen)) == NULL) { in channel_handle_wfd()
2213 chan_mark_dead(ssh, c); in channel_handle_wfd()
2215 chan_write_failed(ssh, c); in channel_handle_wfd()
2253 chan_mark_dead(ssh, c); in channel_handle_wfd()
2256 chan_write_failed(ssh, c); in channel_handle_wfd()
2260 channel_set_used_time(ssh, c); in channel_handle_wfd()
2271 if ((r = sshpkt_msg_ignore(ssh, 4+len)) != 0 || in channel_handle_wfd()
2272 (r = sshpkt_send(ssh)) != 0) in channel_handle_wfd()
2286 channel_handle_efd_write(struct ssh *ssh, Channel *c) in channel_handle_efd_write() argument
2304 channel_close_fd(ssh, c, &c->efd); in channel_handle_efd_write()
2309 channel_set_used_time(ssh, c); in channel_handle_efd_write()
2315 channel_handle_efd_read(struct ssh *ssh, Channel *c) in channel_handle_efd_read() argument
2333 channel_close_fd(ssh, c, &c->efd); in channel_handle_efd_read()
2336 channel_set_used_time(ssh, c); in channel_handle_efd_read()
2345 channel_handle_efd(struct ssh *ssh, Channel *c) in channel_handle_efd() argument
2353 return channel_handle_efd_write(ssh, c); in channel_handle_efd()
2356 return channel_handle_efd_read(ssh, c); in channel_handle_efd()
2362 channel_check_window(struct ssh *ssh, Channel *c) in channel_check_window() argument
2374 if ((r = sshpkt_start(ssh, in channel_check_window()
2376 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in channel_check_window()
2377 (r = sshpkt_put_u32(ssh, c->local_consumed)) != 0 || in channel_check_window()
2378 (r = sshpkt_send(ssh)) != 0) { in channel_check_window()
2390 channel_post_open(struct ssh *ssh, Channel *c) in channel_post_open() argument
2392 channel_handle_rfd(ssh, c); in channel_post_open()
2393 channel_handle_wfd(ssh, c); in channel_post_open()
2394 channel_handle_efd(ssh, c); in channel_post_open()
2395 channel_check_window(ssh, c); in channel_post_open()
2399 read_mux(struct ssh *ssh, Channel *c, u_int need) in read_mux() argument
2414 chan_read_failed(ssh, c); in read_mux()
2423 channel_post_mux_client_read(struct ssh *ssh, Channel *c) in channel_post_mux_client_read() argument
2438 if (read_mux(ssh, c, 4) < 4) /* read header */ in channel_post_mux_client_read()
2446 chan_rcvd_oclose(ssh, c); in channel_post_mux_client_read()
2449 if (read_mux(ssh, c, need + 4) < need + 4) /* read body */ in channel_post_mux_client_read()
2451 if (c->mux_rcb(ssh, c) != 0) { in channel_post_mux_client_read()
2453 chan_mark_dead(ssh, c); in channel_post_mux_client_read()
2459 channel_post_mux_client_write(struct ssh *ssh, Channel *c) in channel_post_mux_client_write() argument
2473 chan_mark_dead(ssh, c); in channel_post_mux_client_write()
2481 channel_post_mux_client(struct ssh *ssh, Channel *c) in channel_post_mux_client() argument
2483 channel_post_mux_client_read(ssh, c); in channel_post_mux_client()
2484 channel_post_mux_client_write(ssh, c); in channel_post_mux_client()
2488 channel_post_mux_listener(struct ssh *ssh, Channel *c) in channel_post_mux_listener() argument
2526 nc = channel_new(ssh, "mux-control", SSH_CHANNEL_MUX_CLIENT, in channel_post_mux_listener()
2532 nc->mux_rcb(ssh, nc); in channel_post_mux_listener()
2579 channel_garbage_collect(struct ssh *ssh, Channel *c) in channel_garbage_collect() argument
2584 if (!chan_is_dead(ssh, c, c->detach_close)) in channel_garbage_collect()
2588 c->detach_user(ssh, c->self, 0, NULL); in channel_garbage_collect()
2594 if (!chan_is_dead(ssh, c, 1)) in channel_garbage_collect()
2597 channel_free(ssh, c); in channel_garbage_collect()
2603 channel_handler(struct ssh *ssh, int table, struct timespec *timeout) in channel_handler() argument
2605 struct ssh_channels *sc = ssh->chanctxt; in channel_handler()
2617 if (ssh_packet_is_rekeying(ssh) && c->type != SSH_CHANNEL_OPEN) in channel_handler()
2627 channel_get_expiry(ssh, c) != 0 && in channel_handler()
2628 now >= channel_get_expiry(ssh, c)) { in channel_handler()
2633 channel_force_close(ssh, c, 1); in channel_handler()
2636 (*ftab[c->type])(ssh, c); in channel_handler()
2640 channel_get_expiry(ssh, c) != 0) { in channel_handler()
2642 channel_get_expiry(ssh, c)); in channel_handler()
2653 channel_garbage_collect(ssh, c); in channel_handler()
2664 channel_before_prepare_io(struct ssh *ssh) in channel_before_prepare_io() argument
2666 struct ssh_channels *sc = ssh->chanctxt; in channel_before_prepare_io()
2675 channel_before_prepare_io_rdynamic(ssh, c); in channel_before_prepare_io()
2799 channel_prepare_poll(struct ssh *ssh, struct pollfd **pfdp, u_int *npfd_allocp, in channel_prepare_poll() argument
2802 struct ssh_channels *sc = ssh->chanctxt; in channel_prepare_poll()
2805 channel_before_prepare_io(ssh); /* might create a new channel */ in channel_prepare_poll()
2824 channel_handler(ssh, CHAN_PRE, timeout); in channel_prepare_poll()
2868 channel_after_poll(struct ssh *ssh, struct pollfd *pfd, u_int npfd) in channel_after_poll() argument
2870 struct ssh_channels *sc = ssh->chanctxt; in channel_after_poll()
2945 channel_handler(ssh, CHAN_POST, NULL); in channel_after_poll()
2953 channel_output_poll_input_open(struct ssh *ssh, Channel *c) in channel_output_poll_input_open() argument
2973 chan_ibuf_empty(ssh, c); in channel_output_poll_input_open()
2995 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_DATA)) != 0 || in channel_output_poll_input_open()
2996 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in channel_output_poll_input_open()
2997 (r = sshpkt_put_string(ssh, pkt, plen)) != 0 || in channel_output_poll_input_open()
2998 (r = sshpkt_send(ssh)) != 0) in channel_output_poll_input_open()
3011 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_DATA)) != 0 || in channel_output_poll_input_open()
3012 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in channel_output_poll_input_open()
3013 (r = sshpkt_put_string(ssh, sshbuf_ptr(c->input), len)) != 0 || in channel_output_poll_input_open()
3014 (r = sshpkt_send(ssh)) != 0) in channel_output_poll_input_open()
3027 channel_output_poll_extended_read(struct ssh *ssh, Channel *c) in channel_output_poll_extended_read() argument
3045 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_EXTENDED_DATA)) != 0 || in channel_output_poll_extended_read()
3046 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in channel_output_poll_extended_read()
3047 (r = sshpkt_put_u32(ssh, SSH2_EXTENDED_DATA_STDERR)) != 0 || in channel_output_poll_extended_read()
3048 (r = sshpkt_put_string(ssh, sshbuf_ptr(c->extended), len)) != 0 || in channel_output_poll_extended_read()
3049 (r = sshpkt_send(ssh)) != 0) in channel_output_poll_extended_read()
3063 channel_output_poll(struct ssh *ssh) in channel_output_poll() argument
3065 struct ssh_channels *sc = ssh->chanctxt; in channel_output_poll()
3091 ret |= channel_output_poll_input_open(ssh, c); in channel_output_poll()
3095 ret |= channel_output_poll_extended_read(ssh, c); in channel_output_poll()
3105 * from the ssh server:
3141 channel_proxy_downstream(struct ssh *ssh, Channel *downstream) in channel_proxy_downstream() argument
3182 c = channel_new(ssh, "mux-proxy", SSH_CHANNEL_MUX_PROXY, in channel_proxy_downstream()
3190 channel_free(ssh, c); in channel_proxy_downstream()
3209 c = channel_new(ssh, "mux-proxy", SSH_CHANNEL_MUX_PROXY, in channel_proxy_downstream()
3219 channel_free(ssh, c); in channel_proxy_downstream()
3248 permission_set_add(ssh, FORWARD_USER, FORWARD_LOCAL, "<mux>", in channel_proxy_downstream()
3255 if ((c = channel_by_remote_id(ssh, remote_id)) != NULL) { in channel_proxy_downstream()
3257 channel_free(ssh, c); in channel_proxy_downstream()
3264 if ((r = sshpkt_start(ssh, type)) != 0 || in channel_proxy_downstream()
3265 (r = sshpkt_putb(ssh, modified)) != 0 || in channel_proxy_downstream()
3266 (r = sshpkt_send(ssh)) != 0) { in channel_proxy_downstream()
3271 if ((r = sshpkt_start(ssh, type)) != 0 || in channel_proxy_downstream()
3272 (r = sshpkt_put(ssh, cp, have)) != 0 || in channel_proxy_downstream()
3273 (r = sshpkt_send(ssh)) != 0) { in channel_proxy_downstream()
3294 channel_proxy_upstream(Channel *c, int type, u_int32_t seq, struct ssh *ssh) in channel_proxy_upstream() argument
3333 cp = sshpkt_ptr(ssh, &len); in channel_proxy_upstream()
3362 channel_free(ssh, c); in channel_proxy_upstream()
3375 channel_parse_id(struct ssh *ssh, const char *where, const char *what) in channel_parse_id() argument
3380 if ((r = sshpkt_get_u32(ssh, &id)) != 0) { in channel_parse_id()
3382 ssh_packet_disconnect(ssh, "Invalid %s message", what); in channel_parse_id()
3386 ssh_packet_disconnect(ssh, "Invalid %s channel id", what); in channel_parse_id()
3393 channel_from_packet_id(struct ssh *ssh, const char *where, const char *what) in channel_from_packet_id() argument
3395 int id = channel_parse_id(ssh, where, what); in channel_from_packet_id()
3398 if ((c = channel_lookup(ssh, id)) == NULL) { in channel_from_packet_id()
3399 ssh_packet_disconnect(ssh, in channel_from_packet_id()
3406 channel_input_data(int type, u_int32_t seq, struct ssh *ssh) in channel_input_data() argument
3410 Channel *c = channel_from_packet_id(ssh, __func__, "data"); in channel_input_data()
3413 if (channel_proxy_upstream(c, type, seq, ssh)) in channel_input_data()
3424 if ((r = sshpkt_get_string_direct(ssh, &data, &data_len)) != 0 || in channel_input_data()
3425 (r = sshpkt_get_end(ssh)) != 0) in channel_input_data()
3456 ssh_packet_disconnect(ssh, "channel %d: peer ignored " in channel_input_data()
3474 channel_input_extended_data(int type, u_int32_t seq, struct ssh *ssh) in channel_input_extended_data() argument
3479 Channel *c = channel_from_packet_id(ssh, __func__, "extended data"); in channel_input_extended_data()
3482 if (channel_proxy_upstream(c, type, seq, ssh)) in channel_input_extended_data()
3489 if (ssh->compat & SSH_BUG_EXTEOF) in channel_input_extended_data()
3493 ssh_packet_disconnect(ssh, "Received extended_data " in channel_input_extended_data()
3497 if ((r = sshpkt_get_u32(ssh, &tcode)) != 0) { in channel_input_extended_data()
3499 ssh_packet_disconnect(ssh, "Invalid extended_data message"); in channel_input_extended_data()
3507 if ((r = sshpkt_get_string_direct(ssh, &data, &data_len)) != 0 || in channel_input_extended_data()
3508 (r = sshpkt_get_end(ssh)) != 0) { in channel_input_extended_data()
3510 ssh_packet_disconnect(ssh, "Invalid extended_data message"); in channel_input_extended_data()
3527 channel_input_ieof(int type, u_int32_t seq, struct ssh *ssh) in channel_input_ieof() argument
3529 Channel *c = channel_from_packet_id(ssh, __func__, "ieof"); in channel_input_ieof()
3532 if ((r = sshpkt_get_end(ssh)) != 0) { in channel_input_ieof()
3534 ssh_packet_disconnect(ssh, "Invalid ieof message"); in channel_input_ieof()
3537 if (channel_proxy_upstream(c, type, seq, ssh)) in channel_input_ieof()
3539 chan_rcvd_ieof(ssh, c); in channel_input_ieof()
3546 chan_ibuf_empty(ssh, c); in channel_input_ieof()
3552 channel_input_oclose(int type, u_int32_t seq, struct ssh *ssh) in channel_input_oclose() argument
3554 Channel *c = channel_from_packet_id(ssh, __func__, "oclose"); in channel_input_oclose()
3557 if (channel_proxy_upstream(c, type, seq, ssh)) in channel_input_oclose()
3559 if ((r = sshpkt_get_end(ssh)) != 0) { in channel_input_oclose()
3561 ssh_packet_disconnect(ssh, "Invalid oclose message"); in channel_input_oclose()
3563 chan_rcvd_oclose(ssh, c); in channel_input_oclose()
3568 channel_input_open_confirmation(int type, u_int32_t seq, struct ssh *ssh) in channel_input_open_confirmation() argument
3570 Channel *c = channel_from_packet_id(ssh, __func__, "open confirmation"); in channel_input_open_confirmation()
3574 if (channel_proxy_upstream(c, type, seq, ssh)) in channel_input_open_confirmation()
3577 ssh_packet_disconnect(ssh, "Received open confirmation for " in channel_input_open_confirmation()
3583 if ((r = sshpkt_get_u32(ssh, &c->remote_id)) != 0 || in channel_input_open_confirmation()
3584 (r = sshpkt_get_u32(ssh, &remote_window)) != 0 || in channel_input_open_confirmation()
3585 (r = sshpkt_get_u32(ssh, &remote_maxpacket)) != 0 || in channel_input_open_confirmation()
3586 (r = sshpkt_get_end(ssh)) != 0) { in channel_input_open_confirmation()
3588 ssh_packet_disconnect(ssh, "Invalid open confirmation message"); in channel_input_open_confirmation()
3597 c->open_confirm(ssh, c->self, 1, c->open_confirm_ctx); in channel_input_open_confirmation()
3600 channel_set_used_time(ssh, c); in channel_input_open_confirmation()
3623 channel_input_open_failure(int type, u_int32_t seq, struct ssh *ssh) in channel_input_open_failure() argument
3625 Channel *c = channel_from_packet_id(ssh, __func__, "open failure"); in channel_input_open_failure()
3630 if (channel_proxy_upstream(c, type, seq, ssh)) in channel_input_open_failure()
3633 ssh_packet_disconnect(ssh, "Received open failure for " in channel_input_open_failure()
3635 if ((r = sshpkt_get_u32(ssh, &reason)) != 0) { in channel_input_open_failure()
3637 ssh_packet_disconnect(ssh, "Invalid open failure message"); in channel_input_open_failure()
3640 if ((r = sshpkt_get_cstring(ssh, &msg, NULL)) != 0 || in channel_input_open_failure()
3641 (r = sshpkt_get_string_direct(ssh, NULL, NULL)) != 0 || in channel_input_open_failure()
3642 (r = sshpkt_get_end(ssh)) != 0) { in channel_input_open_failure()
3644 ssh_packet_disconnect(ssh, "Invalid open failure message"); in channel_input_open_failure()
3651 c->open_confirm(ssh, c->self, 0, c->open_confirm_ctx); in channel_input_open_failure()
3655 chan_mark_dead(ssh, c); in channel_input_open_failure()
3660 channel_input_window_adjust(int type, u_int32_t seq, struct ssh *ssh) in channel_input_window_adjust() argument
3662 int id = channel_parse_id(ssh, __func__, "window adjust"); in channel_input_window_adjust()
3668 if ((c = channel_lookup(ssh, id)) == NULL) { in channel_input_window_adjust()
3673 if (channel_proxy_upstream(c, type, seq, ssh)) in channel_input_window_adjust()
3675 if ((r = sshpkt_get_u32(ssh, &adjust)) != 0 || in channel_input_window_adjust()
3676 (r = sshpkt_get_end(ssh)) != 0) { in channel_input_window_adjust()
3678 ssh_packet_disconnect(ssh, "Invalid window adjust message"); in channel_input_window_adjust()
3690 channel_input_status_confirm(int type, u_int32_t seq, struct ssh *ssh) in channel_input_status_confirm() argument
3692 int id = channel_parse_id(ssh, __func__, "status confirm"); in channel_input_status_confirm()
3697 ssh_packet_set_alive_timeouts(ssh, 0); in channel_input_status_confirm()
3701 if ((c = channel_lookup(ssh, id)) == NULL) { in channel_input_status_confirm()
3705 if (channel_proxy_upstream(c, type, seq, ssh)) in channel_input_status_confirm()
3707 if (sshpkt_get_end(ssh) != 0) in channel_input_status_confirm()
3708 ssh_packet_disconnect(ssh, "Invalid status confirm message"); in channel_input_status_confirm()
3711 cc->cb(ssh, type, c, cc->ctx); in channel_input_status_confirm()
3720 channel_set_af(struct ssh *ssh, int af) in channel_set_af() argument
3722 ssh->chanctxt->IPv4or6 = af; in channel_set_af()
3742 channel_fwd_bind_addr(struct ssh *ssh, const char *listen_addr, int *wildcardp, in channel_fwd_bind_addr() argument
3753 if (((ssh->compat & SSH_OLD_FORWARD_ADDR) && in channel_fwd_bind_addr()
3765 ssh_packet_send_debug(ssh, in channel_fwd_bind_addr()
3796 channel_setup_fwd_listener_tcpip(struct ssh *ssh, int type, in channel_setup_fwd_listener_tcpip() argument
3825 addr = channel_fwd_bind_addr(ssh, fwd->listen_host, &wildcard, in channel_setup_fwd_listener_tcpip()
3835 hints.ai_family = ssh->chanctxt->IPv4or6; in channel_setup_fwd_listener_tcpip()
3842 ssh_packet_disconnect(ssh, "getaddrinfo: fatal error: %s", in channel_setup_fwd_listener_tcpip()
3934 c = channel_new(ssh, "port-listener", type, sock, sock, -1, in channel_setup_fwd_listener_tcpip()
3941 !(ssh->compat & SSH_BUG_DYNAMIC_RPORT)) in channel_setup_fwd_listener_tcpip()
3954 channel_setup_fwd_listener_streamlocal(struct ssh *ssh, int type, in channel_setup_fwd_listener_streamlocal() argument
4017 c = channel_new(ssh, "unix-listener", type, sock, sock, -1, in channel_setup_fwd_listener_streamlocal()
4028 channel_cancel_rport_listener_tcpip(struct ssh *ssh, in channel_cancel_rport_listener_tcpip() argument
4034 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_cancel_rport_listener_tcpip()
4035 Channel *c = ssh->chanctxt->channels[i]; in channel_cancel_rport_listener_tcpip()
4040 channel_free(ssh, c); in channel_cancel_rport_listener_tcpip()
4049 channel_cancel_rport_listener_streamlocal(struct ssh *ssh, const char *path) in channel_cancel_rport_listener_streamlocal() argument
4054 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_cancel_rport_listener_streamlocal()
4055 Channel *c = ssh->chanctxt->channels[i]; in channel_cancel_rport_listener_streamlocal()
4062 channel_free(ssh, c); in channel_cancel_rport_listener_streamlocal()
4071 channel_cancel_rport_listener(struct ssh *ssh, struct Forward *fwd) in channel_cancel_rport_listener() argument
4074 return channel_cancel_rport_listener_streamlocal(ssh, in channel_cancel_rport_listener()
4077 return channel_cancel_rport_listener_tcpip(ssh, in channel_cancel_rport_listener()
4083 channel_cancel_lport_listener_tcpip(struct ssh *ssh, in channel_cancel_lport_listener_tcpip() argument
4089 const char *addr = channel_fwd_bind_addr(ssh, lhost, NULL, 1, fwd_opts); in channel_cancel_lport_listener_tcpip()
4091 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_cancel_lport_listener_tcpip()
4092 Channel *c = ssh->chanctxt->channels[i]; in channel_cancel_lport_listener_tcpip()
4110 channel_free(ssh, c); in channel_cancel_lport_listener_tcpip()
4119 channel_cancel_lport_listener_streamlocal(struct ssh *ssh, const char *path) in channel_cancel_lport_listener_streamlocal() argument
4129 for (i = 0; i < ssh->chanctxt->channels_alloc; i++) { in channel_cancel_lport_listener_streamlocal()
4130 Channel *c = ssh->chanctxt->channels[i]; in channel_cancel_lport_listener_streamlocal()
4137 channel_free(ssh, c); in channel_cancel_lport_listener_streamlocal()
4146 channel_cancel_lport_listener(struct ssh *ssh, in channel_cancel_lport_listener() argument
4150 return channel_cancel_lport_listener_streamlocal(ssh, in channel_cancel_lport_listener()
4153 return channel_cancel_lport_listener_tcpip(ssh, in channel_cancel_lport_listener()
4158 /* protocol local port fwd, used by ssh */
4160 channel_setup_local_fwd_listener(struct ssh *ssh, in channel_setup_local_fwd_listener() argument
4164 return channel_setup_fwd_listener_streamlocal(ssh, in channel_setup_local_fwd_listener()
4167 return channel_setup_fwd_listener_tcpip(ssh, in channel_setup_local_fwd_listener()
4201 check_rfwd_permission(struct ssh *ssh, struct Forward *fwd) in check_rfwd_permission() argument
4203 struct ssh_channels *sc = ssh->chanctxt; in check_rfwd_permission()
4237 channel_setup_remote_fwd_listener(struct ssh *ssh, struct Forward *fwd, in channel_setup_remote_fwd_listener() argument
4240 if (!check_rfwd_permission(ssh, fwd)) { in channel_setup_remote_fwd_listener()
4241 ssh_packet_send_debug(ssh, "port forwarding refused"); in channel_setup_remote_fwd_listener()
4247 ssh_remote_ipaddr(ssh), ssh_remote_port(ssh), in channel_setup_remote_fwd_listener()
4253 ssh_remote_ipaddr(ssh), ssh_remote_port(ssh), in channel_setup_remote_fwd_listener()
4258 ssh_remote_ipaddr(ssh), ssh_remote_port(ssh)); in channel_setup_remote_fwd_listener()
4262 return channel_setup_fwd_listener_streamlocal(ssh, in channel_setup_remote_fwd_listener()
4265 return channel_setup_fwd_listener_tcpip(ssh, in channel_setup_remote_fwd_listener()
4293 channel_request_remote_forwarding(struct ssh *ssh, struct Forward *fwd) in channel_request_remote_forwarding() argument
4301 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in channel_request_remote_forwarding()
4302 (r = sshpkt_put_cstring(ssh, in channel_request_remote_forwarding()
4304 (r = sshpkt_put_u8(ssh, 1)) != 0 || /* want reply */ in channel_request_remote_forwarding()
4305 (r = sshpkt_put_cstring(ssh, fwd->listen_path)) != 0 || in channel_request_remote_forwarding()
4306 (r = sshpkt_send(ssh)) != 0 || in channel_request_remote_forwarding()
4307 (r = ssh_packet_write_wait(ssh)) != 0) in channel_request_remote_forwarding()
4310 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in channel_request_remote_forwarding()
4311 (r = sshpkt_put_cstring(ssh, "tcpip-forward")) != 0 || in channel_request_remote_forwarding()
4312 (r = sshpkt_put_u8(ssh, 1)) != 0 || /* want reply */ in channel_request_remote_forwarding()
4313 (r = sshpkt_put_cstring(ssh, in channel_request_remote_forwarding()
4315 (r = sshpkt_put_u32(ssh, fwd->listen_port)) != 0 || in channel_request_remote_forwarding()
4316 (r = sshpkt_send(ssh)) != 0 || in channel_request_remote_forwarding()
4317 (r = ssh_packet_write_wait(ssh)) != 0) in channel_request_remote_forwarding()
4340 idx = permission_set_add(ssh, FORWARD_USER, FORWARD_LOCAL, in channel_request_remote_forwarding()
4409 channel_request_rforward_cancel_tcpip(struct ssh *ssh, in channel_request_rforward_cancel_tcpip() argument
4412 struct ssh_channels *sc = ssh->chanctxt; in channel_request_rforward_cancel_tcpip()
4428 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in channel_request_rforward_cancel_tcpip()
4429 (r = sshpkt_put_cstring(ssh, "cancel-tcpip-forward")) != 0 || in channel_request_rforward_cancel_tcpip()
4430 (r = sshpkt_put_u8(ssh, 0)) != 0 || /* want reply */ in channel_request_rforward_cancel_tcpip()
4431 (r = sshpkt_put_cstring(ssh, channel_rfwd_bind_host(host))) != 0 || in channel_request_rforward_cancel_tcpip()
4432 (r = sshpkt_put_u32(ssh, port)) != 0 || in channel_request_rforward_cancel_tcpip()
4433 (r = sshpkt_send(ssh)) != 0) in channel_request_rforward_cancel_tcpip()
4446 channel_request_rforward_cancel_streamlocal(struct ssh *ssh, const char *path) in channel_request_rforward_cancel_streamlocal() argument
4448 struct ssh_channels *sc = ssh->chanctxt; in channel_request_rforward_cancel_streamlocal()
4464 if ((r = sshpkt_start(ssh, SSH2_MSG_GLOBAL_REQUEST)) != 0 || in channel_request_rforward_cancel_streamlocal()
4465 (r = sshpkt_put_cstring(ssh, in channel_request_rforward_cancel_streamlocal()
4467 (r = sshpkt_put_u8(ssh, 0)) != 0 || /* want reply */ in channel_request_rforward_cancel_streamlocal()
4468 (r = sshpkt_put_cstring(ssh, path)) != 0 || in channel_request_rforward_cancel_streamlocal()
4469 (r = sshpkt_send(ssh)) != 0) in channel_request_rforward_cancel_streamlocal()
4481 channel_request_rforward_cancel(struct ssh *ssh, struct Forward *fwd) in channel_request_rforward_cancel() argument
4484 return channel_request_rforward_cancel_streamlocal(ssh, in channel_request_rforward_cancel()
4487 return channel_request_rforward_cancel_tcpip(ssh, in channel_request_rforward_cancel()
4499 channel_permit_all(struct ssh *ssh, int where) in channel_permit_all() argument
4501 struct permission_set *pset = permission_set_get(ssh, where); in channel_permit_all()
4511 channel_add_permission(struct ssh *ssh, int who, int where, in channel_add_permission() argument
4515 struct permission_set *pset = permission_set_get(ssh, where); in channel_add_permission()
4523 permission_set_add(ssh, who, where, in channel_add_permission()
4533 channel_disable_admin(struct ssh *ssh, int where) in channel_disable_admin() argument
4535 channel_clear_permission(ssh, FORWARD_ADM, where); in channel_disable_admin()
4536 permission_set_add(ssh, FORWARD_ADM, where, in channel_disable_admin()
4544 channel_clear_permission(struct ssh *ssh, int who, int where) in channel_clear_permission() argument
4549 permission_set_get_array(ssh, who, where, &permp, &npermp); in channel_clear_permission()
4560 channel_update_permission(struct ssh *ssh, int idx, int newport) in channel_update_permission() argument
4562 struct permission_set *pset = &ssh->chanctxt->local_perms; in channel_update_permission()
4578 (ssh->compat & SSH_BUG_DYNAMIC_RPORT) ? 0 : newport; in channel_update_permission()
4673 connect_to_helper(struct ssh *ssh, const char *name, int port, int socktype, in connect_to_helper() argument
4709 hints.ai_family = ssh->chanctxt->IPv4or6; in connect_to_helper()
4739 connect_to(struct ssh *ssh, const char *host, int port, in connect_to() argument
4747 sock = connect_to_helper(ssh, host, port, SOCK_STREAM, ctype, rname, in connect_to()
4753 c = channel_new(ssh, ctype, SSH_CHANNEL_CONNECTING, sock, sock, -1, in connect_to()
4767 channel_connect_by_listen_address(struct ssh *ssh, const char *listen_host, in channel_connect_by_listen_address() argument
4770 struct ssh_channels *sc = ssh->chanctxt; in channel_connect_by_listen_address()
4782 return rdynamic_connect_prepare(ssh, in channel_connect_by_listen_address()
4784 return connect_to(ssh, in channel_connect_by_listen_address()
4795 channel_connect_by_listen_path(struct ssh *ssh, const char *path, in channel_connect_by_listen_path() argument
4798 struct ssh_channels *sc = ssh->chanctxt; in channel_connect_by_listen_path()
4806 return connect_to(ssh, in channel_connect_by_listen_path()
4818 channel_connect_to_port(struct ssh *ssh, const char *host, u_short port, in channel_connect_to_port() argument
4821 struct ssh_channels *sc = ssh->chanctxt; in channel_connect_to_port()
4854 ssh_remote_ipaddr(ssh), ssh_remote_port(ssh), host, port); in channel_connect_to_port()
4861 sock = connect_to_helper(ssh, host, port, SOCK_STREAM, ctype, rname, in channel_connect_to_port()
4868 c = channel_new(ssh, ctype, SSH_CHANNEL_CONNECTING, sock, sock, -1, in channel_connect_to_port()
4879 channel_connect_to_path(struct ssh *ssh, const char *path, in channel_connect_to_path() argument
4882 struct ssh_channels *sc = ssh->chanctxt; in channel_connect_to_path()
4914 return connect_to(ssh, path, PORT_STREAMLOCAL, ctype, rname); in channel_connect_to_path()
4918 channel_send_window_changes(struct ssh *ssh) in channel_send_window_changes() argument
4920 struct ssh_channels *sc = ssh->chanctxt; in channel_send_window_changes()
4931 channel_request_start(ssh, i, "window-change", 0); in channel_send_window_changes()
4932 if ((r = sshpkt_put_u32(ssh, (u_int)ws.ws_col)) != 0 || in channel_send_window_changes()
4933 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_row)) != 0 || in channel_send_window_changes()
4934 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_xpixel)) != 0 || in channel_send_window_changes()
4935 (r = sshpkt_put_u32(ssh, (u_int)ws.ws_ypixel)) != 0 || in channel_send_window_changes()
4936 (r = sshpkt_send(ssh)) != 0) in channel_send_window_changes()
4943 rdynamic_connect_prepare(struct ssh *ssh, char *ctype, char *rname) in rdynamic_connect_prepare() argument
4948 c = channel_new(ssh, ctype, SSH_CHANNEL_RDYNAMIC_OPEN, -1, -1, -1, in rdynamic_connect_prepare()
4957 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION)) != 0 || in rdynamic_connect_prepare()
4958 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || in rdynamic_connect_prepare()
4959 (r = sshpkt_put_u32(ssh, c->self)) != 0 || in rdynamic_connect_prepare()
4960 (r = sshpkt_put_u32(ssh, c->local_window)) != 0 || in rdynamic_connect_prepare()
4961 (r = sshpkt_put_u32(ssh, c->local_maxpacket)) != 0) in rdynamic_connect_prepare()
4968 rdynamic_connect_finish(struct ssh *ssh, Channel *c) in rdynamic_connect_finish() argument
4970 struct ssh_channels *sc = ssh->chanctxt; in rdynamic_connect_finish()
4993 sock = connect_to_helper(ssh, c->path, c->host_port, SOCK_STREAM, NULL, in rdynamic_connect_finish()
5001 channel_register_fds(ssh, c, sock, sock, -1, 0, 1, 0); in rdynamic_connect_finish()
5014 x11_create_display_inet(struct ssh *ssh, int x11_display_offset, in x11_create_display_inet() argument
5033 hints.ai_family = ssh->chanctxt->IPv4or6; in x11_create_display_inet()
5102 nc = channel_new(ssh, "x11-listener", in x11_create_display_inet()
5173 x11_connect_display(struct ssh *ssh) in x11_connect_display() argument
5255 hints.ai_family = ssh->chanctxt->IPv4or6; in x11_connect_display()
5296 x11_request_forwarding_with_spoofing(struct ssh *ssh, int client_session_id, in x11_request_forwarding_with_spoofing() argument
5299 struct ssh_channels *sc = ssh->chanctxt; in x11_request_forwarding_with_spoofing()
5347 channel_request_start(ssh, client_session_id, "x11-req", want_reply); in x11_request_forwarding_with_spoofing()
5348 if ((r = sshpkt_put_u8(ssh, 0)) != 0 || /* bool: single connection */ in x11_request_forwarding_with_spoofing()
5349 (r = sshpkt_put_cstring(ssh, proto)) != 0 || in x11_request_forwarding_with_spoofing()
5350 (r = sshpkt_put_cstring(ssh, new_data)) != 0 || in x11_request_forwarding_with_spoofing()
5351 (r = sshpkt_put_u32(ssh, screen_number)) != 0 || in x11_request_forwarding_with_spoofing()
5352 (r = sshpkt_send(ssh)) != 0 || in x11_request_forwarding_with_spoofing()
5353 (r = ssh_packet_write_wait(ssh)) != 0) in x11_request_forwarding_with_spoofing()