Mercurial > dropbear
diff 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 |
line wrap: on
line diff
--- a/cli-tcpfwd.c Sun Nov 02 12:01:39 2008 +0000 +++ b/cli-tcpfwd.c Sun Nov 02 12:25:08 2008 +0000 @@ -128,7 +128,7 @@ 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 @@ 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;