summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2010-01-12 19:40:27 +1100
committerDarren Tucker <dtucker@zip.com.au>2010-01-12 19:40:27 +1100
commit7ad8dd21da5e2a2687fdff14142b70f1587f96ce (patch)
tree5d8e196d1a258b7dc837ae529e4d945d30014aaf /channels.c
parent43551527dc1cc9f18561c4816960440de2ce289b (diff)
- dtucker@cvs.openbsd.org 2010/01/11 01:39:46
[ssh_config channels.c ssh.1 channels.h ssh.c] Add a 'netcat mode' (ssh -W). This connects stdio on the client to a single port forward on the server. This allows, for example, using ssh as a ProxyCommand to route connections via intermediate servers. bz #1618, man page help from jmc@, ok markus@
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/channels.c b/channels.c
index 87dbe96d3..e8589d8c4 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.c,v 1.300 2010/01/09 23:04:13 dtucker Exp $ */ 1/* $OpenBSD: channels.c,v 1.301 2010/01/11 01:39:46 dtucker Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1217,6 +1217,35 @@ channel_decode_socks5(Channel *c, fd_set *readset, fd_set *writeset)
1217 return 1; 1217 return 1;
1218} 1218}
1219 1219
1220Channel *
1221channel_connect_stdio_fwd(const char *host_to_connect, u_short port_to_connect)
1222{
1223 Channel *c;
1224 int in, out;
1225
1226 debug("channel_connect_stdio_fwd %s:%d", host_to_connect,
1227 port_to_connect);
1228
1229 in = dup(STDIN_FILENO);
1230 out = dup(STDOUT_FILENO);
1231 if (in < 0 || out < 0)
1232 fatal("channel_connect_stdio_fwd: dup() in/out failed");
1233
1234 c = channel_new("stdio-forward", SSH_CHANNEL_OPENING, in, out,
1235 -1, CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
1236 0, "stdio-forward", /*nonblock*/0);
1237
1238 c->path = xstrdup(host_to_connect);
1239 c->host_port = port_to_connect;
1240 c->listening_port = 0;
1241 c->force_drain = 1;
1242
1243 channel_register_fds(c, in, out, -1, 0, 1, 0);
1244 port_open_helper(c, "direct-tcpip");
1245
1246 return c;
1247}
1248
1220/* dynamic port forwarding */ 1249/* dynamic port forwarding */
1221static void 1250static void
1222channel_pre_dynamic(Channel *c, fd_set *readset, fd_set *writeset) 1251channel_pre_dynamic(Channel *c, fd_set *readset, fd_set *writeset)