Main Page | Namespace List | Class List | Directories | File List | Class Members | File Members

channels.h File Reference

#include "buffer.h"

Go to the source code of this file.

Classes

struct  Channel

Defines

#define SSH_CHANNEL_X11_LISTENER   1
#define SSH_CHANNEL_PORT_LISTENER   2
#define SSH_CHANNEL_OPENING   3
#define SSH_CHANNEL_OPEN   4
#define SSH_CHANNEL_CLOSED   5
#define SSH_CHANNEL_AUTH_SOCKET   6
#define SSH_CHANNEL_X11_OPEN   7
#define SSH_CHANNEL_INPUT_DRAINING   8
#define SSH_CHANNEL_OUTPUT_DRAINING   9
#define SSH_CHANNEL_LARVAL   10
#define SSH_CHANNEL_RPORT_LISTENER   11
#define SSH_CHANNEL_CONNECTING   12
#define SSH_CHANNEL_DYNAMIC   13
#define SSH_CHANNEL_ZOMBIE   14
#define SSH_CHANNEL_MAX_TYPE   15
#define SSH_CHANNEL_PATH_LEN   256
#define CHAN_EXTENDED_IGNORE   0
#define CHAN_EXTENDED_READ   1
#define CHAN_EXTENDED_WRITE   2
#define CHAN_SES_PACKET_DEFAULT   (32*1024)
#define CHAN_SES_WINDOW_DEFAULT   (4*CHAN_SES_PACKET_DEFAULT)
#define CHAN_TCP_PACKET_DEFAULT   (32*1024)
#define CHAN_TCP_WINDOW_DEFAULT   (4*CHAN_TCP_PACKET_DEFAULT)
#define CHAN_X11_PACKET_DEFAULT   (16*1024)
#define CHAN_X11_WINDOW_DEFAULT   (4*CHAN_X11_PACKET_DEFAULT)
#define CHAN_INPUT_OPEN   0
#define CHAN_INPUT_WAIT_DRAIN   1
#define CHAN_INPUT_WAIT_OCLOSE   2
#define CHAN_INPUT_CLOSED   3
#define CHAN_OUTPUT_OPEN   0
#define CHAN_OUTPUT_WAIT_DRAIN   1
#define CHAN_OUTPUT_WAIT_IEOF   2
#define CHAN_OUTPUT_CLOSED   3
#define CHAN_CLOSE_SENT   0x01
#define CHAN_CLOSE_RCVD   0x02
#define CHAN_EOF_SENT   0x04
#define CHAN_EOF_RCVD   0x08
#define CHAN_RBUF   16*1024
#define CHANNEL_EFD_INPUT_ACTIVE(c)
#define CHANNEL_EFD_OUTPUT_ACTIVE(c)

Typedefs

typedef Channel Channel
typedef void channel_callback_fn (int, void *)
typedef int channel_infilter_fn (struct Channel *, char *, int)
typedef u_charchannel_outfilter_fn (struct Channel *, u_char **, u_int *)

Functions

Channelchannel_by_id (int)
Channelchannel_lookup (int)
Channelchannel_new (char *, int, int, int, int, u_int, u_int, int, char *, int)
void channel_set_fds (int, int, int, int, int, int, u_int)
void channel_free (Channel *)
void channel_free_all (void)
void channel_stop_listening (void)
void channel_send_open (int)
void channel_request_start (int, char *, int)
void channel_register_cleanup (int, channel_callback_fn *, int)
void channel_register_confirm (int, channel_callback_fn *, void *)
void channel_register_filter (int, channel_infilter_fn *, channel_outfilter_fn *)
void channel_cancel_cleanup (int)
int channel_close_fd (int *)
void channel_send_window_changes (void)
void channel_input_close (int, u_int32_t, void *)
void channel_input_close_confirmation (int, u_int32_t, void *)
void channel_input_data (int, u_int32_t, void *)
void channel_input_extended_data (int, u_int32_t, void *)
void channel_input_ieof (int, u_int32_t, void *)
void channel_input_oclose (int, u_int32_t, void *)
void channel_input_open_confirmation (int, u_int32_t, void *)
void channel_input_open_failure (int, u_int32_t, void *)
void channel_input_port_open (int, u_int32_t, void *)
void channel_input_window_adjust (int, u_int32_t, void *)
void channel_prepare_select (fd_set **, fd_set **, int *, u_int *, int)
void channel_after_select (fd_set *, fd_set *)
void channel_output_poll (void)
int channel_not_very_much_buffered_data (void)
void channel_close_all (void)
int channel_still_open (void)
charchannel_open_message (void)
int channel_find_open (void)
void channel_set_af (int af)
void channel_permit_all_opens (void)
void channel_add_permitted_opens (char *, int)
void channel_clear_permitted_opens (void)
void channel_input_port_forward_request (int, int)
int channel_connect_to (const char *, u_short)
int channel_connect_by_listen_address (u_short)
void channel_request_remote_forwarding (const char *, u_short, const char *, u_short)
int channel_setup_local_fwd_listener (const char *, u_short, const char *, u_short, int)
void channel_request_rforward_cancel (const char *host, u_short port)
int channel_setup_remote_fwd_listener (const char *, u_short, int)
int channel_cancel_rport_listener (const char *, u_short)
int x11_connect_display (void)
int x11_create_display_inet (int, int, int, u_int *, int **)
void x11_input_open (int, u_int32_t, void *)
void x11_request_forwarding_with_spoofing (int, const char *, const char *, const char *)
void deny_input_open (int, u_int32_t, void *)
void auth_request_forwarding (void)
int chan_is_dead (Channel *, int)
void chan_mark_dead (Channel *)
void chan_rcvd_oclose (Channel *)
void chan_read_failed (Channel *)
void chan_ibuf_empty (Channel *)
void chan_rcvd_ieof (Channel *)
void chan_write_failed (Channel *)
void chan_obuf_empty (Channel *)


Define Documentation

#define CHAN_CLOSE_RCVD   0x02
 

Definition at line 146 of file channels.h.

Referenced by chan_is_dead(), chan_rcvd_close2(), channel_check_window(), and channel_output_poll().

#define CHAN_CLOSE_SENT   0x01
 

Definition at line 145 of file channels.h.

Referenced by chan_ibuf_empty(), chan_is_dead(), chan_send_close2(), channel_check_window(), and channel_output_poll().

#define CHAN_EOF_RCVD   0x08
 

Definition at line 148 of file channels.h.

Referenced by chan_rcvd_eof2(), and channel_input_extended_data().

#define CHAN_EOF_SENT   0x04
 

Definition at line 147 of file channels.h.

Referenced by chan_send_eof2(), channel_output_poll(), and channel_pre_open().

#define CHAN_EXTENDED_IGNORE   0
 

Definition at line 121 of file channels.h.

Referenced by session_set_fds().

#define CHAN_EXTENDED_READ   1
 

Definition at line 122 of file channels.h.

Referenced by channel_handle_efd(), channel_output_poll(), channel_pre_open(), and session_set_fds().

#define CHAN_EXTENDED_WRITE   2
 

Definition at line 123 of file channels.h.

Referenced by chan_is_dead(), channel_handle_efd(), channel_input_extended_data(), channel_pre_open(), client_process_control(), and ssh_session2_open().

#define CHAN_INPUT_CLOSED   3
 

Definition at line 137 of file channels.h.

Referenced by chan_ibuf_empty(), chan_is_dead(), chan_rcvd_close2(), chan_rcvd_oclose1(), chan_send_close2(), and chan_set_istate().

#define CHAN_INPUT_OPEN   0
 

Definition at line 134 of file channels.h.

Referenced by chan_rcvd_close2(), chan_rcvd_oclose1(), chan_read_failed(), chan_send_ieof1(), channel_input_ieof(), channel_new(), channel_output_poll(), and channel_pre_open().

#define CHAN_INPUT_WAIT_DRAIN   1
 

Definition at line 135 of file channels.h.

Referenced by chan_ibuf_empty(), chan_rcvd_close2(), chan_rcvd_oclose1(), chan_read_failed(), chan_send_eof2(), chan_send_ieof1(), channel_input_ieof(), and channel_output_poll().

#define CHAN_INPUT_WAIT_OCLOSE   2
 

Definition at line 136 of file channels.h.

Referenced by chan_ibuf_empty(), and chan_rcvd_oclose1().

#define CHAN_OUTPUT_CLOSED   3
 

Definition at line 143 of file channels.h.

Referenced by chan_is_dead(), chan_obuf_empty(), chan_rcvd_close2(), chan_rcvd_ieof1(), chan_send_close2(), chan_set_ostate(), chan_write_failed1(), chan_write_failed2(), session_close_x11(), and session_exit_message().

#define CHAN_OUTPUT_OPEN   0
 

Definition at line 140 of file channels.h.

Referenced by chan_rcvd_close2(), chan_rcvd_eof2(), chan_rcvd_ieof1(), chan_send_oclose1(), chan_write_failed1(), chan_write_failed2(), channel_input_data(), channel_new(), and channel_pre_open().

#define CHAN_OUTPUT_WAIT_DRAIN   1
 

Definition at line 141 of file channels.h.

Referenced by chan_obuf_empty(), chan_rcvd_close2(), chan_rcvd_eof2(), chan_rcvd_ieof(), chan_rcvd_ieof1(), chan_send_oclose1(), chan_write_failed1(), chan_write_failed2(), and channel_pre_open().

#define CHAN_OUTPUT_WAIT_IEOF   2
 

Definition at line 142 of file channels.h.

Referenced by chan_rcvd_ieof1(), and chan_write_failed1().

#define CHAN_RBUF   16*1024
 

Definition at line 150 of file channels.h.

Referenced by channel_handle_efd(), channel_handle_rfd(), and channel_pre_open().

#define CHAN_SES_PACKET_DEFAULT   (32*1024)
 

Definition at line 126 of file channels.h.

Referenced by client_process_control(), server_request_session(), and ssh_session2_open().

#define CHAN_SES_WINDOW_DEFAULT   (4*CHAN_SES_PACKET_DEFAULT)
 

Definition at line 127 of file channels.h.

Referenced by client_process_control(), session_set_fds(), and ssh_session2_open().

#define CHAN_TCP_PACKET_DEFAULT   (32*1024)
 

Definition at line 128 of file channels.h.

Referenced by channel_setup_fwd_listener(), server_request_direct_tcpip(), server_request_tun(), and ssh_session2_setup().

#define CHAN_TCP_WINDOW_DEFAULT   (4*CHAN_TCP_PACKET_DEFAULT)
 

Definition at line 129 of file channels.h.

Referenced by channel_setup_fwd_listener(), client_request_agent(), client_request_forwarded_tcpip(), client_request_x11(), server_request_direct_tcpip(), server_request_tun(), and ssh_session2_setup().

#define CHAN_X11_PACKET_DEFAULT   (16*1024)
 

Definition at line 130 of file channels.h.

Referenced by auth_input_request_forwarding(), client_request_x11(), and x11_create_display_inet().

#define CHAN_X11_WINDOW_DEFAULT   (4*CHAN_X11_PACKET_DEFAULT)
 

Definition at line 131 of file channels.h.

Referenced by auth_input_request_forwarding(), client_request_agent(), and x11_create_display_inet().

#define CHANNEL_EFD_INPUT_ACTIVE  ) 
 

Value:

(compat20 && c->extended_usage == CHAN_EXTENDED_READ && \
        (c->efd != -1 || \
        buffer_len(&c->extended) > 0))

Definition at line 153 of file channels.h.

Referenced by channel_output_poll().

#define CHANNEL_EFD_OUTPUT_ACTIVE  ) 
 

Value:

(compat20 && c->extended_usage == CHAN_EXTENDED_WRITE && \
        c->efd != -1 && (!(c->flags & (CHAN_EOF_RCVD|CHAN_CLOSE_RCVD)) || \
        buffer_len(&c->extended) > 0))

Definition at line 157 of file channels.h.

Referenced by chan_rcvd_ieof(), and channel_pre_open().

#define SSH_CHANNEL_AUTH_SOCKET   6
 

Definition at line 49 of file channels.h.

Referenced by auth_input_request_forwarding(), channel_find_open(), channel_handler_init_13(), channel_handler_init_15(), channel_handler_init_20(), channel_open_message(), channel_still_open(), and channel_stop_listening().

#define SSH_CHANNEL_CLOSED   5
 

Definition at line 48 of file channels.h.

Referenced by channel_find_open(), channel_input_close(), channel_input_close_confirmation(), channel_open_message(), channel_pre_input_draining(), channel_pre_x11_open_13(), and channel_still_open().

#define SSH_CHANNEL_CONNECTING   12
 

Definition at line 55 of file channels.h.

Referenced by channel_find_open(), channel_handler_init_13(), channel_handler_init_15(), channel_handler_init_20(), channel_input_port_open(), channel_lookup(), channel_open_message(), channel_still_open(), client_input_channel_open(), client_request_forwarded_tcpip(), server_input_channel_open(), and server_request_direct_tcpip().

#define SSH_CHANNEL_DYNAMIC   13
 

Definition at line 56 of file channels.h.

Referenced by channel_find_open(), channel_handler_init_13(), channel_handler_init_15(), channel_handler_init_20(), channel_lookup(), channel_open_message(), channel_post_port_listener(), and channel_still_open().

#define SSH_CHANNEL_INPUT_DRAINING   8
 

Definition at line 51 of file channels.h.

Referenced by channel_find_open(), channel_handle_rfd(), channel_handle_wfd(), channel_handler_init_13(), channel_lookup(), channel_open_message(), channel_output_poll(), and channel_still_open().

#define SSH_CHANNEL_LARVAL   10
 

Definition at line 53 of file channels.h.

Referenced by chan_rcvd_close2(), chan_shutdown_read(), chan_shutdown_write(), channel_find_open(), channel_lookup(), channel_open_message(), channel_set_fds(), channel_still_open(), server_input_channel_req(), server_request_session(), and session_input_channel_req().

#define SSH_CHANNEL_MAX_TYPE   15
 

Definition at line 58 of file channels.h.

Referenced by channel_handler_init().

#define SSH_CHANNEL_OPEN   4
 

Definition at line 47 of file channels.h.

Referenced by channel_check_window(), channel_find_open(), channel_handle_ctl(), channel_handle_rfd(), channel_handle_wfd(), channel_handler_init_13(), channel_handler_init_15(), channel_handler_init_20(), channel_input_data(), channel_input_extended_data(), channel_input_open_confirmation(), channel_lookup(), channel_not_very_much_buffered_data(), channel_open_message(), channel_output_poll(), channel_post_connecting(), channel_pre_x11_open(), channel_pre_x11_open_13(), channel_send_window_changes(), channel_set_fds(), channel_still_open(), client_input_agent_open(), client_request_agent(), server_input_channel_req(), and server_request_tun().

#define SSH_CHANNEL_OPENING   3
 

Definition at line 46 of file channels.h.

Referenced by channel_find_open(), channel_input_open_confirmation(), channel_input_open_failure(), channel_lookup(), channel_open_message(), channel_post_auth_listener(), channel_post_port_listener(), channel_post_x11_listener(), channel_pre_dynamic(), channel_still_open(), client_process_control(), ssh_session2_open(), and ssh_session2_setup().

#define SSH_CHANNEL_OUTPUT_DRAINING   9
 

Definition at line 52 of file channels.h.

Referenced by channel_find_open(), channel_handler_init_13(), channel_input_close(), channel_lookup(), channel_open_message(), and channel_still_open().

#define SSH_CHANNEL_PATH_LEN   256
 

Definition at line 60 of file channels.h.

Referenced by channel_setup_fwd_listener().

#define SSH_CHANNEL_PORT_LISTENER   2
 

Definition at line 45 of file channels.h.

Referenced by channel_find_open(), channel_handler_init_13(), channel_handler_init_15(), channel_handler_init_20(), channel_open_message(), channel_setup_fwd_listener(), channel_setup_local_fwd_listener(), channel_still_open(), and channel_stop_listening().

#define SSH_CHANNEL_RPORT_LISTENER   11
 

Definition at line 54 of file channels.h.

Referenced by channel_cancel_rport_listener(), channel_find_open(), channel_handler_init_20(), channel_open_message(), channel_post_port_listener(), channel_setup_fwd_listener(), channel_setup_remote_fwd_listener(), channel_still_open(), and channel_stop_listening().

#define SSH_CHANNEL_X11_LISTENER   1
 

Definition at line 44 of file channels.h.

Referenced by channel_find_open(), channel_handler_init_13(), channel_handler_init_15(), channel_handler_init_20(), channel_open_message(), channel_still_open(), channel_stop_listening(), and x11_create_display_inet().

#define SSH_CHANNEL_X11_OPEN   7
 

Definition at line 50 of file channels.h.

Referenced by channel_find_open(), channel_handler_init_13(), channel_handler_init_15(), channel_handler_init_20(), channel_input_data(), channel_lookup(), channel_open_message(), channel_still_open(), client_request_x11(), and x11_input_open().

#define SSH_CHANNEL_ZOMBIE   14
 

Definition at line 57 of file channels.h.

Referenced by chan_is_dead(), chan_mark_dead(), channel_find_open(), channel_open_message(), and channel_still_open().


Typedef Documentation

typedef struct Channel Channel
 

Definition at line 63 of file channels.h.

typedef void channel_callback_fn(int, void *)
 

Definition at line 65 of file channels.h.

typedef int channel_infilter_fn(struct Channel *, char *, int)
 

Definition at line 66 of file channels.h.

typedef u_char* channel_outfilter_fn(struct Channel *, u_char **, u_int *)
 

Definition at line 67 of file channels.h.


Function Documentation

void auth_request_forwarding void   ) 
 

Definition at line 3130 of file channels.c.

References packet_send(), packet_start(), packet_write_wait(), and SSH_CMSG_AGENT_REQUEST_FORWARDING.

Referenced by ssh_session().

void chan_ibuf_empty Channel  ) 
 

Definition at line 144 of file nchan.c.

References buffer_len(), CHAN_CLOSE_SENT, CHAN_INPUT_CLOSED, CHAN_INPUT_WAIT_DRAIN, CHAN_INPUT_WAIT_OCLOSE, chan_send_eof2(), chan_send_ieof1(), chan_set_istate(), compat20, debug2(), error(), Channel::flags, Channel::input, Channel::istate, and Channel::self.

Referenced by channel_input_ieof(), channel_output_poll(), and channel_pre_x11_open().

00145 {
00146         debug2("channel %d: ibuf empty", c->self);
00147         if (buffer_len(&c->input)) {
00148                 error("channel %d: chan_ibuf_empty for non empty buffer",
00149                     c->self);
00150                 return;
00151         }
00152         switch (c->istate) {
00153         case CHAN_INPUT_WAIT_DRAIN:
00154                 if (compat20) {
00155                         if (!(c->flags & CHAN_CLOSE_SENT))
00156                                 chan_send_eof2(c);
00157                         chan_set_istate(c, CHAN_INPUT_CLOSED);
00158                 } else {
00159                         chan_send_ieof1(c);
00160                         chan_set_istate(c, CHAN_INPUT_WAIT_OCLOSE);
00161                 }
00162                 break;
00163         default:
00164                 error("channel %d: chan_ibuf_empty for istate %d",
00165                     c->self, c->istate);
00166                 break;
00167         }
00168 }

int chan_is_dead Channel ,
int 
 

Definition at line 398 of file nchan.c.

References buffer_len(), CHAN_CLOSE_RCVD, CHAN_CLOSE_SENT, CHAN_EXTENDED_WRITE, CHAN_INPUT_CLOSED, CHAN_OUTPUT_CLOSED, chan_send_close2(), compat20, datafellows, debug2(), Channel::efd, Channel::extended, Channel::extended_usage, Channel::flags, Channel::istate, Channel::ostate, Channel::self, SSH_BUG_EXTEOF, SSH_CHANNEL_ZOMBIE, and Channel::type.

Referenced by channel_garbage_collect().

00399 {
00400         if (c->type == SSH_CHANNEL_ZOMBIE) {
00401                 debug2("channel %d: zombie", c->self);
00402                 return 1;
00403         }
00404         if (c->istate != CHAN_INPUT_CLOSED || c->ostate != CHAN_OUTPUT_CLOSED)
00405                 return 0;
00406         if (!compat20) {
00407                 debug2("channel %d: is dead", c->self);
00408                 return 1;
00409         }
00410         if ((datafellows & SSH_BUG_EXTEOF) &&
00411             c->extended_usage == CHAN_EXTENDED_WRITE &&
00412             c->efd != -1 &&
00413             buffer_len(&c->extended) > 0) {
00414                 debug2("channel %d: active efd: %d len %d",
00415                     c->self, c->efd, buffer_len(&c->extended));
00416                 return 0;
00417         }
00418         if (!(c->flags & CHAN_CLOSE_SENT)) {
00419                 if (do_send) {
00420                         chan_send_close2(c);
00421                 } else {
00422                         /* channel would be dead if we sent a close */
00423                         if (c->flags & CHAN_CLOSE_RCVD) {
00424                                 debug2("channel %d: almost dead",
00425                                     c->self);
00426                                 return 1;
00427                         }
00428                 }
00429         }
00430         if ((c->flags & CHAN_CLOSE_SENT) &&
00431             (c->flags & CHAN_CLOSE_RCVD)) {
00432                 debug2("channel %d: is dead", c->self);
00433                 return 1;
00434         }
00435         return 0;
00436 }

void chan_mark_dead Channel  ) 
 

Definition at line 392 of file nchan.c.

References SSH_CHANNEL_ZOMBIE, and Channel::type.

Referenced by channel_handle_ctl(), channel_handle_rfd(), channel_handle_wfd(), channel_post_connecting(), channel_post_x11_listener(), channel_pre_dynamic(), channel_pre_output_draining(), and session_close_x11().

00393 {
00394         c->type = SSH_CHANNEL_ZOMBIE;
00395 }

void chan_obuf_empty Channel  ) 
 

Definition at line 208 of file nchan.c.

References buffer_len(), CHAN_OUTPUT_CLOSED, CHAN_OUTPUT_WAIT_DRAIN, chan_send_oclose1(), chan_set_ostate(), chan_shutdown_write(), compat20, debug2(), error(), Channel::ostate, Channel::output, and Channel::self.

Referenced by chan_rcvd_ieof(), and channel_pre_open().

00209 {
00210         debug2("channel %d: obuf empty", c->self);
00211         if (buffer_len(&c->output)) {
00212                 error("channel %d: chan_obuf_empty for non empty buffer",
00213                     c->self);
00214                 return;
00215         }
00216         switch (c->ostate) {
00217         case CHAN_OUTPUT_WAIT_DRAIN:
00218                 chan_shutdown_write(c);
00219                 if (!compat20)
00220                         chan_send_oclose1(c);
00221                 chan_set_ostate(c, CHAN_OUTPUT_CLOSED);
00222                 break;
00223         default:
00224                 error("channel %d: internal error: obuf_empty for ostate %d",
00225                     c->self, c->ostate);
00226                 break;
00227         }
00228 }

void chan_rcvd_ieof Channel  ) 
 

Definition at line 363 of file nchan.c.

References buffer_len(), chan_obuf_empty(), CHAN_OUTPUT_WAIT_DRAIN, chan_rcvd_eof2(), chan_rcvd_ieof1(), CHANNEL_EFD_OUTPUT_ACTIVE, and compat20.

Referenced by channel_input_ieof().

00364 {
00365         if (compat20)
00366                 chan_rcvd_eof2(c);
00367         else
00368                 chan_rcvd_ieof1(c);
00369         if (c->ostate == CHAN_OUTPUT_WAIT_DRAIN &&
00370             buffer_len(&c->output) == 0 &&
00371             !CHANNEL_EFD_OUTPUT_ACTIVE(c))
00372                 chan_obuf_empty(c);
00373 }

void chan_rcvd_oclose Channel  ) 
 

Definition at line 375 of file nchan.c.

References chan_rcvd_close2(), chan_rcvd_oclose1(), and compat20.

Referenced by channel_input_oclose().

00376 {
00377         if (compat20)
00378                 chan_rcvd_close2(c);
00379         else
00380                 chan_rcvd_oclose1(c);
00381 }

void chan_read_failed Channel  ) 
 

Definition at line 129 of file nchan.c.

References CHAN_INPUT_OPEN, CHAN_INPUT_WAIT_DRAIN, chan_set_istate(), chan_shutdown_read(), debug2(), error(), Channel::istate, and Channel::self.

Referenced by channel_handle_ctl(), channel_handle_rfd(), and channel_pre_x11_open().

00130 {
00131         debug2("channel %d: read failed", c->self);
00132         switch (c->istate) {
00133         case CHAN_INPUT_OPEN:
00134                 chan_shutdown_read(c);
00135                 chan_set_istate(c, CHAN_INPUT_WAIT_DRAIN);
00136                 break;
00137         default:
00138                 error("channel %d: chan_read_failed for istate %d",
00139                     c->self, c->istate);
00140                 break;
00141         }
00142 }

void chan_write_failed Channel  ) 
 

Definition at line 383 of file nchan.c.

References chan_write_failed1(), chan_write_failed2(), and compat20.

Referenced by channel_handle_ctl(), channel_handle_wfd(), channel_pre_x11_open(), and session_exit_message().

00384 {
00385         if (compat20)
00386                 chan_write_failed2(c);
00387         else
00388                 chan_write_failed1(c);
00389 }

void channel_add_permitted_opens char ,
int 
 

Definition at line 2602 of file channels.c.

References all_opens_permitted, debug(), fatal(), ForwardPermission::host_to_connect, num_permitted_opens, ForwardPermission::port_to_connect, SSH_MAX_FORWARDS_PER_DIRECTION, and xstrdup().

Referenced by auth_parse_options().

02603 {
02604         if (num_permitted_opens >= SSH_MAX_FORWARDS_PER_DIRECTION)
02605                 fatal("channel_request_remote_forwarding: too many forwards");
02606         debug("allow port forwarding to host %s port %d", host, port);
02607 
02608         permitted_opens[num_permitted_opens].host_to_connect = xstrdup(host);
02609         permitted_opens[num_permitted_opens].port_to_connect = port;
02610         num_permitted_opens++;
02611 
02612         all_opens_permitted = 0;
02613 }

void channel_after_select fd_set *  ,
fd_set * 
 

Definition at line 1815 of file channels.c.

References channel_handler(), and channel_post.

Referenced by client_loop(), server_loop(), and server_loop2().

01816 {
01817         channel_handler(channel_post, readset, writeset);
01818 }

Channel* channel_by_id int   ) 
 

Definition at line 143 of file channels.c.

References channels_alloc, and logit().

Referenced by channel_cancel_cleanup(), channel_lookup(), channel_register_cleanup(), and session_close_x11().

00144 {
00145         Channel *c;
00146 
00147         if (id < 0 || (u_int)id >= channels_alloc) {
00148                 logit("channel_by_id: %d: bad id", id);
00149                 return NULL;
00150         }
00151         c = channels[id];
00152         if (c == NULL) {
00153                 logit("channel_by_id: %d: bad id: channel free", id);
00154                 return NULL;
00155         }
00156         return c;
00157 }

void channel_cancel_cleanup int   ) 
 

Definition at line 671 of file channels.c.

References channel_by_id(), Channel::detach_close, Channel::detach_user, and logit().

Referenced by client_channel_closed(), session_close_by_channel(), session_close_single_x11(), and session_close_x11().

00672 {
00673         Channel *c = channel_by_id(id);
00674 
00675         if (c == NULL) {
00676                 logit("channel_cancel_cleanup: %d: bad id", id);
00677                 return;
00678         }
00679         c->detach_user = NULL;
00680         c->detach_close = 0;
00681 }

int channel_cancel_rport_listener const char ,
u_short 
 

Definition at line 2413 of file channels.c.

References __func__, channel_free(), channels_alloc, debug2(), Channel::listening_port, Channel::path, SSH_CHANNEL_RPORT_LISTENER, and Channel::type.

Referenced by server_input_global_request().

02414 {
02415         u_int i;
02416         int found = 0;
02417 
02418         for (i = 0; i < channels_alloc; i++) {
02419                 Channel *c = channels[i];
02420 
02421                 if (c != NULL && c->type == SSH_CHANNEL_RPORT_LISTENER &&
02422                     strncmp(c->path, host, sizeof(c->path)) == 0 &&
02423                     c->listening_port == port) {
02424                         debug2("%s: close channel %d", __func__, i);
02425                         channel_free(c);
02426                         found = 1;
02427                 }
02428         }
02429 
02430         return (found);
02431 }

void channel_clear_permitted_opens void   ) 
 

Definition at line 2616 of file channels.c.

References num_permitted_opens, and xfree().

Referenced by auth_clear_options().

02617 {
02618         int i;
02619 
02620         for (i = 0; i < num_permitted_opens; i++)
02621                 if (permitted_opens[i].host_to_connect != NULL)
02622                         xfree(permitted_opens[i].host_to_connect);
02623         num_permitted_opens = 0;
02624 
02625 }

void channel_close_all void   ) 
 

Definition at line 404 of file channels.c.

References channel_close_fds(), and channels_alloc.

Referenced by child_close_fds(), and packet_disconnect().

00405 {
00406         u_int i;
00407 
00408         for (i = 0; i < channels_alloc; i++)
00409                 if (channels[i] != NULL)
00410                         channel_close_fds(