annotate cli-tcpfwd.c @ 67:86725004a0ea

fake-rfc stuff
author Matt Johnston <matt@ucc.asn.au>
date Thu, 12 Aug 2004 14:39:17 +0000
parents 38c3146aa23d
children b0316ce64e4b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 #include "includes.h"
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 #include "options.h"
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
3 #include "dbutil.h"
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
4 #include "tcpfwd.h"
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 #include "channel.h"
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
6 #include "runopts.h"
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
7 #include "session.h"
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
8 #include "ssh.h"
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
10 static int cli_localtcp(unsigned int listenport, const char* remoteaddr,
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
11 unsigned int remoteport);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
12 static int newtcpforwarded(struct Channel * channel);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
13
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
14 const struct ChanType cli_chan_tcpremote = {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
15 1, /* sepfds */
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
16 "forwarded-tcpip",
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
17 newtcpforwarded,
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
18 NULL,
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
19 NULL,
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
20 NULL
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
21 };
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 static const struct ChanType cli_chan_tcplocal = {
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 1, /* sepfds */
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 "direct-tcpip",
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 NULL,
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 NULL,
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
27 NULL,
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 NULL
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 };
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30
63
dcc43965928f - A nice cleaner structure for tcp (acceptor) forwarding.
Matt Johnston <matt@ucc.asn.au>
parents: 62
diff changeset
31 void setup_localtcp() {
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
33 int ret;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
34
66
38c3146aa23d Some more sanity-checking of args, and just warn and ignore OpenSSH args
Matt Johnston <matt@ucc.asn.au>
parents: 64
diff changeset
35 TRACE(("enter setup_localtcp"));
38c3146aa23d Some more sanity-checking of args, and just warn and ignore OpenSSH args
Matt Johnston <matt@ucc.asn.au>
parents: 64
diff changeset
36
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
37 if (cli_opts.localfwds == NULL) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
38 TRACE(("cli_opts.localfwds == NULL"));
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
39 }
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
40
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
41 while (cli_opts.localfwds != NULL) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
42 ret = cli_localtcp(cli_opts.localfwds->listenport,
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
43 cli_opts.localfwds->connectaddr,
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
44 cli_opts.localfwds->connectport);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
45 if (ret == DROPBEAR_FAILURE) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
46 dropbear_log(LOG_WARNING, "Failed local port forward %d:%s:%d",
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
47 cli_opts.localfwds->listenport,
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
48 cli_opts.localfwds->connectaddr,
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
49 cli_opts.localfwds->connectport);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
50 }
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
51
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
52 cli_opts.localfwds = cli_opts.localfwds->next;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
53 }
66
38c3146aa23d Some more sanity-checking of args, and just warn and ignore OpenSSH args
Matt Johnston <matt@ucc.asn.au>
parents: 64
diff changeset
54 TRACE(("leave setup_localtcp"));
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55
63
dcc43965928f - A nice cleaner structure for tcp (acceptor) forwarding.
Matt Johnston <matt@ucc.asn.au>
parents: 62
diff changeset
56 }
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
57
63
dcc43965928f - A nice cleaner structure for tcp (acceptor) forwarding.
Matt Johnston <matt@ucc.asn.au>
parents: 62
diff changeset
58 static int cli_localtcp(unsigned int listenport, const char* remoteaddr,
dcc43965928f - A nice cleaner structure for tcp (acceptor) forwarding.
Matt Johnston <matt@ucc.asn.au>
parents: 62
diff changeset
59 unsigned int remoteport) {
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
60
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
61 struct TCPListener* tcpinfo = NULL;
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
62 int ret;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
63
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
64 TRACE(("enter cli_localtcp: %d %s %d", listenport, remoteaddr,
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
65 remoteport));
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
66
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
67 tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener*));
63
dcc43965928f - A nice cleaner structure for tcp (acceptor) forwarding.
Matt Johnston <matt@ucc.asn.au>
parents: 62
diff changeset
68 tcpinfo->sendaddr = remoteaddr;
dcc43965928f - A nice cleaner structure for tcp (acceptor) forwarding.
Matt Johnston <matt@ucc.asn.au>
parents: 62
diff changeset
69 tcpinfo->sendport = remoteport;
dcc43965928f - A nice cleaner structure for tcp (acceptor) forwarding.
Matt Johnston <matt@ucc.asn.au>
parents: 62
diff changeset
70 tcpinfo->listenport = listenport;
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
71 tcpinfo->chantype = &cli_chan_tcplocal;
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
72
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
73 ret = listen_tcpfwd(tcpinfo);
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
74
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
75 if (ret == DROPBEAR_FAILURE) {
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
76 m_free(tcpinfo);
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
77 }
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
78 TRACE(("leave cli_localtcp: %d", ret));
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
79 return ret;
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
80 }
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
81
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
82 static void send_msg_global_request_remotetcp(int port) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
83
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
84 TRACE(("enter send_msg_global_request_remotetcp"));
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
85
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
86 CHECKCLEARTOWRITE();
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
87 buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
88 buf_putstring(ses.writepayload, "tcpip-forward", 13);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
89 buf_putbyte(ses.writepayload, 0);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
90 buf_putstring(ses.writepayload, "0.0.0.0", 7); /* TODO: IPv6? */
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
91 buf_putint(ses.writepayload, port);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
92
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
93 encrypt_packet();
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
94
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
95 TRACE(("leave send_msg_global_request_remotetcp"));
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
96 }
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
97
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
98 void setup_remotetcp() {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
99
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
100 struct TCPFwdList * iter = NULL;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
101
66
38c3146aa23d Some more sanity-checking of args, and just warn and ignore OpenSSH args
Matt Johnston <matt@ucc.asn.au>
parents: 64
diff changeset
102 TRACE(("enter setup_remotetcp"));
38c3146aa23d Some more sanity-checking of args, and just warn and ignore OpenSSH args
Matt Johnston <matt@ucc.asn.au>
parents: 64
diff changeset
103
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
104 if (cli_opts.remotefwds == NULL) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
105 TRACE(("cli_opts.remotefwds == NULL"));
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
106 }
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
107
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
108 iter = cli_opts.remotefwds;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
109
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
110 while (iter != NULL) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
111 send_msg_global_request_remotetcp(iter->listenport);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
112 iter = iter->next;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
113 }
66
38c3146aa23d Some more sanity-checking of args, and just warn and ignore OpenSSH args
Matt Johnston <matt@ucc.asn.au>
parents: 64
diff changeset
114 TRACE(("leave setup_remotetcp"));
64
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
115 }
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
116
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
117 static int newtcpforwarded(struct Channel * channel) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
118
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
119 unsigned int origport;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
120 struct TCPFwdList * iter = NULL;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
121 char portstring[NI_MAXSERV];
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
122 int sock;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
123 int ret = DROPBEAR_FAILURE;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
124
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
125 /* We don't care what address they connected to */
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
126 buf_eatstring(ses.payload);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
127
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
128 origport = buf_getint(ses.payload);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
129
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
130 /* Find which port corresponds */
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
131 iter = cli_opts.remotefwds;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
132
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
133 while (iter != NULL) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
134 if (origport == iter->listenport) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
135 break;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
136 }
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
137 iter = iter->next;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
138 }
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
139
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
140 if (iter == NULL) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
141 /* We didn't request forwarding on that port */
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
142 dropbear_log(LOG_INFO, "Server send unrequested port, from port %d",
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
143 origport);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
144 goto out;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
145 }
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
146
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
147 snprintf(portstring, sizeof(portstring), "%d", iter->connectport);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
148 sock = connect_remote(iter->connectaddr, portstring, 1, NULL);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
149 if (sock < 0) {
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
150 TRACE(("leave newtcpdirect: sock failed"));
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
151 goto out;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
152 }
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
153
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
154 ses.maxfd = MAX(ses.maxfd, sock);
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
155
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
156 /* Note that infd is actually the "outgoing" direction on the
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
157 * tcp connection, vice versa for outfd.
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
158 * We don't set outfd, that will get set after the connection's
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
159 * progress succeeds */
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
160 channel->infd = sock;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
161 channel->initconn = 1;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
162
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
163 ret = DROPBEAR_SUCCESS;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
164
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
165 out:
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
166 TRACE(("leave newtcpdirect: ret %d", ret));
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
167 return ret;
efb5e0b335cf TCP forwarding works.
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
168 }