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