<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>Eric S. Raymond pushed to branch master at <a href="https://gitlab.com/NTPsec/ntpsec">NTPsec / ntpsec</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/2a62a835720abda7fab87740dd05ae284893c3dc">2a62a835</a></strong>
<div>
<span>by Eric S. Raymond</span>
<i>at 2015-12-12T13:14:41Z</i>
</div>
<pre class='commit-message'>Morte replay implementation - the all-important ntp_adjtime call.</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
ntpd/ntp_intercept.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/2a62a835720abda7fab87740dd05ae284893c3dc#diff-0'>
<strong>
ntpd/ntp_intercept.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ntpd/ntp_intercept.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/ntpd/ntp_intercept.c
</span><span style="color: #aaaaaa">@@ -464,35 +464,92 @@ int intercept_adjtime(const struct timeval *ntv, struct timeval *otv)
</span> int intercept_ntp_adjtime(struct timex *tx)
 /* for newer systems with PLLs */
 {
<span style="color: #000000;background-color: #ddffdd">+#define ADJFMT "%u %ld %ld %ld %ld %i %ld %ld %ld %ld %ld %i %ld %ld %ld %ld"
+#define ADJDUMP(x, buf)                        \
+    snprintf(buf, sizeof(buf), ADJFMT, \
+            (x)->modes,                     \
+            (x)->offset,                    \
+            (x)->freq,                      \
+            (x)->maxerror,          \
+            (x)->esterror,          \
+            (x)->status,                    \
+            (x)->constant,          \
+            (x)->precision,         \
+            (x)->tolerance,         \
+            (x)->ppsfreq,           \
+            (x)->jitter,                    \
+            (x)->shift,                     \
+            (x)->jitcnt,                    \
+            (x)->calcnt,                    \
+            (x)->errcnt,                    \
+            (x)->stbcnt)
+
+    char txdump[BUFSIZ], rtxdump[BUFSIZ];
+    ADJDUMP(tx, txdump);
</span>     int res = 0;
 
<span style="color: #000000;background-color: #ffdddd">-    /* FIXME: replay logic goes here */
</span><span style="color: #000000;background-color: #ddffdd">+    if (mode == replay)
+    {
+       struct timex rtx;
+       get_operation("ntp_adjtime");
+       if (sscanf(linebuf, "ntp_adtime " ADJFMT " %d",
+                  &rtx.modes,
+                  &rtx.offset,
+                  &rtx.freq,
+                  &rtx.maxerror,
+                  &rtx.esterror,
+                  &rtx.status,
+                  &rtx.constant,
+                  &rtx.precision,
+                  &rtx.tolerance,
+                  &rtx.ppsfreq,
+                  &rtx.jitter,
+                  &rtx.shift,
+                  &rtx.jitcnt,
+                  &rtx.calcnt,
+                  &rtx.errcnt,
+                  &rtx.stbcnt,
+                  &res) != 17)
+       {
+           fprintf(stderr, "ntpd: garbled ntp_adtime format, line %d\n",
+                   lineno);
+           exit(1);
+       }
</span> 
<span style="color: #000000;background-color: #ffdddd">-    if (mode != replay)
</span><span style="color: #000000;background-color: #ddffdd">+   ADJDUMP(&rtx, rtxdump);
+       if (strcmp(txdump, rtxdump) != 0) {
+           printf("ntpd: adjtime mismatch at line %d, saw %s\n",
+                  lineno, txdump);
+           exit(1);
+       }
+    } else {
</span>   res = ntp_adjtime(tx);
 
<span style="color: #000000;background-color: #ffdddd">-    if (mode != none)
-       printf("ntp_adjtime %u %ld %ld %ld %ld %i %ld %ld %ld %ld %ld %i %ld %ld %ld %ld %d\n",
-              tx->modes,
-              tx->offset,
-              tx->freq,
-              tx->maxerror,
-              tx->esterror,
-              tx->status,
-              tx->constant,
-              tx->precision,
-              tx->tolerance,
-              tx->ppsfreq,
-              tx->jitter,
-              tx->shift,
-              tx->jitcnt,
-              tx->calcnt,
-              tx->errcnt,
-              tx->stbcnt,
-              res
-           );
</span><span style="color: #000000;background-color: #ddffdd">+   if (mode == capture)
+           printf("ntp_adjtime " ADJFMT " %d\n",
+                  tx->modes,
+                  tx->offset,
+                  tx->freq,
+                  tx->maxerror,
+                  tx->esterror,
+                  tx->status,
+                  tx->constant,
+                  tx->precision,
+                  tx->tolerance,
+                  tx->ppsfreq,
+                  tx->jitter,
+                  tx->shift,
+                  tx->jitcnt,
+                  tx->calcnt,
+                  tx->errcnt,
+                  tx->stbcnt,
+                  res
+               );
+    }
</span> 
     return res;
<span style="color: #000000;background-color: #ddffdd">+#undef ADJFMT
+#undef ADJDUMP
</span> }
 #endif
 
<span style="color: #aaaaaa">@@ -504,7 +561,7 @@ int intercept_set_tod(struct timespec *tvs)
</span>     }
     else {
        if (mode == capture)
<span style="color: #000000;background-color: #ffdddd">-            printf("set_tod %ld %ld\n", (long)tvs->tv_sec, tvs->tv_nsec);
</span><span style="color: #000000;background-color: #ddffdd">+       printf("set_tod %ld %ld\n", (long)tvs->tv_sec, (long)tvs->tv_nsec);
</span>   return ntp_set_tod(tvs);
     }
     return 0;
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://gitlab.com/NTPsec/ntpsec/commit/2a62a835720abda7fab87740dd05ae284893c3dc">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.com/NTPsec/ntpsec/commit/2a62a835720abda7fab87740dd05ae284893c3dc"}}</script>
</p>
</div>
</body>
</html>