# HG changeset patch # User Matt Johnston # Date 1133887915 0 # Node ID c049490e43fe13bcd44995543f2fb40b42b21adf # Parent 306499676384bac275a1a20d2ffe5d8cfc4daafb * fix -L forwarding on the client, broke last rev diff -r 306499676384 -r c049490e43fe cli-tcpfwd.c --- a/cli-tcpfwd.c Sun Dec 04 16:13:11 2005 +0000 +++ b/cli-tcpfwd.c Tue Dec 06 16:51:55 2005 +0000 @@ -107,6 +107,7 @@ tcpinfo->listenport = listenport; tcpinfo->chantype = &cli_chan_tcplocal; + tcpinfo->tcp_type = direct; ret = listen_tcpfwd(tcpinfo); diff -r 306499676384 -r c049490e43fe svr-tcpfwd.c --- a/svr-tcpfwd.c Sun Dec 04 16:13:11 2005 +0000 +++ b/svr-tcpfwd.c Tue Dec 06 16:51:55 2005 +0000 @@ -208,6 +208,7 @@ tcpinfo->listenaddr = bindaddr; tcpinfo->listenport = port; tcpinfo->chantype = &svr_chan_tcpremote; + tcpinfo->tcp_type = forwarded; ret = listen_tcpfwd(tcpinfo); diff -r 306499676384 -r c049490e43fe tcp-accept.c --- a/tcp-accept.c Sun Dec 04 16:13:11 2005 +0000 +++ b/tcp-accept.c Tue Dec 06 16:51:55 2005 +0000 @@ -65,15 +65,28 @@ } if (send_msg_channel_open_init(fd, tcpinfo->chantype) == DROPBEAR_SUCCESS) { + unsigned char* addr = NULL; + unsigned int port = 0; - // address that was connected - buf_putstring(ses.writepayload, tcpinfo->listenaddr, - strlen(tcpinfo->listenaddr)); - // port that was connected - buf_putint(ses.writepayload, tcpinfo->listenport); - // originator ip + if (tcpinfo->tcp_type == direct) { + /* "direct-tcpip" */ + /* host to connect, port to connect */ + addr = tcpinfo->sendaddr; + port = tcpinfo->sendport; + } else { + dropbear_assert(tcpinfo->tcp_type == forwarded); + /* "forwarded-tcpip" */ + /* address that was connected, port that was connected */ + addr = tcpinfo->listenaddr; + port = tcpinfo->listenport; + } + + buf_putstring(ses.writepayload, addr, strlen(addr)); + buf_putint(ses.writepayload, port); + + /* originator ip */ buf_putstring(ses.writepayload, ipstring, strlen(ipstring)); - // originator port + /* originator port */ buf_putint(ses.writepayload, atol(portstring)); encrypt_packet(); diff -r 306499676384 -r c049490e43fe tcpfwd.h --- a/tcpfwd.h Sun Dec 04 16:13:11 2005 +0000 +++ b/tcpfwd.h Tue Dec 06 16:51:55 2005 +0000 @@ -40,7 +40,7 @@ unsigned int listenport; const struct ChanType *chantype; - + enum {direct, forwarded} tcp_type; }; /* A link in a list of forwards */