svn commit: trunk/busybox: console-tools include libbb networking/u etc...

vda at busybox.net vda at busybox.net
Sun Feb 4 02:41:58 UTC 2007


Author: vda
Date: 2007-02-03 18:41:57 -0800 (Sat, 03 Feb 2007)
New Revision: 17752

Log:
udhcp: use improved gethostbyname replacement from IPv6 code


Modified:
   trunk/busybox/console-tools/setlogcons.c
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/xconnect.c
   trunk/busybox/networking/udhcp/files.c


Changeset:
Modified: trunk/busybox/console-tools/setlogcons.c
===================================================================
--- trunk/busybox/console-tools/setlogcons.c	2007-02-04 02:40:27 UTC (rev 17751)
+++ trunk/busybox/console-tools/setlogcons.c	2007-02-04 02:41:57 UTC (rev 17752)
@@ -11,7 +11,8 @@
 
 #include "busybox.h"
 
-extern int setlogcons_main(int argc, char **argv)
+int setlogcons_main(int argc, char **argv);
+int setlogcons_main(int argc, char **argv)
 {
 	struct {
 		char fn;

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2007-02-04 02:40:27 UTC (rev 17751)
+++ trunk/busybox/include/libbb.h	2007-02-04 02:41:57 UTC (rev 17752)
@@ -319,13 +319,15 @@
  * UNIX socket address being returned, IPX sockaddr etc...
  * On error does bb_error_msg and returns NULL */
 len_and_sockaddr* host2sockaddr(const char *host, int port);
-/* Versions which die on error */
+/* Version which dies on error */
 len_and_sockaddr* xhost2sockaddr(const char *host, int port);
 #if ENABLE_FEATURE_IPV6
 /* Same, useful if you want to force family (e.g. IPv6) */
+len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af);
 len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af);
 #else
-/* [we evaluate af: think about "xhost_and_af2sockaddr(..., af++)"] */
+/* [we evaluate af: think about "host_and_af2sockaddr(..., af++)"] */
+#define host_and_af2sockaddr(host, port, af) ((void)(af), host2sockaddr((host), (port)))
 #define xhost_and_af2sockaddr(host, port, af) ((void)(af), xhost2sockaddr((host), (port)))
 #endif
 /* Assign sin[6]_port member if the socket is of corresponding type,
@@ -346,6 +348,8 @@
 // "old" (ipv4 only) API
 // users: traceroute.c hostname.c
 struct hostent *xgethostbyname(const char *name);
+// Also inetd.c and inetd.c are using gethostbyname(),
+// + inet_common.c has additional IPv4-only stuff
 
 
 extern char *xstrdup(const char *s);

Modified: trunk/busybox/libbb/xconnect.c
===================================================================
--- trunk/busybox/libbb/xconnect.c	2007-02-04 02:40:27 UTC (rev 17751)
+++ trunk/busybox/libbb/xconnect.c	2007-02-04 02:41:57 UTC (rev 17752)
@@ -182,6 +182,11 @@
 #endif
 
 #if ENABLE_FEATURE_IPV6
+len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af)
+{
+	return str2sockaddr(host, port, af, 0);
+}
+
 len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af)
 {
 	return str2sockaddr(host, port, af, DIE_ON_ERROR);

Modified: trunk/busybox/networking/udhcp/files.c
===================================================================
--- trunk/busybox/networking/udhcp/files.c	2007-02-04 02:40:27 UTC (rev 17751)
+++ trunk/busybox/networking/udhcp/files.c	2007-02-04 02:41:57 UTC (rev 17752)
@@ -21,15 +21,14 @@
 /* on these functions, make sure you datatype matches */
 static int read_ip(const char *line, void *arg)
 {
-	struct in_addr *addr = arg;
-	struct hostent *host;
-	int retval = 1;
+	len_and_sockaddr *lsa;
+	int retval = 0;
 
-	if (!inet_aton(line, addr)) {
-		host = gethostbyname(line);
-		if (host)
-			addr->s_addr = *((unsigned long *) host->h_addr_list[0]);
-		else retval = 0;
+	lsa = host_and_af2sockaddr(line, 0, AF_INET);
+	if (lsa) {
+		*(struct in_addr*)arg = lsa->sin.sin_addr;
+		free(lsa);
+		retval = 1;
 	}
 	return retval;
 }




More information about the busybox-cvs mailing list