diff --git a/cli-tcpfwd.c b/cli-tcpfwd.c
index d8f1da61b2f403f7a7f11ea8a1ce4dc57c70bc8b..c3bfd4dc4a88540f4b3d2739578df97c28838bdd 100644
--- a/cli-tcpfwd.c
+++ b/cli-tcpfwd.c
@@ -107,6 +107,7 @@ static int cli_localtcp(unsigned int listenport, const char* remoteaddr,
 	tcpinfo->listenport = listenport;
 
 	tcpinfo->chantype = &cli_chan_tcplocal;
+	tcpinfo->tcp_type = direct;
 
 	ret = listen_tcpfwd(tcpinfo);
 
diff --git a/svr-tcpfwd.c b/svr-tcpfwd.c
index 6e70d676ed1d92a5595f54ca55fb974195fc3a28..53a115ed23dffd74358af96f7ce62121b6a9b764 100644
--- a/svr-tcpfwd.c
+++ b/svr-tcpfwd.c
@@ -208,6 +208,7 @@ static int svr_remotetcpreq() {
 	tcpinfo->listenaddr = bindaddr;
 	tcpinfo->listenport = port;
 	tcpinfo->chantype = &svr_chan_tcpremote;
+	tcpinfo->tcp_type = forwarded;
 
 	ret = listen_tcpfwd(tcpinfo);
 
diff --git a/tcp-accept.c b/tcp-accept.c
index ac335668132438e3667e4919d925d28a61cdb7b5..90d72b3b3d1531010ca5224b659e82cc40727e8b 100644
--- a/tcp-accept.c
+++ b/tcp-accept.c
@@ -65,15 +65,28 @@ static void tcp_acceptor(struct Listener *listener, int sock) {
 	}
 
 	if (send_msg_channel_open_init(fd, tcpinfo->chantype) == DROPBEAR_SUCCESS) {
-
-		// 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
+		unsigned char* addr = NULL;
+		unsigned int port = 0;
+
+		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 --git a/tcpfwd.h b/tcpfwd.h
index e980ee28640eef59f4ab6bc63b04d4f101732e27..28af02987dbef16957ad18fe3008c676e6e8312a 100644
--- a/tcpfwd.h
+++ b/tcpfwd.h
@@ -40,7 +40,7 @@ struct TCPListener {
 	unsigned int listenport;
 
 	const struct ChanType *chantype;
-
+	enum {direct, forwarded} tcp_type;
 };
 
 /* A link in a list of forwards */