Mercurial > dropbear
comparison cli-tcpfwd.c @ 165:0cfba3034be5
Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 02 Jan 2005 20:25:56 +0000 |
parents | 8c2b3506f112 |
children | ca55377e4f7e |
comparison
equal
deleted
inserted
replaced
161:b9d3f725e00b | 165:0cfba3034be5 |
---|---|
60 #ifdef ENABLE_CLI_LOCALTCPFWD | 60 #ifdef ENABLE_CLI_LOCALTCPFWD |
61 void setup_localtcp() { | 61 void setup_localtcp() { |
62 | 62 |
63 int ret; | 63 int ret; |
64 | 64 |
65 TRACE(("enter setup_localtcp")); | 65 TRACE(("enter setup_localtcp")) |
66 | 66 |
67 if (cli_opts.localfwds == NULL) { | 67 if (cli_opts.localfwds == NULL) { |
68 TRACE(("cli_opts.localfwds == NULL")); | 68 TRACE(("cli_opts.localfwds == NULL")) |
69 } | 69 } |
70 | 70 |
71 while (cli_opts.localfwds != NULL) { | 71 while (cli_opts.localfwds != NULL) { |
72 ret = cli_localtcp(cli_opts.localfwds->listenport, | 72 ret = cli_localtcp(cli_opts.localfwds->listenport, |
73 cli_opts.localfwds->connectaddr, | 73 cli_opts.localfwds->connectaddr, |
79 cli_opts.localfwds->connectport); | 79 cli_opts.localfwds->connectport); |
80 } | 80 } |
81 | 81 |
82 cli_opts.localfwds = cli_opts.localfwds->next; | 82 cli_opts.localfwds = cli_opts.localfwds->next; |
83 } | 83 } |
84 TRACE(("leave setup_localtcp")); | 84 TRACE(("leave setup_localtcp")) |
85 | 85 |
86 } | 86 } |
87 | 87 |
88 static int cli_localtcp(unsigned int listenport, const char* remoteaddr, | 88 static int cli_localtcp(unsigned int listenport, const char* remoteaddr, |
89 unsigned int remoteport) { | 89 unsigned int remoteport) { |
103 ret = listen_tcpfwd(tcpinfo); | 103 ret = listen_tcpfwd(tcpinfo); |
104 | 104 |
105 if (ret == DROPBEAR_FAILURE) { | 105 if (ret == DROPBEAR_FAILURE) { |
106 m_free(tcpinfo); | 106 m_free(tcpinfo); |
107 } | 107 } |
108 TRACE(("leave cli_localtcp: %d", ret)); | 108 TRACE(("leave cli_localtcp: %d", ret)) |
109 return ret; | 109 return ret; |
110 } | 110 } |
111 #endif /* ENABLE_CLI_LOCALTCPFWD */ | 111 #endif /* ENABLE_CLI_LOCALTCPFWD */ |
112 | 112 |
113 #ifdef ENABLE_CLI_REMOTETCPFWD | 113 #ifdef ENABLE_CLI_REMOTETCPFWD |
114 static void send_msg_global_request_remotetcp(int port) { | 114 static void send_msg_global_request_remotetcp(int port) { |
115 | 115 |
116 TRACE(("enter send_msg_global_request_remotetcp")); | 116 TRACE(("enter send_msg_global_request_remotetcp")) |
117 | 117 |
118 CHECKCLEARTOWRITE(); | 118 CHECKCLEARTOWRITE(); |
119 buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST); | 119 buf_putbyte(ses.writepayload, SSH_MSG_GLOBAL_REQUEST); |
120 buf_putstring(ses.writepayload, "tcpip-forward", 13); | 120 buf_putstring(ses.writepayload, "tcpip-forward", 13); |
121 buf_putbyte(ses.writepayload, 0); | 121 buf_putbyte(ses.writepayload, 0); |
122 buf_putstring(ses.writepayload, "0.0.0.0", 7); /* TODO: IPv6? */ | 122 buf_putstring(ses.writepayload, "0.0.0.0", 7); /* TODO: IPv6? */ |
123 buf_putint(ses.writepayload, port); | 123 buf_putint(ses.writepayload, port); |
124 | 124 |
125 encrypt_packet(); | 125 encrypt_packet(); |
126 | 126 |
127 TRACE(("leave send_msg_global_request_remotetcp")); | 127 TRACE(("leave send_msg_global_request_remotetcp")) |
128 } | 128 } |
129 | 129 |
130 void setup_remotetcp() { | 130 void setup_remotetcp() { |
131 | 131 |
132 struct TCPFwdList * iter = NULL; | 132 struct TCPFwdList * iter = NULL; |
133 | 133 |
134 TRACE(("enter setup_remotetcp")); | 134 TRACE(("enter setup_remotetcp")) |
135 | 135 |
136 if (cli_opts.remotefwds == NULL) { | 136 if (cli_opts.remotefwds == NULL) { |
137 TRACE(("cli_opts.remotefwds == NULL")); | 137 TRACE(("cli_opts.remotefwds == NULL")) |
138 } | 138 } |
139 | 139 |
140 iter = cli_opts.remotefwds; | 140 iter = cli_opts.remotefwds; |
141 | 141 |
142 while (iter != NULL) { | 142 while (iter != NULL) { |
143 send_msg_global_request_remotetcp(iter->listenport); | 143 send_msg_global_request_remotetcp(iter->listenport); |
144 iter = iter->next; | 144 iter = iter->next; |
145 } | 145 } |
146 TRACE(("leave setup_remotetcp")); | 146 TRACE(("leave setup_remotetcp")) |
147 } | 147 } |
148 | 148 |
149 static int newtcpforwarded(struct Channel * channel) { | 149 static int newtcpforwarded(struct Channel * channel) { |
150 | 150 |
151 unsigned int origport; | 151 unsigned int origport; |
177 } | 177 } |
178 | 178 |
179 snprintf(portstring, sizeof(portstring), "%d", iter->connectport); | 179 snprintf(portstring, sizeof(portstring), "%d", iter->connectport); |
180 sock = connect_remote(iter->connectaddr, portstring, 1, NULL); | 180 sock = connect_remote(iter->connectaddr, portstring, 1, NULL); |
181 if (sock < 0) { | 181 if (sock < 0) { |
182 TRACE(("leave newtcpdirect: sock failed")); | 182 TRACE(("leave newtcpdirect: sock failed")) |
183 err = SSH_OPEN_CONNECT_FAILED; | 183 err = SSH_OPEN_CONNECT_FAILED; |
184 goto out; | 184 goto out; |
185 } | 185 } |
186 | 186 |
187 ses.maxfd = MAX(ses.maxfd, sock); | 187 ses.maxfd = MAX(ses.maxfd, sock); |
194 channel->initconn = 1; | 194 channel->initconn = 1; |
195 | 195 |
196 err = SSH_OPEN_IN_PROGRESS; | 196 err = SSH_OPEN_IN_PROGRESS; |
197 | 197 |
198 out: | 198 out: |
199 TRACE(("leave newtcpdirect: err %d", err)); | 199 TRACE(("leave newtcpdirect: err %d", err)) |
200 return err; | 200 return err; |
201 } | 201 } |
202 #endif /* ENABLE_CLI_REMOTETCPFWD */ | 202 #endif /* ENABLE_CLI_REMOTETCPFWD */ |