<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/e5cf920818686448e95695fa1d034117dd0d0939">e5cf9208</a></strong>
<div>
<span>by Eric S. Raymond</span>
<i>at 2015-12-15T18:56:13Z</i>
</div>
<pre class='commit-message'>Boolification.</pre>
</li>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/d363c6050c73a86405b17d68e55299710ee9c7d3">d363c605</a></strong>
<div>
<span>by Eric S. Raymond</span>
<i>at 2015-12-15T20:31:13Z</i>
</div>
<pre class='commit-message'>In replay, implement full packet parsing.</pre>
</li>
</ul>
<h4>3 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
include/ntp_io.h
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
ntpd/ntp_intercept.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
ntpd/ntp_io.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/f0a57d5e59c8dda9f3a9ec789bd79ab7fde791cc...d363c6050c73a86405b17d68e55299710ee9c7d3#diff-0'>
<strong>
include/ntp_io.h
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/include/ntp_io.h
</span><span style="color: #000000;background-color: #ddffdd">+++ b/include/ntp_io.h
</span><span style="color: #aaaaaa">@@ -47,7 +47,7 @@ typedef enum {
</span> extern int        qos;
 SOCKET         move_fd(SOCKET fd);
 bool   get_broadcastclient_flag(void);
<span style="color: #000000;background-color: #ffdddd">-extern int      is_ip_address(const char *, u_short, sockaddr_u *);
</span><span style="color: #000000;background-color: #ddffdd">+extern bool        is_ip_address(const char *, u_short, sockaddr_u *);
</span> extern void       sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *);
 extern void    add_nic_rule(nic_rule_match match_type,
                             const char *if_name, int prefixlen,
</code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/f0a57d5e59c8dda9f3a9ec789bd79ab7fde791cc...d363c6050c73a86405b17d68e55299710ee9c7d3#diff-1'>
<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">@@ -433,15 +433,20 @@ int intercept_adjtime(const struct timeval *ntv, struct timeval *otv)
</span> {
     if (mode == replay) {
        struct timeval rntv, rotv;
<span style="color: #000000;background-color: #ddffdd">+        long nsec, nusec, osec, ousec;
</span>   get_operation("adjtime ");
        /* bletch - likely to foo up on 32-bit machines */
        if (sscanf(linebuf, "adjtime %ld %ld %ld %ld",
<span style="color: #000000;background-color: #ffdddd">-                   &rntv.tv_sec, &rntv.tv_usec,
-                  &rotv.tv_sec, &rotv.tv_usec) != 4)
</span><span style="color: #000000;background-color: #ddffdd">+              &nsec, &nusec, &osec, &ousec) != 4)
</span>   {
            fprintf(stderr, "ntpd: garbled adjtime format, line %d\n", lineno);
            exit(1);
        }
<span style="color: #000000;background-color: #ddffdd">+        /* avoid compiler warnings due to time_t having an unexpected length */
+       rntv.tv_sec = nsec;
+       rntv.tv_usec = nusec;
+       rntv.tv_sec = osec;
+       rntv.tv_usec = ousec;
</span>   if (ntv->tv_sec != rntv.tv_sec
            || ntv->tv_usec != rntv.tv_usec
            || otv->tv_sec != rotv.tv_sec
<span style="color: #aaaaaa">@@ -622,7 +627,6 @@ static void packet_dump(char *buf, size_t buflen,
</span>     snprintf(buf, buflen, "%s %d:%d:%d:%d:%u:%u:%u:%s:%s:%s:%s ",
           socktoa(dest),
           pkt->li_vn_mode, pkt->stratum, pkt->ppoll, pkt->precision,
<span style="color: #000000;background-color: #ffdddd">-           /* FIXME: might be better to dump these in fixed-point */
</span>      pkt->rootdelay, pkt->rootdisp,
           pkt->refid,
           lfpdump(&pkt->reftime), lfpdump(&pkt->org),
<span style="color: #aaaaaa">@@ -703,7 +707,10 @@ void intercept_replay(void)
</span>   else if (strncmp(linebuf, "receive ", 8) == 0)
        {
            struct recvbuf rbuf;
<span style="color: #000000;background-color: #ddffdd">+            struct pkt *pkt;
+           int li_vn_mode = 0, stratum = 0, ppoll = 0, precision = 0;
</span>       char recvbuf[BUFSIZ], srcbuf[BUFSIZ], pktbuf[BUFSIZ], macbuf[BUFSIZ];
<span style="color: #000000;background-color: #ddffdd">+            char refbuf[32], orgbuf[32], recbuf[32], xmtbuf[32];
</span> 
            if (sscanf(linebuf, "receive %x %s %s %s %s",
                       &rbuf.cast_flags, recvbuf, srcbuf, pktbuf, macbuf) != 5)
<span style="color: #aaaaaa">@@ -713,8 +720,42 @@ void intercept_replay(void)
</span>       }
 
            atolfp(recvbuf, &rbuf.recv_time);
<span style="color: #000000;background-color: #ffdddd">-            /* FIXME: parse source address */
-           /* FIXME: parse packet and MAC */
</span><span style="color: #000000;background-color: #ddffdd">+       if (!is_ip_address(srcbuf, AF_UNSPEC, &rbuf.recv_srcadr)) {
+               fprintf(stderr, "ntpd: invalid IP address in receive at line %d\n", lineno);
+               exit(1);
+           }
+
+           pkt = &rbuf.recv_pkt;
+           if (sscanf(pktbuf, "%d:%d:%d:%d:%u:%u:%u:%s:%s:%s:%s",
+                      &li_vn_mode, &stratum,
+                      &ppoll, &precision,
+                      &pkt->rootdelay, &pkt->rootdisp,
+                      &pkt->refid,
+                      refbuf, orgbuf, recbuf, xmtbuf) != 7)
+           {
+               fprintf(stderr, "ntpd: malformed packet dump at line %d\n",
+                       lineno);
+               exit(1);
+           }
+           /* extra transfers required because the struct members are int8_t */
+           pkt->li_vn_mode = li_vn_mode;
+           pkt->stratum = stratum;
+           pkt->ppoll = ppoll;
+           pkt->precision = precision;
+           atolfp(refbuf, &pkt->reftime);
+           atolfp(orgbuf, &pkt->org);
+           atolfp(recbuf, &pkt->rec);
+           atolfp(xmtbuf, &pkt->xmt);
+
+           memset(pkt->exten, '\0', sizeof(pkt->exten));
+           if (strcmp(macbuf, "nomac") != 0) {
+               size_t i;
+               for (i = 0; i < strlen(macbuf)/2; i++) {
+                   int hexval;
+                   sscanf(macbuf + 2*i, "%02x", &hexval);
+                   pkt->exten[i] = hexval & 0xff;
+               }
+           }
</span> 
            /*
             * If the packet doesn't dump identically to how it came in,
</code></pre>

<br>
</li>
<li id='diff-2'>
<a href='https://gitlab.com/NTPsec/ntpsec/compare/f0a57d5e59c8dda9f3a9ec789bd79ab7fde791cc...d363c6050c73a86405b17d68e55299710ee9c7d3#diff-2'>
<strong>
ntpd/ntp_io.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ntpd/ntp_io.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/ntpd/ntp_io.c
</span><span style="color: #aaaaaa">@@ -716,7 +716,7 @@ addr_samesubnet(
</span>  * and set the return value
  * see the bind9/getaddresses.c for details
  */
<span style="color: #000000;background-color: #ffdddd">-int
</span><span style="color: #000000;background-color: #ddffdd">+bool
</span> is_ip_address(
        const char *    host,
        u_short         af,
</code></pre>

<br>
</li>

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

<br>
<a href="https://gitlab.com/NTPsec/ntpsec/compare/f0a57d5e59c8dda9f3a9ec789bd79ab7fde791cc...d363c6050c73a86405b17d68e55299710ee9c7d3">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.

</p>
</div>
</body>
</html>