]> andersk Git - openssh.git/blobdiff - channels.c
- guenther@cvs.openbsd.org 2010/01/15 00:05:22
[openssh.git] / channels.c
index 94939239022df3867337d554afc3d14a39c28af0..e8589d8c4d148287f46e3cab4c850f12eb8ede39 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: channels.c,v 1.299 2009/11/11 21:37:03 markus Exp $ */
+/* $OpenBSD: channels.c,v 1.301 2010/01/11 01:39:46 dtucker Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -163,9 +163,6 @@ static u_int x11_fake_data_len;
 /* AF_UNSPEC or AF_INET or AF_INET6 */
 static int IPv4or6 = AF_UNSPEC;
 
-/* Set the routing domain a.k.a. VRF */
-static int channel_rdomain = -1;
-
 /* helper */
 static void port_open_helper(Channel *c, char *rtype);
 
@@ -1220,6 +1217,35 @@ channel_decode_socks5(Channel *c, fd_set *readset, fd_set *writeset)
        return 1;
 }
 
+Channel *
+channel_connect_stdio_fwd(const char *host_to_connect, u_short port_to_connect)
+{
+       Channel *c;
+       int in, out;
+
+       debug("channel_connect_stdio_fwd %s:%d", host_to_connect,
+           port_to_connect);
+
+       in = dup(STDIN_FILENO);
+       out = dup(STDOUT_FILENO);
+       if (in < 0 || out < 0)
+               fatal("channel_connect_stdio_fwd: dup() in/out failed");
+
+       c = channel_new("stdio-forward", SSH_CHANNEL_OPENING, in, out,
+           -1, CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
+           0, "stdio-forward", /*nonblock*/0);
+
+       c->path = xstrdup(host_to_connect);
+       c->host_port = port_to_connect;
+       c->listening_port = 0;
+       c->force_drain = 1;
+
+       channel_register_fds(c, in, out, -1, 0, 1, 0);
+       port_open_helper(c, "direct-tcpip");
+
+       return c;
+}
+
 /* dynamic port forwarding */
 static void
 channel_pre_dynamic(Channel *c, fd_set *readset, fd_set *writeset)
@@ -2466,12 +2492,6 @@ channel_set_af(int af)
        IPv4or6 = af;
 }
 
-void
-channel_set_rdomain(int rdomain)
-{
-       channel_rdomain = rdomain;
-}
-
 static int
 channel_setup_fwd_listener(int type, const char *listen_addr,
     u_short listen_port, int *allocated_listen_port,
@@ -2580,8 +2600,7 @@ channel_setup_fwd_listener(int type, const char *listen_addr,
                        continue;
                }
                /* Create a port to listen for the host. */
-               sock = socket_rdomain(ai->ai_family, ai->ai_socktype,
-                   ai->ai_protocol, channel_rdomain);
+               sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
                if (sock < 0) {
                        /* this is no error since kernel may not support ipv6 */
                        verbose("socket: %.100s", strerror(errno));
@@ -2922,9 +2941,8 @@ connect_next(struct channel_connect *cctx)
                        error("connect_next: getnameinfo failed");
                        continue;
                }
-               if ((sock = socket_rdomain(cctx->ai->ai_family,
-                   cctx->ai->ai_socktype, cctx->ai->ai_protocol,
-                   channel_rdomain)) == -1) {
+               if ((sock = socket(cctx->ai->ai_family, cctx->ai->ai_socktype,
+                   cctx->ai->ai_protocol)) == -1) {
                        if (cctx->ai->ai_next == NULL)
                                error("socket: %.100s", strerror(errno));
                        else
@@ -3110,8 +3128,8 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost,
                for (ai = aitop; ai; ai = ai->ai_next) {
                        if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
                                continue;
-                       sock = socket_rdomain(ai->ai_family, ai->ai_socktype,
-                           ai->ai_protocol, channel_rdomain);
+                       sock = socket(ai->ai_family, ai->ai_socktype,
+                           ai->ai_protocol);
                        if (sock < 0) {
                                if ((errno != EINVAL) && (errno != EAFNOSUPPORT)) {
                                        error("socket: %.100s", strerror(errno));
@@ -3286,8 +3304,7 @@ x11_connect_display(void)
        }
        for (ai = aitop; ai; ai = ai->ai_next) {
                /* Create a socket. */
-               sock = socket_rdomain(ai->ai_family, ai->ai_socktype,
-                   ai->ai_protocol, channel_rdomain);
+               sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
                if (sock < 0) {
                        debug2("socket: %.100s", strerror(errno));
                        continue;
This page took 0.037398 seconds and 4 git commands to generate.