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