proxy_session.c 2.49 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* proxy_session.c
 *
 * $Id$ */

/* lsh, an implementation of the ssh protocol
 *
 * Copyright (C) 1999 Balázs Scheidler
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "proxy_session.h"
25
26
27

#include "channel_commands.h"
#include "format.h"
Niels Möller's avatar
Niels Möller committed
28
#include "gateway_channel.h"
29
30
#include "ssh.h"
#include "werror.h"
31
#include "xalloc.h"
32
33
34

#include "proxy_session.c.x"

35
#define WINDOW_SIZE 10000
36

37

38
39
40
41
42
/* GABA:
   (class
     (name proxy_open_session)
     (super channel_open)
     (vars
43
44
45
46
47
       ; requests to accept from server -> client
       (server_requests object alist)
       ; requests to accept from client -> server
       (client_requests object alist)))

48
49
50
51
52
*/

static void
do_proxy_open_session(struct channel_open *s,
		      struct ssh_connection *connection,
53
		      struct channel_open_info *info,
54
55
56
57
58
59
60
61
62
63
		      struct simple_buffer *args,
		      struct command_continuation *c,
		      struct exception_handler *e)
{
  CAST(proxy_open_session, closure, s);

  debug("server.c: do_proxy_open_session()\n");

  if (parse_eod(args))
    {
Niels Möller's avatar
Niels Möller committed
64
65
66
67
68
      struct gateway_channel *server
	= make_gateway_channel(closure->server_requests);

      /* NOTE: The origin's rec_window_size and rec_max_packet becomes the target's
       * send_window_size and send_max_packet. */
69
      struct command *o =
70
71
72
	make_gateway_channel_open_command(info,
					  ssh_format(""),
					  closure->client_requests);
73
74
75

      COMMAND_CALL(o,
		   connection->chain,
Niels Möller's avatar
Niels Möller committed
76
		   make_gateway_channel_open_continuation(c, server),
77
78
		   e);

79
80
81
    }
  else
    {
82
      PROTOCOL_ERROR(e, "Trailing garbage in open message");
83
84
85
86
    }
}

struct channel_open *
87
88
make_proxy_open_session(struct alist *server_requests,
			struct alist *client_requests)
89
90
91
92
{
  NEW(proxy_open_session, self);

  self->super.handler = do_proxy_open_session;
93
94
  self->server_requests = server_requests;
  self->client_requests = client_requests;
95
96
  return &self->super;
}