<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/583281c8eb39d6ad857e40467f639f9d5ac33f0a">583281c8</a></strong>
<div>
<span>by Eric S. Raymond</span>
<i>at 2015-12-08T14:24:59Z</i>
</div>
<pre class='commit-message'>Proof-of-concept capture code. Much work to be done yet.</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/583281c8eb39d6ad857e40467f639f9d5ac33f0a#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">@@ -137,20 +137,37 @@ void intercept_argparse(int *argc, char ***argv)
</span>           printf(" %s", (*argv)[i]);
        putchar('\n');
     }
<span style="color: #000000;background-color: #ddffdd">+
+    /* FIXME: replay logic goes here */
+}
+
+static bool pump(const char *fn, const char *lead, const char *trail, FILE *ofp)
+{
+       FILE *fp = fopen(fn, "r");
+       if (fp == NULL)
+           return false;
+       else
+       {
+           int c;
+
+           fputs(lead, ofp);
+           while ((c = fgetc(fp)) != EOF)
+               fputc(c, ofp);
+           fclose(fp);
+           fputs(trail, ofp);
+           return true;
+       }
</span> }
 
<span style="color: #000000;background-color: #ddffdd">+
</span> void intercept_getconfig(const char *configfile)
 {
<span style="color: #000000;background-color: #ffdddd">-    if (mode == none)
</span><span style="color: #000000;background-color: #ddffdd">+    printf("CONFIG %s\n", configfile);
+    if (mode != replay)
</span>   getconfig(configfile);
<span style="color: #000000;background-color: #ffdddd">-    else {
-       fputs("startconfig\n", stdout);
-#ifdef SAVECONFIG
-       dump_all_config_trees(stdout, false);
-#endif
-       fputs("endconfig\n", stdout);
</span> 
<span style="color: #000000;background-color: #ffdddd">-    }
</span><span style="color: #000000;background-color: #ddffdd">+    if (mode == capture)
+       pump(configfile, "startconfig\n", "endconfig\n", stdout);
</span> 
     if (mode == replay) {
        stats_control = false;  /* suppress writing stats files */
<span style="color: #aaaaaa">@@ -304,18 +321,8 @@ intercept_leapsec_load_file(
</span>     if (mode != replay)
        loaded = leapsec_load_file(fname, sb_old, force, logall);
 
<span style="color: #000000;background-color: #ffdddd">-    if (mode == capture) {
-       FILE *fp = fopen(fname, "r");
-       if (fp != NULL) {
-           int c;
-
-           fputs("startleapsec\n", stdout);
-           while ((c = fgetc(fp)) != EOF)
-               putchar(c);
-           fclose(fp);
-           fputs("endleapsec\n", stdout);
-       }
-    }
</span><span style="color: #000000;background-color: #ddffdd">+    if (mode == capture)
+       pump(fname, "startleapsec\n", "endleapsec\n", stdout);
</span> 
     /* FIXME: replay logic goes here */
     
<span style="color: #aaaaaa">@@ -336,7 +343,6 @@ static void packet_dump(sockaddr_u *dest, struct pkt *pkt, int len)
</span>     /* dump MAC as len - LEN_PKT_NOMAC chars in hex */
     for (i = 0; i < len - LEN_PKT_NOMAC; i++)
        printf("%02x", pkt->exten[i]);
<span style="color: #000000;background-color: #ffdddd">-    fputs("\n", stdout);
</span> }
 
 void intercept_sendpkt(const char *legend,
<span style="color: #aaaaaa">@@ -347,7 +353,7 @@ void intercept_sendpkt(const char *legend,
</span>   sendpkt(dest, ep, ttl, pkt, len);
 
     if (mode != none) {
<span style="color: #000000;background-color: #ffdddd">-        printf("event sendpkt \"%s\"", legend);
</span><span style="color: #000000;background-color: #ddffdd">+   printf("event sendpkt \"%s\" ", legend);
</span>   packet_dump(dest, pkt, len);
        fputs("\n", stdout);
     }
</code></pre>

<br>
</li>

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

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