Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 2013 07:12:07 GMT
From:      "Ronald S. Storey" <RonaldSStorey@dayrep.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/183148: [patch] add getaddrinfo(1) tool from NetBSD
Message-ID:  <201310210712.r9L7C7Dq037379@oldred.freebsd.org>
Resent-Message-ID: <201310210720.r9L7K0Yo061528@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         183148
>Category:       bin
>Synopsis:       [patch] add getaddrinfo(1) tool from NetBSD
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 21 07:20:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Ronald S. Storey
>Release:        
>Organization:
Klopfenstein's
>Environment:
>Description:
Add an utility to diagnose getaddrinfo() and nsswitch.conf issues
where drill(1) doesn't help.

>How-To-Repeat:
$ getaddrinfo -c -t stream -s 80 wiki.freebsd.org
canonname wfe0.ysv.freebsd.org
stream inet6 tcp 2001:1900:2254:206a::50:0 80
stream inet tcp 8.8.178.110 80

>Fix:
Before applying the patch

$ export CVSROOT=anoncvs@anoncvs.NetBSD.org:/cvsroot
$ cvs co src/lib/libutil
$ cvs co src/usr.bin/getaddrinfo
$ cp src/lib/libutil/sockaddr_snprintf.c /usr/src/lib/libnetbsd/
$ cp -R src/usr.bin/getaddrinfo /usr/src/usr.bin/
$ svn add /usr/src/lib/libnetbsd/sockaddr_snprintf.c /usr/src/usr.bin/

--- getaddrinfo.1.diff begins here ---
Index: lib/libnetbsd/Makefile
===================================================================
--- lib/libnetbsd/Makefile	(revision 256668)
+++ lib/libnetbsd/Makefile	(working copy)
@@ -6,7 +6,7 @@ LIB=	netbsd
 
 CFLAGS+=	-I${.CURDIR}
 
-SRCS+=	strsuftoll.c util.c util.h
+SRCS+=	sockaddr_snprintf.c strsuftoll.c util.c util.h
 
 INTERNALLIB=
 
Index: lib/libnetbsd/sockaddr_snprintf.c
===================================================================
RCS file: /cvsroot/src/lib/libutil/sockaddr_snprintf.c,v
retrieving revision 1.10
diff -u -p -r1.10 sockaddr_snprintf.c
--- lib/libutil/sockaddr_snprintf.c	7 Jun 2013 17:23:26 -0000	1.10
+++ lib/libnetbsd/sockaddr_snprintf.c	21 Oct 2013 03:32:40 -0000
@@ -29,9 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.10 2013/06/07 17:23:26 christos Exp $");
-#endif /* LIBC_SCCS and not lint */
+__FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
 #include <sys/socket.h>
Index: lib/libnetbsd/util.h
===================================================================
--- lib/libnetbsd/util.h	(revision 256668)
+++ lib/libnetbsd/util.h	(working copy)
@@ -36,6 +36,8 @@
 #include <libutil.h>
 
 char	*flags_to_string(u_long flags, const char *def);
+int	 sockaddr_snprintf(char *, size_t, const char *,
+			   const struct sockaddr *);
 int	 string_to_flags(char **stringp, u_long *setp, u_long *clrp);
 
 #endif	/* _UTIL_H_ */
Index: usr.bin/Makefile
===================================================================
--- usr.bin/Makefile	(revision 256668)
+++ usr.bin/Makefile	(working copy)
@@ -57,6 +57,7 @@ SUBDIR=	alias \
 	ftp \
 	gcore \
 	gencat \
+	getaddrinfo \
 	getconf \
 	getent \
 	getopt \
Index: usr.bin/getaddrinfo/Makefile
===================================================================
RCS file: /cvsroot/src/usr.bin/getaddrinfo/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- usr.bin/getaddrinfo/Makefile	30 Sep 2013 06:19:22 -0000	1.1
+++ usr.bin/getaddrinfo/Makefile	21 Oct 2013 03:37:04 -0000
@@ -1,20 +1,23 @@
 #	$NetBSD: Makefile,v 1.1 2013/09/30 06:19:22 riastradh Exp $
+#	$FreeBSD$
 
 PROG=	getaddrinfo
 
+CFLAGS+=	-I${.CURDIR}/../../lib/libnetbsd
+LIBNETBSDDIR=	${.OBJDIR}/../../lib/libnetbsd
+LIBNETBSD=	${LIBNETBSDDIR}/libnetbsd.a
+DPADD+=		${LIBNETBSD}
+LDADD+=		${LIBNETBSD}
+
 DPADD+=	${LIBUTIL}
 LDADD+=	-lutil
 
-WARNS=	5
-
-SYS_SOCKET_H?=	${NETBSDSRCDIR}/sys/sys/socket.h
+SYS_SOCKET_H?=	${.CURDIR}/../../sys/sys/socket.h
 
-CPPFLAGS+=	-I.
+CFLAGS+=	-I.
 DPSRCS+=	tables.h
 CLEANFILES+=	tables.h
 tables.h: tables.awk ${SYS_SOCKET_H}
-	${_MKTARGET_CREATE}
-	${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET}.tmp \
-	&& mv -f -- ${.TARGET}.tmp ${.TARGET}
+	LC_ALL=C awk -f ${.ALLSRC} > ${.TARGET}
 
 .include <bsd.prog.mk>
Index: usr.bin/getaddrinfo/getaddrinfo.1
===================================================================
RCS file: /cvsroot/src/usr.bin/getaddrinfo/getaddrinfo.1,v
retrieving revision 1.2
diff -u -p -r1.2 getaddrinfo.1
--- usr.bin/getaddrinfo/getaddrinfo.1	30 Sep 2013 08:13:59 -0000	1.2
+++ usr.bin/getaddrinfo/getaddrinfo.1	21 Oct 2013 03:37:04 -0000
@@ -62,7 +62,7 @@ system's
 .Xr nsswitch.conf 5
 configuration, it is not intended to be a general-purpose utility to
 query the DNS; use the
-.Xr dig 1
+.Xr drill 1
 utility for that.
 .Pp
 The following options are available:
@@ -155,7 +155,7 @@ stream inet6 tcp 2001:470:1f05:3d::21 80
 stream inet tcp 199.233.217.249 80
 .Ed
 .Sh SEE ALSO
-.Xr dig 1 ,
+.Xr drill 1 ,
 .Xr getent 1 ,
 .Xr getaddrinfo 3 ,
 .Xr getnameinfo 3 ,
@@ -169,4 +169,6 @@ stream inet tcp 199.233.217.249 80
 The
 .Nm
 command first appeared in
+.Fx 11.0 .
+It was ported from
 .Nx 7.0 .
Index: usr.bin/getaddrinfo/getaddrinfo.c
===================================================================
RCS file: /cvsroot/src/usr.bin/getaddrinfo/getaddrinfo.c,v
retrieving revision 1.1
diff -u -p -r1.1 getaddrinfo.c
--- usr.bin/getaddrinfo/getaddrinfo.c	30 Sep 2013 06:19:22 -0000	1.1
+++ usr.bin/getaddrinfo/getaddrinfo.c	21 Oct 2013 03:37:04 -0000
@@ -30,7 +30,9 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: getaddrinfo.c,v 1.1 2013/09/30 06:19:22 riastradh Exp $");
+__FBSDID("$FreeBSD$");
+
+#include <sys/socket.h>
 
 #include <assert.h>
 #include <err.h>
@@ -39,6 +41,7 @@
 #include <netdb.h>
 #include <stdbool.h>
 #include <stdint.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
Index: usr.bin/getaddrinfo/tables.awk
===================================================================
RCS file: /cvsroot/src/usr.bin/getaddrinfo/tables.awk,v
retrieving revision 1.1
diff -u -p -r1.1 tables.awk
--- usr.bin/getaddrinfo/tables.awk	30 Sep 2013 06:19:22 -0000	1.1
+++ usr.bin/getaddrinfo/tables.awk	21 Oct 2013 03:51:59 -0000
@@ -38,11 +38,11 @@ BEGIN {
 	next
 }
 
-$2 ~ /^AF_[A-Z0-9_]*$/ {
+$2 ~ /^AF_[A-Z0-9_]*$/ && $2 !~ /^AF_MAX$/ {
 	afs[n_afs++] = substr($2, 4)
 }
 
-$2 ~ /^SOCK_[A-Z0-9_]*$/ {
+$2 ~ /^SOCK_[A-Z0-9_]*$/ && $2 !~ /^SOCK_MAXADDRLEN$/ {
 	socktypes[n_socktypes++] = substr($2, 6)
 }
 
--- getaddrinfo.1.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310210712.r9L7C7Dq037379>