10cbfa66cSDaniel Fojt /* $OpenBSD: clientloop.h,v 1.37 2020/04/03 02:40:32 djm Exp $ */ 218de8d7fSPeter Avalos 318de8d7fSPeter Avalos /* 418de8d7fSPeter Avalos * Author: Tatu Ylonen <ylo@cs.hut.fi> 518de8d7fSPeter Avalos * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 618de8d7fSPeter Avalos * All rights reserved 718de8d7fSPeter Avalos * 818de8d7fSPeter Avalos * As far as I am concerned, the code I have written for this software 918de8d7fSPeter Avalos * can be used freely for any purpose. Any derived versions of this 1018de8d7fSPeter Avalos * software must be clearly marked as such, and if the derived work is 1118de8d7fSPeter Avalos * incompatible with the protocol description in the RFC file, it must be 1218de8d7fSPeter Avalos * called by a name other than "ssh" or "Secure Shell". 1318de8d7fSPeter Avalos */ 1418de8d7fSPeter Avalos /* 1518de8d7fSPeter Avalos * Copyright (c) 2001 Markus Friedl. All rights reserved. 1618de8d7fSPeter Avalos * 1718de8d7fSPeter Avalos * Redistribution and use in source and binary forms, with or without 1818de8d7fSPeter Avalos * modification, are permitted provided that the following conditions 1918de8d7fSPeter Avalos * are met: 2018de8d7fSPeter Avalos * 1. Redistributions of source code must retain the above copyright 2118de8d7fSPeter Avalos * notice, this list of conditions and the following disclaimer. 2218de8d7fSPeter Avalos * 2. Redistributions in binary form must reproduce the above copyright 2318de8d7fSPeter Avalos * notice, this list of conditions and the following disclaimer in the 2418de8d7fSPeter Avalos * documentation and/or other materials provided with the distribution. 2518de8d7fSPeter Avalos * 2618de8d7fSPeter Avalos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2718de8d7fSPeter Avalos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2818de8d7fSPeter Avalos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2918de8d7fSPeter Avalos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 3018de8d7fSPeter Avalos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 3118de8d7fSPeter Avalos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3218de8d7fSPeter Avalos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3318de8d7fSPeter Avalos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3418de8d7fSPeter Avalos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3518de8d7fSPeter Avalos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3618de8d7fSPeter Avalos */ 3718de8d7fSPeter Avalos 3818de8d7fSPeter Avalos #include <termios.h> 3918de8d7fSPeter Avalos 40ce74bacaSMatthew Dillon struct ssh; 41ce74bacaSMatthew Dillon 4218de8d7fSPeter Avalos /* Client side main loop for the interactive session. */ 43ce74bacaSMatthew Dillon int client_loop(struct ssh *, int, int, int); 44ce74bacaSMatthew Dillon int client_x11_get_proto(struct ssh *, const char *, const char *, 45ce74bacaSMatthew Dillon u_int, u_int, char **, char **); 4618de8d7fSPeter Avalos void client_global_request_reply_fwd(int, u_int32_t, void *); 47ce74bacaSMatthew Dillon void client_session2_setup(struct ssh *, int, int, int, 48664f4763Szrj const char *, struct termios *, int, struct sshbuf *, char **); 490cbfa66cSDaniel Fojt char *client_request_tun_fwd(struct ssh *, int, int, int, 500cbfa66cSDaniel Fojt channel_open_fn *, void *); 511c188a7fSPeter Avalos void client_stop_mux(void); 5218de8d7fSPeter Avalos 5318de8d7fSPeter Avalos /* Escape filter for protocol 2 sessions */ 5418de8d7fSPeter Avalos void *client_new_escape_filter_ctx(int); 55ce74bacaSMatthew Dillon void client_filter_cleanup(struct ssh *, int, void *); 56ce74bacaSMatthew Dillon int client_simple_escape_filter(struct ssh *, Channel *, char *, int); 5718de8d7fSPeter Avalos 5818de8d7fSPeter Avalos /* Global request confirmation callbacks */ 59ce74bacaSMatthew Dillon typedef void global_confirm_cb(struct ssh *, int, u_int32_t, void *); 6018de8d7fSPeter Avalos void client_register_global_confirm(global_confirm_cb *, void *); 6118de8d7fSPeter Avalos 621c188a7fSPeter Avalos /* Channel request confirmation callbacks */ 631c188a7fSPeter Avalos enum confirm_action { CONFIRM_WARN = 0, CONFIRM_CLOSE, CONFIRM_TTY }; 64ce74bacaSMatthew Dillon void client_expect_confirm(struct ssh *, int, const char *, 65ce74bacaSMatthew Dillon enum confirm_action); 661c188a7fSPeter Avalos 6718de8d7fSPeter Avalos /* Multiplexing protocol version */ 68856ea928SPeter Avalos #define SSHMUX_VER 4 6918de8d7fSPeter Avalos 7018de8d7fSPeter Avalos /* Multiplexing control protocol flags */ 7118de8d7fSPeter Avalos #define SSHMUX_COMMAND_OPEN 1 /* Open new connection */ 7218de8d7fSPeter Avalos #define SSHMUX_COMMAND_ALIVE_CHECK 2 /* Check master is alive */ 7318de8d7fSPeter Avalos #define SSHMUX_COMMAND_TERMINATE 3 /* Ask master to exit */ 74856ea928SPeter Avalos #define SSHMUX_COMMAND_STDIO_FWD 4 /* Open stdio fwd (ssh -W) */ 75856ea928SPeter Avalos #define SSHMUX_COMMAND_FORWARD 5 /* Forward only, no command */ 761c188a7fSPeter Avalos #define SSHMUX_COMMAND_STOP 6 /* Disable mux but not conn */ 7799e85e0dSPeter Avalos #define SSHMUX_COMMAND_CANCEL_FWD 7 /* Cancel forwarding(s) */ 78ce74bacaSMatthew Dillon #define SSHMUX_COMMAND_PROXY 8 /* Open new connection */ 7918de8d7fSPeter Avalos 80ce74bacaSMatthew Dillon void muxserver_listen(struct ssh *); 81ce74bacaSMatthew Dillon int muxclient(const char *); 82ce74bacaSMatthew Dillon void mux_exit_message(struct ssh *, Channel *, int); 83ce74bacaSMatthew Dillon void mux_tty_alloc_failed(struct ssh *ssh, Channel *); 841c188a7fSPeter Avalos 85