1*1c7715ddSchristos /* $NetBSD: clientloop.h,v 1.19 2024/07/08 22:33:43 christos Exp $ */ 2*1c7715ddSchristos /* $OpenBSD: clientloop.h,v 1.38 2024/05/17 06:42:04 jsg Exp $ */ 3ca32bd8dSchristos 4ca32bd8dSchristos /* 5ca32bd8dSchristos * Author: Tatu Ylonen <ylo@cs.hut.fi> 6ca32bd8dSchristos * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 7ca32bd8dSchristos * All rights reserved 8ca32bd8dSchristos * 9ca32bd8dSchristos * As far as I am concerned, the code I have written for this software 10ca32bd8dSchristos * can be used freely for any purpose. Any derived versions of this 11ca32bd8dSchristos * software must be clearly marked as such, and if the derived work is 12ca32bd8dSchristos * incompatible with the protocol description in the RFC file, it must be 13ca32bd8dSchristos * called by a name other than "ssh" or "Secure Shell". 14ca32bd8dSchristos */ 15ca32bd8dSchristos /* 16ca32bd8dSchristos * Copyright (c) 2001 Markus Friedl. All rights reserved. 17ca32bd8dSchristos * 18ca32bd8dSchristos * Redistribution and use in source and binary forms, with or without 19ca32bd8dSchristos * modification, are permitted provided that the following conditions 20ca32bd8dSchristos * are met: 21ca32bd8dSchristos * 1. Redistributions of source code must retain the above copyright 22ca32bd8dSchristos * notice, this list of conditions and the following disclaimer. 23ca32bd8dSchristos * 2. Redistributions in binary form must reproduce the above copyright 24ca32bd8dSchristos * notice, this list of conditions and the following disclaimer in the 25ca32bd8dSchristos * documentation and/or other materials provided with the distribution. 26ca32bd8dSchristos * 27ca32bd8dSchristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 28ca32bd8dSchristos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29ca32bd8dSchristos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 30ca32bd8dSchristos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 31ca32bd8dSchristos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 32ca32bd8dSchristos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33ca32bd8dSchristos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34ca32bd8dSchristos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35ca32bd8dSchristos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 36ca32bd8dSchristos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37ca32bd8dSchristos */ 38ca32bd8dSchristos 39ca32bd8dSchristos #include <termios.h> 40ca32bd8dSchristos 417a183406Schristos struct ssh; 427a183406Schristos 43ca32bd8dSchristos /* Client side main loop for the interactive session. */ 447a183406Schristos int client_loop(struct ssh *, int, int, int); 457a183406Schristos int client_x11_get_proto(struct ssh *, const char *, const char *, 467a183406Schristos u_int, u_int, char **, char **); 477a183406Schristos void client_session2_setup(struct ssh *, int, int, int, 4855a4608bSchristos const char *, struct termios *, int, struct sshbuf *, char **); 498db691beSchristos char *client_request_tun_fwd(struct ssh *, int, int, int, 508db691beSchristos channel_open_fn *, void *); 516f47b660Schristos void client_stop_mux(void); 52ca32bd8dSchristos 53ca32bd8dSchristos /* Escape filter for protocol 2 sessions */ 54ca32bd8dSchristos void *client_new_escape_filter_ctx(int); 557a183406Schristos void client_filter_cleanup(struct ssh *, int, void *); 567a183406Schristos int client_simple_escape_filter(struct ssh *, Channel *, const char *, int); 57ca32bd8dSchristos 58ca32bd8dSchristos /* Global request confirmation callbacks */ 597a183406Schristos typedef void global_confirm_cb(struct ssh *, int, u_int32_t, void *); 60ca32bd8dSchristos void client_register_global_confirm(global_confirm_cb *, void *); 61ca32bd8dSchristos 626f47b660Schristos /* Channel request confirmation callbacks */ 636f47b660Schristos enum confirm_action { CONFIRM_WARN = 0, CONFIRM_CLOSE, CONFIRM_TTY }; 647a183406Schristos void client_expect_confirm(struct ssh *, int, const char *, 657a183406Schristos enum confirm_action); 666f47b660Schristos 67ca32bd8dSchristos /* Multiplexing protocol version */ 6834b27b53Sadam #define SSHMUX_VER 4 69ca32bd8dSchristos 70ca32bd8dSchristos /* Multiplexing control protocol flags */ 71ca32bd8dSchristos #define SSHMUX_COMMAND_OPEN 1 /* Open new connection */ 72ca32bd8dSchristos #define SSHMUX_COMMAND_ALIVE_CHECK 2 /* Check master is alive */ 73ca32bd8dSchristos #define SSHMUX_COMMAND_TERMINATE 3 /* Ask master to exit */ 7434b27b53Sadam #define SSHMUX_COMMAND_STDIO_FWD 4 /* Open stdio fwd (ssh -W) */ 7534b27b53Sadam #define SSHMUX_COMMAND_FORWARD 5 /* Forward only, no command */ 766f47b660Schristos #define SSHMUX_COMMAND_STOP 6 /* Disable mux but not conn */ 77091c4109Schristos #define SSHMUX_COMMAND_CANCEL_FWD 7 /* Cancel forwarding(s) */ 78ee85abc4Schristos #define SSHMUX_COMMAND_PROXY 8 /* Open new connection */ 79ca32bd8dSchristos 807a183406Schristos void muxserver_listen(struct ssh *); 81ee85abc4Schristos int muxclient(const char *); 827a183406Schristos void mux_exit_message(struct ssh *, Channel *, int); 837a183406Schristos void mux_tty_alloc_failed(struct ssh *ssh, Channel *); 846f47b660Schristos 85