[Git][NTPsec/ntpsec][master] Removing dead code: socktohost().

Eric S. Raymond gitlab at mg.gitlab.com
Thu Nov 10 04:44:37 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
a0d515bf by Eric S. Raymond at 2016-11-09T23:44:02-05:00
Removing dead code: socktohost().

- - - - -


3 changed files:

- include/ntp_stdlib.h
- − libntp/socktohost.c
- libntp/wscript


Changes:

=====================================
include/ntp_stdlib.h
=====================================
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -157,7 +157,6 @@ extern	const char * socktoa	(const sockaddr_u *);
 extern	const char * sockporttoa(const sockaddr_u *);
 extern	unsigned short	sock_hash	(const sockaddr_u *);
 extern	int	sockaddr_masktoprefixlen(const sockaddr_u *);
-extern	const char * socktohost	(const sockaddr_u *);
 extern	bool	octtoint	(const char *, unsigned long *);
 extern	unsigned long	ranp2		(int);
 extern	const char *refid_str	(uint32_t, int);


=====================================
libntp/socktohost.c deleted
=====================================
--- a/libntp/socktohost.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * socktoa - return a numeric host name from a sockaddr_storage structure
- */
-#include <config.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <arpa/inet.h>
-
-#include <stdio.h>
-
-#include "ntp_fp.h"
-#include "lib_strbuf.h"
-#include "ntp_stdlib.h"
-#include "ntp.h"
-#include "ntp_debug.h"
-
-
-const char *
-socktohost(
-	const sockaddr_u *sock
-	)
-{
-	const char		svc[] = "ntp";
-	char *			pbuf;
-	char *			pliar;
-	int			gni_flags;
-	struct addrinfo		hints;
-	struct addrinfo *	alist;
-	struct addrinfo *	ai;
-	sockaddr_u		addr;
-	size_t			octets;
-	int			a_info;
-
-	/* reverse the address to purported DNS name */
-	LIB_GETBUF(pbuf);
-	gni_flags = NI_DGRAM | NI_NAMEREQD;
-	if (getnameinfo(&sock->sa, SOCKLEN(sock), pbuf, LIB_BUFLENGTH,
-			NULL, 0, gni_flags))
-		return socktoa(sock);	/* use address */
-
-	TRACE(1, ("%s reversed to %s\n", socktoa(sock), pbuf));
-
-	/*
-	 * Resolve the reversed name and make sure the reversed address
-	 * is among the results.
-	 */
-	ZERO(hints);
-	hints.ai_family = AF(sock);
-	hints.ai_protocol = IPPROTO_UDP;
-	hints.ai_socktype = SOCK_DGRAM;
-	hints.ai_flags = 0;
-	alist = NULL;
-
-	a_info = getaddrinfo(pbuf, svc, &hints, &alist);
-	if (a_info == EAI_NONAME
-#ifdef EAI_NODATA
-	    || a_info == EAI_NODATA
-#endif
-	   ) {
-		hints.ai_flags = AI_CANONNAME;
-#ifdef AI_ADDRCONFIG
-		hints.ai_flags |= AI_ADDRCONFIG;
-#endif
-		a_info = getaddrinfo(pbuf, svc, &hints, &alist);	
-	}
-#ifdef AI_ADDRCONFIG
-	/* Some older implementations don't like AI_ADDRCONFIG. */
-	if (a_info == EAI_BADFLAGS) {
-		hints.ai_flags &= ~AI_ADDRCONFIG;
-		a_info = getaddrinfo(pbuf, svc, &hints, &alist);	
-	}
-#endif
-	if (a_info)
-		goto forward_fail;
-
-	NTP_INSIST(alist != NULL);
-
-	for (ai = alist; ai != NULL; ai = ai->ai_next) {
-		/*
-		 * Make a convenience sockaddr_u copy from ai->ai_addr
-		 * because casting from sockaddr * to sockaddr_u * is
-		 * risking alignment problems on platforms where
-		 * sockaddr_u has stricter alignment than sockaddr,
-		 * such as sparc.
-		 */
-		ZERO_SOCK(&addr);
-		octets = min(sizeof(addr), ai->ai_addrlen);
-		memcpy(&addr, ai->ai_addr, octets);
-		if (SOCK_EQ(sock, &addr))
-			break;
-	}
-	freeaddrinfo(alist);
-
-	if (ai != NULL)
-		return pbuf;	/* forward check passed */
-
-    forward_fail:
-	TRACE(1, ("%s forward check lookup fail: %s\n", pbuf,
-		  gai_strerror(a_info)));
-	LIB_GETBUF(pliar);
-	snprintf(pliar, LIB_BUFLENGTH, "%s (%s)", socktoa(sock), pbuf);
-
-	return pliar;
-}


=====================================
libntp/wscript
=====================================
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -30,7 +30,6 @@ def build(ctx):
 		"refidsmear.c",
 		"socket.c",
 		"socktoa.c",
-		"socktohost.c",
 		"ssl_init.c",
 		"strl_obsd.c",
 		"syssignal.c",



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a0d515bfa8efc184029faf7eb789ce6e4d3a5062
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161110/8a495159/attachment.html>


More information about the vc mailing list