Mercurial > dropbear
annotate tcpfwd-direct.c @ 60:2ca590852f45
Just a test for merging heads
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 09 Aug 2004 08:08:42 +0000 |
parents | 0969767bca0d |
children |
rev | line source |
---|---|
9
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1 #include "includes.h" |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2 #include "session.h" |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
3 #include "dbutil.h" |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
4 #include "channel.h" |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
5 #include "tcpfwd-direct.h" |
24 | 6 #include "runopts.h" |
9
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
7 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
8 #ifndef DISABLE_TCPFWD_DIRECT |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
9 static int newtcpdirect(struct Channel * channel); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
10 static int newtcp(const char * host, int port); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
11 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
12 const struct ChanType chan_tcpdirect = { |
11
f76c9389e9e0
Mostly done with the listener changeover
Matt Johnston <matt@ucc.asn.au>
parents:
9
diff
changeset
|
13 1, /* sepfds */ |
9
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
14 "direct-tcpip", |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
15 newtcpdirect, /* init */ |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
16 NULL, /* checkclose */ |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
17 NULL, /* reqhandler */ |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
18 NULL /* closehandler */ |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
19 }; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
20 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
21 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
22 /* Called upon creating a new direct tcp channel (ie we connect out to an |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
23 * address */ |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
24 static int newtcpdirect(struct Channel * channel) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
25 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
26 unsigned char* desthost = NULL; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
27 unsigned int destport; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
28 unsigned char* orighost = NULL; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
29 unsigned int origport; |
26 | 30 char portstring[6]; |
9
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
31 int sock; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
32 int len; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
33 int ret = DROPBEAR_FAILURE; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
34 |
24 | 35 if (opts.nolocaltcp) { |
9
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
36 TRACE(("leave newtcpdirect: local tcp forwarding disabled")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
37 goto out; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
38 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
39 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
40 desthost = buf_getstring(ses.payload, &len); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
41 if (len > MAX_HOST_LEN) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
42 TRACE(("leave newtcpdirect: desthost too long")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
43 goto out; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
44 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
45 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
46 destport = buf_getint(ses.payload); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
47 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
48 orighost = buf_getstring(ses.payload, &len); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
49 if (len > MAX_HOST_LEN) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
50 TRACE(("leave newtcpdirect: orighost too long")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
51 goto out; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
52 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
53 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
54 origport = buf_getint(ses.payload); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
55 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
56 /* best be sure */ |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
57 if (origport > 65535 || destport > 65535) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
58 TRACE(("leave newtcpdirect: port > 65535")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
59 goto out; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
60 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
61 |
26 | 62 snprintf(portstring, sizeof(portstring), "%d", destport); |
63 sock = connect_remote(desthost, portstring, 1, NULL); | |
9
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
64 if (sock < 0) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
65 TRACE(("leave newtcpdirect: sock failed")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
66 goto out; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
67 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
68 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
69 ses.maxfd = MAX(ses.maxfd, sock); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
70 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
71 /* Note that infd is actually the "outgoing" direction on the |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
72 * tcp connection, vice versa for outfd. |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
73 * We don't set outfd, that will get set after the connection's |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
74 * progress succeeds */ |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
75 channel->infd = sock; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
76 channel->initconn = 1; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
77 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
78 ret = DROPBEAR_SUCCESS; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
79 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
80 out: |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
81 m_free(desthost); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
82 m_free(orighost); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
83 TRACE(("leave newtcpdirect: ret %d", ret)); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
84 return ret; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
85 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
86 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
87 /* Initiate a new TCP connection - this is non-blocking, so the socket |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
88 * returned will need to be checked for success when it is first written. |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
89 * Similarities with OpenSSH's connect_to() are not coincidental. |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
90 * Returns -1 on failure */ |
26 | 91 #if 0 |
9
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
92 static int newtcp(const char * host, int port) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
93 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
94 int sock = -1; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
95 char portstring[6]; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
96 struct addrinfo *res = NULL, *ai; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
97 int val; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
98 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
99 struct addrinfo hints; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
100 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
101 TRACE(("enter newtcp")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
102 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
103 memset(&hints, 0, sizeof(hints)); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
104 /* TCP, either ip4 or ip6 */ |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
105 hints.ai_socktype = SOCK_STREAM; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
106 hints.ai_family = PF_UNSPEC; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
107 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
108 snprintf(portstring, sizeof(portstring), "%d", port); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
109 if (getaddrinfo(host, portstring, &hints, &res) != 0) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
110 if (res) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
111 freeaddrinfo(res); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
112 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
113 TRACE(("leave newtcp: failed getaddrinfo")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
114 return -1; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
115 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
116 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
117 /* Use the first socket that works */ |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
118 for (ai = res; ai != NULL; ai = ai->ai_next) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
119 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
120 if (ai->ai_family != PF_INET && ai->ai_family != PF_INET6) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
121 continue; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
122 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
123 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
124 sock = socket(ai->ai_family, SOCK_STREAM, 0); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
125 if (sock < 0) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
126 TRACE(("TCP socket() failed")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
127 continue; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
128 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
129 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
130 if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
131 close(sock); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
132 TRACE(("TCP non-blocking failed")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
133 continue; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
134 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
135 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
136 /* non-blocking, so it might return without success (EINPROGRESS) */ |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
137 if (connect(sock, ai->ai_addr, ai->ai_addrlen) < 0) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
138 if (errno == EINPROGRESS) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
139 TRACE(("connect in progress")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
140 } else { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
141 close(sock); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
142 TRACE(("TCP connect failed")); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
143 continue; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
144 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
145 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
146 break; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
147 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
148 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
149 freeaddrinfo(res); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
150 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
151 if (ai == NULL) { |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
152 return -1; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
153 } |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
154 |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
155 setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*)&val, sizeof(val)); |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
156 return sock; |
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
157 } |
26 | 158 #endif |
9
7f77962de998
- Reworked non-channel fd handling to listener.c
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
159 #endif /* DISABLE_TCPFWD_DIRECT */ |