Blob Blame History Raw
diff -up ntp-4.2.6p1/ntpstat-0.2/ntpstat.c.maxerror ntp-4.2.6p1/ntpstat-0.2/ntpstat.c
--- ntp-4.2.6p1/ntpstat-0.2/ntpstat.c.maxerror	2010-05-03 11:37:49.000000000 +0200
+++ ntp-4.2.6p1/ntpstat-0.2/ntpstat.c	2010-05-03 12:20:08.000000000 +0200
@@ -89,7 +89,9 @@ int main (void) {
     "modem"};         /* 9 */
   char *newstr;
   char *dispstr;
+  char *delaystr;
   const char DISP[] = "rootdisp=";
+  const char DELAY[] = "rootdelay=";
   const char STRATUM[] = "stratum=";
   const char POLL[] = "tc=";
   const char REFID[] = "refid=";
@@ -235,16 +237,19 @@ int main (void) {
     /* Set the position of the start of the string to 
        "rootdispersion=" part of the string. */
     strncpy(buff, ntpmsg.payload, sizeof(buff));
-    if ((newstr = strstr (buff, DISP))) {
-      newstr += sizeof(DISP) - 1;
-      dispstr = strtok(newstr,".");
+    if ((dispstr = strstr (buff, DISP)) && (delaystr = strstr (buff, DELAY))) {
+      dispstr += sizeof(DISP) - 1;
+      dispstr = strtok(dispstr,",");
+      delaystr += sizeof(DELAY) - 1;
+      delaystr = strtok(delaystr,",");
 
       /* Check the resultant string is of a reasonable length */
-      if ((strlen (dispstr) == 0) || (strlen (dispstr) > 4)) {
+      if ((strlen (dispstr) == 0) || (strlen (dispstr) > 10) ||
+	      (strlen (delaystr) == 0) || (strlen (delaystr) > 10)) {
 	printf ("accuracy unreadable\n");
       }
       else {
-	printf("   time correct to within %s ms\n",dispstr);
+	printf("   time correct to within %.0f ms\n", atof(dispstr) + atof(delaystr) / 2.0);
       }
     } else {
       rc=1;