diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-22 17:42:06 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-22 17:42:06 +0000 |
commit | adbf0f34138366d2cd4209ce690f27ec278604de (patch) | |
tree | 4eeb99add58df59c1462600eaaddd768283febe3 /libbb | |
parent | 35411e5e3a0b97f0d578301b2f168fe5e5f0f3df (diff) | |
download | busybox-w32-adbf0f34138366d2cd4209ce690f27ec278604de.tar.gz busybox-w32-adbf0f34138366d2cd4209ce690f27ec278604de.tar.bz2 busybox-w32-adbf0f34138366d2cd4209ce690f27ec278604de.zip |
fix double merge
git-svn-id: svn://busybox.net/trunk/busybox@16628 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/xconnect.c | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index cf1f9d59a..9f95e38f8 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -121,82 +121,6 @@ int create_and_bind_socket_ip4or6(const char *hostaddr, int port) | |||
121 | sockaddr_inet sa; | 121 | sockaddr_inet sa; |
122 | 122 | ||
123 | memset(&sa, 0, sizeof(sa)); | 123 | memset(&sa, 0, sizeof(sa)); |
124 | if (hostaddr && dotted2sockaddr(hostaddr, &sa.sa, sizeof(sa))) | ||
125 | bb_show_usage(); | ||
126 | |||
127 | if (!sa.sa.sa_family) | ||
128 | fd = xsocket_stream_ip4or6(&sa.sa.sa_family); | ||
129 | else /* user specified bind addr dictates family */ | ||
130 | fd = xsocket(sa.sa.sa_family, SOCK_STREAM, 0); | ||
131 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); | ||
132 | |||
133 | /* if (port >= 0) { */ | ||
134 | #if ENABLE_FEATURE_IPV6 | ||
135 | if (sa.sa.sa_family == AF_INET6 /* && !sa.sin6.sin6_port */) | ||
136 | sa.sin6.sin6_port = htons(port); | ||
137 | #endif | ||
138 | if (sa.sa.sa_family == AF_INET /* && !sa.sin.sin_port */) | ||
139 | sa.sin.sin_port = htons(port); | ||
140 | /* } */ | ||
141 | |||
142 | xbind(fd, &sa.sa, sizeof(sa)); | ||
143 | return fd; | ||
144 | } | ||
145 | |||
146 | int dotted2sockaddr(const char *dotted, struct sockaddr* sp, int socklen) | ||
147 | { | ||
148 | union { | ||
149 | struct in_addr a4; | ||
150 | #if ENABLE_FEATURE_IPV6 | ||
151 | struct in6_addr a6; | ||
152 | #endif | ||
153 | } a; | ||
154 | |||
155 | /* TODO maybe: port spec? like n.n.n.n:nn */ | ||
156 | |||
157 | #if ENABLE_FEATURE_IPV6 | ||
158 | if (socklen >= sizeof(struct sockaddr_in6) | ||
159 | && inet_pton(AF_INET6, dotted, &a.a6) > 0 | ||
160 | ) { | ||
161 | ((struct sockaddr_in6*)sp)->sin6_family = AF_INET6; | ||
162 | ((struct sockaddr_in6*)sp)->sin6_addr = a.a6; | ||
163 | /* ((struct sockaddr_in6*)sp)->sin6_port = */ | ||
164 | return 0; /* success */ | ||
165 | } | ||
166 | #endif | ||
167 | if (socklen >= sizeof(struct sockaddr_in) | ||
168 | && inet_pton(AF_INET, dotted, &a.a4) > 0 | ||
169 | ) { | ||
170 | ((struct sockaddr_in*)sp)->sin_family = AF_INET; | ||
171 | ((struct sockaddr_in*)sp)->sin_addr = a.a4; | ||
172 | /* ((struct sockaddr_in*)sp)->sin_port = */ | ||
173 | return 0; /* success */ | ||
174 | } | ||
175 | return 1; | ||
176 | } | ||
177 | |||
178 | int xsocket_stream_ip4or6(sa_family_t *fp) | ||
179 | { | ||
180 | int fd; | ||
181 | #if ENABLE_FEATURE_IPV6 | ||
182 | fd = socket(AF_INET6, SOCK_STREAM, 0); | ||
183 | if (fp) *fp = AF_INET6; | ||
184 | if (fd < 0) | ||
185 | #endif | ||
186 | { | ||
187 | fd = xsocket(AF_INET, SOCK_STREAM, 0); | ||
188 | if (fp) *fp = AF_INET; | ||
189 | } | ||
190 | return fd; | ||
191 | } | ||
192 | |||
193 | int create_and_bind_socket_ip4or6(const char *hostaddr, int port) | ||
194 | { | ||
195 | static const int on = 1; | ||
196 | int fd; | ||
197 | sockaddr_inet sa; | ||
198 | |||
199 | memset(&sa, 0, sizeof(sa)); | ||
200 | if (hostaddr) { | 124 | if (hostaddr) { |
201 | if (dotted2sockaddr(hostaddr, &sa.sa, sizeof(sa))) | 125 | if (dotted2sockaddr(hostaddr, &sa.sa, sizeof(sa))) |
202 | bb_error_msg_and_die("bad address '%s'", hostaddr); | 126 | bb_error_msg_and_die("bad address '%s'", hostaddr); |