From: Harlan Stenn Date: Mon, 4 Dec 2017 08:24:49 +0000 (-0800) Subject: record_raw_stats(): Log entire packet. Log writes. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2be821a7b5a07e283355b9b55d9baa4af123b4df;p=thirdparty%2Fntp.git record_raw_stats(): Log entire packet. Log writes. bk: 5a250651bqz2hlj7ni1ji_msyYW61w --- diff --git a/ChangeLog b/ChangeLog index add12209e..9607521f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -48,6 +48,7 @@ * refclock_jjy.c: Add missing "%s" to an msyslog() call. HStenn. * Build ntpq and libntpq.a with NTP_HARD_*FLAGS. perlinger@ntp.org * Fix bug in the override portion of the compiler hardening macro. HStenn. +* record_raw_stats(): Log entire packet. Log writes. HStenn. --- (4.2.8p10) 2017/03/21 Released by Harlan Stenn diff --git a/include/ntpd.h b/include/ntpd.h index f944235cd..2b4bddcd6 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -288,7 +288,7 @@ extern void record_loop_stats (double, double, double, double, int); extern void record_clock_stats (sockaddr_u *, const char *); extern int mprintf_clock_stats(sockaddr_u *, const char *, ...) NTP_PRINTF(2, 3); -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 ppoll, int precision, double root_delay, double root_dispersion, u_int32 refid); +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 ppoll, int precision, double root_delay, double root_dispersion, u_int32 refid, int len, u_char *extra); extern void check_leap_file (int is_daily_check, u_int32 ntptime, const time_t * systime); extern void record_crypto_stats (sockaddr_u *, const char *); #ifdef DEBUG diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 20ef13a0c..c20067972 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -3091,6 +3091,7 @@ sendpkt( int cc; int rc; u_char cttl; + l_fp fp_zero = { 0, 0 }; ismcast = IS_MCAST(dest); if (!ismcast) @@ -3174,6 +3175,18 @@ sendpkt( if (ismcast) src = src->mclink; } while (ismcast && src != NULL); + + record_raw_stats(&src->sin, dest, + &pkt->org, &pkt->rec, &pkt->xmt, &fp_zero, + PKT_MODE(pkt->li_vn_mode), + PKT_VERSION(pkt->li_vn_mode), + PKT_LEAP(pkt->li_vn_mode), + pkt->stratum, + pkt->ppoll, pkt->precision, + pkt->rootdelay, pkt->rootdisp, pkt->refid, + len - MIN_V4_PKT_LEN, (u_char *)&pkt->exten); + + return; } diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 2b88e07d5..86444c5a0 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -2207,7 +2207,8 @@ process_packet( &peer->dstadr->sin : NULL, &p_org, &p_rec, &p_xmt, &peer->dst, pleap, pversion, pmode, pstratum, pkt->ppoll, pkt->precision, - p_del, p_disp, pkt->refid); + p_del, p_disp, pkt->refid, + len - MIN_V4_PKT_LEN, (u_char *)&pkt->exten); peer->leap = pleap; peer->stratum = min(pstratum, STRATUM_UNSPEC); peer->pmode = pmode; diff --git a/ntpd/ntp_util.c b/ntpd/ntp_util.c index 3a9581982..0b4a8ddd3 100644 --- a/ntpd/ntp_util.c +++ b/ntpd/ntp_util.c @@ -666,6 +666,8 @@ mprintf_clock_stats( * peer ip address * IP address * t1 t2 t3 t4 timestamps + * leap, version, mode, stratum, ppoll, precision, root delay, root dispersion, REFID + * length and hex dump of any EFs and any legacy MAC. */ void record_raw_stats( @@ -683,7 +685,9 @@ record_raw_stats( int precision, double root_delay, /* seconds */ double root_dispersion,/* seconds */ - u_int32 refid + u_int32 refid, + int len, + u_char *extra ) { l_fp now; @@ -697,13 +701,22 @@ record_raw_stats( day = now.l_ui / 86400 + MJD_1900; now.l_ui %= 86400; if (rawstats.fp != NULL) { - fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s %d %d %d %d %d %d %.6f %.6f %s\n", + fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s %d %d %d %d %d %d %.6f %.6f %s", day, ulfptoa(&now, 3), stoa(srcadr), dstadr ? stoa(dstadr) : "-", ulfptoa(t1, 9), ulfptoa(t2, 9), ulfptoa(t3, 9), ulfptoa(t4, 9), leap, version, mode, stratum, ppoll, precision, root_delay, root_dispersion, refid_str(refid, stratum)); + if (len > 0) { + int i; + + fprintf(rawstats.fp, " %d: ", len); + for (i = 0; i < len; ++i) { + fprintf(rawstats.fp, "%02x", extra[i]); + } + } + fprintf(rawstats.fp, "\n"); fflush(rawstats.fp); } }