<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>Hal Murray 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/498caa219cb44231b0128200cc46859b24150538">498caa21</a></strong>
<div>
<span>by Hal Murray</span>
<i>at 2015-12-01T04:19:25Z</i>
</div>
<pre class='commit-message'>Add util/bumpclock.c which should have been in the previous commit</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
<span class='new-file'>
+
util/bumpclock.c
</span>
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/498caa219cb44231b0128200cc46859b24150538#diff-0'>
<strong>
util/bumpclock.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- /dev/null
</span><span style="color: #000000;background-color: #ddffdd">+++ b/util/bumpclock.c
</span><span style="color: #aaaaaa">@@ -0,0 +1,62 @@
</span><span style="color: #000000;background-color: #ddffdd">+/*
+ * Hack to bump the system time for testing ntpd response.
+ * Must be run as root.
+ * Arg is microseconds, default is 100000.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+int main(int argc, char *argv[]) {
+    struct timeval was, set, now;
+    int rc1, rc2, rc3;
+    int er1, er2, er3;
+    int bump = 100000;
+
+    if (argc > 1) {
+       bump = atoi(argv[1]);
+    }
+    printf("Bumping clock by %d microseconds.\n", bump);
+
+    rc1 = gettimeofday(&was, NULL);
+    er1 = errno;
+
+    set = was;
+    set.tv_usec += bump;
+    while (set.tv_usec >= 1000000 ) {
+       set.tv_usec -= 1000000;
+       set.tv_sec +=1;
+    }
+    while (set.tv_usec <= 0 ) {
+       set.tv_usec += 1000000;
+       set.tv_sec -=1;
+    }
+    rc2 = settimeofday(&set, NULL);
+    er2 = errno;
+
+    rc3 = gettimeofday(&now, NULL);
+    er3 = errno;
+
+    /* Defer printing so it doesn't distort timing. */
+    if (rc1)
+       printf("Couldn't get time: %s\n", strerror(er1));
+    else
+       printf("Was: %ld.%06ld\n", (long)was.tv_sec, (long)was.tv_usec);
+
+    if (rc2) {
+       printf("Couldn't set time: %s\n", strerror(er2));
+       printf("Try: %ld.%06ld\n", (long)set.tv_sec, (long)set.tv_usec);
+    } else
+       printf("Set: %ld.%06ld\n", (long)set.tv_sec, (long)set.tv_usec);

+   if (rc3)
+       printf("Couldn't set time: %s\n", strerror(er3));
+    else
+       printf("Now: %ld.%06ld\n", (long)now.tv_sec, (long)now.tv_usec);
+
+    return (rc1!=0 || rc2!=0 || rc3!=0);
+
+}
</span></code></pre>

<br>
</li>

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

<br>
<a href="https://gitlab.com/NTPsec/ntpsec/commit/498caa219cb44231b0128200cc46859b24150538">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/498caa219cb44231b0128200cc46859b24150538"}}</script>
</p>
</div>
</body>
</html>