View | Details | Raw Unified | Return to bug 1232
Collapse All | Expand All

(-)ssh.c (-28 / +14 lines)
Lines 857-862 ssh_init_forwarding(void) Link Here
857
				    "forwarding.");
857
				    "forwarding.");
858
		}
858
		}
859
	}
859
	}
860
861
	/* Initiate tunnel forwarding. */
862
	if (options.tun_open != SSH_TUNMODE_NO) {
863
		if (client_request_tun_fwd(options.tun_open,
864
		    options.tun_local, options.tun_remote) < 0) {
865
			if (options.exit_on_forward_failure)
866
				fatal("Could not request tunnel forwarding.");
867
			else
868
				error("Could not request tunnel forwarding.");
869
		}
870
	}			
860
}
871
}
861
872
862
static void
873
static void
Lines 1119-1151 ssh_session2_setup(int id, void *arg) Link Here
1119
		packet_send();
1130
		packet_send();
1120
	}
1131
	}
1121
1132
1122
	if (options.tun_open != SSH_TUNMODE_NO) {
1123
		Channel *c;
1124
		int fd;
1125
1126
		debug("Requesting tun.");
1127
		if ((fd = tun_open(options.tun_local,
1128
		    options.tun_open)) >= 0) {
1129
			c = channel_new("tun", SSH_CHANNEL_OPENING, fd, fd, -1,
1130
			    CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
1131
			    0, "tun", 1);
1132
			c->datagram = 1;
1133
#if defined(SSH_TUN_FILTER)
1134
			if (options.tun_open == SSH_TUNMODE_POINTOPOINT)
1135
				channel_register_filter(c->self, sys_tun_infilter,
1136
				    sys_tun_outfilter);
1137
#endif
1138
			packet_start(SSH2_MSG_CHANNEL_OPEN);
1139
			packet_put_cstring("tun@openssh.com");
1140
			packet_put_int(c->self);
1141
			packet_put_int(c->local_window_max);
1142
			packet_put_int(c->local_maxpacket);
1143
			packet_put_int(options.tun_open);
1144
			packet_put_int(options.tun_remote);
1145
			packet_send();
1146
		}
1147
	}
1148
1149
	client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"),
1133
	client_session2_setup(id, tty_flag, subsystem_flag, getenv("TERM"),
1150
	    NULL, fileno(stdin), &command, environ, &ssh_subsystem_reply);
1134
	    NULL, fileno(stdin), &command, environ, &ssh_subsystem_reply);
1151
1135
Lines 1205-1211 ssh_session2(void) Link Here
1205
1189
1206
	/* XXX should be pre-session */
1190
	/* XXX should be pre-session */
1207
	ssh_init_forwarding();
1191
	ssh_init_forwarding();
1208
	ssh_control_listener();
1209
1192
1210
	if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN))
1193
	if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN))
1211
		id = ssh_session2_open();
1194
		id = ssh_session2_open();
Lines 1214-1219 ssh_session2(void) Link Here
1214
	if (options.local_command != NULL &&
1197
	if (options.local_command != NULL &&
1215
	    options.permit_local_command)
1198
	    options.permit_local_command)
1216
		ssh_local_cmd(options.local_command);
1199
		ssh_local_cmd(options.local_command);
1200
1201
	/* Start listening for multiplex clients */
1202
	ssh_control_listener();
1217
1203
1218
	/* If requested, let ssh continue in the background. */
1204
	/* If requested, let ssh continue in the background. */
1219
	if (fork_after_authentication_flag)
1205
	if (fork_after_authentication_flag)
(-)clientloop.c (+45 lines)
Lines 1773-1778 client_request_agent(const char *request Link Here
1773
	return c;
1773
	return c;
1774
}
1774
}
1775
1775
1776
int
1777
client_request_tun_fwd(int tun_mode, int local_tun, int remote_tun)
1778
{
1779
	Channel *c;
1780
	int fd;
1781
1782
	if (tun_mode == SSH_TUNMODE_NO)
1783
		return 0;
1784
1785
	if (!compat20) {
1786
		error("Tunnel forwarding is not support for protocol 1");
1787
		return -1;
1788
	}
1789
1790
	debug("Requesting tun unit %d in mode %d", local_tun, tun_mode);
1791
1792
	/* Open local tunnel device */
1793
	if ((fd = tun_open(local_tun, tun_mode)) == -1) {
1794
		error("Tunnel device open failed.");
1795
		return -1;
1796
	}
1797
1798
	c = channel_new("tun", SSH_CHANNEL_OPENING, fd, fd, -1,
1799
	    CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, "tun", 1);
1800
	c->datagram = 1;
1801
1802
#if defined(SSH_TUN_FILTER)
1803
	if (options.tun_open == SSH_TUNMODE_POINTOPOINT)
1804
		channel_register_filter(c->self, sys_tun_infilter,
1805
		    sys_tun_outfilter);
1806
#endif
1807
1808
	packet_start(SSH2_MSG_CHANNEL_OPEN);
1809
	packet_put_cstring("tun@openssh.com");
1810
	packet_put_int(c->self);
1811
	packet_put_int(c->local_window_max);
1812
	packet_put_int(c->local_maxpacket);
1813
	packet_put_int(tun_mode);
1814
	packet_put_int(remote_tun);
1815
	packet_send();
1816
1817
	/* Assume that server accepts the request */
1818
	return 0;
1819
}
1820
1776
/* XXXX move to generic input handler */
1821
/* XXXX move to generic input handler */
1777
static void
1822
static void
1778
client_input_channel_open(int type, u_int32_t seq, void *ctxt)
1823
client_input_channel_open(int type, u_int32_t seq, void *ctxt)
(-)clientloop.h (+1 lines)
Lines 44-49 void client_x11_get_proto(const char *, Link Here
44
void	 client_global_request_reply_fwd(int, u_int32_t, void *);
44
void	 client_global_request_reply_fwd(int, u_int32_t, void *);
45
void	 client_session2_setup(int, int, int, const char *, struct termios *,
45
void	 client_session2_setup(int, int, int, const char *, struct termios *,
46
	    int, Buffer *, char **, dispatch_fn *);
46
	    int, Buffer *, char **, dispatch_fn *);
47
int	 client_request_tun_fwd(int, int, int);
47
48
48
/* Multiplexing protocol version */
49
/* Multiplexing protocol version */
49
#define SSHMUX_VER			1
50
#define SSHMUX_VER			1

Return to bug 1232