diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-04 02:41:57 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-04 02:41:57 +0000 |
commit | e99130340610a09de7581abe5c127c024347bc32 (patch) | |
tree | 85f96b893cc174965b65d8691901da659468ed97 | |
parent | 10944524238532ad35aaefec89cf7cc950745d6b (diff) | |
download | busybox-w32-e99130340610a09de7581abe5c127c024347bc32.tar.gz busybox-w32-e99130340610a09de7581abe5c127c024347bc32.tar.bz2 busybox-w32-e99130340610a09de7581abe5c127c024347bc32.zip |
udhcp: use improved gethostbyname replacement from IPv6 code
-rw-r--r-- | console-tools/setlogcons.c | 3 | ||||
-rw-r--r-- | include/libbb.h | 8 | ||||
-rw-r--r-- | libbb/xconnect.c | 5 | ||||
-rw-r--r-- | networking/udhcp/files.c | 17 |
4 files changed, 21 insertions, 12 deletions
diff --git a/console-tools/setlogcons.c b/console-tools/setlogcons.c index ae15b9b28..7b5addca7 100644 --- a/console-tools/setlogcons.c +++ b/console-tools/setlogcons.c | |||
@@ -11,7 +11,8 @@ | |||
11 | 11 | ||
12 | #include "busybox.h" | 12 | #include "busybox.h" |
13 | 13 | ||
14 | extern int setlogcons_main(int argc, char **argv) | 14 | int setlogcons_main(int argc, char **argv); |
15 | int setlogcons_main(int argc, char **argv) | ||
15 | { | 16 | { |
16 | struct { | 17 | struct { |
17 | char fn; | 18 | char fn; |
diff --git a/include/libbb.h b/include/libbb.h index d22efe05b..7342f89f6 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -319,13 +319,15 @@ int xconnect_stream(const len_and_sockaddr *lsa); | |||
319 | * UNIX socket address being returned, IPX sockaddr etc... | 319 | * UNIX socket address being returned, IPX sockaddr etc... |
320 | * On error does bb_error_msg and returns NULL */ | 320 | * On error does bb_error_msg and returns NULL */ |
321 | len_and_sockaddr* host2sockaddr(const char *host, int port); | 321 | len_and_sockaddr* host2sockaddr(const char *host, int port); |
322 | /* Versions which die on error */ | 322 | /* Version which dies on error */ |
323 | len_and_sockaddr* xhost2sockaddr(const char *host, int port); | 323 | len_and_sockaddr* xhost2sockaddr(const char *host, int port); |
324 | #if ENABLE_FEATURE_IPV6 | 324 | #if ENABLE_FEATURE_IPV6 |
325 | /* Same, useful if you want to force family (e.g. IPv6) */ | 325 | /* Same, useful if you want to force family (e.g. IPv6) */ |
326 | len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af); | ||
326 | len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af); | 327 | len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af); |
327 | #else | 328 | #else |
328 | /* [we evaluate af: think about "xhost_and_af2sockaddr(..., af++)"] */ | 329 | /* [we evaluate af: think about "host_and_af2sockaddr(..., af++)"] */ |
330 | #define host_and_af2sockaddr(host, port, af) ((void)(af), host2sockaddr((host), (port))) | ||
329 | #define xhost_and_af2sockaddr(host, port, af) ((void)(af), xhost2sockaddr((host), (port))) | 331 | #define xhost_and_af2sockaddr(host, port, af) ((void)(af), xhost2sockaddr((host), (port))) |
330 | #endif | 332 | #endif |
331 | /* Assign sin[6]_port member if the socket is of corresponding type, | 333 | /* Assign sin[6]_port member if the socket is of corresponding type, |
@@ -346,6 +348,8 @@ char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa, socklen_t salen) | |||
346 | // "old" (ipv4 only) API | 348 | // "old" (ipv4 only) API |
347 | // users: traceroute.c hostname.c | 349 | // users: traceroute.c hostname.c |
348 | struct hostent *xgethostbyname(const char *name); | 350 | struct hostent *xgethostbyname(const char *name); |
351 | // Also inetd.c and inetd.c are using gethostbyname(), | ||
352 | // + inet_common.c has additional IPv4-only stuff | ||
349 | 353 | ||
350 | 354 | ||
351 | extern char *xstrdup(const char *s); | 355 | extern char *xstrdup(const char *s); |
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index c3ccc470b..22f98dcf2 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -182,6 +182,11 @@ USE_FEATURE_IPV6(sa_family_t af,) | |||
182 | #endif | 182 | #endif |
183 | 183 | ||
184 | #if ENABLE_FEATURE_IPV6 | 184 | #if ENABLE_FEATURE_IPV6 |
185 | len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af) | ||
186 | { | ||
187 | return str2sockaddr(host, port, af, 0); | ||
188 | } | ||
189 | |||
185 | len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af) | 190 | len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af) |
186 | { | 191 | { |
187 | return str2sockaddr(host, port, af, DIE_ON_ERROR); | 192 | return str2sockaddr(host, port, af, DIE_ON_ERROR); |
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index c3ab17de4..e35f50a17 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c | |||
@@ -21,15 +21,14 @@ | |||
21 | /* on these functions, make sure you datatype matches */ | 21 | /* on these functions, make sure you datatype matches */ |
22 | static int read_ip(const char *line, void *arg) | 22 | static int read_ip(const char *line, void *arg) |
23 | { | 23 | { |
24 | struct in_addr *addr = arg; | 24 | len_and_sockaddr *lsa; |
25 | struct hostent *host; | 25 | int retval = 0; |
26 | int retval = 1; | 26 | |
27 | 27 | lsa = host_and_af2sockaddr(line, 0, AF_INET); | |
28 | if (!inet_aton(line, addr)) { | 28 | if (lsa) { |
29 | host = gethostbyname(line); | 29 | *(struct in_addr*)arg = lsa->sin.sin_addr; |
30 | if (host) | 30 | free(lsa); |
31 | addr->s_addr = *((unsigned long *) host->h_addr_list[0]); | 31 | retval = 1; |
32 | else retval = 0; | ||
33 | } | 32 | } |
34 | return retval; | 33 | return retval; |
35 | } | 34 | } |