summaryrefslogtreecommitdiffhomepage
path: root/tcp-accept.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2005-12-06 16:51:55 +0000
committerMatt Johnston <matt@ucc.asn.au>2005-12-06 16:51:55 +0000
commit6c56271e8c2f1a07de8ca7fddeb4f8efb5041b4c (patch)
treedc6bece4692049393b3d3ffd4990629c2c502ff5 /tcp-accept.c
parenta673d609639b180eee3a4ba49d7f07d0239ea666 (diff)
* fix -L forwarding on the client, broke last rev
--HG-- extra : convert_revision : 826db75f8001f7da7b0b8c91dcf66a44bf107b49
Diffstat (limited to 'tcp-accept.c')
-rw-r--r--tcp-accept.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/tcp-accept.c b/tcp-accept.c
index ac33566..90d72b3 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();