comparison cli-tcpfwd.c @ 297:79bf1023cf11 agent-client

propagate from branch 'au.asn.ucc.matt.dropbear' (head 0501e6f661b5415eb76f3b312d183c3adfbfb712) to branch 'au.asn.ucc.matt.dropbear.cli-agent' (head 01038174ec27245b51bd43a66c01ad930880f67b)
author Matt Johnston <matt@ucc.asn.au>
date Tue, 21 Mar 2006 16:20:59 +0000
parents c049490e43fe
children 805e557fdff7
comparison
equal deleted inserted replaced
225:ca7e76d981d9 297:79bf1023cf11
93 93
94 TRACE(("enter cli_localtcp: %d %s %d", listenport, remoteaddr, 94 TRACE(("enter cli_localtcp: %d %s %d", listenport, remoteaddr,
95 remoteport)); 95 remoteport));
96 96
97 tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener)); 97 tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener));
98
98 tcpinfo->sendaddr = m_strdup(remoteaddr); 99 tcpinfo->sendaddr = m_strdup(remoteaddr);
99 tcpinfo->sendport = remoteport; 100 tcpinfo->sendport = remoteport;
101
102 if (opts.listen_fwd_all) {
103 tcpinfo->listenaddr = m_strdup("");
104 } else {
105 tcpinfo->listenaddr = m_strdup("localhost");
106 }
100 tcpinfo->listenport = listenport; 107 tcpinfo->listenport = listenport;
108
101 tcpinfo->chantype = &cli_chan_tcplocal; 109 tcpinfo->chantype = &cli_chan_tcplocal;
110 tcpinfo->tcp_type = direct;
102 111
103 ret = listen_tcpfwd(tcpinfo); 112 ret = listen_tcpfwd(tcpinfo);
104 113
105 if (ret == DROPBEAR_FAILURE) { 114 if (ret == DROPBEAR_FAILURE) {
106 m_free(tcpinfo); 115 m_free(tcpinfo);
111 #endif /* ENABLE_CLI_LOCALTCPFWD */ 120 #endif /* ENABLE_CLI_LOCALTCPFWD */
112 121
113 #ifdef ENABLE_CLI_REMOTETCPFWD 122 #ifdef ENABLE_CLI_REMOTETCPFWD
114 static void send_msg_global_request_remotetcp(int port) { 123 static void send_msg_global_request_remotetcp(int port) {
115 124
125 char* listenspec = NULL;
116 TRACE(("enter send_msg_global_request_remotetcp")) 126 TRACE(("enter send_msg_global_request_remotetcp"))
117 127
118 CHECKCLEARTOWRITE(); 128 CHECKCLEARTOWRITE();
119 buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST); 129 buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST);
120 buf_putstring(ses.writepayload, "tcpip-forward", 13); 130 buf_putstring(ses.writepayload, "tcpip-forward", 13);
121 buf_putbyte(ses.writepayload, 0); 131 buf_putbyte(ses.writepayload, 0);
122 buf_putstring(ses.writepayload, "0.0.0.0", 7); /* TODO: IPv6? */ 132 if (opts.listen_fwd_all) {
133 listenspec = "";
134 } else {
135 listenspec = "localhost";
136 }
137 /* TODO: IPv6? */;
138 buf_putstring(ses.writepayload, listenspec, strlen(listenspec));
123 buf_putint(ses.writepayload, port); 139 buf_putint(ses.writepayload, port);
124 140
125 encrypt_packet(); 141 encrypt_packet();
126 142
127 TRACE(("leave send_msg_global_request_remotetcp")) 143 TRACE(("leave send_msg_global_request_remotetcp"))
184 goto out; 200 goto out;
185 } 201 }
186 202
187 ses.maxfd = MAX(ses.maxfd, sock); 203 ses.maxfd = MAX(ses.maxfd, sock);
188 204
189 /* Note that infd is actually the "outgoing" direction on the 205 /* We don't set readfd, that will get set after the connection's
190 * tcp connection, vice versa for outfd.
191 * We don't set outfd, that will get set after the connection's
192 * progress succeeds */ 206 * progress succeeds */
193 channel->infd = sock; 207 channel->writefd = sock;
194 channel->initconn = 1; 208 channel->initconn = 1;
195 209
196 err = SSH_OPEN_IN_PROGRESS; 210 err = SSH_OPEN_IN_PROGRESS;
197 211
198 out: 212 out: