version 1.127, 2017/08/30 03:59:08 |
version 1.128, 2017/09/12 06:32:07 |
|
|
struct ssh; |
struct ssh; |
struct Channel; |
struct Channel; |
typedef struct Channel Channel; |
typedef struct Channel Channel; |
|
struct fwd_perm_list; |
|
|
typedef void channel_open_fn(int, int, void *); |
typedef void channel_open_fn(struct ssh *, int, int, void *); |
typedef void channel_callback_fn(int, void *); |
typedef void channel_callback_fn(struct ssh *, int, void *); |
typedef int channel_infilter_fn(struct Channel *, char *, int); |
typedef int channel_infilter_fn(struct ssh *, struct Channel *, char *, int); |
typedef void channel_filter_cleanup_fn(int, void *); |
typedef void channel_filter_cleanup_fn(struct ssh *, int, void *); |
typedef u_char *channel_outfilter_fn(struct Channel *, u_char **, u_int *); |
typedef u_char *channel_outfilter_fn(struct ssh *, struct Channel *, |
|
u_char **, size_t *); |
|
|
/* Channel success/failure callbacks */ |
/* Channel success/failure callbacks */ |
typedef void channel_confirm_cb(int, struct Channel *, void *); |
typedef void channel_confirm_cb(struct ssh *, int, struct Channel *, void *); |
typedef void channel_confirm_abandon_cb(struct Channel *, void *); |
typedef void channel_confirm_abandon_cb(struct ssh *, struct Channel *, void *); |
struct channel_confirm { |
struct channel_confirm { |
TAILQ_ENTRY(channel_confirm) entry; |
TAILQ_ENTRY(channel_confirm) entry; |
channel_confirm_cb *cb; |
channel_confirm_cb *cb; |
|
|
}; |
}; |
|
|
/* Callbacks for mux channels back into client-specific code */ |
/* Callbacks for mux channels back into client-specific code */ |
typedef int mux_callback_fn(struct Channel *); |
typedef int mux_callback_fn(struct ssh *, struct Channel *); |
|
|
struct Channel { |
struct Channel { |
int type; /* channel type/state */ |
int type; /* channel type/state */ |
int self; /* my own channel identifier */ |
int self; /* my own channel identifier */ |
int remote_id; /* channel identifier for remote peer */ |
int remote_id; /* channel identifier for remote peer */ |
|
/* XXX should be uint32_t */ |
u_int istate; /* input from channel (state of receive half) */ |
u_int istate; /* input from channel (state of receive half) */ |
u_int ostate; /* output to channel (state of transmit half) */ |
u_int ostate; /* output to channel (state of transmit half) */ |
int flags; /* close sent/rcvd */ |
int flags; /* close sent/rcvd */ |
|
|
* to a matching pre-select handler. |
* to a matching pre-select handler. |
* this way post-select handlers are not |
* this way post-select handlers are not |
* accidentally called if a FD gets reused */ |
* accidentally called if a FD gets reused */ |
Buffer input; /* data read from socket, to be sent over |
struct sshbuf *input; /* data read from socket, to be sent over |
* encrypted connection */ |
* encrypted connection */ |
Buffer output; /* data received over encrypted connection for |
struct sshbuf *output; /* data received over encrypted connection for |
* send on socket */ |
* send on socket */ |
Buffer extended; |
struct sshbuf *extended; |
|
|
char *path; |
char *path; |
/* path for unix domain sockets, or host name for forwards */ |
/* path for unix domain sockets, or host name for forwards */ |
int listening_port; /* port being listened for forwards */ |
int listening_port; /* port being listened for forwards */ |
|
|
int datagram; |
int datagram; |
|
|
/* non-blocking connect */ |
/* non-blocking connect */ |
|
/* XXX make this a pointer so the structure can be opaque */ |
struct channel_connect connect_ctx; |
struct channel_connect connect_ctx; |
|
|
/* multiplexing protocol hook, called for each packet received */ |
/* multiplexing protocol hook, called for each packet received */ |
|
|
#define CHAN_EOF_RCVD 0x08 |
#define CHAN_EOF_RCVD 0x08 |
#define CHAN_LOCAL 0x10 |
#define CHAN_LOCAL 0x10 |
|
|
#define CHAN_RBUF 16*1024 |
/* Read buffer size */ |
|
#define CHAN_RBUF (16*1024) |
|
|
|
/* Hard limit on number of channels */ |
|
#define CHANNELS_MAX_CHANNELS (16*1024) |
|
|
/* check whether 'efd' is still in use */ |
/* check whether 'efd' is still in use */ |
#define CHANNEL_EFD_INPUT_ACTIVE(c) \ |
#define CHANNEL_EFD_INPUT_ACTIVE(c) \ |
(c->extended_usage == CHAN_EXTENDED_READ && \ |
(c->extended_usage == CHAN_EXTENDED_READ && \ |
(c->efd != -1 || \ |
(c->efd != -1 || \ |
buffer_len(&c->extended) > 0)) |
sshbuf_len(c->extended) > 0)) |
#define CHANNEL_EFD_OUTPUT_ACTIVE(c) \ |
#define CHANNEL_EFD_OUTPUT_ACTIVE(c) \ |
(c->extended_usage == CHAN_EXTENDED_WRITE && \ |
(c->extended_usage == CHAN_EXTENDED_WRITE && \ |
c->efd != -1 && (!(c->flags & (CHAN_EOF_RCVD|CHAN_CLOSE_RCVD)) || \ |
c->efd != -1 && (!(c->flags & (CHAN_EOF_RCVD|CHAN_CLOSE_RCVD)) || \ |
buffer_len(&c->extended) > 0)) |
sshbuf_len(c->extended) > 0)) |
|
|
|
/* Add channel management structures to SSH transport instance */ |
|
void channel_init_channels(struct ssh *ssh); |
|
|
/* channel management */ |
/* channel management */ |
|
|
Channel *channel_by_id(int); |
Channel *channel_by_id(struct ssh *, int); |
Channel *channel_by_remote_id(int); |
Channel *channel_by_remote_id(struct ssh *, int); |
Channel *channel_lookup(int); |
Channel *channel_lookup(struct ssh *, int); |
Channel *channel_new(char *, int, int, int, int, u_int, u_int, int, char *, int); |
Channel *channel_new(struct ssh *, char *, int, int, int, int, |
void channel_set_fds(int, int, int, int, int, int, int, u_int); |
u_int, u_int, int, char *, int); |
void channel_free(Channel *); |
void channel_set_fds(struct ssh *, int, int, int, int, int, |
void channel_free_all(void); |
int, int, u_int); |
void channel_stop_listening(void); |
void channel_free(struct ssh *, Channel *); |
|
void channel_free_all(struct ssh *); |
|
void channel_stop_listening(struct ssh *); |
|
|
void channel_send_open(int); |
void channel_send_open(struct ssh *, int); |
void channel_request_start(int, char *, int); |
void channel_request_start(struct ssh *, int, char *, int); |
void channel_register_cleanup(int, channel_callback_fn *, int); |
void channel_register_cleanup(struct ssh *, int, |
void channel_register_open_confirm(int, channel_open_fn *, void *); |
channel_callback_fn *, int); |
void channel_register_filter(int, channel_infilter_fn *, |
void channel_register_open_confirm(struct ssh *, int, |
channel_outfilter_fn *, channel_filter_cleanup_fn *, void *); |
channel_open_fn *, void *); |
void channel_register_status_confirm(int, channel_confirm_cb *, |
void channel_register_filter(struct ssh *, int, channel_infilter_fn *, |
channel_confirm_abandon_cb *, void *); |
channel_outfilter_fn *, channel_filter_cleanup_fn *, void *); |
void channel_cancel_cleanup(int); |
void channel_register_status_confirm(struct ssh *, int, |
int channel_close_fd(int *); |
channel_confirm_cb *, channel_confirm_abandon_cb *, void *); |
void channel_send_window_changes(void); |
void channel_cancel_cleanup(struct ssh *, int); |
|
int channel_close_fd(struct ssh *, int *); |
|
void channel_send_window_changes(struct ssh *); |
|
|
/* mux proxy support */ |
/* mux proxy support */ |
|
|
int channel_proxy_downstream(Channel *mc); |
int channel_proxy_downstream(struct ssh *, Channel *mc); |
int channel_proxy_upstream(Channel *, int, u_int32_t, struct ssh *); |
int channel_proxy_upstream(Channel *, int, u_int32_t, struct ssh *); |
|
|
/* protocol handler */ |
/* protocol handler */ |
|
|
void channel_prepare_select(struct ssh *, fd_set **, fd_set **, int *, |
void channel_prepare_select(struct ssh *, fd_set **, fd_set **, int *, |
u_int*, time_t*); |
u_int*, time_t*); |
void channel_after_select(struct ssh *, fd_set *, fd_set *); |
void channel_after_select(struct ssh *, fd_set *, fd_set *); |
void channel_output_poll(void); |
void channel_output_poll(struct ssh *); |
|
|
int channel_not_very_much_buffered_data(void); |
int channel_not_very_much_buffered_data(struct ssh *); |
void channel_close_all(void); |
void channel_close_all(struct ssh *); |
int channel_still_open(void); |
int channel_still_open(struct ssh *); |
char *channel_open_message(void); |
char *channel_open_message(struct ssh *); |
int channel_find_open(void); |
int channel_find_open(struct ssh *); |
|
|
/* tcp forwarding */ |
/* tcp forwarding */ |
struct Forward; |
struct Forward; |
struct ForwardOptions; |
struct ForwardOptions; |
void channel_set_af(int af); |
void channel_set_af(struct ssh *, int af); |
void channel_permit_all_opens(void); |
void channel_permit_all_opens(struct ssh *); |
void channel_add_permitted_opens(char *, int); |
void channel_add_permitted_opens(struct ssh *, char *, int); |
int channel_add_adm_permitted_opens(char *, int); |
int channel_add_adm_permitted_opens(struct ssh *, char *, int); |
void channel_disable_adm_local_opens(void); |
void channel_copy_adm_permitted_opens(struct ssh *, |
void channel_update_permitted_opens(int, int); |
const struct fwd_perm_list *); |
void channel_clear_permitted_opens(void); |
void channel_disable_adm_local_opens(struct ssh *); |
void channel_clear_adm_permitted_opens(void); |
void channel_update_permitted_opens(struct ssh *, int, int); |
void channel_print_adm_permitted_opens(void); |
void channel_clear_permitted_opens(struct ssh *); |
Channel *channel_connect_to_port(const char *, u_short, char *, char *, int *, |
void channel_clear_adm_permitted_opens(struct ssh *); |
const char **); |
void channel_print_adm_permitted_opens(struct ssh *); |
Channel *channel_connect_to_path(const char *, char *, char *); |
Channel *channel_connect_to_port(struct ssh *, const char *, u_short, |
Channel *channel_connect_stdio_fwd(const char*, u_short, int, int); |
char *, char *, int *, const char **); |
Channel *channel_connect_by_listen_address(const char *, u_short, |
Channel *channel_connect_to_path(struct ssh *, const char *, char *, char *); |
char *, char *); |
Channel *channel_connect_stdio_fwd(struct ssh *, const char*, |
Channel *channel_connect_by_listen_path(const char *, char *, char *); |
u_short, int, int); |
int channel_request_remote_forwarding(struct Forward *); |
Channel *channel_connect_by_listen_address(struct ssh *, const char *, |
int channel_setup_local_fwd_listener(struct Forward *, struct ForwardOptions *); |
u_short, char *, char *); |
int channel_request_rforward_cancel(struct Forward *); |
Channel *channel_connect_by_listen_path(struct ssh *, const char *, |
int channel_setup_remote_fwd_listener(struct Forward *, int *, struct ForwardOptions *); |
char *, char *); |
int channel_cancel_rport_listener(struct Forward *); |
int channel_request_remote_forwarding(struct ssh *, struct Forward *); |
int channel_cancel_lport_listener(struct Forward *, int, struct ForwardOptions *); |
int channel_setup_local_fwd_listener(struct ssh *, struct Forward *, |
|
struct ForwardOptions *); |
|
int channel_request_rforward_cancel(struct ssh *, struct Forward *); |
|
int channel_setup_remote_fwd_listener(struct ssh *, struct Forward *, |
|
int *, struct ForwardOptions *); |
|
int channel_cancel_rport_listener(struct ssh *, struct Forward *); |
|
int channel_cancel_lport_listener(struct ssh *, struct Forward *, |
|
int, struct ForwardOptions *); |
int permitopen_port(const char *); |
int permitopen_port(const char *); |
|
|
/* x11 forwarding */ |
/* x11 forwarding */ |
|
|
void channel_set_x11_refuse_time(u_int); |
void channel_set_x11_refuse_time(struct ssh *, u_int); |
int x11_connect_display(void); |
int x11_connect_display(struct ssh *); |
int x11_create_display_inet(int, int, int, u_int *, int **); |
int x11_create_display_inet(struct ssh *, int, int, int, u_int *, int **); |
void x11_request_forwarding_with_spoofing(int, const char *, const char *, |
void x11_request_forwarding_with_spoofing(struct ssh *, int, |
const char *, int); |
const char *, const char *, const char *, int); |
|
|
/* channel close */ |
/* channel close */ |
|
|
int chan_is_dead(Channel *, int); |
int chan_is_dead(struct ssh *, Channel *, int); |
void chan_mark_dead(Channel *); |
void chan_mark_dead(struct ssh *, Channel *); |
|
|
/* channel events */ |
/* channel events */ |
|
|
void chan_rcvd_oclose(Channel *); |
void chan_rcvd_oclose(struct ssh *, Channel *); |
void chan_rcvd_eow(Channel *); /* SSH2-only */ |
void chan_rcvd_eow(struct ssh *, Channel *); |
void chan_read_failed(Channel *); |
void chan_read_failed(struct ssh *, Channel *); |
void chan_ibuf_empty(Channel *); |
void chan_ibuf_empty(struct ssh *, Channel *); |
|
void chan_rcvd_ieof(struct ssh *, Channel *); |
void chan_rcvd_ieof(Channel *); |
void chan_write_failed(struct ssh *, Channel *); |
void chan_write_failed(Channel *); |
void chan_obuf_empty(struct ssh *, Channel *); |
void chan_obuf_empty(Channel *); |
|
|
|
#endif |
#endif |