summaryrefslogtreecommitdiff
path: root/cli-tcpfwd.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2008-11-02 12:25:08 +0000
committerMatt Johnston <matt@ucc.asn.au>2008-11-02 12:25:08 +0000
commit3a0a7c65e79deffc9bceec2f946c46d76b80b8bd (patch)
treec93488a101d8b57a5c29335b95fb5ec071644e07 /cli-tcpfwd.c
parent0c81baf08b945251f0dbc7d8ec2adb7060fd261c (diff)
downloaddropbear-3a0a7c65e79deffc9bceec2f946c46d76b80b8bd.tar.gz
Report errors if a remote request fails
Diffstat (limited to 'cli-tcpfwd.c')
-rw-r--r--cli-tcpfwd.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/cli-tcpfwd.c b/cli-tcpfwd.c
index c3bfd4d..0e60090 100644
--- a/cli-tcpfwd.c
+++ b/cli-tcpfwd.c
@@ -128,7 +128,7 @@ static void send_msg_global_request_remotetcp(int port) {
CHECKCLEARTOWRITE();
buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST);
buf_putstring(ses.writepayload, "tcpip-forward", 13);
- buf_putbyte(ses.writepayload, 0);
+ buf_putbyte(ses.writepayload, 1); /* want_reply */
if (opts.listen_fwd_all) {
listenspec = "";
} else {
@@ -143,6 +143,42 @@ static void send_msg_global_request_remotetcp(int port) {
TRACE(("leave send_msg_global_request_remotetcp"))
}
+/* The only global success/failure messages are for remotetcp.
+ * Since there isn't any identifier in these messages, we have to rely on them
+ * being in the same order as we sent the requests. This is the ordering
+ * of the cli_opts.remotefwds list */
+void cli_recv_msg_request_success() {
+
+ /* Nothing in the packet. We just mark off that we have received the reply,
+ * so that we can report failure for later ones. */
+ struct TCPFwdList * iter = NULL;
+
+ iter = cli_opts.remotefwds;
+ while (iter != NULL) {
+ if (!iter->have_reply)
+ {
+ iter->have_reply = 1;
+ return;
+ }
+ iter = iter->next;
+ }
+}
+
+void cli_recv_msg_request_failure() {
+ struct TCPFwdList * iter = NULL;
+
+ iter = cli_opts.remotefwds;
+ while (iter != NULL) {
+ if (!iter->have_reply)
+ {
+ iter->have_reply = 1;
+ dropbear_log(LOG_WARNING, "Remote TCP forward request failed (port %d -> %s:%d)", iter->listenport, iter->connectaddr, iter->connectport);
+ return;
+ }
+ iter = iter->next;
+ }
+}
+
void setup_remotetcp() {
struct TCPFwdList * iter = NULL;