<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/a24a82ad16280bb066789fd9d1edfeeea3eeba29">a24a82ad</a></strong>
<div>
<span>by Eric S. Raymond</span>
<i>at 2015-12-15T12:47:45Z</i>
</div>
<pre class='commit-message'>More tweaks to the packet dump format.</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/a24a82ad16280bb066789fd9d1edfeeea3eeba29#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">@@ -333,12 +333,12 @@ long intercept_ntp_random(const char *legend)
</span> 
 void intercept_timer(void)
 {
<span style="color: #000000;background-color: #ddffdd">+    timer();
</span>     if (mode == capture)
        printf("timer\n");
     else if (mode == replay)
        /* probably is not necessary to record this... */
        get_operation("timer");
<span style="color: #000000;background-color: #ffdddd">-    timer();
</span> }
 
 bool intercept_drift_read(const char *drift_file, double *drift)
<span style="color: #aaaaaa">@@ -627,15 +627,11 @@ intercept_leapsec_load_file(
</span> static void packet_dump(char *buf, size_t buflen,
                        sockaddr_u *dest, struct pkt *pkt, int len)
 {
<span style="color: #000000;background-color: #ddffdd">+    size_t i;
</span>     /*
<span style="color: #000000;background-color: #ffdddd">-     * Order is: cast flags, receipt time, interface name, source
-     * address, packet, length.  Cast flags are only kept because
-     * they change the ntpq display, they have no implications for
-     * the protocol machine.  We don't dump srcadr because only
-     * the parse clock uses that.
</span><span style="color: #000000;background-color: #ddffdd">+     * Format is three tokens: source address, packet, MAC token. 
</span>      */
<span style="color: #000000;background-color: #ffdddd">-    size_t i;
-    snprintf(buf, buflen, "%s %d:%d:%d:%d:%u:%u:%u:%s:%s:%s:%s",
</span><span style="color: #000000;background-color: #ddffdd">+    snprintf(buf, buflen, "%s %d:%d:%d:%d:%u:%u:%u:%s:%s:%s:%s ",
</span>      socktoa(dest),
           pkt->li_vn_mode, pkt->stratum, pkt->ppoll, pkt->precision,
           /* FIXME: might be better to dump these in fixed-point */
<span style="color: #aaaaaa">@@ -643,13 +639,15 @@ static void packet_dump(char *buf, size_t buflen,
</span>      pkt->refid,
           lfpdump(&pkt->reftime), lfpdump(&pkt->org),
           lfpdump(&pkt->rec), lfpdump(&pkt->xmt));
<span style="color: #000000;background-color: #ffdddd">-    /* dump MAC as len - LEN_PKT_NOMAC chars in hex */
-    for (i = 0; i < len - LEN_PKT_NOMAC; i++) {
-       if (i == 0)
-           strlcat(buf, " ", buflen);
-       snprintf(buf + strlen(buf), buflen - strlen(buf),
-                "%02x", pkt->exten[i]);
-    }
</span><span style="color: #000000;background-color: #ddffdd">+
+    if (len == LEN_PKT_NOMAC)
+       strlcat(buf, "nomac", buflen);
+    else
+       /* dump MAC as len - LEN_PKT_NOMAC chars in hex */
+       for (i = 0; i < len - LEN_PKT_NOMAC; i++) {
+           snprintf(buf + strlen(buf), buflen - strlen(buf),
+                    "%02x", pkt->exten[i]);
+       }
</span> }
 
 void intercept_sendpkt(const char *legend,
<span style="color: #aaaaaa">@@ -684,23 +682,26 @@ void intercept_receive(struct recvbuf *rbufp)
</span>     packet_dump(pkt_dump, sizeof(pkt_dump),
                &rbufp->recv_srcadr,
                &rbufp->recv_pkt, rbufp->recv_length);
<span style="color: #000000;background-color: #ddffdd">+    /*
+     * Order is: cast flags, receipt time, source address, packet,
+     * MAC.  Cast flags are only kept because they change the ntpq
+     * display, they have no implications for the protocol machine.
+     * We don't dump srcadr because only the parse clock uses that.
+     */
</span>     snprintf(newpacket, sizeof(newpacket),
             "receive %0x %s %s\n",
             rbufp->cast_flags, lfpdump(&rbufp->recv_time), pkt_dump);
 
     if (mode == replay) {
<span style="color: #000000;background-color: #ffdddd">-        get_operation("receive ");
</span>   if (strcmp(linebuf, newpacket) != 0) {
            fprintf(stderr, "ntpd: line %d, receive mismatch saw %s\n",
                    lineno, newpacket);
            exit(1);
        }
<span style="color: #000000;background-color: #ffdddd">-    } else {
-       if (mode == capture)
-           fputs(newpacket, stdout);
</span><span style="color: #000000;background-color: #ddffdd">+    } else if (mode == capture)
+       fputs(newpacket, stdout);
</span> 
<span style="color: #000000;background-color: #ffdddd">-        receive(rbufp);
-    }
</span><span style="color: #000000;background-color: #ddffdd">+    receive(rbufp);
</span> }
 
 void
</code></pre>

<br>
</li>

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

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