diff --git a/dist/ntp/ntpd/refclock_heath.c b/dist/ntp/ntpd/refclock_heath.c index 2e97bf8dadc9..449dd5031e52 100644 --- a/dist/ntp/ntpd/refclock_heath.c +++ b/dist/ntp/ntpd/refclock_heath.c @@ -1,4 +1,4 @@ -/* $NetBSD: refclock_heath.c,v 1.2 2003/12/04 16:23:37 drochner Exp $ */ +/* $NetBSD: refclock_heath.c,v 1.3 2006/05/13 23:55:23 christos Exp $ */ /* * refclock_heath - clock driver for Heath GC-1000 and and GC-1000 II @@ -298,6 +298,39 @@ heath_receive( refclock_report(peer, CEVNT_BADREPLY); return; } + + /* + * We determine the day of the year from the DIPswitches. This + * should be fixed, since somebody might forget to set them. + * Someday this hazard will be fixed by a fiendish scheme that + * looks at the timecode and year the radio shows, then computes + * the residue of the seconds mod the seconds in a leap cycle. + * If in the third year of that cycle and the third and later + * months of that year, add one to the day. Then, correct the + * timecode accordingly. Icky pooh. This bit of nonsense could + * be avoided if the engineers had been required to write a + * device driver before finalizing the timecode format. + */ + if (month < 1 || month > 12 || day < 1) { + refclock_report(peer, CEVNT_BADTIME); + return; + } + if (pp->year % 4) { + if (day > day1tab[month - 1]) { + refclock_report(peer, CEVNT_BADTIME); + return; + } + for (i = 0; i < month - 1; i++) + day += day1tab[i]; + } else { + if (day > day2tab[month - 1]) { + refclock_report(peer, CEVNT_BADTIME); + return; + } + for (i = 0; i < month - 1; i++) + day += day2tab[i]; + } + pp->day = day; break; /* @@ -316,38 +349,6 @@ heath_receive( return; } - /* - * We determine the day of the year from the DIPswitches. This - * should be fixed, since somebody might forget to set them. - * Someday this hazard will be fixed by a fiendish scheme that - * looks at the timecode and year the radio shows, then computes - * the residue of the seconds mod the seconds in a leap cycle. - * If in the third year of that cycle and the third and later - * months of that year, add one to the day. Then, correct the - * timecode accordingly. Icky pooh. This bit of nonsense could - * be avoided if the engineers had been required to write a - * device driver before finalizing the timecode format. - */ - if (month < 1 || month > 12 || day < 1) { - refclock_report(peer, CEVNT_BADTIME); - return; - } - if (pp->year % 4) { - if (day > day1tab[month - 1]) { - refclock_report(peer, CEVNT_BADTIME); - return; - } - for (i = 0; i < month - 1; i++) - day += day1tab[i]; - } else { - if (day > day2tab[month - 1]) { - refclock_report(peer, CEVNT_BADTIME); - return; - } - for (i = 0; i < month - 1; i++) - day += day2tab[i]; - } - pp->day = day; /* * Determine synchronization and last update