comparison tcpfwd-direct.c @ 26:0969767bca0d

snapshot of stuff
author Matt Johnston <matt@ucc.asn.au>
date Mon, 26 Jul 2004 02:44:20 +0000
parents 469950e86d0f
children
comparison
equal deleted inserted replaced
25:e4b6e2d569b2 26:0969767bca0d
25 25
26 unsigned char* desthost = NULL; 26 unsigned char* desthost = NULL;
27 unsigned int destport; 27 unsigned int destport;
28 unsigned char* orighost = NULL; 28 unsigned char* orighost = NULL;
29 unsigned int origport; 29 unsigned int origport;
30 char portstring[6];
30 int sock; 31 int sock;
31 int len; 32 int len;
32 int ret = DROPBEAR_FAILURE; 33 int ret = DROPBEAR_FAILURE;
33 34
34 if (opts.nolocaltcp) { 35 if (opts.nolocaltcp) {
56 if (origport > 65535 || destport > 65535) { 57 if (origport > 65535 || destport > 65535) {
57 TRACE(("leave newtcpdirect: port > 65535")); 58 TRACE(("leave newtcpdirect: port > 65535"));
58 goto out; 59 goto out;
59 } 60 }
60 61
61 sock = newtcp(desthost, destport); 62 snprintf(portstring, sizeof(portstring), "%d", destport);
63 sock = connect_remote(desthost, portstring, 1, NULL);
62 if (sock < 0) { 64 if (sock < 0) {
63 TRACE(("leave newtcpdirect: sock failed")); 65 TRACE(("leave newtcpdirect: sock failed"));
64 goto out; 66 goto out;
65 } 67 }
66 68
84 86
85 /* Initiate a new TCP connection - this is non-blocking, so the socket 87 /* Initiate a new TCP connection - this is non-blocking, so the socket
86 * returned will need to be checked for success when it is first written. 88 * returned will need to be checked for success when it is first written.
87 * Similarities with OpenSSH's connect_to() are not coincidental. 89 * Similarities with OpenSSH's connect_to() are not coincidental.
88 * Returns -1 on failure */ 90 * Returns -1 on failure */
91 #if 0
89 static int newtcp(const char * host, int port) { 92 static int newtcp(const char * host, int port) {
90 93
91 int sock = -1; 94 int sock = -1;
92 char portstring[6]; 95 char portstring[6];
93 struct addrinfo *res = NULL, *ai; 96 struct addrinfo *res = NULL, *ai;
150 } 153 }
151 154
152 setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*)&val, sizeof(val)); 155 setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*)&val, sizeof(val));
153 return sock; 156 return sock;
154 } 157 }
158 #endif
155 #endif /* DISABLE_TCPFWD_DIRECT */ 159 #endif /* DISABLE_TCPFWD_DIRECT */