[Git][NTPsec/ntpsec][master] 2 commits: Simopify intercept_sendpkt() by using socktoa().

Eric S. Raymond gitlab at mg.gitlab.com
Wed Dec 2 19:13:11 UTC 2015


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


Commits:
2e1d5628 by Eric S. Raymond at 2015-12-02T08:07:29Z
Simopify intercept_sendpkt() by using socktoa().

- - - - -
bee0a60c by Eric S. Raymond at 2015-12-02T14:12:45Z
Add a link to Mills on Mills-speak.

- - - - -


2 changed files:

- docs/ntpspeak.txt
- ntpd/ntp_intercept.c


Changes:

=====================================
docs/ntpspeak.txt
=====================================
--- a/docs/ntpspeak.txt
+++ b/docs/ntpspeak.txt
@@ -126,7 +126,10 @@ Mills-speak::
    wrote in a vivid and idiosyncratic style which is still preserved in
    much of NTP's documentation.  He coined many neologisms which
    connoisseurs refer to as "Mills-speak"; examples in this glossary
-   include <<falseticker>>, <<proventic>>, and <<truechimer>>.
+   include <<falseticker>>, <<proventic>>, and <<truechimer>>.  The
+   close-to-definitive reference is
+   http://lists.ntp.org/pipermail/questions/2007-December/016592.html[The
+   NTP dictionary], though not all those terms are still in use.
 
 [[NIST]]
 NIST::


=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -327,30 +327,20 @@ void intercept_sendpkt(const char *legend,
 	sendpkt(dest, ep, ttl, pkt, len);
 
     if (mode != none) {
-	char host[BUFSIZ], serv[BUFSIZ];
-	/* sanity check: serv should always be "ntp" */
-	int status = getnameinfo(&dest->sa, SOCKLEN(dest),
-				 host, sizeof(host),
-				 serv, sizeof(serv),
-				 NI_NUMERICSERV);
-	if (status != 0)
-	    fprintf(stderr, "ntpd: getnameinfo() failed in intercept_sendpkt()\n");
-	else {
-	    size_t i;
-	    printf("event sendpkt \"%s\" %s %s %d:%d:%d:%d:%u:%u:%u:%d:%d:%d:%d",
-		   legend, host, serv,
-		   pkt->li_vn_mode, pkt->stratum, pkt->ppoll, pkt->precision,
-		   /* FIXME: might be better to dump these in fixed-point */
-		   pkt->rootdelay, pkt->rootdisp,
-		   pkt->refid,
-		   /* FIXME: might be better to dump last 4 in fixed-point */
-		   pkt->reftime.l_uf, pkt->org.l_uf,
-		   pkt->rec.l_uf, pkt->xmt.l_uf);
-	    /* dump MAC as len - LEN_PKT_NOMAC chars in hex */
-	    for (i = 0; i < len - LEN_PKT_NOMAC; i++)
-		printf("%02x", pkt->exten[i]);
-	    fputs("\n", stdout);
-	}
+	size_t i;
+	printf("event sendpkt \"%s\" %s %d:%d:%d:%d:%u:%u:%u:%d:%d:%d:%d",
+	       legend, socktoa(dest),
+	       pkt->li_vn_mode, pkt->stratum, pkt->ppoll, pkt->precision,
+	       /* FIXME: might be better to dump these in fixed-point */
+	       pkt->rootdelay, pkt->rootdisp,
+	       pkt->refid,
+	       /* FIXME: might be better to dump last 4 in fixed-point */
+	       pkt->reftime.l_uf, pkt->org.l_uf,
+	       pkt->rec.l_uf, pkt->xmt.l_uf);
+	/* dump MAC as len - LEN_PKT_NOMAC chars in hex */
+	for (i = 0; i < len - LEN_PKT_NOMAC; i++)
+	    printf("%02x", pkt->exten[i]);
+	fputs("\n", stdout);
     }
 
     /* FIXME: replay logic goes here */



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/dad92dab379a5e756244c85bdb8d615429586029...bee0a60cc7558e8fc979534618a0cd7204e2deb1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151202/97e5ee83/attachment.html>


More information about the vc mailing list