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