Blame SOURCES/ntp-4.2.6p5-rawstats.patch

063937
commit 63b405a67040ad6545abb102bf0714ccb5a50558
063937
Author:  <murray@pogo.udel.edu>   
063937
Date:   Thu Dec 27 20:09:00 2012 -0500
063937
063937
    ntp_util.c, ntpd.h, ChangeLog, ntp_proto.c:
063937
      Fix for bug 2081
063937
063937
diff -up ntp-4.2.6p5/include/ntpd.h.rawstats ntp-4.2.6p5/include/ntpd.h
063937
--- ntp-4.2.6p5/include/ntpd.h.rawstats	2015-07-22 14:19:37.220167860 +0200
063937
+++ ntp-4.2.6p5/include/ntpd.h	2015-07-22 14:20:52.819392212 +0200
063937
@@ -244,7 +244,7 @@ extern	void	record_peer_stats (sockaddr_
063937
 extern	void	record_proto_stats (char *);
063937
 extern	void	record_loop_stats (double, double, double, double, int);
063937
 extern	void	record_clock_stats (sockaddr_u *, const char *);
063937
-extern	void	record_raw_stats (sockaddr_u *, sockaddr_u *, l_fp *, l_fp *, l_fp *, l_fp *);
063937
+extern	void	record_raw_stats (sockaddr_u *srcadr, sockaddr_u *dstadr, l_fp *t1, l_fp *t2, l_fp *t3, l_fp *t4, int leap, int version, int mode, int stratum, int poll, int precision, double root_delay, double root_dispersion, u_int32 refid);
063937
 extern	u_long	leap_month(u_long);
063937
 extern	void	record_crypto_stats (sockaddr_u *, const char *);
063937
 #ifdef DEBUG
063937
diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.rawstats ntp-4.2.6p5/ntpd/ntp_proto.c
063937
--- ntp-4.2.6p5/ntpd/ntp_proto.c.rawstats	2015-07-22 14:19:37.218167854 +0200
063937
+++ ntp-4.2.6p5/ntpd/ntp_proto.c	2015-07-22 14:19:37.221167862 +0200
063937
@@ -1341,7 +1341,7 @@ process_packet(
063937
 	double	t34, t21;
063937
 	double	p_offset, p_del, p_disp;
063937
 	l_fp	p_rec, p_xmt, p_org, p_reftime, ci;
063937
-	u_char	pmode, pleap, pstratum;
063937
+	u_char	pmode, pleap, pversion, pstratum;
063937
 	char	statstr[NTP_MAXSTRLEN];
063937
 #ifdef ASSYM
063937
 	int	itemp;
063937
@@ -1359,14 +1359,17 @@ process_packet(
063937
 	NTOHL_FP(&pkt->xmt, &p_xmt);
063937
 	pmode = PKT_MODE(pkt->li_vn_mode);
063937
 	pleap = PKT_LEAP(pkt->li_vn_mode);
063937
+	pversion = PKT_VERSION(pkt->li_vn_mode);
063937
 	pstratum = PKT_TO_STRATUM(pkt->stratum);
063937
 
063937
 	/*
063937
 	 * Capture the header values in the client/peer association..
063937
 	 */
063937
 	record_raw_stats(&peer->srcadr, peer->dstadr ?
063937
-	    &peer->dstadr->sin : NULL, &p_org, &p_rec, &p_xmt,
063937
-	    &peer->dst);
063937
+	    &peer->dstadr->sin : NULL,
063937
+	    &p_org, &p_rec, &p_xmt, &peer->dst,
063937
+	    pleap, pversion, pmode, pstratum, pkt->ppoll, pkt->precision,
063937
+	    p_del, p_disp, pkt->refid);
063937
 	peer->leap = pleap;
063937
 	peer->stratum = min(pstratum, STRATUM_UNSPEC);
063937
 	peer->pmode = pmode;
063937
diff -up ntp-4.2.6p5/ntpd/ntp_util.c.rawstats ntp-4.2.6p5/ntpd/ntp_util.c
063937
--- ntp-4.2.6p5/ntpd/ntp_util.c.rawstats	2010-10-22 09:37:31.000000000 +0200
063937
+++ ntp-4.2.6p5/ntpd/ntp_util.c	2015-07-22 14:19:37.221167862 +0200
063937
@@ -707,7 +707,16 @@ record_raw_stats(
063937
 	l_fp	*t1,		/* originate timestamp */
063937
 	l_fp	*t2,		/* receive timestamp */
063937
 	l_fp	*t3,		/* transmit timestamp */
063937
-	l_fp	*t4		/* destination timestamp */
063937
+	l_fp	*t4,		/* destination timestamp */
063937
+	int	leap,
063937
+	int	version,
063937
+	int	mode,
063937
+	int	stratum,
063937
+	int	poll,
063937
+	int	precision,
063937
+	double	root_delay,	/* seconds */
063937
+	double	root_dispersion,/* seconds */
063937
+	u_int32	refid
063937
 	)
063937
 {
063937
 	l_fp	now;
063937
@@ -721,10 +730,13 @@ record_raw_stats(
063937
 	day = now.l_ui / 86400 + MJD_1900;
063937
 	now.l_ui %= 86400;
063937
 	if (rawstats.fp != NULL) {
063937
-		fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s\n", day,
063937
-		    ulfptoa(&now, 3), stoa(srcadr), dstadr ? 
063937
-		    stoa(dstadr) : "-",	ulfptoa(t1, 9), ulfptoa(t2, 9),
063937
-		    ulfptoa(t3, 9), ulfptoa(t4, 9));
063937
+		fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s %d %d %d %d %d %d %.6f %.6f %s\n",
063937
+		    day, ulfptoa(&now, 3),
063937
+		    stoa(srcadr), dstadr ?  stoa(dstadr) : "-",
063937
+		    ulfptoa(t1, 9), ulfptoa(t2, 9),
063937
+		    ulfptoa(t3, 9), ulfptoa(t4, 9),
063937
+		    leap, version, mode, stratum, poll, precision,
063937
+		    root_delay, root_dispersion, refid_str(refid, stratum));
063937
 		fflush(rawstats.fp);
063937
 	}
063937
 }
063937
063937
commit f626c563dbf6c00c40f9d12e8200b427759ed0bf
063937
Author:  <davehart@shiny.ad.hartbrothers.com>
063937
Date:   Sat Dec 25 06:12:51 2010 +0000
063937
063937
    Add ntpq sysinfo command, similar to ntpdc's sysinfo.
063937
063937
diff --git a/libntp/numtoa.c b/libntp/numtoa.c
063937
index 36a7c58..0fbbab7 100644
063937
--- a/libntp/numtoa.c
063937
+++ b/libntp/numtoa.c
063937
@@ -31,3 +31,29 @@ numtoa(
063937
 		 (u_long)netnum & 0xff);
063937
 	return buf;
063937
 }
063937
+
063937
+
063937
+/* Convert a refid & stratum to a string */
063937
+const char *
063937
+refid_str(
063937
+	u_int32	refid,
063937
+	int	stratum
063937
+	)
063937
+{
063937
+	char *	text;
063937
+	size_t	tlen;
063937
+
063937
+	if (stratum > 1)
063937
+		return numtoa(refid);
063937
+
063937
+	LIB_GETBUF(text);
063937
+	text[0] = '.';
063937
+	strncpy(&text[1], (void *)&refid, sizeof(refid));
063937
+	text[1 + sizeof(refid)] = '\0';
063937
+	tlen = strlen(text);
063937
+	text[tlen] = '.';
063937
+	text[tlen + 1] = '\0';
063937
+
063937
+	return text;
063937
+}
063937
+
063937
diff -up ntp-4.2.6p5/include/ntp_stdlib.h.rawstats ntp-4.2.6p5/include/ntp_stdlib.h
063937
--- ntp-4.2.6p5/include/ntp_stdlib.h.rawstats	2015-07-22 15:13:16.870503486 +0200
063937
+++ ntp-4.2.6p5/include/ntp_stdlib.h	2015-07-22 15:14:21.893714802 +0200
063937
@@ -134,6 +134,7 @@ extern	char *	socktohost	(const sockaddr
063937
 extern	int	octtoint	(const char *, u_long *);
063937
 extern	u_long	ranp2		(int);
063937
 extern	char *	refnumtoa	(sockaddr_u *);
063937
+extern	const char *refid_str	(u_int32, int);
063937
 extern	int	tsftomsu	(u_long, int);
063937
 extern	char *	uinttoa		(u_long);
063937