comparison cli-tcpfwd.c @ 505:805e557fdff7

Report errors if a remote request fails
author Matt Johnston <matt@ucc.asn.au>
date Sun, 02 Nov 2008 12:25:08 +0000
parents c049490e43fe
children c3f2ec71e3d4 69e98c45db7c
comparison
equal deleted inserted replaced
504:950c38b854a1 505:805e557fdff7
126 TRACE(("enter send_msg_global_request_remotetcp")) 126 TRACE(("enter send_msg_global_request_remotetcp"))
127 127
128 CHECKCLEARTOWRITE(); 128 CHECKCLEARTOWRITE();
129 buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST); 129 buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST);
130 buf_putstring(ses.writepayload, "tcpip-forward", 13); 130 buf_putstring(ses.writepayload, "tcpip-forward", 13);
131 buf_putbyte(ses.writepayload, 0); 131 buf_putbyte(ses.writepayload, 1); /* want_reply */
132 if (opts.listen_fwd_all) { 132 if (opts.listen_fwd_all) {
133 listenspec = ""; 133 listenspec = "";
134 } else { 134 } else {
135 listenspec = "localhost"; 135 listenspec = "localhost";
136 } 136 }
139 buf_putint(ses.writepayload, port); 139 buf_putint(ses.writepayload, port);
140 140
141 encrypt_packet(); 141 encrypt_packet();
142 142
143 TRACE(("leave send_msg_global_request_remotetcp")) 143 TRACE(("leave send_msg_global_request_remotetcp"))
144 }
145
146 /* The only global success/failure messages are for remotetcp.
147 * Since there isn't any identifier in these messages, we have to rely on them
148 * being in the same order as we sent the requests. This is the ordering
149 * of the cli_opts.remotefwds list */
150 void cli_recv_msg_request_success() {
151
152 /* Nothing in the packet. We just mark off that we have received the reply,
153 * so that we can report failure for later ones. */
154 struct TCPFwdList * iter = NULL;
155
156 iter = cli_opts.remotefwds;
157 while (iter != NULL) {
158 if (!iter->have_reply)
159 {
160 iter->have_reply = 1;
161 return;
162 }
163 iter = iter->next;
164 }
165 }
166
167 void cli_recv_msg_request_failure() {
168 struct TCPFwdList * iter = NULL;
169
170 iter = cli_opts.remotefwds;
171 while (iter != NULL) {
172 if (!iter->have_reply)
173 {
174 iter->have_reply = 1;
175 dropbear_log(LOG_WARNING, "Remote TCP forward request failed (port %d -> %s:%d)", iter->listenport, iter->connectaddr, iter->connectport);
176 return;
177 }
178 iter = iter->next;
179 }
144 } 180 }
145 181
146 void setup_remotetcp() { 182 void setup_remotetcp() {
147 183
148 struct TCPFwdList * iter = NULL; 184 struct TCPFwdList * iter = NULL;