]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Merge shiny.ad.hartbrothers.com:C:/ntp/ntp-stable-2050-59-66-68-69
authorDave Hart <hart@ntp.org>
Sat, 26 Nov 2011 10:14:46 +0000 (10:14 +0000)
committerDave Hart <hart@ntp.org>
Sat, 26 Nov 2011 10:14:46 +0000 (10:14 +0000)
into  shiny.ad.hartbrothers.com:C:/ntp/ntp-dev-2050-59-66-68-69

bk: 4ed0bc16bOgoPdQNQ3Ibzi8Co4i8wg

17 files changed:
1  2 
ChangeLog
include/ntp.h
include/ntp_refclock.h
include/ntp_request.h
include/ntp_types.h
include/ntpd.h
ntpd/ntp_config.c
ntpd/ntp_control.c
ntpd/ntp_io.c
ntpd/ntp_peer.c
ntpd/ntp_proto.c
ntpd/ntp_refclock.c
ntpd/ntp_request.c
ntpd/ntp_timer.c
ntpq/ntpq-subs.c
ntpq/ntpq.c
ntpq/ntpq.h

diff --cc ChangeLog
index a27c35a32852ca9ba48b74c46a64ae77a84e28bf,c8434aae7b04324b9b0ef5e97e05371f1a18938d..c84c915fa3e3e8fbb5c83ecaa57b30a5ede13180
+++ b/ChangeLog
++* [Bug 2050] from 4.2.6p5-RC2: Orphan mode stratum counting to infinity.
++* [Bug 2059] from 4.2.6p5-RC2: optional billboard column "server" does
++  not honor -n.
++* [Bug 2066] from 4.2.6p5-RC2: ntpq lopeers ipv6 "local" column overrun.
++* [Bug 2068] from 4.2.6p5-RC2: ntpd sends nonprintable stratum 16 refid
++  to ntpq.
++* [Bug 2069] from 4.2.6p5-RC2: broadcastclient, multicastclient spin up
++  duplicate ephemeral associations without broadcastdelay.
++* from 4.2.6p5-RC2: Exclude not-yet-determined sys_refid from use in
++  loopback TEST12 (from David Mills).  
 +(4.2.7p236) 2011/11/16 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p235) 2011/11/16 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 2052] Autokey CRYPTO_ASSOC host@group vallen needs checking.
 +(4.2.7p234) 2011/11/07 Released by Harlan Stenn <stenn@ntp.org>
 +* Clean up -libm entries regarding libntp.a
 +(4.2.7p233) 2011/11/06 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p232) 2011/11/05 Released by Harlan Stenn <stenn@ntp.org>
 +* Update the NEWS file so we note the default disable of mode 7 requests.
 +* Clean up some bitrotted code in libntp/socket.c.
 +(4.2.7p231) 2011/11/03 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1940] ignore auth key if hex decoding fails.
 +* Add ntpq reslist command to query access restrictions, similar to
 +  ntpdc's reslist.
 +(4.2.7p230) 2011/11/01 Released by Harlan Stenn <stenn@ntp.org>
 +* Disable mode 7 (ntpdc) query processing in ntpd by default.  ntpq is
 +  believed to provide all functionality ntpdc did, and uses a less-
 +  fragile protocol that's safer and easier to maintain.  If you do find
 +  some management via ntpdc is needed, you can use "enable mode7" in the
 +  ntpd configuration.
 +* Directly limit the number of datagrams in a mrulist response, rather
 +  than limiting the number of entries returned to indirectly limit the
 +  datagram count.
 +* Documentation updates from Dave Mills.
 +(4.2.7p229) 2011/10/26 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1995] fix wrong use of ZERO() macro in 'ntp_calendar.c'
 +(4.2.7p228) 2011/10/23 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1995] add compile time stamp based era unfolding for
 +  'step_systime()' and necessary support to 'ntp-calendar.c'.
 +(4.2.7p227) 2011/10/22 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 2036] gcc 2.95.3 preprocessor can't nest #ifdef in macro args.
 +* A number of compiler warnings eliminated.
 +(4.2.7p226) 2011/10/21 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 2035] ntpq -c mrulist sleeps 1 sec between queries, not 5 msec.
 +* Documentation updates from Dave Mills.
 +(4.2.7p225) 2011/10/15 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p224) 2011/10/14 Released by Harlan Stenn <stenn@ntp.org>
 +* ntpq mrulist shows intermediate counts every five seconds while
 +  retrieving list, and allows Ctrl-C interruption of the retrieval,
 +  showing the incomplete list as retrieved.  Reduce delay between
 +  successive mrulist retrieval queries from 30 to 5 msec.  Do not
 +  give up mrulist retrieval when a single query times out.
 +(4.2.7p223) 2011/10/12 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p222) 2011/10/11 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 2029] "make check" clutters syslog.
 +* Log signal description along with number on ntpd exit.
 +(4.2.7p221) 2011/10/10 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 2025] Switching between daemon and kernel loops can doubly-
 +  correct drift
 +* [Bug 2028] ntpd -n (nofork) redirects logging to stderr.
 +* Documentation updates from Dave Mills.
 +(4.2.7p220) 2011/10/05 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1945] mbg_gps166.h use of _TM_DEFINED conflicts with MS VC.
 +* [Bug 1946] parse_start uses open; does not work on Windows.
 +* [Bug 1947] Porting parse-based Wharton refclock driver to Windows.
 +* [Bug 2024] Remove unused system event code EVNT_CLKHOP.
 +(4.2.7p219) 2011/10/04 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p218) 2011/10/03 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 2019] Allow selection of cipher for private key files.
 +* Documentation updates from Dave Mills.
 +* ntp-keygen private key cipher default now triple-key triple DES CBC.
 +* ntp-keygen -M is intended to ignore all other defaults and
 +  options, so do not attempt to open existing Autokey host certificate
 +  before generating symmetric keys and terminating.
 +* Restore IFF, MV, and GQ identity parameter filename convention to
 +  ntpkey_<scheme>par_<group/host> in ntpd, matching ntp-keygen.
 +* Change some error logging to syslog to ignore logconfig mask, such
 +  as reporting PPSAPI failure in NMEA and WWVB refclocks.
 +* ntp-keygen on Windows XP and later systems will now create links
 +  expected by ntpd.  They are hardlinks on Windows, soft on POSIX.
 +* Conditionalize NMEA serial open message under clockevent.
 +* Send all peer variables to trappers in report_event().
 +(4.2.7p217) 2011/09/29 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 2020] ntp-keygen -s no longer sets host in cert file name.
 +* [Backward Incompatible] ntp-keygen -i option long name changed from
 +  misleading --issuer-name to --ident.
 +(4.2.7p216) 2011/09/27 Released by Harlan Stenn <stenn@ntp.org>
 +* sntp documentation tag cleanup.
 +* mdoc2man improvements.
 +(4.2.7p215) 2011/09/24 Released by Harlan Stenn <stenn@ntp.org>
 +* Use patched mdoc2man script, from Eric Feng.
 +* Sync with ntp-4.2.6p4 (a no-op).
 +(4.2.7p214) 2011/09/20 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1981] Initial offset convergence applies frequency correction 2x
 +  with kernel discipline.
 +* [Bug 2008] Initial offset convergence degraded with 500 PPM adjtime().
 +* [Bug 2009] EVNT_NSET adj_systime() mishandled by Windows ntpd.
 +(4.2.7p213) 2011/09/08 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1999] NMEA does not send PMOTG messages any more.
 +(4.2.7p212) 2011/09/07 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 2003] from 4.2.6p4-RC3: ntpq_read_assoc_peervars() broken.
 +(4.2.7p211) 2011/09/01 Released by Harlan Stenn <stenn@ntp.org>
 +* Update libevent to git head (2.1 branch) as of 2.0.14-stable.
 +(4.2.7p210) 2011/08/31 Released by Harlan Stenn <stenn@ntp.org>
 +* Require -D4 or higher for ntpd SIGALRM debug trace from [Bug 2000].
 +(4.2.7p209) 2011/08/27 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 2000] ntpd worker threads must block signals expected in main
 +  thread.
 +* [Bug 2001] add ntpq -c timerstats like ntpdc -c timerstats.
 +* [Bug 2001] from 4.2.6p4-RC3: ntpdc timerstats reports overruns as
 +  handled.
 +* Update sntp tests to track the change of root dispersion to
 +  synchronization distance.
 +(4.2.7p208) 2011/08/24 Released by Harlan Stenn <stenn@ntp.org>
 +* Fix the CLOCK_MONOTONIC TRACE() message.
 +(4.2.7p207) 2011/08/22 Released by Harlan Stenn <stenn@ntp.org>
 +* Restore the original CLOCK_MONOTONIC output format in sntp.
 +* Cleanups for ntp-wait-opts.def and ntp.keys.def .
 +(4.2.7p206) 2011/08/20 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1993] ntpd Windows port adj_systime() broken in 4.2.7p203.
 +* sntp documentation and behavior improvements suggested by
 +  Steven Sommars.
 +* Have sntp report synchronization distance instead of root dispersion.
 +* Clean up ntp-wait-opts.def .
 +(4.2.7p205) 2011/08/19 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1992] util/tg2 doesn't compile, needs libntp.
 +(4.2.7p204) 2011/08/16 Released by Harlan Stenn <stenn@ntp.org>
 +* Added support for Garmin's $PGRMF sentence to NMEA driver
 +* [Bug 1988] Better sntp send failed error message needed.
 +* [Bug 1989] sntp manual page sometimes refers to SNTP as a program.
 +* [Bug 1990] sntp output should include stratum.
 +(4.2.7p203) 2011/08/13 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1986] Require Visual C++ 2005 or later compilers in Windows port.
 +* Actually use long long for (u_)int64 by correcting spelling of
 +  SIZEOF_LONG_LONG in ntp_types.h.
 +* Force .exe minimum Windows version to 0x0400 to allow NT4 in
 +  vs2005/*.vcproj files.
 +* Fix make distcheck with --enable-libevent-regress problem with
 +  unwritable $srcdir.
 +* Correct init_logging()'s def_syslogmask type to u_int32 following
 +  change of ntp_syslogmask from u_long to u_int32 in p202.
 +(4.2.7p202) 2011/08/09 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1983] --without-sntp build breaks in sntp subdir.
 +* [Bug 1984] from 4.2.6p4-RC3: ntp/libisc fails to compile on OS X 10.7.
 +* [Bug 1985] from 4.2.6p4-RC3: "logconfig =allall" rejected.
 +(4.2.7p201) 2011/08/05 Released by Harlan Stenn <stenn@ntp.org>
 +* sntp: change -h/--headspace to -g/--gap, and change the default gap
 +  from 10 to 50ms
 +* [Backward Incompatible] from 4.2.6p4: sntp: -l/--filelog ->
 +  -l/--logfile, to be consistent with ntpd.
 +* Documentation updates from Dave Mills.
 +* From 4.2.6p4: libopts/file.c fix from Bruce Korb (arg-type=file).
 +(4.2.7p200) 2011/08/04 Released by Harlan Stenn <stenn@ntp.org>
 +* Sync with 4.2.6p4-RC2.
 +(4.2.7p199) 2011/07/29 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p198) 2011/07/28 Released by Harlan Stenn <stenn@ntp.org>
 +* remove old binsubdir stuff from SNTP, as NTP_LOCINFO does that now.
 +(4.2.7p197) 2011/07/28 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1975] from 4.2.6p4-RC2: libntp/mktime.c won't work with 64-bit
 +  time_t
 +* [Bug 1976] genLocInfo writes to srcdir break 'make distcheck'.
 +* [Bug 1977] Fix flag/description mismatches in ntp-keygen-opts.def.
 +* Do not force "legacy" when --with-locfile is not given, genLocInfo
 +  will find the correct default for the system.
 +* Fix warnings in ntp_request.c ([Bug 1973] oversight) and sntp/main.c
 +  (CID 159, apparent overrun due to union, actually correct).
 +* Update sntp/loc/solaris to conform to stock locations.
 +(4.2.7p196) 2011/07/27 Released by Harlan Stenn <stenn@ntp.org>
 +* DEFAULT INSTALLATION DIRECTORY CHANGES ON SOME OSes: to get the old
 +  behavior, pass --with-locfile=legacy to 'configure'
 +* [Bug 1972] from 4.2.6p4-RC2: checking for struct rtattr fails.
 +* [Bug 1973] Widen reference clock mode from 8 to 32 bits.
 +* Removed sntp/m4/ntp_bindir.m4 - no longer needed.
 +* Move loc/ to sntp/loc/ .
 +* Move scripts/cvo.sh to sntp/scripts/cvo.sh .
 +* Move scripts/genLocInfo to sntp/scripts/genLocInfo .
 +* Give NTP_LOCINFO an optional path-to argument.
 +* Remove hacks to get NTP_LOCINFO-related data to sntp/ .
 +* Move sntp/include/mansec2subst.sed to sntp/scripts/mansec2subst.sed .
 +* If no "more specific" loc file is found for redhat* or fedora*,
 +  look for a loc/redhat file.
 +* If no "more specific" loc file is found and uname says this is Linux,
 +  look for a loc/linux file.
 +* Improve the help text: --with-locfile=XXX .
 +* work around solaris /bin/sh issues for genLocInfo.
 +(4.2.7p195) 2011/07/25 Released by Harlan Stenn <stenn@ntp.org>
 +* Added loc/redhat.
 +(4.2.7p194) 2011/07/25 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1608] from 4.2.6p4-RC2: Parse Refclock driver should honor
 +  trusttime.
 +* Add support for installing programs and scripts to libexec.
 +* Added loc/solaris.
 +(4.2.7p193) 2011/07/24 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1970] from 4.2.6p4-RC2: UNLINK_EXPR_SLIST() causes crash if list
 +  is empty.
 +* Update libevent to 2.1 HEAD as of merge of 2.0.13-stable-dev.
 +* Match addr_eqprefix() sizeof and memcpy destination to make it clear
 +  to static analysis that there is no buffer overrun (CID 402).
 +(4.2.7p192) 2011/07/18 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1966] Broken FILES section for ntp.keys.def.
 +(4.2.7p191) 2011/07/17 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1948] Update man page section layout.
 +* [Bug 1963] add reset command for ntpq :config, similar to ntpdc's.
 +* [Bug 1964] --without-sntp should not build sntp.
 +(4.2.7p190) 2011/07/13 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1961] from 4.2.6p4: html2man update: distribute ntp-wait.html.
 +* Require autogen-5.12.
 +(4.2.7p189) 2011/07/11 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1134] from 4.2.6p4-RC1: ntpd fails binding to tentative IPv6
 +  addresses.
 +* [Bug 1790] from 4.2.6p4-RC1: Update config.guess and config.sub to
 +  detect AIX6.
 +(4.2.7p188) 2011/06/28 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1958] genLocInfo must export PATH.
 +* ntp-wait: some versions of ntpd spell "associd" differently.
 +(4.2.7p187) 2011/06/24 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1954] Fix typos in [s]bin_PROGRAMS in ntpd/Makefile.am.
 +* Implement --with-locfile=filename configure argument.  If filename is
 +  empty we'll look under loc/ for a good fit.  If the filename contains
 +  a / character, it will be treated as a "normal" pathname.  Otherwise,
 +  that explicit file will be searched for under loc/ .
 +(4.2.7p186) 2011/06/23 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1950] Control installation of event_rpcgen.py.
 +* Update .point-changed-filelist for the new man pages.
 +* Update the building of OS-specific programs.
 +* Finish conversion to genLocInfo.
 +* validate MANTAGFMT in genLocInfo.
 +* Documentation update from Dave Mills.
 +(4.2.7p185) 2011/06/21 Released by Harlan Stenn <stenn@ntp.org>
 +* ntp_locs.m4: handle the case where . is not in the PATH.
 +* More genLocInfo cleanup.
 +(4.2.7p184) 2011/06/20 Released by Harlan Stenn <stenn@ntp.org>
 +* Added ntp_locs.m4.
 +* genLocInfo improvements.
 +* Add the man page tag "flavor" to the loc.* files.
 +* Add/distribute genLocInfo.
 +(4.2.7p183) 2011/06/19 Released by Harlan Stenn <stenn@ntp.org>
 +* Update the autogen include list for scripts/Makefile.am.
 +* Added loc.freebsd (and distribute it).
 +* Added loc.legacy (and distribute it).
 +(4.2.7p182) 2011/06/15 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1304] Update sntp.html to reflect new implementation.
 +* Update .point-changed-filelist .
 +* ntpdc documentation fixes.
 +* Update ntp-wait autogen docs.
 +* Update the ntpd autogen docs.
 +* Update the ntpsnmpd autogen docs.
 +* Use autogen to produce ntp-keygen docs.
 +* Add "license name" to ntp.lic for autogen-5.11.10.
 +* Prepare for ntp.keys.5.
 +(4.2.7p181) 2011/06/07 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1938] addr_eqprefix() doesn't clear enough storage.
 +(4.2.7p180) 2011/06/06 Released by Harlan Stenn <stenn@ntp.org>
 +* Upgrade to libevent-2.0.12.
 +* More sntp.1 cleanups.
 +* Produce ntpq.1 with the new autogen macros.
 +* Remove the deprecated "detail" stanza from ntpdc-opts.def.
 +(4.2.7p179) 2011/06/03 Released by Harlan Stenn <stenn@ntp.org>
 +* Update cmd-doc.tlib to autogen-5.11.10pre5.
 +* Upgrade local autoopts templates to 5.11.10pre5.
 +(4.2.7p178) 2011/06/02 Released by Harlan Stenn <stenn@ntp.org>
 +* Update the std_def_list to include the ntp.lic file.
 +* Distribute the ntp.lic file.
 +* Add http://ntp.org/license to the ntp.lic file.
 +(4.2.7p177) 2011/06/01 Released by Harlan Stenn <stenn@ntp.org>
 +* Use the latest autogen's new copyright template code.
 +* Clean up the ntp.lic file.
 +(4.2.7p176) 2011/05/31 Released by Harlan Stenn <stenn@ntp.org>
 +* sntp documentation cleanup.
 +* autogen documentation template cleanup.
 +(4.2.7p175) 2011/05/30 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1936] Correctly set IPV6_MULTICAST_LOOP.
 +* cmd-doc.tlib cleanup from Bruce Korb.
 +* sntp documentation cleanup.
 +(4.2.7p174) 2011/05/28 Released by Harlan Stenn <stenn@ntp.org>
 +* ntpdc documentation cleanup.
 +* sntp documentation cleanup.
 +* Don't build libevent with openssl support.  Right now, libevent
 +  doesn't use pkg-config to find openssl's installation location.
 +(4.2.7p173) 2011/05/25 Released by Harlan Stenn <stenn@ntp.org>
 +* Typo in emalloc.c hides file and line number from emalloc() error msg.
 +* parsesolaris.c compile fails on SPARC Solaris with conflicting printf.
 +* ntp_util.c compile fails on AIX and OSF with conflicting statsdir.
 +(4.2.7p172) 2011/05/24 Released by Harlan Stenn <stenn@ntp.org>
 +* Remove hardcoded 1/960 s. fudge for <CR> transmission time at 9600 8n1
 +  from WWVB/Spectracom driver introduced in 4.2.7p169.
 +(4.2.7p171) 2011/05/23 Released by Harlan Stenn <stenn@ntp.org>
 +* Eliminate warnings about shadowing global "basename" on Linux.
 +* Use filegen_config() consistently when changing filegen options.
 +* mprintf() should go to stdout, not stderr.  DPRINTF() uses mprintf().
 +* Repair a few simulator problems (more remain).
 +* Documentation updates from Dave Mills.
 +(4.2.7p170) 2011/05/19 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1932] libevent/util_internal.h builtin_expect compile error with
 +  gcc 2.95.
 +* Use 64-bit scalars in LFPTOD() and DTOLFP() on more platforms by
 +  conditionalizing on HAVE_U_INT64 rather than UINT64_MAX.
 +(4.2.7p169) 2011/05/18 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1933] WWVB/Spectracom driver timestamps LFs, not CRs.
 +(4.2.7p168) 2011/05/16 Released by Harlan Stenn <stenn@ntp.org>
 +* Convert receive buffer queue from doubly-linked list to FIFO.
 +(4.2.7p167) 2011/05/14 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1927] io_closeclock() should purge pending recvbufs.
 +* [Bug 1931] cv always includes fudgetime1, never fudgetime2.
 +* Use acts_close() in acts_shutdown() to avoid leaving a stale lockfile
 +  if unpeered via runtime configuration while the modem is open.
 +* Correct acts_close() test of pp->io.fd to see if it is open.
 +* 4.2.7p164 documentation updates re: 'tos orphanwait' expanded scope.
 +(4.2.7p166) 2011/05/13 Released by Harlan Stenn <stenn@ntp.org>
 +* If we have local overrides for autogen template files, use them.
 +* Convert more of the sntp-opt.def documentation from man to mdoc.
 +(4.2.7p165) 2011/05/11 Released by Harlan Stenn <stenn@ntp.org>
 +* Convert snmp docs to mdoc format, which requires autogen 5.11.9.
 +* from 4.2.6p4-RC1: Require autogen 5.11.9.
 +(4.2.7p164) 2011/05/11 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 988] Local clock eats up -g option, so ntpd stops with large
 +  initial time offset.
 +* [Bug 1921] LOCAL, ACTS drivers with "prefer" excluded from initial
 +  candidate list.
 +* [Bug 1922] "tos orphanwait" applied incorrectly at startup.
 +* [Bug 1923] orphan parent favored over LOCAL, ACTS drivers.
 +* [Bug 1924] Billboard tally codes sometimes do not match operation,
 +  variables.
 +* Change "pool DNS" messages from msyslog to debug trace output.
 +* Remove unused FLAG_SYSPEER from peer->status.
 +* Respect "tos orphanwait" at startup.  Previously there was an
 +  unconditional 300 s. startup orphanwait, though other values were
 +  respected for subsequent orphan wait periods after no_sys_peer events.
 +* Apply "tos orphanwait" (def. 300 seconds) to LOCAL and ACTS reference
 +  clock drivers, in addition to orphan parent operation.  LOCAL and ACTS
 +  are not selectable during the orphanwait delay at startup and after
 +  each no_sys_peer event.  This prevents a particular form of clock-
 +  hopping, such as using LOCAL briefly at startup before remote peers
 +  are selectable.  This fixes the issue reported in [Bug 988].
 +* Documentation updates from Dave Mills.
 +(4.2.7p163) 2011/05/08 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1911] missing curly brace in libntp/ntp_rfc2553.c
 +(4.2.7p162) 2011/05/03 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1910] Support the Tristate Ltd. TS-GPSclock-01.
 +(4.2.7p161) 2011/05/02 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1904] 4.2.7p160 Windows build broken (POSIX_SHELL).
 +* [Bug 1906] 4.2.7p160 - libtool: compile: cannot determine name of
 +  library object in ./libevent
 +* Share a single sntp/libevent/build-aux directory between all three
 +  configure scripts.
 +* Add missing --enable-local-libevent help to top-level configure.
 +(4.2.7p160) 2011/05/01 Released by Harlan Stenn <stenn@ntp.org>
 +* from 4.2.6p4-RC1: Upgrade to libopts 35.0.10 from AutoGen 5.11.9pre8.
 +* [Bug 1901] Simulator does not set progname.
 +(4.2.7p159) 2011/04/28 Released by Harlan Stenn <stenn@ntp.org>
 +* Fix a couple of unused variable warnings.
 +* cleanup in timespecops.c / timevalops.c
 +(4.2.7p158) 2011/04/24 Released by Harlan Stenn <stenn@ntp.org>
 +* Update libevent --disable-libevent-regress handling to work when
 +  building libevent using mingw.
 +(4.2.7p157) 2011/04/21 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1890] 4.2.7p156 segfault in duplicate freeaddrinfo().
 +(4.2.7p156) 2011/04/19 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1851] freeaddrinfo() called after getaddrinfo() fails.
 +(4.2.7p155) 2011/04/18 Released by Harlan Stenn <stenn@ntp.org>
 +* Fix leak in refclock_datum.c start failure path.
 +(4.2.7p154) 2011/04/17 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1887] DNS fails on 4.2.7p153 using threads.
 +(4.2.7p153) 2011/04/16 Released by Harlan Stenn <stenn@ntp.org>
 +* A few more Coverity Scan cleanups.
 +(4.2.7p152) 2011/04/15 Released by Harlan Stenn <stenn@ntp.org>
 +* Update embedded libevent to current 2.1 git HEAD.
 +(4.2.7p151) 2011/04/14 Released by Harlan Stenn <stenn@ntp.org>
 +* Detect vsnprintf() support for "%m" and disable our "%m" expansion.
 +* Add --enable-c99-sprintf to configure args for -noopenssl variety of
 +  flock-build to avoid regressions in (v)snprintf() replacement.
 +* More msnprintf() unit tests.
 +* Coverity Scan error checking fixes.
 +* Log failure to fetch time from HOPF_P hardware.
 +* Check HOPF_S sscanf() conversion count before converted values.
 +(4.2.7p150) 2011/04/13 Released by Harlan Stenn <stenn@ntp.org>
 +* Remove never-used, incomplete ports/winnt/ntpd/refclock_trimbledc.[ch]
 +* On systems without C99-compliant (v)snprintf(), use C99-snprintf
 +  replacements (http://www.jhweiss.de/software/snprintf.html)
 +* Remove remaining sprintf() calls except refclock_ripencc.c (which is
 +  kept out of --enable-all-clocks as a result), upstream libs which use
 +  sprintf() only after careful buffer sizing.
 +(4.2.7p149) 2011/04/11 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1881] describe the {+,-,s} characters in configure --help output.
 +(4.2.7p148) 2011/04/09 Released by Harlan Stenn <stenn@ntp.org>
 +* Use _mkgmtime() as timegm() in the Windows port, rather than
 +  libntp/mktime.c's timegm().  Fixed [Bug 1875] on Windows using the old
 +  asn2ntp() code from before 4.2.7p147.
 +* ntp_crypto.c string buffer safety.
 +* Remove use of MAXFILENAME in mode 7 (ntpdc) on-wire structs.
 +* Change ntpd MAXFILENAME from 128 to 256 to match ntp-keygen.
 +* Buffer safety and sign extension fixes (thanks Coverity Scan).
 +(4.2.7p147) 2011/04/07 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1875] 'asn2ntp()' rewritten with 'caltontp()'; 'timegm()'
 +  substitute likely to crash with 64bit time_t.
 +(4.2.7p146) 2011/04/05 Released by Harlan Stenn <stenn@ntp.org>
 +* String buffer safety cleanup, converting to strlcpy() and strlcat().
 +* Use utmpname() before pututline() so repeated steps do not
 +  accidentally record into wtmp where utmp was intended.
 +* Use setutent() before each pututline() including first.
 +(4.2.7p145) 2011/04/04 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1840] ntp_lists.h FIFO macros buggy.
 +(4.2.7p144) 2011/04/03 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1874] ntpq -c "rv 0 sys_var_list" empty.
 +(4.2.7p143) 2011/03/31 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1732] ntpd ties up CPU on disconnected USB refclock.
 +* [Bug 1861] tickadj build failure using uClibc.
 +* [Bug 1862] in6addr_any test in configure fooled by arm gcc 4.1.3 -O2.
 +* Remove kernel line discipline driver code for clk and chu, deprecate
 +  related LDISC_ flags, and remove associated ntpd code to decode the
 +  timestamps, remove clktest line discipline test program.
 +* Remove "signal_no_reset: signal 17 had flags 4000000" logging, as it
 +  indicates no problem and is interpreted as an error.  Previously some
 +  bits had been ignored one-by-one, but Linux SA_RESTORER definition is
 +  unavailable to user headers.
 +(4.2.7p142) 2011/03/21 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1844] ntpd 4.2.7p131 NetBSD, --gc-sections links bad executable.
 +* Fix "make distcheck" break in libevent/sample caused by typo.
 +(4.2.7p141) 2011/03/20 Released by Harlan Stenn <stenn@ntp.org>
 +* Add "ntpq -c iostats" similar to "ntpdc -c iostats".
 +* Compare entire timestamp to reject duplicates in refclock_pps().
 +(4.2.7p140) 2011/03/17 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1848] ntpd 4.2.7p139 --disable-thread-support does not compile.
 +* Add --disable-thread-support to one flock-build variation.
 +* One more lock-while-init in lib/isc/task.c to quiet lock analysis.
 +(4.2.7p139) 2011/03/16 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1848] make check ntpd --saveconfigquit clutters syslog.
 +(4.2.7p138) 2011/03/08 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1846] MacOSX: debug symbol not found by propdelay or tickadj.
 +(4.2.7p137) 2011/03/07 Released by Harlan Stenn <stenn@ntp.org>
 +* Use TRACE() instead of DPRINTF() for libntp and utilities, which
 +  use the "debug" variable regardless of #ifdef DEBUG.
 +* Declare debug in libntp instead of each program.  Expose extern
 +  declaration to utilities, libntp, and DEBUG ntpd.
 +* Lock under-construction task, taskmgr objects to satisfy Coverity's
 +  mostly-correct assumptions about which variables are protected by
 +  which locks.
 +(4.2.7p136) 2011/03/02 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1839] 4.2.7p135 still installs libevent ev*.h headers.
 +(4.2.7p135) 2011/03/02 Released by Harlan Stenn <stenn@ntp.org>
 +* libevent: When building on systems with CLOCK_MONOTONIC available,
 +  separate the internal timeline (possibly counting since system boot)
 +  from the gettimeofday() timeline in event_base cached timevals.  Adds
 +  new event_base_tv_cached() to retrieve cached callback round start
 +  time on the internal timeline, and changes
 +  event_based_gettimeofday_cached() to always return times using the
 +  namesake timeline.  This preserves the benefit of using the never-
 +  stepped monotonic clock for event timeouts while providing clients
 +  with times consistently using gettimeofday().
 +* Correct event_base_gettimeofday_cached() workaround code in
 +  sntp to work with corrected libevent.
 +* Remove sntp l_fp_output() test now that it uses prettydate().
 +* [Bug 1839] 4.2.7p131 installs libevent ev*.h headers.
 +* Ensure CONFIG_SHELL is not empty before relying on it for #! scripts.
 +(4.2.7p134) 2011/02/24 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1837] Build fails on Win7 due to regedit requiring privilege.
 +* Provide fallback definitions for GetAdaptersAddresses() for Windows
 +  build environments lacking iphlpapi.h.
 +* Rename file containing 1.xxxx ChangeSet revision from version to
 +  scm-rev to avoid invoking GNU make implicit rules attempting to
 +  compile version.c into version.  Problem was with sntp/version.o
 +  during make distcheck after fix for spurious sntp rebuilds.
 +* Add INC_ALIGNED_PTR() macro to align pointers like malloc().
 +(4.2.7p133) 2011/02/23 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1834] ntpdate 4.2.7p131 aborts with assertion failure.
 +* Move sntp last in top-level Makefile.am SUBDIRS so that the libevent
 +  tearoff (if required) and sntp are compiled after the rest.
 +* Use a single set of Automake options for each package in configure.ac
 +  AM_INIT, remove Makefile.am AUTOMAKE_OPTIONS= lines.
 +* Correct spurious sntp rebuilds triggered by a make misperception
 +  sntp/version was out-of-date relative to phony target FRC.version.
 +* Do not cache paths to perl, test, or pkg-config, searching the PATH
 +  at configure time is worth it to pick up tool updates.
 +(4.2.7p132) 2011/02/22 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1832] ntpdate doesn't allow timeout > 2s.
 +* [Bug 1833] The checking sem_timedwait() fails without -pthread.
 +* ElectricFence was suffering bitrot - remove it.  valgrind works well.
 +* Enable all relevant automake warnings.
 +* Correct Solaris 2.1x PTHREAD_ONCE_INIT extra braces test to avoid
 +  triggering warnings due to excess braces.
 +* Remove libevent-cfg from sntp/Makefile.am.
 +* Provide bug report and URL options to Autoconf.
 +* Avoid relying on remake rules for routine build/flock-build for
 +  libevent as for the top-level and sntp subproject.
 +(4.2.7p131) 2011/02/21 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1087] -v/--normalverbose conflicts with -v/--version in sntp.
 +* [Bug 1088] sntp should (only) report the time difference without -s/-a.
 +* older autoconf sometimes dislikes [].
 +* Move "can't write KoD file" warning from sntp shutdown to startup.
 +* refclock_acts.c cleanup from Dave Mills.
 +* Convert sntp to libevent event-driven socket programming.  Instead of
 +  blocking name resolution and querying one NTP server at a time,
 +  resolve server names and send NTP queries without blocking.  Add
 +  sntp command-line options to adjust timing and optionally wait for all
 +  servers to respond instead of exiting after the first.
 +* Import libevent 2.0.10-stable plus local patches as a tearoff, used
 +  only if the target system lacks an installed libevent 2.0.9 or later.
 +* Move blocking worker and resolver to libntp from ntpd.
 +* Use threads rather than forked child processes for blocking worker
 +  when possible.  Override with configure --disable-thread-support.
 +* Move init_logging(), change_logfile(), and setup_logfile() from ntpd
 +  to libntp, use them in sntp.
 +* Test --without-sntp in flock-build script's -no-refclocks variety.
 +* Avoid invoking config.status twice in a row in build script.
 +* Move more m4sh tests needed by libntp to shared .m4 files.
 +* Split up ntp_libntp.m4 into smaller, more specific subsets.
 +* Enable gcc -Wcast-align, fix many instances of warnings when casting
 +  a pointer to a more-strictly-aligned underlying type.
 +(4.2.7p130) 2011/02/12 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1811] Update the download location in WHERE-TO-START.
 +(4.2.7p129) 2011/02/09 Released by Harlan Stenn <stenn@ntp.org>
 +* Add missing "break;" to ntp_control.c ctl_putsys() for caliberrs, used
 +  by ntpq -c kerninfo introduced in 4.2.7p104.
 +* Fix leak in ntp_control.c read_mru_list().
 +(4.2.7p128) 2011/01/30 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1799] ntpq mrv crash.
 +* [Bug 1801] ntpq mreadvar requires prior association caching.
 +(4.2.7p127) 2011/01/28 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1797] Restore stale timestamp check from the RANGEGATE cleanup.
 +(4.2.7p126) 2011/01/27 Released by Harlan Stenn <stenn@ntp.org>
 +* Fix unexposed fencepost error in format_time_fraction().
 +* Add more unit tests for timeval_tostr() and timespec_tostr().
 +(4.2.7p125) 2011/01/26 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1794] ntpq -c rv missing clk_wander information.
 +* [Bug 1795] ntpq readvar does not display last variable.
 +(4.2.7p124) 2011/01/25 Released by Harlan Stenn <stenn@ntp.org>
 +* sntp/Makefile.am needs any passed-in CFLAGS.
 +(4.2.7p123) 2011/01/24 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1788] tvtots.c tables inaccurate
 +(4.2.7p122) 2011/01/22 Released by Harlan Stenn <stenn@ntp.org>
 +* ACTS refclock cleanup from Dave Mills.
 +* Avoid shadowing the "group" global variable.
 +(4.2.7p121) 2011/01/21 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1786] Remove extra semicolon from ntp_proto.c .
 +(4.2.7p120) 2011/01/20 Released by Harlan Stenn <stenn@ntp.org>
 +* Change new timeval and timespec to string routines to use snprintf()
 +  rather than hand-crafted conversion, avoid signed int overflow there.
 +* Add configure support for SIZEOF_LONG_LONG to enable portable use of
 +  snprintf() with time_t.
 +* Grow ntpd/work_thread.c arrays as needed.
 +* Add DEBUG_* variants of ntp_assert.h macros which compile away using
 +  ./configure --disable-debugging.
 +* Fix tvalops.cpp unit test failures for 32-bit builds.
 +* Return to a single autoreconf invocation in ./bootstrap script.
 +* Fix warnings seen on FreeBSD 9.
 +* crypto group changes from Dave Mills.
 +* Lose the RANGEGATE check in PPS, from Dave Mills.
 +* ACTS refclock cleanup from Dave Mills.
 +* Documentation updates from Dave Mills.
 +* NMEA driver documentation update from Juergen Perlinger.
 +(4.2.7p119) 2011/01/18 Released by Harlan Stenn <stenn@ntp.org>
 +* added timespecops.{c,h} and tievalops.{c.h} to libntp and include
 +  added tspecops.cpp to tests/libntp
 +* Correct msyslog.c build break on Solaris 2.9 from #ifdef/#if mixup.
 +(4.2.7p118) 2011/01/15 Released by Harlan Stenn <stenn@ntp.org>
 +* Simplify the built-sources stuff in sntp/ .
 +* Fix check for -lipv6 on HP-UX 11.
 +(4.2.7p117) 2011/01/13 Released by Harlan Stenn <stenn@ntp.org>
 +* Add configure --without-sntp option to disable building sntp and
 +  sntp/tests.  withsntp=no in the environment changes the default.
 +* Build infrastructure cleanup:
 +  Move m4 directory to sntp/m4.
 +  Share a single set of genver output between sntp and the top level.
 +  Share a single set of autogen included .defs in sntp/include.
 +  Share a single set of build-aux scripts (e.g. config.guess, missing).
 +  Add ntp_libntp.m4 and ntp_ipv6.m4 to reduce configure.ac duplication.
 +  Warn and exit build/flock-build if bootstrap needs to be run.
 +(4.2.7p116) 2011/01/10 Released by Harlan Stenn <stenn@ntp.org>
 +* refclock_nmea.c refactoring by Juergen Perlinger.
 +(4.2.7p115) 2011/01/09 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1780] Windows ntpd 4.2.7p114 crashes in ioctl().
 +* [Bug 1781] longlong undefined in sntp handle_pkt() on Debian amd64.
 +(4.2.7p114) 2011/01/08 Released by Harlan Stenn <stenn@ntp.org>
 +* Fix for openssl pkg-config detection eval failure.
 +* Add erealloc_zero(), refactor estrdup(), emalloc(), emalloc_zero() to
 +  separate tracking callsite file/line from using debug MS C runtime,
 +  and to reduce code duplication.
 +(4.2.7p113) 2011/01/07 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1776] sntp mishandles -t/--timeout and -a/--authentication.
 +* Default to silent make rules, override with make V=1 or ./configure
 +  --disable-silent-rules.
 +* Correct --with-openssl-incdir defaulting with pkg-config.
 +* Correct ./build on systems without gtest available.
 +* Begin moving some of the low-level socket stuff to libntp.
 +(4.2.7p112) 2011/01/06 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1773] openssl not detected during ./configure.
 +* [Bug 1774] Segfaults if cryptostats enabled and built without OpenSSL.
 +* Use make V=0 in build script to increase signal/noise ratio.
 +(4.2.7p111) 2011/01/05 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1772] refclock_open() return value check wrong for ACTS.
 +* Default --with-openssl-libdir and --with-openssl-incdir to the values
 +  from pkg-config, falling back on our usual search paths if pkg-config
 +  is not available or does not have openssl.pc on PKG_CONFIG_PATH.
 +* Change refclock_open() to return -1 on failure like open().
 +* Update all refclock_open() callers to check for fd <= 0 indicating
 +  failure, so they work with older and newer refclock_open() and can
 +  easily backport.
 +* Initialize refclockproc.rio.fd to -1, harmonize refclock shutdown
 +  entrypoints to avoid crashing, particularly if refclock_open() fails.
 +* Enable tickadj-like taming of wildly off-spec Windows clock using
 +  NTPD_TICKADJ_PPM env. var. specifying baseline slew.
 +(4.2.7p110) 2011/01/04 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1771] algorithmic error in 'clocktime()' fixed.
 +* Unit tests extended for hard-coded system time.
 +* make V=0 and configure --enable-silent-rules supported.
 +* setvar modemsetup = ATE0... overrides ACTS driver default.
 +* Preserve last timecode in ACTS driver (ntpq -ccv).
 +* Tolerate previous ATE1 state when sending ACTS setup.
 +* Enable raw tty line discipline in Windows port.
 +* Allow tty open/close/open to succeed on Windows port.
 +* Enable ACTS and CHU reference clock drivers on Windows.
 +(4.2.7p109) 2011/01/02 Released by Harlan Stenn <stenn@ntp.org>
 +* Remove nearly all strcpy() and most strcat() from NTP distribution.
 +  One major pocket remains in ntp_crypto.c.  libopts & libisc also have
 +  (safe) uses of strcpy() and strcat() remaining.
 +* Documentation updates from Dave Mills.
 +(4.2.7p108) 2011/01/01 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1764] Move Palisade modem control logic to configure.ac.
 +* [Bug 1768] TIOCFLUSH undefined in linux for refclock_acts.
 +* Autokey multiple identity group improvements from Dave Mills.
 +* from 4.2.6p3: Update the copyright year.
 +(4.2.7p107) 2010/12/31 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1764] Palisade driver doesn't build on Linux.
 +* [Bug 1766] Oncore clock has offset/high jitter at startup.
 +* Move ntp_control.h variable IDs to ntp_control.c, remove their use by
 +  ntpq.  They are implementation details private to ntpd.  [Bug 597] was
 +  caused by ntpq's reliance on these IDs it need not know about.
 +* refclock_acts.c updates from Dave Mills.
 +(4.2.7p106) 2010/12/30 Released by Harlan Stenn <stenn@ntp.org>
 +* from 4.2.6p3: Update genCommitLog for the bk-5 release.
 +(4.2.7p105) 2010/12/29 Released by Harlan Stenn <stenn@ntp.org>
 +(4.2.7p104) 2010/12/28 Released by Harlan Stenn <stenn@ntp.org>
 +* from 4.2.6p3: Create and use scripts/check--help when generating
 +  .texi files.
 +* from 4.2.6p3: Update bk triggers for the bk-5 release.
 +* Support for multiple Autokey identity groups from Dave Mills.
 +* Documentation updates from Dave Mills.
 +* Add ntpq kerninfo, authinfo, and sysinfo commands similar to ntpdc's.
 +(4.2.7p103) 2010/12/24 Released by Harlan Stenn <stenn@ntp.org>
 +* Add ntpq pstats command similar to ntpdc's.
 +* Remove ntpq pstatus command, rv/readvar does the same and more.
 +* Documentation updates from Dave Mills.
 +(4.2.7p102) 2010/12/23 Released by Harlan Stenn <stenn@ntp.org>
 +* Allow ntpq &1 associd use without preceding association-fetching.
 +* Documentation updates from Dave Mills.
 +(4.2.7p101) 2010/12/22 Released by Harlan Stenn <stenn@ntp.org>
 +* from 4.2.6p3-RC12: Upgrade to libopts 34.0.9 from AutoGen 5.11.6pre7.
 +* from 4.2.6p3-RC12: Relax minimum Automake version to 1.10 with updated
 +  libopts.m4.
 +(4.2.7p100) 2010/12/21 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1743] from 4.2.6p3-RC12: Display timezone offset when showing
 +  time for sntp in the local timezone (documentation updates).
 +(4.2.7p99) 2010/12/21 Released by Harlan Stenn <stenn@ntp.org>
 +* Add unit tests for msnprintf().
 +(4.2.7p98) 2010/12/20 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1761] clockstuff/clktest-opts.h omitted from tarball.
 +* [Bug 1762] from 4.2.6p3-RC12: manycastclient responses interfere.
 +* Documentation updates from Dave Mills.
 +(4.2.7p97) 2010/12/19 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1458] from 4.2.6p3-RC12: Can not compile NTP on FreeBSD 4.7.
 +* [Bug 1760] from 4.2.6p3-RC12: ntpd Windows interpolation cannot be
 +  disabled.
 +* from 4.2.6p3-RC12: Upgrade to libopts 34.0.9 from AutoGen 5.11.6pre5.
 +* Documentation updates from Dave Mills.
 +(4.2.7p96) 2010/12/18 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1758] from 4.2.6p3-RC12: setsockopt IPV6_MULTICAST_IF with wrong
 +  ifindex.
 +* Documentation updates from Dave Mills.
 +(4.2.7p95) 2010/12/17 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1753] 4.2.7p94 faults on startup in newpeer(), strdup(NULL).
 +* [Bug 1754] from 4.2.6p3-RC12: --version output should be more verbose.
 +* [Bug 1757] from 4.2.6p3-RC12: oncore snprintf("%m") doesn't expand %m.
 +* from 4.2.6p3-RC12: Suppress ntp-keygen OpenSSL version display for
 +  --help, --version, display both build and runtime OpenSSL versions
 +  when they differ.
 +* from 4.2.6p3-RC12: Upgrade to libopts 33.5.8 from AutoGen 5.11.6pre3.
 +* Documentation updates from Dave Mills.
 +(4.2.7p94) 2010/12/15 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1751] from 4.2.6p3-RC12: Support for Atari FreeMiNT OS.
 +* Documentation updates from Dave Mills.
 +(4.2.7p93) 2010/12/13 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1510] from 4.2.6p3-RC12: Add modes 20/21 for driver 8 to support
 +  RAWDCF @ 75 baud.
 +* [Bug 1741] from 4.2.6p3-RC12: Enable multicast reception on each
 +  address (Windows).
 +* from 4.2.6p3-RC12: Other manycastclient repairs:
 +  Separate handling of scope ID embedded in many in6_addr from ifindex
 +  used for IPv6 multicasting ioctls.
 +  Add INT_PRIVACY endpt bit flag for IPv6 RFC 4941 privacy addresses.
 +  Enable outbound multicast from only one address per interface in the
 +  same subnet, and in that case prefer embedded MAC address modified
 +  EUI-64 IPv6 addresses first, then static, and last RFC 4941 privacy
 +  addresses.
 +  Use setsockopt(IP[V6]_MULTICAST_IF) before each send to multicast to
 +  select the local source address, using the correct socket is not
 +  enough.
 +* "server ... ident <groupname>" changes from Dave Mills.
 +* Documentation updates from Dave Mills.
 +(4.2.7p92) 2010/12/08 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1743] from 4.2.6p3-RC12: Display timezone offset when showing
 +  time for sntp in the local timezone.
 +(4.2.7p91) 2010/12/07 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1732] ntpd ties up CPU on disconnected USB device.
 +* [Bug 1742] form 4.2.6p3-RC12: Fix a typo in an error message in the
 +  "build" script.
 +(4.2.7p90) 2010/12/06 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1738] Windows ntpd has wrong net adapter name.
 +* [Bug 1740] ntpdc -c reslist packet count wrongly treated as signed.
 +(4.2.7p89) 2010/12/04 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1736] tos int, bool options broken in 4.2.7p66.
 +* from 4.2.6p3-RC12: Clean up the SNTP documentation.
 +(4.2.7p88) 2010/12/02 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1735] 'clocktime()' aborts ntpd on bogus input
 +(4.2.7p87) 2010/12/01 Released by Harlan Stenn <stenn@ntp.org>
 +* from 4.2.6p3-RC12: Clean up m4 quoting in configure.ac, *.m4 files,
 +  resolving intermittent AC_LANG_PROGRAM possibly undefined errors.
 +(4.2.7p86) 2010/11/29 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p85) 2010/11/24 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p84) 2010/11/22 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1618] Unreachable code in jjy_start().
 +* [Bug 1725] from 4.2.6p3-RC11: ntpd sends multicast from only one
 +  address.
 +* from 4.2.6p3-RC11: Upgrade libopts to 33.3.8.
 +* from 4.2.6p3-RC11: Bump minimum Automake version to 1.11, required for
 +  AM_COND_IF use in LIBOPTS_CHECK.
 +* An almost complete rebuild of the initial loopfilter configuration
 +  process, including the code that determines the interval between
 +  frequency file updates, from Dave Mills.
 +* Documentation updates from Dave Mills.
 +* Add ntp-keygen -l/--lifetime to control certificate expiry.
 +* JJY driver improvements for Tristate JJY01/02, including changes
 +  to its clockstats format.
 +* Add "nonvolatile" ntp.conf directive to control how often the
 +  driftfile is written.
 +(4.2.7p83) 2010/11/17 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1727] ntp-keygen PLEN, ILEN undeclared --without-crypto.
 +* Remove top-level libopts, use sntp/libopts.
 +* from 4.2.6p3-RC11: Remove log_msg() and debug_msg() from sntp in favor
 +  of msyslog().
 +* Documentation updates from Dave Mills.
 +(4.2.7p82) 2010/11/16 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1728] from 4.2.6p3-RC11: In ntp_openssl.m4, don't add
 +  -I/usr/include or -L/usr/lib to CPPFLAGS or LDFLAGS.
 +(4.2.7p81) 2010/11/14 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1681] from 4.2.6p3-RC10: More sntp logging cleanup.
 +* [Bug 1683] from 4.2.6p3-RC10: Non-localhost on loopback exempted from
 +  nic rules.
 +* [Bug 1719] Cleanup for ntp-keygen and fix -V crash, from Dave Mills.
 +(4.2.7p80) 2010/11/10 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1574] from 4.2.6p3-RC9: sntp doesn't set tv_usec correctly.
 +* [Bug 1681] from 4.2.6p3-RC9: sntp logging cleanup.
 +* [Bug 1683] from 4.2.6p3-RC9: Interface binding does not seem to work
 +  as intended.
 +* [Bug 1708] make check fails with googletest 1.4.0.
 +* [Bug 1709] from 4.2.6p3-RC9: ntpdate ignores replies with equal
 +  receive and transmit timestamps.
 +* [Bug 1715] sntp utilitiesTest.IPv6Address failed.
 +* [Bug 1718] Improve gtest checks in configure.ac.
 +(4.2.7p79) 2010/11/07 Released by Harlan Stenn <stenn@ntp.org>
 +* Correct frequency estimate with no drift file, from David Mills.
 +(4.2.7p78) 2010/11/04 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1697] filegen implementation should be improved.
 +* Refactor calendar functions in terms of new common code.
 +* Documentation updates from Dave Mills.
 +(4.2.7p77) 2010/11/03 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1692] packageinfo.sh needs to be "sourced" using ./ .
 +* [Bug 1695] ntpdate takes longer than necessary.
 +(4.2.7p76) 2010/11/02 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1690] Unit tests fails to build on some systems.
 +* [Bug 1691] Use first NMEA sentence each second.
 +* Put the sntp tests under sntp/ .
 +* ... and only build/run them if we have gtest.
 +* Documentation updates from Dave Mills.
 +(4.2.7p75) 2010/10/30 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +* Include Linus Karlsson's GSoC 2010 testing code.
 +(4.2.7p74) 2010/10/29 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1685] from 4.2.6p3-RC8: NMEA driver mode byte confusion.
 +* from 4.2.6p3-RC8: First cut at using scripts/checkChangeLog.
 +* Documentation updates from Dave Mills.
 +(4.2.7p73) 2010/10/27 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1680] Fix alignment of clock_select() arrays.
 +* refinements to new startup behavior from David Mills.
 +* For the bootstrap script, touch .html files last.
 +* Add 'make check' test case that would have caught [Bug 1678].
 +(4.2.7p72) 2010/10/26 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1679] Fix test for -lsocket.
 +* Clean up missing ;; entries in configure.ac.
 +(4.2.7p71) 2010/10/25 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1676] from 4.2.6p3-RC7: NMEA: $GPGLL did not work after fix
 +  for Bug 1571.
 +* [Bug 1678] "restrict source" treated as "restrict default".
 +* from 4.2.6p3-RC7: Added scripts/checkChangeLog.
 +(4.2.7p70) 2010/10/24 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1571] from 4.2.6p3-RC6: NMEA does not relate data to PPS edge.
 +* [Bug 1572] from 4.2.p63-RC6: NMEA time adjustment for GPZDG buggy.
 +* [Bug 1675] from 4.2.6p3-RC6: Prohibit includefile remote config.
 +* Enable generating ntpd/ntp_keyword.h after keyword-gen.c changes on
 +  Windows as well as POSIX platforms.
 +* Fix from Dave Mills for a rare singularity in clock_combine().
 +(4.2.7p69) 2010/10/23 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1671] Automatic delay calibration is sometimes inaccurate.
 +(4.2.7p68) 2010/10/22 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1669] from 4.2.6p3-RC5: NTP fails to compile on IBM AIX 5.3.
 +* [Bug 1670] Fix peer->bias and broadcastdelay.
 +* Documentation updates from Dave Mills.
 +* Documentation EOL cleanup.
 +(4.2.7p67) 2010/10/21 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1649] from 4.2.6p3-RC5: Require NMEA checksum if $GPRMC or
 +  previously seen.
 +(4.2.7p66) 2010/10/19 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1277] Provide and use O(1) FIFOs, esp. in the config tree code.
 +* Remove unused 'bias' configuration keyword.
 +(4.2.7p65) 2010/10/16 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1584] from 4.2.6p3-RC4: wrong SNMP type for precision,
 +  resolution.
 +* Remove 'calldelay' and 'sign' remnants from parser, ntp_config.c.
 +(4.2.7p64) 2010/10/15 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1584] from 4.2.6p3-RC3: ntpsnmpd OID must be mib-2.197.
 +* [Bug 1659] from 4.2.6p3-RC4: Need CLOCK_TRUETIME not CLOCK_TRUE.
 +* [Bug 1663] ntpdsim should not open net sockets.
 +* [Bug 1665] from 4.2.6p3-RC4: is_anycast() u_int32_t should be u_int32.
 +* from 4.2.6p3: ntpsnmpd, libntpq warning cleanup.
 +* Remove 'calldelay' and 'sign' keywords (Dave Mills).
 +* Documentation updates from Dave Mills.
 +(4.2.7p63) 2010/10/13 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1080] from 4.2.6p3-RC3: ntpd on ipv6 routers very chatty.
 +* Documentation nit cleanup.
 +* Documentation updates from Dave Mills.
 +(4.2.7p62) 2010/10/12 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 750] from 4.2.6p3-RC3: Non-existing device causes coredump with 
 +  RIPE-NCC driver.
 +* [Bug 1567] from 4.2.6p3-RC3: Support Arbiter 1093C Satellite Clock on
 +  Windows.
 +* [Bug 1581] from 4.2.6p3-RC3: printf format string mismatch leftover.
 +* [Bug 1659] from 4.2.6p3-RC3: Support Truetime Satellite Clocks on
 +  Windows. 
 +* [Bug 1660] from 4.2.6p3-RC3: On some systems, test is in /usr/bin, not
 +  /bin. 
 +* [Bug 1661] from 4.2.6p3-RC3: Re-indent refclock_ripencc.c.
 +* Lose peer_count from ntp_peer.c and ntp_proto.c (Dave Mills).
 +* Documentation updates from Dave Mills.
 +(4.2.7p61) 2010/10/06 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation and code cleanup from Dave Mills. No more NTP_MAXASSOC.
 +(4.2.7p60) 2010/10/04 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p59) 2010/10/02 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +* Variable name cleanup from Dave Mills.
 +* [Bug 1657] darwin needs res_9_init, not res_init.
 +(4.2.7p58) 2010/09/30 Released by Harlan Stenn <stenn@ntp.org>
 +* Clock select bugfix from Dave Mills.
 +* [Bug 1554] peer may stay selected as system peer after becoming
 +  unreachable.
 +* [Bug 1644] from 4.2.6p3-RC3: cvo.sh should use lsb_release to identify
 +  linux distros.
 +* [Bug 1646] ntpd crashes with relative path to logfile.
 +(4.2.7p57) 2010/09/27 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p56) 2010/09/25 Released by Harlan Stenn <stenn@ntp.org>
 +* Clock combining algorithm improvements from Dave Mills.
 +* Documentation updates from Dave Mills.
 +* [Bug 1642] ntpdsim can't find simulate block in config file.
 +* [Bug 1643] from 4.2.6p3-RC3: Range-check the decoding of the RIPE-NCC
 +  status codes.
 +(4.2.7p55) 2010/09/22 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +* [Bug 1636] from 4.2.6p3-RC2: segfault after denied remote config.
 +(4.2.7p54) 2010/09/21 Released by Harlan Stenn <stenn@ntp.org>
 +* More Initial convergence improvements from Dave Mills.
 +* Documentation updates from Dave Mills.
 +* [Bug 1635] from 4.2.6p3-RC2: "filegen ... enable" is not default.
 +(4.2.7p53) 2010/09/20 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +* More Initial convergence improvements from Dave Mills.
 +(4.2.7p52) 2010/09/19 Released by Harlan Stenn <stenn@ntp.org>
 +* Initial convergence improvements from Dave Mills.
 +(4.2.7p51) 2010/09/18 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1344] from 4.2.6p3-RC1: ntpd on Windows exits without logging
 +  cause.
 +* [Bug 1629] 4.2.7p50 configure.ac changes invalidate config.cache.
 +* [Bug 1630] 4.2.7p50 cannot bootstrap on Autoconf 2.61.
 +(4.2.7p50) 2010/09/16 Released by Harlan Stenn <stenn@ntp.org>
 +* Cleanup NTP_LIB_M.
 +* [Bug 1628] Clean up -lxnet/-lsocket usage for (open)solaris.
 +(4.2.7p49) 2010/09/13 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p48) 2010/09/12 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +(4.2.7p47) 2010/09/11 Released by Harlan Stenn <stenn@ntp.org>
 +* Documentation updates from Dave Mills.
 +* [Bug 1588] finish configure --disable-autokey implementation.
 +* [Bug 1616] refclock_acts.c: if (pp->leap == 2) is always false.
 +* [Bug 1620] [Backward Incompatible] "discard minimum" value should be in
 +  seconds, not log2 seconds.
 +(4.2.7p46) 2010/09/10 Released by Harlan Stenn <stenn@ntp.org>
 +* Use AC_SEARCH_LIBS instead of AC_CHECK_LIB for NTP_LIB_M.
 +(4.2.7p45) 2010/09/05 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1578] Consistently use -lm when needed.
 +(4.2.7p44) 2010/08/27 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1573] from 4.2.6p3-beta1: Miscalculation of offset in sntp.
 +(4.2.7p43) 2010/08/26 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1602] Refactor some of the sntp/ directory to facililtate testing.
 +(4.2.7p42) 2010/08/18 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1593] ntpd abort in free() with logconfig syntax error.
 +* [Bug 1595] from 4.2.6p3-beta1: empty last line in key file causes
 +  duplicate key to be added
 +* [Bug 1597] from 4.2.6p3-beta1: packet processing ignores RATE KoD packets,
 +  Because of a bug in string comparison.
 +(4.2.7p41) 2010/07/28 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1581] from 4.2.6p3-beta1: ntp_intres.c size_t printf format
 +  string mismatch.
 +* [Bug 1586] ntpd 4.2.7p40 doesn't write to syslog after fork on QNX.
 +* Avoid race with parallel builds using same source directory in
 +  scripts/genver by using build directory for temporary files.
 +* orphanwait documentation updates.
 +(4.2.7p40) 2010/07/12 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1395] ease ntpdate elimination with ntpd -w/--wait-sync
 +* [Bug 1396] allow servers on ntpd command line like ntpdate
 +(4.2.7p39) 2010/07/09 Released by Harlan Stenn <stenn@ntp.org>
 +* Fix typo in driver28.html.
 +* [Bug 1581] from 4.2.6p2: size_t printf format string mismatches, IRIG
 +  string buffers undersized.  Mostly backported from earlier ntp-dev
 +  fixes by Juergen Perlinger.
 +(4.2.7p38) 2010/06/20 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1570] backported to 4.2.6p2-RC7.
 +* [Bug 1575] from 4.2.6p2-RC7: use 'snprintf' with LIB_BUFLENGTH in
 +  inttoa.c, tvtoa.c and utvtoa.c
 +* [Bug 1576] backported to 4.2.6p2-RC7.
 +* Typo fix in a comment in ntp_proto.c.
 +(4.2.7p37) 2010/06/19 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1576] sys/sysctl.h depends on sys/param.h on OpenBSD.
 +(4.2.7p36) 2010/06/15 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1560] Initial support for orphanwait, from Dave Mills.
 +* clock_filter()/reachability fixes from Dave Mills.
 +(4.2.7p35) 2010/06/12 Released by Harlan Stenn <stenn@ntp.org>
 +* Rewrite of multiprecision macros in 'ntp_fp.h' from J. Perlinger
 +  <perlinger@ntp.org>
 +* [Bug 715] from 4.2.6p2-RC6: libisc Linux IPv6 interface iteration
 +  drops multicast flags.
 +(4.2.7p34) 2010/06/05 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1570] serial clock drivers get outdated input from kernel tty
 +  line buffer after startup
 +(4.2.7p33) 2010/06/04 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1561] from 4.2.6p2-RC5: ntpq, ntpdc "passwd" prompts for MD5
 +  password w/SHA1.
 +* [Bug 1565] from 4.2.6p2-RC5: sntp/crypto.c compile fails on MacOS over
 +  vsnprintf().
 +* from 4.2.6p2-RC5: Windows port: do not exit in
 +  ntp_timestamp_from_counter() without first logging the reason.
 +(4.2.7p32) 2010/05/19 Released by Harlan Stenn <stenn@ntp.org>
 +* Copyright file cleanup from Dave Mills.
 +* [Bug 1555] from 4.2.6p2-RC4: sntp illegal C (mixed code and
 +  declarations).
 +* [Bug 1558] pool prototype associations have 0.0.0.0 for remote addr.
 +* configure.ac: add --disable-autokey, #define AUTOKEY to enable future
 +  support for building without Autokey, but with OpenSSL for its digest
 +  algorithms (hash functions).  Code must be modified to use #ifdef
 +  AUTOKEY instead of #ifdef OPENSSL where appropriate to complete this.
 +* include/ntp_crypto.h: make assumption AUTOKEY implies OPENSSL explicit.
 +(4.2.7p31) 2010/05/11 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1325] from 4.2.6p2-RC3: unreachable code sntp recv_bcst_data().
 +* [Bug 1459] from 4.2.6p2-RC3: sntp MD5 authentication does not work
 +  with ntpd.
 +* [Bug 1552] from 4.2.6p2-RC3: update and complete broadcast and crypto
 +  features in sntp.
 +* [Bug 1553] from 4.2.6p2-RC3: sntp/configure.ac OpenSSL support.
 +* from 4.2.6p2-RC3: Escape unprintable characters in a refid in ntpq -p
 +  billboard.
 +* from 4.2.6p2-RC3: Simplify hash client code by providing OpenSSL
 +  EVP_*() API when built without OpenSSL.  (already in 4.2.7)
 +* from 4.2.6p2-RC3: Do not depend on ASCII in sntp.
 +(4.2.7p30) 2010/05/06 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1526] ntpd DNS pipe read EINTR with no network at startup.
 +* Update the ChangeLog entries when merging items from -stable.
 +(4.2.7p29) 2010/05/04 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1542] ntpd mrulist response may have incorrect last.older.
 +* [Bug 1543] ntpq mrulist must refresh nonce when retrying.
 +* [Bug 1544] ntpq mrulist sscanf timestamp format mismatch on 64-bit.
 +* Windows compiling hints/winnt.html update from G. Sunil Tej.
 +(4.2.7p28) 2010/05/03 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1512] from 4.2.6p2-RC3: ntpsnmpd should connect to net-snmpd
 +  via a unix-domain socket by default.
 +  Provide a command-line 'socket name' option.
 +* [Bug 1538] from 4.2.6p2-RC3: update refclock_nmea.c's call to
 +  getprotobyname().
 +* [Bug 1541] from 4.2.6p2-RC3: Fix wrong keyword for "maxclock".
 +(4.2.7p27) 2010/04/27 Released by Harlan Stenn <stenn@ntp.org>
 +(4.2.7p26) 2010/04/24 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1465] from 4.2.6p2-RC2: Make sure time from TS2100 is not
 +  invalid (backport from -dev).
 +* [Bug 1528] from 4.2.6p2-RC2: Fix EDITLINE_LIBS link order for ntpq
 +  and ntpdc.
 +* [Bug 1531] Require nonce with mrulist requests.
 +* [Bug 1532] Remove ntpd support for ntpdc's monlist in favor of ntpq's
 +  mrulist.
 +* [Bug 1534] from 4.2.6p2-RC2: conflicts with VC++ 2010 errno.h.
 +* [Bug 1535] from 4.2.6p2-RC2: "restrict -4 default" and "restrict
 +  -6 default" ignored.
 +(4.2.7p25) 2010/04/20 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1528] from 4.2.6p2-RC2: Remove --with-arlib from br-flock.
 +* [Bug 1503] [Bug 1504] [Bug 1518] [Bug 1522] from 4.2.6p2-RC2:
 +  all of which were fixed in 4.2.7 previously. 
 +(4.2.7p24) 2010/04/13 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1390] Control PPS on the Oncore M12.
 +* [Bug 1518] Windows ntpd should lock to one processor more
 +  conservatively.
 +* [Bug 1520] '%u' formats for size_t gives warnings with 64-bit builds.
 +* [Bug 1522] Enable range syntax "trustedkey (301 ... 399)".
 +* Documentation updates for 4.2.7p22 changes and additions, updating
 +  ntpdc.html, ntpq.html, accopt.html, confopt.html, manyopt.html,
 +  miscopt.html, and miscopt.txt.
 +* accopt.html: non-ntpport doc changes from Dave Mills.
 +* Modify full MRU list preemption when full to match "discard monitor"
 +  documentation, by removing exception for count == 1.
 +(4.2.7p23) 2010/04/04 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1516] unpeer by IP address fails, DNS name works.
 +* [Bug 1517] ntpq and ntpdc should verify reverse DNS before use.
 +  ntpq and ntpdc now use the following format for showing purported
 +  DNS names from IP address "reverse" DNS lookups when the DNS name
 +  does not exist or does not include the original IP address among
 +  the results: "192.168.1.2 (fake.dns.local)".
 +(4.2.7p22) 2010/04/02 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1432] Don't set inheritable flag for linux capabilities.
 +* [Bug 1465] Make sure time from TS2100 is not invalid.
 +* [Bug 1483] AI_NUMERICSERV undefined in 4.2.7p20.
 +* [Bug 1497] fudge is broken by getnetnum() change.
 +* [Bug 1503] Auto-enabling of monitor for "restrict ... limited" wrong.
 +* [Bug 1504] ntpdate tickles ntpd "discard minimum 1" rate limit if
 +  "restrict ... limited" is used.
 +* ntpdate: stop querying source after KoD packet response, log it.
 +* ntpdate: rate limit each server to 2s between packets.
 +* From J. N. Perlinger: avoid pointer wraparound warnings in dolfptoa(),
 +  printf format mismatches with 64-bit size_t.
 +* Broadcast client (ephemeral) associations should be demobilized only
 +  if they are not heard from for 10 consecutive polls, regardless of
 +  surviving the clock selection.  Fix from David Mills.
 +* Add "ntpq -c ifstats" similar to "ntpdc -c ifstats".
 +* Add "ntpq -c sysstats" similar to "ntpdc -c sysstats".
 +* Add "ntpq -c monstats" to show monlist knobs and stats.
 +* Add "ntpq -c mrulist" similar to "ntpdc -c monlist" but not
 +  limited to 600 rows, and with filtering and sorting options:
 +  ntpq -c "mrulist mincount=2 laddr=192.168.1.2 sort=-avgint"
 +  ntpq -c "mrulist sort=addr"
 +  ntpq -c "mrulist mincount=2 sort=count"
 +  ntpq -c "mrulist sort=-lstint"
 +* Modify internal representation of MRU list to use l_fp fixed-point
 +  NTP timestamps instead of seconds since startup.  This increases the
 +  resolution and substantially improves accuracy of sorts involving
 +  timestamps, at the cost of flushing all MRU entries when the clock is
 +  stepped, to ensure the timestamps can be compared with the current
 +  get_systime() results.
 +* Add ntp.conf "mru" directive to configure MRU parameters, such as
 +  "mru mindepth 600 maxage 64 maxdepth 5000 maxmem 1024" or
 +  "mru initalloc 0 initmem 16 incalloc 99 incmem 4".  Several pairs are
 +  equivalent with one in units of MRU entries and its twin in units of
 +  kilobytes of memory, so the last one used in ntp.conf controls:
 +  maxdepth/maxmem, initalloc/initmem, incalloc/incmem.  With the above
 +  values, ntpd will preallocate 16kB worth of MRU entries, allocating
 +  4kB worth each time more are needed, with a hard limit of 1MB of MRU
 +  entries.  Until there are more than 600 entries none would be reused.
 +  Then only entries for addresses last seen 64 seconds or longer ago are
 +  reused.
 +* Limit "ntpdc -c monlist" response in ntpd to 600 entries, the previous
 +  overall limit on the MRU list depth which was driven by the monlist
 +  implementation limit of one request with a single multipacket
 +  response.
 +* New "pool" directive implementation modeled on manycastclient.
 +* Do not abort on non-ASCII characters in ntp.conf, ignore them.
 +* ntpq: increase response reassembly limit from 24 to 32 packets, add
 +  discussion in comment regarding results with even larger MAXFRAGS.
 +* ntpq: handle "passwd MYPASSWORD" (without prompting) as with ntpdc.
 +* ntpdc: do not examine argument to "passwd" if not supplied.
 +* configure: remove check for pointer type used with qsort(), we
 +  require ANSI C which mandates void *.
 +* Reset sys_kodsent to 0 in proto_clr_stats().
 +* Add sptoa()/sockporttoa() similar to stoa()/socktoa() adding :port.
 +* Use memcpy() instead of memmove() when buffers can not overlap.
 +* Remove sockaddr_storage from our sockaddr_u union of sockaddr,
 +  sockaddr_in, and sockaddr_in6, shaving about 100 bytes from its size
 +  and substantially decreasing MRU entry memory consumption.
 +* Extend ntpq readvar (alias rv) to allow fetching up to three named
 +  variables in one operation:  ntpq -c "rv 0 version offset frequency".
 +* ntpq: use srchost variable to show .POOL. prototype associations'
 +  hostname instead of address 0.0.0.0.
 +* "restrict source ..." configures override restrictions for time
 +  sources, allows tight default restrictions to be used with the pool
 +  directive (where server addresses are not known in advance).
 +* Ignore "preempt" modifier on manycastclient and pool prototype
 +  associations.  The resulting associations are preemptible, but the
 +  prototype must not be.
 +* Maintain and use linked list of associations (struct peer) in ntpd,
 +  avoiding walking 128 hash table entries to iterate over peers.
 +* Remove more workarounds unneeded since we require ISO C90 AKA ANSI C:
 +  - remove fallback implementations for memmove(), memset, strstr().
 +  - do not test for atexit() or memcpy().
 +* Collapse a bunch of code duplication in ntpd/ntp_restrict.c added with
 +  support for IPv6.
 +* Correct some corner case failures in automatically enabling the MRU
 +  list if any "restrict ... limited" is in effect, and in disabling MRU
 +  maintenance. (ntp_monitor.c, ntp_restrict.c)
 +* Reverse the internal sort order of the address restriction lists, but
 +  preserve the same behavior.  This allows removal of special-case code
 +  related to the default restrictions and more straightforward lookups
 +  of restrictions for a given address (now, stop on first match).
 +* Move ntp_restrict.c MRU doubly-linked list maintenance code into
 +  ntp_lists.h macros, allowing more duplicated source excision.
 +* Repair ntpdate.c to no longer test HAVE_TIMER_SETTIME.
 +* Do not reference peer_node/unpeer_node after freeing when built with
 +  --disable-saveconfig and using DNS.
 +(4.2.7p21) 2010/03/31 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1514] from 4.2.6p1-RC6: Typo in ntp_proto.c: fabs(foo < .4)
 +  should be fabs(foo) < .4.
 +* [Bug 1464] from 4.2.6p1-RC6: synchronization source wrong for
 +  refclocks ARCRON_MSF (27) and SHM (28).
 +* From 4.2.6p1-RC6: Correct Windows port's refclock_open() to
 +  return 0 on failure not -1.
 +* From 4.2.6p1-RC6: Correct CHU, dumbclock, and WWVB drivers to
 +  check for 0 returned from refclock_open() on failure.
 +* From 4.2.6p1-RC6: Correct "SIMUL=4 ./flock-build -1" to
 +  prioritize -1/--one.
 +* [Bug 1306] constant conditionals in audio_gain().
 +(4.2.7p20) 2010/02/13 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1483] hostname in ntp.conf "restrict" parameter rejected.
 +* Use all addresses for each restrict by hostname.
 +* Use async DNS to resolve trap directive hostnames.
 +(4.2.7p19) 2010/02/09 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1338] Update the association type codes in ntpq.html.
 +* [Bug 1478] from 4.2.6p1-RC5: linking fails: EVP_MD_pkey_type.
 +* [Bug 1479] from 4.2.6p1-RC5: not finding readline headers.
 +* [Bug 1484] from 4.2.6p1-RC5: ushort is not defined in QNX6.
 +(4.2.7p18) 2010/02/07 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1480] from 4.2.6p1-RC5: snprintf() cleanup caused 
 +  unterminated refclock IDs.
 +* Stop using getaddrinfo() to convert numeric address strings to on-wire
 +  addresses in favor of is_ip_address() alone.
 +(4.2.7p17) 2010/02/05 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1477] from 4.2.6p1-RC5: First non-gmake make in clone
 +  w/VPATH can't make COPYRIGHT.
 +* Attempts to cure CID 108 CID 118 CID 119 TAINTED_SCALAR warnings.
 +* Broaden ylwrap workaround VPATH_HACK to all non-GNU make.
 +(4.2.7p16) 2010/02/04 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1474] from 4.2.6p1-RC4: ntp_keygen LCRYPTO after libntp.a.
 +* Include 4.2.6p1-RC4: Remove arlib.
 +(4.2.7p15) 2010/02/03 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1455] from 4.2.6p1: ntpd does not try /etc/ntp.audio.
 +* Include 4.2.6p1: Convert many sprintf() calls to snprintf(), also
 +  strcpy(), strcat().
 +* Include 4.2.6p1: Fix widely cut-n-pasted bug in refclock shutdown
 +  after failed start.
 +* Include 4.2.6p1: Remove some dead code checking for emalloc()
 +  returning NULL.
 +(4.2.7p14) 2010/02/02 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1338] ntpq displays incorrect association type codes.
 +* [Bug 1469] u_int32, int32 changes broke HP-UX 10.20 build.
 +* [Bug 1470] from 4.2.6p1: "make distdir" compiles keyword-gen.
 +* [Bug 1471] CID 120 CID 121 CID 122 is_ip_address() uninit family.
 +* [Bug 1472] CID 116 CID 117 minor warnings in new DNS code.
 +* [Bug 1473] from 4.2.6p1: "make distcheck" version.m4 error.
 +(4.2.7p13) 2010/01/31 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1467] from 4.2.6p1: Fix bogus rebuild of sntp/sntp.html.
 +(4.2.7p12) 2010/01/30 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1468] 'make install' broken for root on default NFS mount.
 +(4.2.7p11) 2010/01/28 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 47] Debugging and logging do not work after a fork.
 +* [Bug 1010] getaddrinfo() could block and thus should not be called by
 +  the main thread/process.
 +* New async DNS resolver in ntpd allows nonblocking queries anytime,
 +  instead of only once at startup.
 +(4.2.7p10) 2010/01/24 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1140] from 4.2.6p1-RC5: Clean up debug.html, decode.html,
 +  and ntpq.html.
 +* Include 4.2.6p1-RC3: Use TZ=UTC instead of TZ= when calling date in
 +  scripts/mkver.in .
 +* [Bug 1448] from 4.2.6p1-RC3: Some macros not correctly conditionally
 +  or absolutely defined on Windows.
 +* [Bug 1449] from 4.2.6p1-RC3: ntpsim.h in ntp_config.c should be used
 +  conditionally.
 +* [Bug 1450] from 4.2.6p1-RC3: Option to exclude warnings not
 +  unconditionally defined on Windows.
 +(4.2.7p9) 2010/01/13 Released by Harlan Stenn <stenn@ntp.org>
 +(4.2.7p8) 2010/01/12 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 702] ntpd service logic should use libopts to examine cmdline.
 +* [Bug 1451] from 4.2.6p1-RC3: sntp leaks KoD entry updating.
 +* [Bug 1453] from 4.2.6p1-RC3: Use $CC in config.cache filename.
 +(4.2.7p7) 2009/12/30 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 620] ntpdc getresponse() esize != *rsize s/b size != *rsize.
 +* [Bug 1446] 4.2.7p6 requires autogen, missing ntpd.1, *.texi, *.menu.
 +(4.2.7p6) 2009/12/28 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1443] Remove unnecessary dependencies on ntp_io.h
 +* [Bug 1442] Move Windows functions into libntp files
 +* [Bug 1127] from 4.2.6p1-RC3: Check the return of X590_verify().
 +* [Bug 1439] from 4.2.6p1-RC3: .texi gen after binary is linked.
 +* [Bug 1440] from 4.2.6p1-RC3: Update configure.ac to support kfreebsd.
 +* [Bug 1445] from 4.2.6p1-RC3: IRIX does not have -lcap or support
 +  linux capabilities.
 +(4.2.7p5) 2009/12/25 Released by Harlan Stenn <stenn@ntp.org>
 +* Include 4.2.6p1-RC2
 +(4.2.7p4) 2009/12/24 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1429] ntpd -4 option does not reliably force IPv4 resolution.
 +* [Bug 1431] System headers must come before ntp headers in ntp_intres.c .
 +(4.2.7p3) 2009/12/22 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1426] scripts/VersionName needs . on the search path.
 +* [Bug 1427] quote missing in ./build - shows up on NetBSD.
 +* [Bug 1428] Use AC_HEADER_RESOLV to fix breaks from resolv.h
 +(4.2.7p2) 2009/12/20 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1419] ntpdate, ntpdc, sntp, ntpd ignore configure --bindir.
 +* [Bug 1421] add util/tg2, a clone of tg that works on Linux, NetBSD, and
 +  FreeBSD
 +(4.2.7p1) 2009/12/15 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1348] ntpd Windows port should wait for sendto() completion.
 +* [Bug 1413] test OpenSSL headers regarding -Wno-strict-prototypes.
 +* [Bug 1418] building ntpd/ntpdc/ntpq statically with ssl fails.
 +(4.2.7p0) 2009/12/13 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1412] m4/os_cflags.m4 caches results that depend on $CC.
 +* [Bug 1414] Enable "make distcheck" success with BSD make.
 +(4.2.7) 2009/12/09 Released by Harlan Stenn <stenn@ntp.org>
 +* [Bug 1407] configure.ac: recent GNU Make -v does not include "version".
  ---
+ * [Bug 2050] Orphan mode stratum counting to infinity.
+ * [Bug 2059] optional billboard column "server" does not honor -n.
+ * [Bug 2066] ntpq lopeers ipv6 "local" column overrun.
+ * [Bug 2068] ntpd sends nonprintable stratum 16 refid to ntpq.
+ * [Bug 2069] broadcastclient, multicastclient spin up duplicate
+   ephemeral associations without broadcastdelay.
+ * Exclude not-yet-determined sys_refid from use in loopback TEST12
+   (from David Mills).  
+ ---
  (4.2.6p5-RC1) 2011/10/18 Released by Harlan Stenn <stenn@ntp.org>
  
  * [Bug 2034] Listening address configuration with prefix misapplied.
diff --cc include/ntp.h
Simple merge
Simple merge
Simple merge
index c85f8c3be16438dc2610440c50f3229c9636a878,cbc0c1c1693d8cce6ca2c69c23ec380f4a1dc2a3..a9e0b324ff9563d257946cbb824994f3ab39bd6b
  #if defined(VMS)
  #include <socket.h>
  typedef unsigned int u_int;
 -/*
 - * Note: VMS DECC has  long == int  (even on __alpha),
 - *     so the distinction below doesn't matter
 - */
  #endif /* VMS */
  
 -#if (SIZEOF_INT == 4)
 -# ifndef int32
 -#  define int32 int
 +#ifdef HAVE_UINT32_T
 +# ifndef HAVE_INT32
 +   typedef    int32_t         int32;
++#  define INT32_MIN INT32_T_MIN
++#  define INT32_MAX INT32_T_MAX
 +# endif
 +# ifndef HAVE_U_INT32
 +   typedef    uint32_t        u_int32;
++#  define U_INT32_MAX UINT32_T_MAX
 +# endif
 +#elif (SIZEOF_INT == 4)
 +# if !defined(HAVE_INT32) && !defined(int32)
 +   typedef    int             int32;
+ #  define INT32_MIN INT_MIN
+ #  define INT32_MAX INT_MAX
  # endif
 -# ifndef u_int32
 -#  define u_int32 unsigned int
 +# if !defined(HAVE_U_INT32) && !defined(u_int32)
 +   typedef    unsigned        u_int32;
+ #  define U_INT32_MAX UINT_MAX
  # endif
 -#else /* not sizeof(int) == 4 */
 +#else /* SIZEOF_INT != 4 */
  # if (SIZEOF_LONG == 4)
 -#  ifndef int32
 -#   define int32 long
 +# if !defined(HAVE_INT32) && !defined(int32)
 +    typedef   long            int32;
+ #   define INT32_MIN LONG_MIN
+ #   define INT32_MAX LONG_MAX
  #  endif
 -#  ifndef u_int32
 -#   define u_int32 unsigned long
 +# if !defined(HAVE_U_INT32) && !defined(u_int32)
 +    typedef   unsigned long   u_int32;
+ #   define U_INT32_MAX ULONG_MAX
  #  endif
 -# else /* not sizeof(long) == 4 */
 +# else        /* SIZEOF_LONG != 4 */
  #  include "Bletch: what's 32 bits on this machine?"
 -# endif /* not sizeof(long) == 4 */
 -#endif /* not sizeof(int) == 4 */
 +# endif
 +#endif        /* !HAVE_UINT32_T && SIZEOF_INT != 4 */
 +
 +#ifndef UINT32_MAX
 +#define UINT32_MAX    0xffffffff
 +#endif
 +
 +
 +/*
 + * Ugly dance to find out if we have 64bit integer type.
 + */
 +#if !defined(HAVE_INT64)
 +
 +/* assume best for now, fix if frustrated later. */
 +# define HAVE_INT64
 +# define HAVE_U_INT64
 +
 +/* now check the cascade. Feel free to add things. */
 +# ifdef INT64_MAX
 +
 +typedef int64_t int64;
 +typedef uint64_t u_int64;
 +
 +# elif SIZEOF_LONG == 8
 +
 +typedef long int64;
 +typedef unsigned long u_int64;
 +
 +# elif SIZEOF_LONG_LONG == 8
 +
 +typedef long long int64;
 +typedef unsigned long long u_int64;
 +
 +# else
 +
 +/* no 64bit scalar, give it up. */
 +#  undef HAVE_INT64
 +#  undef HAVE_U_INT64
 +
 +# endif
 +
 +#endif
 +
 +/*
 + * and here the trouble starts: We need a representation with more than
 + * 64 bits. If a scalar of that size is not available, we need a struct
 + * that holds the value in split representation.
 + *
 + * To ease the usage a bit, we alwys use a union that is in processor
 + * byte order and might or might not contain a 64bit scalar.
 + */
 +
 +#if SIZEOF_SHORT != 2
 +# error short is not 2 bytes -- what is 16 bit integer on this target?
 +#endif
 +
 +typedef union {
 +#   ifdef WORDS_BIGENDIAN
 +      struct {
 +              short   hh; u_short hl; u_short lh; u_short ll;
 +      } w_s;
 +      struct {
 +              u_short hh; u_short hl; u_short lh; u_short ll;
 +      } W_s;
 +      struct {
 +                int32 hi; u_int32 lo;
 +      } d_s;
 +      struct {
 +              u_int32 hi; u_int32 lo;
 +      } D_s;
 +#   else
 +      struct {
 +              u_short ll; u_short lh; u_short hl;   short hh;
 +      } w_s;
 +      struct {
 +              u_short ll; u_short lh; u_short hl; u_short hh;
 +      } W_s;
 +      struct {
 +              u_int32 lo;   int32 hi;
 +      } d_s;
 +      struct {
 +              u_int32 lo; u_int32 hi;
 +      } D_s;
 +#   endif
 +
 +#   ifdef HAVE_INT64
 +      int64   q_s;    /*   signed quad scalar */
 +      u_int64 Q_s;    /* unsigned quad scalar */
 +#   endif
 +} vint64; /* variant int 64 */
 +
  
  typedef u_char                ntp_u_int8_t;
  typedef u_short               ntp_u_int16_t;
diff --cc include/ntpd.h
index 1d6959ebca08426f279e262547314ac3afd5ba24,75e87de97a4168f8e346402c094dc54e9af4fc77..bf2ceb98ccd78ed80e9b4dcb66f1c363f1e3cf01
@@@ -166,24 -128,16 +166,23 @@@ extern  void    mon_clearinterface(endpt *i
  
  /* ntp_peer.c */
  extern        void    init_peer       (void);
 -extern        struct peer *findexistingpeer (sockaddr_u *, struct peer *, int, u_char);
 +extern        struct peer *findexistingpeer(sockaddr_u *, const char *,
-                                     struct peer *, int);
++                                    struct peer *, int, u_char);
  extern        struct peer *findpeer   (struct recvbuf *, int, int *);
 -extern        struct peer *findpeerbyassoc (u_int);
 -extern  void  set_peerdstadr  (struct peer *peer, struct interface *interface);
 -extern        struct peer *newpeer    (sockaddr_u *, struct interface *, int, int, int, int, u_int, u_char, int, keyid_t);
 +extern        struct peer *findpeerbyassoc(associd_t);
- extern  void  set_peerdstadr  (struct peer *peer,
-                                endpt *interface);
++extern  void  set_peerdstadr  (struct peer *, endpt *);
 +extern        struct peer *newpeer    (sockaddr_u *, const char *,
 +                               endpt *, u_char, u_char,
 +                               u_char, u_char, u_int, u_char, u_int32,
 +                               keyid_t, const char *);
  extern        void    peer_all_reset  (void);
  extern        void    peer_clr_stats  (void);
 -extern        struct peer *peer_config (sockaddr_u *, struct interface *, int, int, int, int, u_int, int, keyid_t, u_char *);
 +extern        struct peer *peer_config(sockaddr_u *, const char *,
 +                               endpt *, u_char, u_char,
 +                               u_char, u_char, u_int, u_int32,
 +                               keyid_t, const char *);
  extern        void    peer_reset      (struct peer *);
 -extern        void    refresh_all_peerinterfaces (void);
 +extern        void    refresh_all_peerinterfaces(void);
  extern        void    unpeer          (struct peer *);
  extern        void    clear_all       (void);
  extern        int     score_all       (struct peer *);
index 6382f0f486bb123663e8eb6da8bfd09d4669cc15,db9682a74cbd04b7277dab6dcce7136a6d303016..eecff179bbd583ae14d291a23c91a89cbdbdc348
@@@ -3521,473 -3319,188 +3521,473 @@@ is_sane_resolved_address
        return 1;
  }
  
 -static int
 +
 +#ifndef SIM
 +static u_char
  get_correct_host_mode(
 -      int hmode
 +      int token
        )
  {
 -      switch (hmode) {
 -          case T_Server:
 -          case T_Pool:
 -          case T_Manycastclient:
 +      switch (token) {
 +
 +      case T_Server:
 +      case T_Pool:
 +      case T_Manycastclient:
                return MODE_CLIENT;
 -              break;
 -          case T_Peer:
 +
 +      case T_Peer:
                return MODE_ACTIVE;
 -              break;
 -          case T_Broadcast:
 +
 +      case T_Broadcast:
                return MODE_BROADCAST;
 -              break;
 -          default:
 -              return -1;
 +
 +      default:
 +              return 0;
 +      }
 +}
 +
 +
 +/*
 + * peerflag_bits()    get config_peers() peerflags value from a
 + *                    peer_node's queue of flag attr_val entries.
 + */
 +static int
 +peerflag_bits(
 +      peer_node *pn
 +      )
 +{
 +      int peerflags;
 +      attr_val *option;
 +
 +      /* translate peerflags options to bits */
 +      peerflags = 0;
 +      option = HEAD_PFIFO(pn->peerflags);
 +      for (; option != NULL; option = option->link) {
 +              switch (option->value.i) {
 +
 +              default:
 +                      NTP_INSIST(0);
 +                      break;
 +
 +              case T_Autokey:
 +                      peerflags |= FLAG_SKEY;
 +                      break;
 +
 +              case T_Burst:
 +                      peerflags |= FLAG_BURST;
 +                      break;
 +
 +              case T_Iburst:
 +                      peerflags |= FLAG_IBURST;
 +                      break;
 +
 +              case T_Noselect:
 +                      peerflags |= FLAG_NOSELECT;
 +                      break;
 +
 +              case T_Preempt:
 +                      peerflags |= FLAG_PREEMPT;
 +                      break;
 +
 +              case T_Prefer:
 +                      peerflags |= FLAG_PREFER;
 +                      break;
 +
 +              case T_True:
 +                      peerflags |= FLAG_TRUE;
 +                      break;
 +
 +              case T_Xleave:
 +                      peerflags |= FLAG_XLEAVE;
 +                      break;
 +              }
        }
 +
 +      return peerflags;
  }
  
 +
  static void
  config_peers(
 -      struct config_tree *ptree
 +      config_tree *ptree
        )
  {
 -      struct addrinfo *res, *res_bak;
 -      sockaddr_u peeraddr;
 -      struct peer_node *curr_peer;
 -      struct attr_val *option;
 -      int hmode;
 -      int peerflags;
 -      int status;
 -      int no_needed;
 -      int i;
 +      sockaddr_u              peeraddr;
 +      struct addrinfo         hints;
 +      peer_node *             curr_peer;
 +      peer_resolved_ctx *     ctx;
 +      u_char                  hmode;
 +
 +      /* add servers named on the command line with iburst implied */
 +      for (;
 +           cmdline_server_count > 0;
 +           cmdline_server_count--, cmdline_servers++) {
  
 -      curr_peer = queue_head(ptree->peers);
 -      while (curr_peer != NULL) {
 -              /* Find the number of associations needed.
 -               * If a pool coomand is specified, then sys_maxclock needed
 -               * else, only one is needed
 +              ZERO_SOCK(&peeraddr);
 +              /*
 +               * If we have a numeric address, we can safely
 +               * proceed in the mainline with it.  Otherwise, hand
 +               * the hostname off to the blocking child.
                 */
 -              no_needed = (T_Pool == curr_peer->host_mode)
 -                              ? sys_maxclock
 -                              : 1;
 +              if (is_ip_address(*cmdline_servers, AF_UNSPEC,
 +                                &peeraddr)) {
 +
 +                      SET_PORT(&peeraddr, NTP_PORT);
 +                      if (is_sane_resolved_address(&peeraddr,
 +                                                   T_Server))
 +                              peer_config(
 +                                      &peeraddr,
 +                                      NULL,
 +                                      NULL,
 +                                      MODE_CLIENT,
 +                                      NTP_VERSION,
 +                                      0,
 +                                      0,
 +                                      FLAG_IBURST,
 +                                      0,
 +                                      0,
 +                                      NULL);
 +              } else {
 +                      /* we have a hostname to resolve */
 +# ifdef WORKER
 +                      ctx = emalloc_zero(sizeof(*ctx));
 +                      ctx->family = AF_UNSPEC;
 +                      ctx->host_mode = T_Server;
 +                      ctx->hmode = MODE_CLIENT;
 +                      ctx->version = NTP_VERSION;
 +                      ctx->flags = FLAG_IBURST;
 +
 +                      ZERO(hints);
 +                      hints.ai_family = (u_short)ctx->family;
 +                      hints.ai_socktype = SOCK_DGRAM;
 +                      hints.ai_protocol = IPPROTO_UDP;
 +
 +                      getaddrinfo_sometime(*cmdline_servers,
 +                                           "ntp", &hints,
 +                                           INITIAL_DNS_RETRY,
 +                                           &peer_name_resolved,
 +                                           (void *)ctx);
 +# else        /* !WORKER follows */
 +                      msyslog(LOG_ERR,
 +                              "hostname %s can not be used, please use IP address instead.\n",
 +                              curr_peer->addr->address);
 +# endif
 +              }
 +      }
  
 +      /* add associations from the configuration file */
 +      curr_peer = HEAD_PFIFO(ptree->peers);
 +      for (; curr_peer != NULL; curr_peer = curr_peer->link) {
 +              ZERO_SOCK(&peeraddr);
                /* Find the correct host-mode */
                hmode = get_correct_host_mode(curr_peer->host_mode);
 -              NTP_INSIST(hmode != -1);
 +              NTP_INSIST(hmode != 0);
 +
 +              if (T_Pool == curr_peer->host_mode) {
 +                      AF(&peeraddr) = curr_peer->addr->type;
 +                      peer_config(
 +                              &peeraddr,
 +                              curr_peer->addr->address,
 +                              NULL,
 +                              hmode,
 +                              curr_peer->peerversion,
 +                              curr_peer->minpoll,
 +                              curr_peer->maxpoll,
 +                              peerflag_bits(curr_peer),
 +                              curr_peer->ttl,
 +                              curr_peer->peerkey,
 +                              curr_peer->group);
 +              /*
 +               * If we have a numeric address, we can safely
 +               * proceed in the mainline with it.  Otherwise, hand
 +               * the hostname off to the blocking child.
 +               */
 +              } else if (is_ip_address(curr_peer->addr->address,
 +                                curr_peer->addr->type, &peeraddr)) {
 +
 +                      SET_PORT(&peeraddr, NTP_PORT);
 +                      if (is_sane_resolved_address(&peeraddr,
 +                          curr_peer->host_mode))
 +                              peer_config(
 +                                      &peeraddr,
 +                                      NULL,
 +                                      NULL,
 +                                      hmode,
 +                                      curr_peer->peerversion,
 +                                      curr_peer->minpoll,
 +                                      curr_peer->maxpoll,
 +                                      peerflag_bits(curr_peer),
 +                                      curr_peer->ttl,
 +                                      curr_peer->peerkey,
 +                                      curr_peer->group);
 +              } else {
 +                      /* we have a hostname to resolve */
 +# ifdef WORKER
 +                      ctx = emalloc_zero(sizeof(*ctx));
 +                      ctx->family = curr_peer->addr->type;
 +                      ctx->host_mode = curr_peer->host_mode;
 +                      ctx->hmode = hmode;
 +                      ctx->version = curr_peer->peerversion;
 +                      ctx->minpoll = curr_peer->minpoll;
 +                      ctx->maxpoll = curr_peer->maxpoll;
 +                      ctx->flags = peerflag_bits(curr_peer);
 +                      ctx->ttl = curr_peer->ttl;
 +                      ctx->keyid = curr_peer->peerkey;
 +                      ctx->group = curr_peer->group;
 +
 +                      ZERO(hints);
 +                      hints.ai_family = ctx->family;
 +                      hints.ai_socktype = SOCK_DGRAM;
 +                      hints.ai_protocol = IPPROTO_UDP;
 +
 +                      getaddrinfo_sometime(curr_peer->addr->address,
 +                                           "ntp", &hints,
 +                                           INITIAL_DNS_RETRY,
 +                                           &peer_name_resolved, ctx);
 +# else        /* !WORKER follows */
 +                      msyslog(LOG_ERR,
 +                              "hostname %s can not be used, please use IP address instead.\n",
 +                              curr_peer->addr->address);
 +# endif
 +              }
 +      }
 +}
 +#endif        /* !SIM */
  
 -              /* translate peerflags options to bits */
 -              peerflags = 0;
 -              option = queue_head(curr_peer->peerflags);
 -              for (;  option != NULL; option = next_node(option))
 -                      switch (option->value.i) {
 +/*
 + * peer_name_resolved()
 + *
 + * Callback invoked when config_peers()'s DNS lookup completes.
 + */
 +#ifdef WORKER
 +void
 +peer_name_resolved(
 +      int                     rescode,
 +      int                     gai_errno,
 +      void *                  context,
 +      const char *            name,
 +      const char *            service,
 +      const struct addrinfo * hints,
 +      const struct addrinfo * res
 +      )
 +{
 +      sockaddr_u              peeraddr;
 +      peer_resolved_ctx *     ctx;
 +      u_short                 af;
 +      const char *            fam_spec;
  
 -                      default:
 -                              NTP_INSIST(0);
 -                              break;
 +      ctx = context;
  
 -                      case T_Autokey:
 -                              peerflags |= FLAG_SKEY;
 -                              break;
 +      DPRINTF(1, ("peer_name_resolved(%s) rescode %d\n", name, rescode));
  
 -                      case T_Burst:
 -                              peerflags |= FLAG_BURST;
 -                              break;
 +      if (rescode) {
 +#ifndef IGNORE_DNS_ERRORS
 +              free(ctx);
 +              msyslog(LOG_ERR,
 +                      "giving up resolving host %s: %s (%d)",
 +                      name, gai_strerror(rescode), rescode);
 +#else /* IGNORE_DNS_ERRORS follows */
 +              getaddrinfo_sometime(name, service, hints,
 +                                   INITIAL_DNS_RETRY,
 +                                   &peer_name_resolved, context);
 +#endif
 +              return;
 +      }
  
 -                      case T_Iburst:
 -                              peerflags |= FLAG_IBURST;
 -                              break;
 +      /* Loop to configure a single association */
 +      for (; res != NULL; res = res->ai_next) {
 +              memcpy(&peeraddr, res->ai_addr, res->ai_addrlen);
 +              if (is_sane_resolved_address(&peeraddr,
 +                                           ctx->host_mode)) {
 +                      NLOG(NLOG_SYSINFO) {
 +                              af = ctx->family;
 +                              fam_spec = (AF_INET6 == af)
 +                                             ? "(AAAA) "
 +                                             : (AF_INET == af)
 +                                                   ? "(A) "
 +                                                   : "";
 +                              msyslog(LOG_INFO, "DNS %s %s-> %s",
 +                                      name, fam_spec,
 +                                      stoa(&peeraddr));
 +                      }
 +                      peer_config(
 +                              &peeraddr,
 +                              NULL,
 +                              NULL,
 +                              ctx->hmode,
 +                              ctx->version,
 +                              ctx->minpoll,
 +                              ctx->maxpoll,
 +                              ctx->flags,
 +                              ctx->ttl,
 +                              ctx->keyid,
 +                              ctx->group);
 +                      break;
 +              }
 +      }
 +      free(ctx);
 +}
 +#endif        /* WORKER */
  
 -                      case T_Noselect:
 -                              peerflags |= FLAG_NOSELECT;
 -                              break;
  
 -                      case T_Preempt:
 -                              peerflags |= FLAG_PREEMPT;
 -                              break;
 +#ifdef FREE_CFG_T
 +static void
 +free_config_peers(
 +      config_tree *ptree
 +      )
 +{
 +      peer_node *curr_peer;
  
 -                      case T_Prefer:
 -                              peerflags |= FLAG_PREFER;
 +      if (ptree->peers != NULL) {
 +              while (1) {
 +                      UNLINK_FIFO(curr_peer, *ptree->peers, link);
 +                      if (NULL == curr_peer)
                                break;
 +                      destroy_address_node(curr_peer->addr);
 +                      destroy_attr_val_fifo(curr_peer->peerflags);
 +                      free(curr_peer);
 +              }
 +              free(ptree->peers);
 +              ptree->peers = NULL;
 +      }
 +}
 +#endif        /* FREE_CFG_T */
  
 -                      case T_True:
 -                              peerflags |= FLAG_TRUE;
 -                              break;
  
 -                      case T_Xleave:
 -                              peerflags |= FLAG_XLEAVE;
 -                              break;
 -                      }
 +#ifndef SIM
 +static void
 +config_unpeers(
 +      config_tree *ptree
 +      )
 +{
 +      sockaddr_u              peeraddr;
 +      struct addrinfo         hints;
 +      unpeer_node *           curr_unpeer;
 +      struct peer *           p;
 +      const char *            name;
 +      int                     rc;
 +
 +      curr_unpeer = HEAD_PFIFO(ptree->unpeers);
 +      for (; curr_unpeer != NULL; curr_unpeer = curr_unpeer->link) {
 +              /*
 +               * Either AssocID will be zero, and we unpeer by name/
 +               * address addr, or it is nonzero and addr NULL.
 +               */
 +              if (curr_unpeer->assocID) {
 +                      p = findpeerbyassoc(curr_unpeer->assocID);
 +                      if (p != NULL) {
 +                              msyslog(LOG_NOTICE, "unpeered %s",
 +                                      stoa(&p->srcadr));
 +                              peer_clear(p, "GONE");
 +                              unpeer(p);
 +                      }       
  
 -              /* Attempt to resolve the address */
 -              ZERO_SOCK(&peeraddr);
 -              AF(&peeraddr) = (u_short)curr_peer->addr->type;
 +                      continue;
 +              }
  
 -              status = get_multiple_netnums(curr_peer->addr->address,
 -                  &peeraddr, &res, 0, t_UNK);
 +              ZERO(peeraddr);
 +              AF(&peeraddr) = curr_unpeer->addr->type;
 +              name = curr_unpeer->addr->address;
 +              rc = getnetnum(name, &peeraddr, 0, t_UNK);
 +              /* Do we have a numeric address? */
 +              if (rc > 0) {
 +                      DPRINTF(1, ("unpeer: searching for %s\n",
 +                                  stoa(&peeraddr)));
-                       p = findexistingpeer(&peeraddr, NULL, NULL, -1);
++                      p = findexistingpeer(&peeraddr, NULL, NULL, -1, 0);
 +                      if (p != NULL) {
 +                              msyslog(LOG_NOTICE, "unpeered %s",
 +                                      stoa(&peeraddr));
 +                              peer_clear(p, "GONE");
 +                              unpeer(p);
 +                      }
  
 -#ifdef FORCE_DEFER_DNS
 -              /* Hack for debugging Deferred DNS
 -               * Pretend working names didn't work.
 +                      continue;
 +              }
 +              /* 
 +               * It's not a numeric IP address, it's a hostname.
 +               * Check for associations with a matching hostname.
                 */
 -              if (status == 1) {
 -                      /* Deferring everything breaks refclocks. */
 -                      memcpy(&peeraddr, res->ai_addr, res->ai_addrlen);
 -                      if (!ISREFCLOCKADR(&peeraddr)) {
 -                              status = 0;  /* force deferred DNS path */
 -                              msyslog(LOG_INFO, "Forcing Deferred DNS for %s, %s",
 -                                      curr_peer->addr->address, stoa(&peeraddr));
 -                      } else {
 -                              msyslog(LOG_INFO, "NOT Deferring DNS for %s, %s",
 -                                      curr_peer->addr->address, stoa(&peeraddr));
 -                      }
 +              for (p = peer_list; p != NULL; p = p->p_link)
 +                      if (p->hostname != NULL)
 +                              if (!strcasecmp(p->hostname, name))
 +                                      break;
 +              if (p != NULL) {
 +                      msyslog(LOG_NOTICE, "unpeered %s", name);
 +                      peer_clear(p, "GONE");
 +                      unpeer(p);
                }
 -#endif
 +              /* Resolve the hostname to address(es). */
 +# ifdef WORKER
 +              ZERO(hints);
 +              hints.ai_family = curr_unpeer->addr->type;
 +              hints.ai_socktype = SOCK_DGRAM;
 +              hints.ai_protocol = IPPROTO_UDP;
 +              getaddrinfo_sometime(name, "ntp", &hints,
 +                                   INITIAL_DNS_RETRY,
 +                                   &unpeer_name_resolved, NULL);
 +# else        /* !WORKER follows */
 +              msyslog(LOG_ERR,
 +                      "hostname %s can not be used, please use IP address instead.\n",
 +                      name);
 +# endif
 +      }
 +}
 +#endif        /* !SIM */
  
 -              /* I don't know why getnetnum would return -1.
 -               * The old code had this test, so I guess it must be
 -               * useful
 -               */
 -              if (status == -1) {
 -                      /* Do nothing, apparently we found an IPv6
 -                       * address and can't do anything about it */
 -              }
 -              /* Check if name resolution failed. If yes, store the
 -               * peer information in a file for asynchronous
 -               * resolution later
 -               */
 -              else if (status != 1) {
 -                      msyslog(LOG_INFO, "Deferring DNS for %s %d", curr_peer->addr->address, no_needed);
 -                      save_resolve(curr_peer->addr->address,
 -                                   no_needed,
 -                                   curr_peer->addr->type,
 -                                   hmode,
 -                                   curr_peer->peerversion,
 -                                   curr_peer->minpoll,
 -                                   curr_peer->maxpoll,
 -                                   peerflags,
 -                                   curr_peer->ttl,
 -                                   curr_peer->peerkey,
 -                                   (u_char *)"*");
 -              }
 -              /* Yippie!! Name resolution has succeeded!!!
 -               * Now we can proceed to some more sanity checks on
 -               * the resolved address before we start to configure
 -               * the peer
 -               */
 -              else {
 -                      res_bak = res;
  
 -                      /*
 -                       * Loop to configure the desired number of
 -                       * associations
 -                       */
 -                      for (i = 0; (i < no_needed) && res; res =
 -                          res->ai_next) {
 -                              ++i;
 -                              memcpy(&peeraddr, res->ai_addr,
 -                                  res->ai_addrlen);
 -                              if (is_sane_resolved_address(
 -                                      &peeraddr,
 -                                      curr_peer->host_mode))
 -
 -                                      peer_config(&peeraddr,
 -                                          NULL,
 -                                          hmode,
 -                                          curr_peer->peerversion,
 -                                          curr_peer->minpoll,
 -                                          curr_peer->maxpoll,
 -                                          peerflags,
 -                                          curr_peer->ttl,
 -                                          curr_peer->peerkey,
 -                                          (u_char *)"*");
 -                      }
 -                      freeaddrinfo(res_bak);
 +/*
 + * unpeer_name_resolved()
 + *
 + * Callback invoked when config_unpeers()'s DNS lookup completes.
 + */
 +#ifdef WORKER
 +void
 +unpeer_name_resolved(
 +      int                     rescode,
 +      int                     gai_errno,
 +      void *                  context,
 +      const char *            name,
 +      const char *            service,
 +      const struct addrinfo * hints,
 +      const struct addrinfo * res
 +      )
 +{
 +      sockaddr_u      peeraddr;
 +      struct peer *   peer;
 +      u_short         af;
 +      const char *    fam_spec;
 +
 +      DPRINTF(1, ("unpeer_name_resolved(%s) rescode %d\n", name, rescode));
 +
 +      if (rescode) {
 +              msyslog(LOG_ERR, "giving up resolving unpeer %s: %s (%d)", 
 +                      name, gai_strerror(rescode), rescode);
 +              return;
 +      }
 +      /*
 +       * Loop through the addresses found
 +       */
 +      for (; res != NULL; res = res->ai_next) {
 +              NTP_INSIST(res->ai_addrlen <= sizeof(peeraddr));
 +              memcpy(&peeraddr, res->ai_addr, res->ai_addrlen);
 +              DPRINTF(1, ("unpeer: searching for peer %s\n",
 +                          stoa(&peeraddr)));
-               peer = findexistingpeer(&peeraddr, NULL, NULL, -1);
++              peer = findexistingpeer(&peeraddr, NULL, NULL, -1, 0);
 +              if (peer != NULL) {
 +                      af = AF(&peeraddr);
 +                      fam_spec = (AF_INET6 == af)
 +                                     ? "(AAAA) "
 +                                     : (AF_INET == af)
 +                                           ? "(A) "
 +                                           : "";
 +                      msyslog(LOG_NOTICE, "unpeered %s %s-> %s", name,
 +                              fam_spec, stoa(&peeraddr));
 +                      peer_clear(peer, "GONE");
 +                      unpeer(peer);
                }
 -              curr_peer = next_node(curr_peer);
        }
  }
 +#endif        /* WORKER */
  
  
  #ifdef FREE_CFG_T
index 80bf910440855e096bd1d1e94806968419f37c1c,a6904697693a6194b89e80176451607ad3ad23b8..09cbbe8bb49d694522e7297827f6dd58d7c983fc
@@@ -1729,15 -1365,14 +1743,14 @@@ ctl_putsys
                           sys_rootdisp * 1e3);
                break;
  
 -          case CS_REFID:
 +      case CS_REFID:
                if (sys_stratum > 1 && sys_stratum < STRATUM_UNSPEC)
-                       ctl_putadr(sys_var[CS_REFID].text, sys_refid, NULL);
+                       ctl_putadr(sys_var[varid].text, sys_refid, NULL);
                else
-                       ctl_putid(sys_var[CS_REFID].text,
-                                 (char *)&sys_refid);
+                       ctl_putrefid(sys_var[varid].text, sys_refid);
                break;
  
 -          case CS_REFTIME:
 +      case CS_REFTIME:
                ctl_putts(sys_var[CS_REFTIME].text, &sys_reftime);
                break;
  
  }
  
  
 -#ifdef REFCLOCK
  /*
 - * ctl_putclock - output clock variables
 + * ctl_putpeer - output a peer variable
   */
  static void
 -ctl_putclock(
 -      int varid,
 -      struct refclockstat *clock_stat,
 -      int mustput
 +ctl_putpeer(
 +      int id,
 +      struct peer *p
        )
  {
 -      switch(varid) {
 +      char buf[CTL_MAX_DATA_LEN];
 +      char *s;
 +      char *t;
 +      char *be;
 +      int i;
 +      const struct ctl_var *k;
 +#ifdef AUTOKEY
 +      struct autokey *ap;
 +      const EVP_MD *dp;
 +      const char *str;
 +#endif        /* AUTOKEY */
  
 -          case CC_TYPE:
 -              if (mustput || clock_stat->clockdesc == NULL
 -                  || *(clock_stat->clockdesc) == '\0') {
 -                      ctl_putuint(clock_var[CC_TYPE].text, clock_stat->type);
 -              }
 +      switch (id) {
 +
 +      case CP_CONFIG:
 +              ctl_putuint(peer_var[id].text,
 +                          !(FLAG_PREEMPT & p->flags));
                break;
 -          case CC_TIMECODE:
 -              ctl_putstr(clock_var[CC_TIMECODE].text,
 -                         clock_stat->p_lastcode,
 -                         (unsigned)clock_stat->lencode);
 +
 +      case CP_AUTHENABLE:
 +              ctl_putuint(peer_var[id].text, !(p->keyid));
                break;
  
 -          case CC_POLL:
 -              ctl_putuint(clock_var[CC_POLL].text, clock_stat->polls);
 +      case CP_AUTHENTIC:
 +              ctl_putuint(peer_var[id].text,
 +                          !!(FLAG_AUTHENTIC & p->flags));
                break;
  
 -          case CC_NOREPLY:
 -              ctl_putuint(clock_var[CC_NOREPLY].text,
 -                          clock_stat->noresponse);
 +      case CP_SRCADR:
 +              ctl_putadr(peer_var[id].text, 0, &p->srcadr);
                break;
  
 -          case CC_BADFORMAT:
 -              ctl_putuint(clock_var[CC_BADFORMAT].text,
 -                          clock_stat->badformat);
 +      case CP_SRCPORT:
 +              ctl_putuint(peer_var[id].text, SRCPORT(&p->srcadr));
                break;
  
 -          case CC_BADDATA:
 -              ctl_putuint(clock_var[CC_BADDATA].text,
 -                          clock_stat->baddata);
 +      case CP_SRCHOST:
 +              if (p->hostname != NULL)
 +                      ctl_putstr(peer_var[id].text, p->hostname,
 +                                 strlen(p->hostname));
                break;
  
 -          case CC_FUDGETIME1:
 -              if (mustput || (clock_stat->haveflags & CLK_HAVETIME1))
 -                      ctl_putdbl(clock_var[CC_FUDGETIME1].text,
 -                                 clock_stat->fudgetime1 * 1e3);
 +      case CP_DSTADR:
 +              ctl_putadr(peer_var[id].text, 0,
 +                         (p->dstadr != NULL)
 +                              ? &p->dstadr->sin
 +                              : NULL);
                break;
  
 -          case CC_FUDGETIME2:
 -              if (mustput || (clock_stat->haveflags & CLK_HAVETIME2))
 -                      ctl_putdbl(clock_var[CC_FUDGETIME2].text,
 -                                 clock_stat->fudgetime2 * 1e3);
 +      case CP_DSTPORT:
 +              ctl_putuint(peer_var[id].text,
 +                          (p->dstadr != NULL)
 +                              ? SRCPORT(&p->dstadr->sin)
 +                              : 0);
                break;
  
 -          case CC_FUDGEVAL1:
 -              if (mustput || (clock_stat->haveflags & CLK_HAVEVAL1))
 -                      ctl_putint(clock_var[CC_FUDGEVAL1].text,
 -                                 clock_stat->fudgeval1);
 +      case CP_IN:
 +              if (p->r21 > 0.)
 +                      ctl_putdbl(peer_var[id].text, p->r21 / 1e3);
                break;
  
 -          case CC_FUDGEVAL2:
 -              if (mustput || (clock_stat->haveflags & CLK_HAVEVAL2)) {
 -                      if (clock_stat->fudgeval1 > 1)
 -                              ctl_putadr(clock_var[CC_FUDGEVAL2].text,
 -                                         clock_stat->fudgeval2, NULL);
 -                      else
 -                              ctl_putrefid(clock_var[CC_FUDGEVAL2].text,
 -                                           clock_stat->fudgeval2);
 -              }
 +      case CP_OUT:
 +              if (p->r34 > 0.)
 +                      ctl_putdbl(peer_var[id].text, p->r34 / 1e3);
                break;
  
 -          case CC_FLAGS:
 -              if (mustput || (clock_stat->haveflags & (CLK_HAVEFLAG1 |
 -                                                       CLK_HAVEFLAG2 | CLK_HAVEFLAG3 | CLK_HAVEFLAG4)))
 -                      ctl_putuint(clock_var[CC_FLAGS].text,
 -                                  clock_stat->flags);
 +      case CP_RATE:
 +              ctl_putuint(peer_var[id].text, p->throttle);
                break;
  
 -          case CC_DEVICE:
 -              if (clock_stat->clockdesc == NULL ||
 -                  *(clock_stat->clockdesc) == '\0') {
 -                      if (mustput)
 -                              ctl_putstr(clock_var[CC_DEVICE].text,
 -                                         "", 0);
 -              } else {
 -                      ctl_putstr(clock_var[CC_DEVICE].text,
 -                                 clock_stat->clockdesc,
 -                                 strlen(clock_stat->clockdesc));
 -              }
 +      case CP_LEAP:
 +              ctl_putuint(peer_var[id].text, p->leap);
                break;
  
 -          case CC_VARLIST:
 -          {
 -                  char buf[CTL_MAX_DATA_LEN];
 -                  register char *s, *t, *be;
 -                  register const char *ss;
 -                  register int i;
 -                  register struct ctl_var *k;
 -
 -                  s = buf;
 -                  be = buf + sizeof(buf);
 -                  if (s + strlen(clock_var[CC_VARLIST].text) + 4 >
 -                      be)
 -                          break;      /* really long var name */
 -
 -                  snprintf(s, sizeof(buf), "%s=\"", 
 -                      clock_var[CC_VARLIST].text);
 -                  s += strlen(s);
 -                  t = s;
 -
 -                  for (k = clock_var; !(k->flags & EOV); k++) {
 -                          if (k->flags & PADDING)
 -                                  continue;
 -
 -                          i = strlen(k->text);
 -                          if (s + i + 1 >= be)
 -                                  break;
 -
 -                          if (s != t)
 -                                  *s++ = ',';
 -                          memcpy(s, k->text, i);
 -                          s += i;
 -                  }
 -
 -                  for (k = clock_stat->kv_list; k && !(k->flags &
 -                                                       EOV); k++) {
 -                          if (k->flags & PADDING)
 -                                  continue;
 -
 -                          ss = k->text;
 -                          if (!ss)
 -                                  continue;
 -
 -                          while (*ss && *ss != '=')
 -                                  ss++;
 -                          i = ss - k->text;
 -                          if (s+i+1 >= be)
 -                                  break;
 -
 -                          if (s != t)
 -                                  *s++ = ',';
 -                          memcpy(s, k->text, (unsigned)i);
 -                          s += i;
 -                          *s = '\0';
 -                  }
 -                  if (s+2 >= be)
 -                          break;
 -
 -                  *s++ = '"';
 -                  *s = '\0';
 -                  ctl_putdata(buf, (unsigned)( s - buf ), 0);
 -          }
 -          break;
 -      }
 -}
 -#endif
 +      case CP_HMODE:
 +              ctl_putuint(peer_var[id].text, p->hmode);
 +              break;
  
 +      case CP_STRATUM:
 +              ctl_putuint(peer_var[id].text, p->stratum);
 +              break;
  
 +      case CP_PPOLL:
 +              ctl_putuint(peer_var[id].text, p->ppoll);
 +              break;
  
 -/*
 - * ctl_getitem - get the next data item from the incoming packet
 - */
 -static struct ctl_var *
 -ctl_getitem(
 -      struct ctl_var *var_list,
 -      char **data
 -      )
 -{
 -      register struct ctl_var *v;
 -      register char *cp;
 -      register char *tp;
 -      static struct ctl_var eol = { 0, EOV, };
 -      static char buf[128];
 +      case CP_HPOLL:
 +              ctl_putuint(peer_var[id].text, p->hpoll);
 +              break;
  
 -      /*
 -       * Delete leading commas and white space
 -       */
 -      while (reqpt < reqend && (*reqpt == ',' ||
 -                                isspace((unsigned char)*reqpt)))
 -              reqpt++;
 -      if (reqpt >= reqend)
 -              return (0);
 +      case CP_PRECISION:
 +              ctl_putint(peer_var[id].text, p->precision);
 +              break;
  
 -      if (var_list == (struct ctl_var *)0)
 -              return (&eol);
 +      case CP_ROOTDELAY:
 +              ctl_putdbl(peer_var[id].text, p->rootdelay * 1e3);
 +              break;
  
 -      /*
 -       * Look for a first character match on the tag.  If we find
 +      case CP_ROOTDISPERSION:
 +              ctl_putdbl(peer_var[id].text, p->rootdisp * 1e3);
 +              break;
 +
 +      case CP_REFID:
-               if (FLAG_REFCLOCK & p->flags)
-                       ctl_putid(peer_var[id].text, (char *)&p->refid);
-               else if (1 < p->stratum && p->stratum < STRATUM_UNSPEC)
-                       ctl_putadr(peer_var[id].text, p->refid, NULL);
++#ifdef REFCLOCK
++              if (peer->flags & FLAG_REFCLOCK) {
++                      ctl_putrefid(peer_var[varid].text, peer->refid);
++                      break;
++              }
++#endif
++              if (peer->stratum > 1 && peer->stratum < STRATUM_UNSPEC)
++                      ctl_putadr(peer_var[varid].text, peer->refid,
++                                 NULL);
 +              else
-                       ctl_putid(peer_var[id].text, (char *)&p->refid);
++                      ctl_putrefid(peer_var[varid].text, peer->refid);
 +              break;
 +
 +      case CP_REFTIME:
 +              ctl_putts(peer_var[id].text, &p->reftime);
 +              break;
 +
 +      case CP_ORG:
 +              ctl_putts(peer_var[id].text, &p->aorg);
 +              break;
 +
 +      case CP_REC:
 +              ctl_putts(peer_var[id].text, &p->dst);
 +              break;
 +
 +      case CP_XMT:
 +              if (p->xleave)
 +                      ctl_putdbl(peer_var[id].text, p->xleave * 1e3);
 +              break;
 +
 +      case CP_BIAS:
 +              if (p->bias != 0.)
 +                      ctl_putdbl(peer_var[id].text, p->bias * 1e3);
 +              break;
 +
 +      case CP_REACH:
 +              ctl_puthex(peer_var[id].text, p->reach);
 +              break;
 +
 +      case CP_FLASH:
 +              ctl_puthex(peer_var[id].text, p->flash);
 +              break;
 +
 +      case CP_TTL:
 +              if (p->ttl)
 +                      ctl_putint(peer_var[id].text,
 +                                 sys_ttl[p->ttl]);
 +              break;
 +
 +      case CP_UNREACH:
 +              ctl_putuint(peer_var[id].text, p->unreach);
 +              break;
 +
 +      case CP_TIMER:
 +              ctl_putuint(peer_var[id].text,
 +                          p->nextdate - current_time);
 +              break;
 +
 +      case CP_DELAY:
 +              ctl_putdbl(peer_var[id].text, p->delay * 1e3);
 +              break;
 +
 +      case CP_OFFSET:
 +              ctl_putdbl(peer_var[id].text, p->offset * 1e3);
 +              break;
 +
 +      case CP_JITTER:
 +              ctl_putdbl(peer_var[id].text, p->jitter * 1e3);
 +              break;
 +
 +      case CP_DISPERSION:
 +              ctl_putdbl(peer_var[id].text, p->disp * 1e3);
 +              break;
 +
 +      case CP_KEYID:
 +              if (p->keyid > NTP_MAXKEY)
 +                      ctl_puthex(peer_var[id].text, p->keyid);
 +              else
 +                      ctl_putuint(peer_var[id].text, p->keyid);
 +              break;
 +
 +      case CP_FILTDELAY:
 +              ctl_putarray(peer_var[id].text, p->filter_delay,
 +                           p->filter_nextpt);
 +              break;
 +
 +      case CP_FILTOFFSET:
 +              ctl_putarray(peer_var[id].text, p->filter_offset,
 +                           p->filter_nextpt);
 +              break;
 +
 +      case CP_FILTERROR:
 +              ctl_putarray(peer_var[id].text, p->filter_disp,
 +                           p->filter_nextpt);
 +              break;
 +
 +      case CP_PMODE:
 +              ctl_putuint(peer_var[id].text, p->pmode);
 +              break;
 +
 +      case CP_RECEIVED:
 +              ctl_putuint(peer_var[id].text, p->received);
 +              break;
 +
 +      case CP_SENT:
 +              ctl_putuint(peer_var[id].text, p->sent);
 +              break;
 +
 +      case CP_VARLIST:
 +              s = buf;
 +              be = buf + sizeof(buf);
 +              if (strlen(peer_var[id].text) + 4 > sizeof(buf))
 +                      break;  /* really long var name */
 +
 +              snprintf(s, sizeof(buf), "%s=\"", peer_var[id].text);
 +              s += strlen(s);
 +              t = s;
 +              for (k = peer_var; !(EOV & k->flags); k++) {
 +                      if (PADDING & k->flags)
 +                              continue;
 +                      i = strlen(k->text);
 +                      if (s + i + 1 >= be)
 +                              break;
 +                      if (s != t)
 +                              *s++ = ',';
 +                      memcpy(s, k->text, i);
 +                      s += i;
 +              }
 +              if (s + 2 < be) { 
 +                      *s++ = '"';
 +                      *s = '\0';
 +                      ctl_putdata(buf, (u_int)(s - buf), 0);
 +              }
 +              break;
 +
 +      case CP_TIMEREC:
 +              ctl_putuint(peer_var[id].text,
 +                          current_time - p->timereceived);
 +              break;
 +
 +      case CP_TIMEREACH:
 +              ctl_putuint(peer_var[id].text,
 +                          current_time - p->timereachable);
 +              break;
 +
 +      case CP_BADAUTH:
 +              ctl_putuint(peer_var[id].text, p->badauth);
 +              break;
 +
 +      case CP_BOGUSORG:
 +              ctl_putuint(peer_var[id].text, p->bogusorg);
 +              break;
 +
 +      case CP_OLDPKT:
 +              ctl_putuint(peer_var[id].text, p->oldpkt);
 +              break;
 +
 +      case CP_SELDISP:
 +              ctl_putuint(peer_var[id].text, p->seldisptoolarge);
 +              break;
 +
 +      case CP_SELBROKEN:
 +              ctl_putuint(peer_var[id].text, p->selbroken);
 +              break;
 +
 +      case CP_CANDIDATE:
 +              ctl_putuint(peer_var[id].text, p->status);
 +              break;
 +#ifdef AUTOKEY
 +      case CP_FLAGS:
 +              if (p->crypto)
 +                      ctl_puthex(peer_var[id].text, p->crypto);
 +              break;
 +
 +      case CP_SIGNATURE:
 +              if (p->crypto) {
 +                      dp = EVP_get_digestbynid(p->crypto >> 16);
 +                      str = OBJ_nid2ln(EVP_MD_pkey_type(dp));
 +                      ctl_putstr(peer_var[id].text, str, strlen(str));
 +              }
 +              break;
 +
 +      case CP_HOST:
 +              if (p->subject != NULL)
 +                      ctl_putstr(peer_var[id].text, p->subject,
 +                          strlen(p->subject));
 +              break;
 +
 +      case CP_VALID:          /* not used */
 +              break;
 +
 +      case CP_INITSEQ:
 +              if (NULL == (ap = p->recval.ptr))
 +                      break;
 +
 +              ctl_putint(peer_var[CP_INITSEQ].text, ap->seq);
 +              ctl_puthex(peer_var[CP_INITKEY].text, ap->key);
 +              ctl_putfs(peer_var[CP_INITTSP].text,
 +                        ntohl(p->recval.tstamp));
 +              break;
 +
 +      case CP_IDENT:
 +              if (p->ident != NULL)
 +                      ctl_putstr(peer_var[id].text, p->ident,
 +                          strlen(p->ident));
 +              break;
 +
 +              
 +#endif        /* AUTOKEY */
 +      }
 +}
 +
 +
 +#ifdef REFCLOCK
 +/*
 + * ctl_putclock - output clock variables
 + */
 +static void
 +ctl_putclock(
 +      int id,
 +      struct refclockstat *pcs,
 +      int mustput
 +      )
 +{
 +      char buf[CTL_MAX_DATA_LEN];
 +      char *s, *t, *be;
 +      const char *ss;
 +      int i;
 +      const struct ctl_var *k;
 +
 +      switch (id) {
 +
 +      case CC_TYPE:
 +              if (mustput || pcs->clockdesc == NULL
 +                  || *(pcs->clockdesc) == '\0') {
 +                      ctl_putuint(clock_var[id].text, pcs->type);
 +              }
 +              break;
 +      case CC_TIMECODE:
 +              ctl_putstr(clock_var[id].text,
 +                         pcs->p_lastcode,
 +                         (unsigned)pcs->lencode);
 +              break;
 +
 +      case CC_POLL:
 +              ctl_putuint(clock_var[id].text, pcs->polls);
 +              break;
 +
 +      case CC_NOREPLY:
 +              ctl_putuint(clock_var[id].text,
 +                          pcs->noresponse);
 +              break;
 +
 +      case CC_BADFORMAT:
 +              ctl_putuint(clock_var[id].text,
 +                          pcs->badformat);
 +              break;
 +
 +      case CC_BADDATA:
 +              ctl_putuint(clock_var[id].text,
 +                          pcs->baddata);
 +              break;
 +
 +      case CC_FUDGETIME1:
 +              if (mustput || (pcs->haveflags & CLK_HAVETIME1))
 +                      ctl_putdbl(clock_var[id].text,
 +                                 pcs->fudgetime1 * 1e3);
 +              break;
 +
 +      case CC_FUDGETIME2:
 +              if (mustput || (pcs->haveflags & CLK_HAVETIME2))
 +                      ctl_putdbl(clock_var[id].text,
-                          pcs->fudgetime2 * 1e3);
++                                 pcs->fudgetime2 * 1e3);
 +              break;
 +
 +      case CC_FUDGEVAL1:
 +              if (mustput || (pcs->haveflags & CLK_HAVEVAL1))
 +                      ctl_putint(clock_var[id].text,
 +                                 pcs->fudgeval1);
 +              break;
 +
 +      case CC_FUDGEVAL2:
 +              if (mustput || (pcs->haveflags & CLK_HAVEVAL2)) {
 +                      if (pcs->fudgeval1 > 1)
 +                              ctl_putadr(clock_var[id].text,
-                                          (u_int32)pcs->fudgeval2, NULL);
++                                         pcs->fudgeval2, NULL);
 +                      else
-                               ctl_putid(clock_var[id].text,
-                                         (char *)&pcs->fudgeval2);
++                              ctl_putrefid(clock_var[id].text,
++                                           clock_stat->fudgeval2);
 +              }
 +              break;
 +
 +      case CC_FLAGS:
 +              ctl_putuint(clock_var[id].text, pcs->flags);
 +              break;
 +
 +      case CC_DEVICE:
 +              if (pcs->clockdesc == NULL ||
 +                  *(pcs->clockdesc) == '\0') {
 +                      if (mustput)
 +                              ctl_putstr(clock_var[id].text,
 +                                         "", 0);
 +              } else {
 +                      ctl_putstr(clock_var[id].text,
 +                                 pcs->clockdesc,
 +                                 strlen(pcs->clockdesc));
 +              }
 +              break;
 +
 +      case CC_VARLIST:
 +              s = buf;
 +              be = buf + sizeof(buf);
 +              if (strlen(clock_var[CC_VARLIST].text) + 4 >
 +                  sizeof(buf))
 +                      break;  /* really long var name */
 +
 +              snprintf(s, sizeof(buf), "%s=\"", 
 +                       clock_var[CC_VARLIST].text);
 +              s += strlen(s);
 +              t = s;
 +
 +              for (k = clock_var; !(EOV & k->flags); k++) {
 +                      if (PADDING & k->flags)
 +                              continue;
 +
 +                      i = strlen(k->text);
 +                      if (s + i + 1 >= be)
 +                              break;
 +
 +                      if (s != t)
 +                              *s++ = ',';
 +                      memcpy(s, k->text, i);
 +                      s += i;
 +              }
 +
 +              for (k = pcs->kv_list; k && !(EOV & k->flags); k++) {
 +                      if (PADDING & k->flags)
 +                              continue;
 +
 +                      ss = k->text;
 +                      if (NULL == ss)
 +                              continue;
 +
 +                      while (*ss && *ss != '=')
 +                              ss++;
 +                      i = ss - k->text;
 +                      if (s + i + 1 >= be)
 +                              break;
 +
 +                      if (s != t)
 +                              *s++ = ',';
 +                      memcpy(s, k->text, (unsigned)i);
 +                      s += i;
 +                      *s = '\0';
 +              }
 +              if (s + 2 >= be)
 +                      break;
 +
 +              *s++ = '"';
 +              *s = '\0';
 +              ctl_putdata(buf, (unsigned)(s - buf), 0);
 +              break;
 +      }
 +}
 +#endif
 +
 +
 +
 +/*
 + * ctl_getitem - get the next data item from the incoming packet
 + */
 +static const struct ctl_var *
 +ctl_getitem(
 +      const struct ctl_var *var_list,
 +      char **data
 +      )
 +{
 +      static const struct ctl_var eol = { 0, EOV, NULL };
 +      static char buf[128];
 +      static u_long quiet_until;
 +      const struct ctl_var *v;
 +      const char *pch;
 +      char *cp;
 +      char *tp;
 +
 +      /*
 +       * Delete leading commas and white space
 +       */
 +      while (reqpt < reqend && (*reqpt == ',' ||
 +                                isspace((unsigned char)*reqpt)))
 +              reqpt++;
 +      if (reqpt >= reqend)
 +              return NULL;
 +
 +      if (NULL == var_list)
 +              return &eol;
 +
 +      /*
 +       * Look for a first character match on the tag.  If we find
         * one, see if it is a full match.
         */
        v = var_list;
diff --cc ntpd/ntp_io.c
index f5f78b9f0aaf1b88606e1cf51d8f21f7e7c2a663,f5584462732f4945e9e1ef071d4627ce1bb20606..72d38f338bb74c03509efd3f572c85f2cc4b7b58
@@@ -4290,6 -4377,6 +4290,17 @@@ localaddrtoa
  }
  
  
++const char *
++localaddrtoa(
++      endpt *la
++      )
++{
++      return (NULL == la)
++                 ? "<null>"
++                 : stoa(&la->sin);
++}
++
++
  #ifdef HAS_ROUTING_SOCKET
  # ifndef UPDATE_GRACE
  #  define UPDATE_GRACE        2       /* wait UPDATE_GRACE seconds before scanning */
diff --cc ntpd/ntp_peer.c
index 4b97ecd6a97f055d1da596de9e3d38ef8a3e07bc,619e389f03394c09c10d058f4400fb06e8fee09e..54d97d7e61f874dd7cba0232507c63da29b0e6b3
@@@ -168,41 -178,18 +168,42 @@@ getmorepeermem(void
  }
  
  
 -/*
 - * findexistingpeer - return a pointer to a peer in the hash table
 - */
 -struct peer *
 -findexistingpeer(
 +static struct peer *
 +findexistingpeer_name(
 +      const char *    hostname,
 +      u_short         hname_fam,
 +      struct peer *   start_peer,
 +      int             mode
 +      )
 +{
 +      struct peer *p;
 +
 +      if (NULL == start_peer)
 +              p = peer_list;
 +      else
 +              p = start_peer->p_link;
 +      for (; p != NULL; p = p->p_link)
 +              if (p->hostname != NULL
 +                  && (-1 == mode || p->hmode == mode)
 +                  && (AF_UNSPEC == hname_fam
 +                      || AF_UNSPEC == AF(&p->srcadr)
 +                      || hname_fam == AF(&p->srcadr))
 +                  && !strcasecmp(p->hostname, hostname))
 +                      break;
 +      return p;
 +}
 +
 +
 +static
 +struct peer *         
 +findexistingpeer_addr(
        sockaddr_u *    addr,
        struct peer *   start_peer,
 -      int             mode,
 +      int             mode
+       u_char          cast_flags
        )
  {
 -      register struct peer *peer;
 +      struct peer *peer;
  
        /*
         * start_peer is included so we can locate instances of the
        if (NULL == start_peer)
                peer = peer_hash[NTP_HASH_ADDR(addr)];
        else
 -              peer = start_peer->next;
 +              peer = start_peer->adr_link;
        
        while (peer != NULL) {
-               if ((-1 == mode || peer->hmode == mode)
-                   && SOCK_EQ(addr, &peer->srcadr)
-                   && NSRCPORT(addr) == NSRCPORT(&peer->srcadr))
 -              if (ADDR_PORT_EQ(addr, &peer->srcadr)
 -                  && (-1 == mode || peer->hmode == mode ||
 -                      ((MDF_BCLNT & peer->cast_flags) &&
 -                       (MDF_BCLNT & cast_flags))))
++              if ((-1 == mode || peer->hmode == mode ||
++                   ((MDF_BCLNT & peer->cast_flags) &&
++                    (MDF_BCLNT & cast_flags))) &&
++                  ADDR_PORT_EQ(addr, &peer->srcadr))
                        break;
 -              peer = peer->next;
 +              peer = peer->adr_link;
        }
  
        return peer;
  }
  
  
-       int             mode
 +/*
 + * findexistingpeer - search by address and return a pointer to a peer.
 + */
 +struct peer *
 +findexistingpeer(
 +      sockaddr_u *    addr,
 +      const char *    hostname,
 +      struct peer *   start_peer,
-               return findexistingpeer_addr(addr, start_peer, mode);
++      int             mode,
++      u_char          cast_flags
 +      )
 +{
 +      if (hostname != NULL)
 +              return findexistingpeer_name(hostname, AF(addr),
 +                                           start_peer, mode);
 +      else
++              return findexistingpeer_addr(addr, start_peer, mode,
++                                           cast_flags);
 +}
 +
 +
  /*
-  * findpeer - find and return a peer in the hash table.
+  * findpeer - find and return a peer match for a received datagram in
+  *          the peer_hash table.
   */
  struct peer *
  findpeer(
@@@ -747,19 -766,24 +759,25 @@@ newpeer
         * actual interface, because that's what gets put into the peer
         * structure.
         */
-       peer = findexistingpeer(srcadr, hostname, NULL, hmode);
        if (dstadr != NULL) {
 -              peer = findexistingpeer(srcadr, NULL, hmode, cast_flags);
++              peer = findexistingpeer(srcadr, hostname, hmode,
++                                      cast_flags);
                while (peer != NULL) {
-                       if (peer->dstadr == dstadr)
+                       if (peer->dstadr == dstadr ||
+                           ((MDF_BCLNT & cast_flags) &&
+                            (MDF_BCLNT & peer->cast_flags)))
                                break;
  
                        if (dstadr == ANY_INTERFACE_CHOOSE(srcadr) &&
                            peer->dstadr == findinterface(srcadr))
                                break;
  
 -                      peer = findexistingpeer(srcadr, peer, hmode,
 -                                              cast_flags);
 +                      peer = findexistingpeer(srcadr, hostname, peer,
-                                               hmode);
++                                              hmode, cast_flags);
                }
 -              peer = findexistingpeer(srcadr, NULL, hmode, cast_flags);
+       } else {
+               /* no endpt address given */
++              peer = findexistingpeer(srcadr, hostname, hmode, cast_flags);
        }
  
        /*
index 6dd7c1ca62d6fc3d00980fd03ebef344b653085d,3229ca884652db52a185e086de5aa5560a2e3eeb..41535bc5837f4c764550d1402f7e0acea1a68b15
@@@ -126,19 -121,12 +126,20 @@@ u_long  sys_kodsent;            /* KoD sent *
  static        double  root_distance   (struct peer *);
  static        void    clock_combine   (struct peer **, int);
  static        void    peer_xmit       (struct peer *);
 -static        void    fast_xmit       (struct recvbuf *, int, keyid_t,
 -                                  int);
 +static        void    fast_xmit       (struct recvbuf *, int, keyid_t, int);
 +static        void    pool_xmit       (struct peer *);
  static        void    clock_update    (struct peer *);
  static        int     default_get_precision (void);
+ static        int     local_refid     (struct peer *);
  static        int     peer_unfit      (struct peer *);
 +#ifdef AUTOKEY
 +static        int     group_test      (char *, char *);
 +#endif /* AUTOKEY */
 +#ifdef WORKER
 +void  pool_name_resolved      (int, int, void *, const char *,
 +                               const char *, const struct addrinfo *,
 +                               const struct addrinfo *);
 +#endif /* WORKER */
  
  
  /*
@@@ -965,8 -848,22 +967,22 @@@ receive
                        sys_declined++;
                        return;                 /* protocol error */
                }
 -#endif /* OPENSSL */
 +#endif        /* AUTOKEY */
  
+               /*
+                * Broadcasts received via a multicast address may
+                * arrive after a unicast volley has begun
+                * with the same remote address.  newpeer() will not
+                * find duplicate associations on other local endpoints
+                * if a non-NULL endpoint is supplied.  multicastclient
+                * ephemeral associations are unique across all local
+                * endpoints.
+                */
+               if (!(INT_MCASTOPEN & rbufp->dstadr->flags))
+                       match_ep = rbufp->dstadr;
+               else
+                       match_ep = NULL;
                /*
                 * Determine whether to execute the initial volley.
                 */
                         * Do not execute the volley. Start out in
                         * broadcast client mode.
                         */
-                       if ((peer = newpeer(&rbufp->recv_srcadr, NULL,
-                           rbufp->dstadr, MODE_BCLIENT, hisversion,
-                           pkt->ppoll, pkt->ppoll, 0, 0, 0,
-                           skeyid, sys_ident)) == NULL) {
 -                      peer = newpeer(&rbufp->recv_srcadr, match_ep,
 -                          MODE_BCLIENT, hisversion, pkt->ppoll,
 -                          pkt->ppoll, FLAG_PREEMPT, MDF_BCLNT, 0,
 -                          skeyid);
++                      peer = newpeer(&rbufp->recv_srcadr, NULL,
++                          match_ep, MODE_BCLIENT, hisversion,
++                          pkt->ppoll, pkt->ppoll, FLAG_PREEMPT,
++                          MDF_BCLNT, 0, skeyid, sys_ident);
+                       if (NULL == peer) {
                                sys_restricted++;
                                return;         /* ignore duplicate */
  
                 * packet, normally 6 (64 s) and that the poll interval
                 * is fixed at this value.
                 */
-               if ((peer = newpeer(&rbufp->recv_srcadr, NULL,
-                   rbufp->dstadr, MODE_CLIENT, hisversion, pkt->ppoll,
-                   pkt->ppoll, FLAG_IBURST, MDF_BCLNT, 0, skeyid,
-                   sys_ident)) == NULL) {
 -              peer = newpeer(&rbufp->recv_srcadr, match_ep,
++              peer = newpeer(&rbufp->recv_srcadr, NULL, match_ep,
+                   MODE_CLIENT, hisversion, pkt->ppoll, pkt->ppoll,
+                   FLAG_BC_VOL | FLAG_IBURST | FLAG_PREEMPT, MDF_BCLNT,
 -                  0, skeyid);
++                  0, skeyid, sys_ident);
+               if (NULL == peer) {
                        sys_restricted++;
                        return;                 /* ignore duplicate */
                }
@@@ -1634,9 -1513,9 +1652,9 @@@ process_packet
                 * timestamp. This works for both basic and interleaved
                 * modes.
                 */
-               if (peer->cast_flags & MDF_BCLNT) {
-                       peer->cast_flags &= ~MDF_BCLNT;
+               if (FLAG_BC_VOL & peer->flags) {
+                       peer->flags &= ~FLAG_BC_VOL;
 -                      peer->delay = (peer->offset - p_offset) * 2;
 +                      peer->delay = fabs(peer->offset - p_offset) * 2;
                }
                p_del = peer->delay;
                p_offset += p_del / 2;
         * client mode when the client is fit and the autokey dance is
         * complete.
         */
-       if ((peer->cast_flags & MDF_BCLNT) && !(peer_unfit(peer) &
-           TEST11)) {
+       if ((FLAG_BC_VOL & peer->flags) && MODE_CLIENT == peer->hmode &&
+           !(TEST11 & peer_unfit(peer))) {     /* distance exceeded */
 -#ifdef OPENSSL
 +#ifdef AUTOKEY
                if (peer->flags & FLAG_SKEY) {
                        if (!(~peer->crypto & CRYPTO_FLAG_ALL))
                                peer->hmode = MODE_BCLIENT;
@@@ -2355,7 -2221,8 +2373,7 @@@ clock_select(void
        double  d, e, f, g;
        double  high, low;
        double  seljitter;
-       double  orphdist = 1e10;
 -      double  synch[NTP_MAXASSOC], error[NTP_MAXASSOC];
+       double  orphmet = 2.0 * U_INT32_MAX; /* 2x is greater than */
        struct peer *osys_peer = NULL;
        struct peer *sys_prefer = NULL; /* prefer peer */
        struct peer *typesystem = NULL;
         * bucks and collectively crank the chimes.
         */
        nlist = nl3 = 0;        /* none yet */
 -      for (n = 0; n < NTP_HASH_SIZE; n++) {
 -              for (peer = peer_hash[n]; peer != NULL; peer =
 -                  peer->next) {
 -                      peer->new_status = CTL_PST_SEL_REJECT;
 +      for (peer = peer_list; peer != NULL; peer = peer->p_link) {
 +              peer->new_status = CTL_PST_SEL_REJECT;
  
 -                      /*
 -                       * Leave the island immediately if the peer is
 -                       * unfit to synchronize.
 -                       */
 -                      if (peer_unfit(peer))
 -                              continue;
 +              /*
 +               * Leave the island immediately if the peer is
 +               * unfit to synchronize.
 +               */
 +              if (peer_unfit(peer))
 +                      continue;
  
 -                      /*
 -                       * If this peer is an orphan parent, elect the
 -                       * one with the lowest metric defined as the
 -                       * IPv4 address or the first 64 bits of the
 -                       * hashed IPv6 address.  To ensure convergence
 -                       * on the same selected orphan, consider as
 -                       * well that this system may have the lowest
 -                       * metric and be the orphan parent.  If this
 -                       * system wins, sys_peer will be NULL to trigger
 -                       * orphan mode in timer().
 -                       */
 -                      if (peer->stratum == sys_orphan) {
 -                              u_int32 localmet;
 -                              u_int32 peermet;
 -
 -                              localmet = peer->dstadr->addr_refid;
 -                              peermet = addr2refid(&peer->srcadr);
 -                              if (peermet < localmet &&
 -                                  peermet < orphmet) {
 -                                      typeorphan = peer;
 -                                      orphmet = peermet;
 -                              }
 -                              continue;
 +              /*
-                * If this is an orphan, choose the one with
-                * the lowest metric defined as the IPv4 address
-                * or the first 64 bits of the hashed IPv6 address.
++               * If this peer is an orphan parent, elect the
++               * one with the lowest metric defined as the
++               * IPv4 address or the first 64 bits of the
++               * hashed IPv6 address.  To ensure convergence
++               * on the same selected orphan, consider as
++               * well that this system may have the lowest
++               * metric and be the orphan parent.  If this
++               * system wins, sys_peer will be NULL to trigger
++               * orphan mode in timer().
 +               */
 +              if (peer->stratum == sys_orphan) {
-                       double  ftemp;
++                      u_int32 localmet;
++                      u_int32 peermet;
 +
-                       ftemp = addr2refid(&peer->srcadr);
-                       if (ftemp < orphdist) {
++                      localmet = peer->dstadr->addr_refid;
++                      peermet = addr2refid(&peer->srcadr);
++                      if (peermet < localmet &&
++                          peermet < orphmet) {
 +                              typeorphan = peer;
-                               orphdist = ftemp;
++                              orphmet = peermet;
                        }
 -                      /*
 -                       * If this peer could have the orphan parent
 -                       * as a synchronization ancestor, exclude it
 -                       * from selection to avoid forming a 
 -                       * synchronization loop within the orphan mesh,
 -                       * triggering stratum climb to infinity 
 -                       * instability.  Peers at stratum higher than
 -                       * the orphan stratum could have the orphan
 -                       * parent in ancestry so are excluded.
 -                       * See http://bugs.ntp.org/2050
 -                       */
 -                      if (peer->stratum > sys_orphan)
 -                              continue;
 +                      continue;
 +              }
++              /*
++               * If this peer could have the orphan parent
++               * as a synchronization ancestor, exclude it
++               * from selection to avoid forming a 
++               * synchronization loop within the orphan mesh,
++               * triggering stratum climb to infinity 
++               * instability.  Peers at stratum higher than
++               * the orphan stratum could have the orphan
++               * parent in ancestry so are excluded.
++               * See http://bugs.ntp.org/2050
++               */
++              if (peer->stratum > sys_orphan)
++                      continue;
  #ifdef REFCLOCK
 -                      /*
 -                       * The following are special cases. We deal
 -                       * with them later.
 -                       */
 -                      if (!(peer->flags & FLAG_PREFER)) {
 -                              switch (peer->refclktype) {
 -                              case REFCLK_LOCALCLOCK:
 -                                      if (typelocal == NULL)
 -                                              typelocal = peer;
 -                                      continue;
 -
 -                              case REFCLK_ACTS:
 -                                      if (typeacts == NULL)
 -                                              typeacts = peer;
 -                                      continue;
 -                              }
 +              /*
 +               * The following are special cases. We deal
 +               * with them later.
 +               */
 +              if (!(peer->flags & FLAG_PREFER)) {
 +                      switch (peer->refclktype) {
 +                      case REFCLK_LOCALCLOCK:
 +                              if (current_time > orphwait &&
 +                                  typelocal == NULL)
 +                                      typelocal = peer;
 +                              continue;
 +
 +                      case REFCLK_ACTS:
 +                              if (current_time > orphwait &&
 +                                  typeacts == NULL)
 +                                      typeacts = peer;
 +                              continue;
                        }
 +              }
  #endif /* REFCLOCK */
  
 -                      /*
 -                       * If we get this far, the peer can stay on the
 -                       * island, but does not yet have the immunity
 -                       * idol.
 -                       */
 -                      peer->new_status = CTL_PST_SEL_SANE;
 -                      peer_list[nlist++] = peer;
 -
 -                      /*
 -                       * Insert each interval endpoint on the sorted
 -                       * list.
 -                       */
 -                      e = peer->offset;        /* Upper end */
 -                      f = root_distance(peer);
 -                      e = e + f;
 -                      for (i = nl3 - 1; i >= 0; i--) {
 -                              if (e >= endpoint[indx[i]].val)
 -                                      break;
 -
 -                              indx[i + 3] = indx[i];
 -                      }
 -                      indx[i + 3] = nl3;
 -                      endpoint[nl3].type = 1;
 -                      endpoint[nl3++].val = e;
 +              /*
 +               * If we get this far, the peer can stay on the
 +               * island, but does not yet have the immunity
 +               * idol.
 +               */
 +              peer->new_status = CTL_PST_SEL_SANE;
 +              peers[nlist++] = peer;
  
 -                      e = e - f;              /* Center point */
 -                      for (; i >= 0; i--) {
 -                              if (e >= endpoint[indx[i]].val)
 -                                      break;
 +              /*
 +               * Insert each interval endpoint on the sorted
 +               * list. This code relies on the endpoints being at
 +               * increasing offsets.
 +               */
 +              e = peer->offset;        /* upper end */
 +              f = root_distance(peer);
 +              e = e + f;
 +              j = 0;
 +              for (i = nl3 - 1; i >= 0; i--) {
 +                      j = nl3 - 1 + 2;
 +                      if (e >= endpoint[indx[i]].val)
 +                              break;
  
 -                              indx[i + 2] = indx[i];
 -                      }
 -                      indx[i + 2] = nl3;
 -                      endpoint[nl3].type = 0;
 -                      endpoint[nl3++].val = e;
 +                      indx[i + 2] = indx[i];
 +              }
 +              indx[i + 2] = nl3;
 +              endpoint[nl3].type = 1;
 +              endpoint[nl3++].val = e;
  
 -                      e = e - f;              /* Lower end */
 -                      for (; i >= 0; i--) {
 -                              if (e >= endpoint[indx[i]].val)
 -                                      break;
 +              e = e - f - f;          /* lower end */
 +              for (; i >= 0; i--) {
 +                      if (e >= endpoint[indx[i]].val)
 +                              break;
  
 -                              indx[i + 1] = indx[i];
 -                      }
 -                      indx[i + 1] = nl3;
 -                      endpoint[nl3].type = -1;
 -                      endpoint[nl3++].val = e;
 +                      indx[i + 1] = indx[i];
                }
 +              indx[i + 1] = nl3;
 +              endpoint[nl3].type = -1;
 +              endpoint[nl3++].val = e;
        }
  #ifdef DEBUG
        if (debug > 2)
@@@ -3675,9 -3427,32 +3716,32 @@@ key_expire
                    peer->associd);
  #endif
  }
 -#endif /* OPENSSL */
 +#endif        /* AUTOKEY */
  
  
+ /*
+  * local_refid(peer) - check peer refid to avoid selecting peers
+  *                   currently synced to this ntpd.
+  */
+ static int
+ local_refid(
+       struct peer *   p
+       )
+ {
+       endpt * unicast_ep;
+       if (!(INT_MCASTIF & p->dstadr->flags))
+               unicast_ep = p->dstadr;
+       else
+               unicast_ep = findinterface(&p->srcadr);
+       if (unicast_ep != NULL && p->refid == unicast_ep->addr_refid)
+               return TRUE;
+       else
+               return FALSE;
+ }
  /*
   * Determine if the peer is unfit for synchronization
   *
index f6e527fcdd161495d8237b15eb6844b92f5bcb5d,a4d30e80b118f7ff24d22e741c18547f957fd2fd..bead17da61186c38de7451f07b932e0f8f00f12c
@@@ -1010,12 -1041,11 +1010,12 @@@ refclock_control
        clktype = (u_char)REFCLOCKTYPE(srcadr);
        unit = REFCLOCKUNIT(srcadr);
  
-       peer = findexistingpeer(srcadr, NULL, NULL, -1);
 -      peer = findexistingpeer(srcadr, NULL, -1, 0);
++      peer = findexistingpeer(srcadr, NULL, NULL, -1, 0);
  
 -      if (NULL == peer || NULL == peer->procptr)
 +      if (NULL == peer)
                return;
  
 +      NTP_INSIST(peer->procptr != NULL);
        pp = peer->procptr;
  
        /*
@@@ -1121,7 -1140,7 +1121,7 @@@ refclock_buginfo
        clktype = (u_char) REFCLOCKTYPE(srcadr);
        unit = REFCLOCKUNIT(srcadr);
  
-       peer = findexistingpeer(srcadr, NULL, NULL, -1);
 -      peer = findexistingpeer(srcadr, NULL, -1, 0);
++      peer = findexistingpeer(srcadr, NULL, NULL, -1, 0);
  
        if (NULL == peer || NULL == peer->procptr)
                return;
index af7b4ffb9abe4749d797bea9e67299f3d012e2df,a3c17e2267e84886347a9c2056d67ba17cc24309..a626e9c42fa4155467c7127291876e7091d48c59
@@@ -846,9 -851,9 +846,10 @@@ peer_info 
  #ifdef ISC_PLATFORM_HAVESALEN
                addr.sa.sa_len = SOCKLEN(&addr);
  #endif
 -              ipl++;
 -              pp = findexistingpeer(&addr, NULL, -1, 0);
 +              datap += item_sz;
 +
-               if ((pp = findexistingpeer(&addr, NULL, NULL, -1)) == 0)
++              pp = findexistingpeer(&addr, NULL, NULL, -1, 0);
+               if (NULL == pp)
                        continue;
                if (IS_IPV6(srcadr)) {
                        if (pp->dstadr)
@@@ -987,11 -986,13 +988,12 @@@ peer_stats 
                addr.sa.sa_len = SOCKLEN(&addr);
  #endif
                DPRINTF(1, ("peer_stats: looking for %s, %d, %d\n",
 -                          stoa(&addr), ipl->port, NSRCPORT(&addr)));
 +                          stoa(&addr), ipl.port, NSRCPORT(&addr)));
  
 -              ipl = (struct info_peer_list *)((char *)ipl +
 -                  INFO_ITEMSIZE(inpkt->mbz_itemsize));
 +              datap += item_sz;
  
-               if ((pp = findexistingpeer(&addr, NULL, NULL, -1)) == NULL)
 -              pp = findexistingpeer(&addr, NULL, -1, 0);
++              pp = findexistingpeer(&addr, NULL, NULL, -1, 0);
+               if (NULL == pp)
                        continue;
  
                DPRINTF(1, ("peer_stats: found %s\n", stoa(&addr)));
@@@ -1421,16 -1577,16 +1423,16 @@@ do_unconf
                DPRINTF(1, ("searching for %s\n", stoa(&peeraddr)));
  
                while (!found) {
-                       p = findexistingpeer(&peeraddr, NULL, p, -1);
 -                      peer = findexistingpeer(&peeraddr, peer, -1, 0);
 -                      if (!peer)
++                      p = findexistingpeer(&peeraddr, NULL, p, -1, 0);
 +                      if (NULL == p)
                                break;
 -                      if (peer->flags & FLAG_CONFIG)
 -                              found = 1;
 +                      if (FLAG_CONFIG & p->flags)
 +                              found = TRUE;
                }
                if (!found)
 -                      bad = 1;
 -              cp = (struct conf_unpeer *)
 -                      ((char *)cp + INFO_ITEMSIZE(inpkt->mbz_itemsize));
 +                      bad = TRUE;
 +
 +              datap += item_sz;
        }
  
        if (bad) {
  #ifdef ISC_PLATFORM_HAVESALEN
                peeraddr.sa.sa_len = SOCKLEN(&peeraddr);
  #endif
 -              found = 0;
 -              peer = NULL;
 +              found = FALSE;
 +              p = NULL;
  
                while (!found) {
-                       p = findexistingpeer(&peeraddr, NULL, p, -1);
 -                      peer = findexistingpeer(&peeraddr, peer, -1, 0);
 -                      if (!peer)
++                      p = findexistingpeer(&peeraddr, NULL, p, -1, 0);
 +                      if (NULL == p)
                                break;
 -                      if (peer->flags & FLAG_CONFIG)
 -                              found = 1;
 +                      if (FLAG_CONFIG & p->flags)
 +                              found = TRUE;
                }
 -              NTP_INSIST(found);
 -              NTP_INSIST(peer);
 +              INSIST(found);
 +              INSIST(NULL != p);
  
 -              peer_clear(peer, "GONE");
 -              unpeer(peer);
 +              peer_clear(p, "GONE");
 +              unpeer(p);
  
 -              cp = (struct conf_unpeer *)
 -                      ((char *)cp + INFO_ITEMSIZE(inpkt->mbz_itemsize));
 +              datap += item_sz;
        }
  
        req_ack(srcadr, inter, inpkt, INFO_OKAY);
@@@ -1898,10 -2137,11 +1900,10 @@@ reset_peer
  #ifdef ISC_PLATFORM_HAVESALEN
                peeraddr.sa.sa_len = SOCKLEN(&peeraddr);
  #endif
-               p = findexistingpeer(&peeraddr, NULL, NULL, -1);
 -              peer = findexistingpeer(&peeraddr, NULL, -1, 0);
 -              if (NULL == peer)
++              p = findexistingpeer(&peeraddr, NULL, NULL, -1, 0);
 +              if (NULL == p)
                        bad++;
 -              cp = (struct conf_unpeer *)((char *)cp +
 -                  INFO_ITEMSIZE(inpkt->mbz_itemsize));
 +              datap += item_sz;
        }
  
        if (bad) {
  #ifdef ISC_PLATFORM_HAVESALEN
                peeraddr.sa.sa_len = SOCKLEN(&peeraddr);
  #endif
-               p = findexistingpeer(&peeraddr, NULL, NULL, -1);
 -              peer = findexistingpeer(&peeraddr, NULL, -1, 0);
 -              while (peer != NULL) {
 -                      peer_reset(peer);
 -                      peer = findexistingpeer(&peeraddr, peer, -1, 0);
++              p = findexistingpeer(&peeraddr, NULL, NULL, -1, 0);
 +              while (p != NULL) {
 +                      peer_reset(p);
-                       p = findexistingpeer(&peeraddr, NULL, p, -1);
++                      p = findexistingpeer(&peeraddr, NULL, p, -1, 0);
                }
 -              cp = (struct conf_unpeer *)((char *)cp +
 -                  INFO_ITEMSIZE(inpkt->mbz_itemsize));
 +              datap += item_sz;
        }
  
        req_ack(srcadr, inter, inpkt, INFO_OKAY);
@@@ -2396,8 -2683,8 +2398,8 @@@ get_clock_info
  
        while (items-- > 0) {
                NSRCADR(&addr) = *clkaddr++;
--              if (!ISREFCLOCKADR(&addr) ||
-                   findexistingpeer(&addr, NULL, NULL, -1) == NULL) {
 -                  findexistingpeer(&addr, NULL, -1, 0) == NULL) {
++              if (!ISREFCLOCKADR(&addr) || NULL ==
++                  findexistingpeer(&addr, NULL, NULL, -1, 0)) {
                        req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
                        return;
                }
@@@ -2460,8 -2747,8 +2462,8 @@@ set_clock_fudge
                addr.sa.sa_len = SOCKLEN(&addr);
  #endif
                SET_PORT(&addr, NTP_PORT);
--              if (!ISREFCLOCKADR(&addr) ||
-                   findexistingpeer(&addr, NULL, NULL, -1) == 0) {
 -                  findexistingpeer(&addr, NULL, -1, 0) == 0) {
++              if (!ISREFCLOCKADR(&addr) || NULL ==
++                  findexistingpeer(&addr, NULL, NULL, -1, 0)) {
                        req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
                        return;
                }
@@@ -2535,8 -2822,8 +2537,8 @@@ get_clkbug_info
  
        while (items-- > 0) {
                NSRCADR(&addr) = *clkaddr++;
--              if (!ISREFCLOCKADR(&addr) ||
-                   findexistingpeer(&addr, NULL, NULL, -1) == 0) {
 -                  findexistingpeer(&addr, NULL, -1, 0) == 0) {
++              if (!ISREFCLOCKADR(&addr) || NULL ==
++                  findexistingpeer(&addr, NULL, NULL, -1, 0)) {
                        req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
                        return;
                }
index cb291ff12d528f33610133af2a30394f28a33e1e,3c2c832b198617f0bce98297f1eb745dda582e61..11ec7f81ab86c22673dfeddef5daac0d88da21c9
@@@ -332,18 -302,17 +332,18 @@@ timer(void
  
        /*
         * Orphan mode is active when enabled and when no servers less
-        * than the orphan statum are available. A server with no other
-        * synchronization source is an orphan It shows offset zero and
+        * than the orphan stratum are available. A server with no other
+        * synchronization source is an orphan. It shows offset zero and
         * reference ID the loopback address.
         */
 -      if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL) {
 +      if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL &&
 +          current_time > orphwait) {
                if (sys_leap == LEAP_NOTINSYNC) {
                        sys_leap = LEAP_NOWARNING;
 -#ifdef OPENSSL
 +#ifdef AUTOKEY
                        if (crypto_flags)       
                                crypto_update();
 -#endif /* OPENSSL */
 +#endif        /* AUTOKEY */
                }
                sys_stratum = (u_char)sys_orphan;
                if (sys_stratum > 1)
index 3cd78bf1b6a88826c88c96e69bb6a9761733a7f5,ba235f1575e91ef21dc89ce20f3d9d068ef7e302..8294be290afe7cc4010c66740d9fd6a89ed28887
  #include "ntpq-opts.h"
  
  extern char * chosts[];
 -extern char currenthost[];
 -extern int currenthostisnum;
 +extern char   currenthost[];
++extern int    currenthostisnum;
+ extern int    numhosts;
 -int   maxhostlen;
 +size_t                maxhostlen;
  
  /*
   * Declarations for command handlers in here
@@@ -1566,17 -1438,15 +1568,19 @@@ doprintpeers
  {
        char *name;
        char *value = NULL;
 -      int i;
        int c;
 -
 +      int len;
 +      int have_srchost;
 +      int have_jitter;
        sockaddr_u srcadr;
        sockaddr_u dstadr;
 +      sockaddr_u dum_store;
+       sockaddr_u refidadr;
 +      long hmode = 0;
        u_long srcport = 0;
 -      char *dstadr_refid = "0.0.0.0";
 +      u_int32 u32;
 +      const char *dstadr_refid = "0.0.0.0";
+       char *serverlocal;
        size_t drlen;
        u_long stratum = 0;
        long ppoll = 0;
        char whenbuf[8], pollbuf[8];
        char clock_name[LENHOSTNAME];
  
 -      memset((char *)havevar, 0, sizeof(havevar));
        get_systime(&ts);
        
 +      have_srchost = FALSE;
 +      have_jitter = FALSE;
        ZERO_SOCK(&srcadr);
        ZERO_SOCK(&dstadr);
 -
 -      /* Initialize by zeroing out estimate variables */
 -      memset((char *)&estoffset, 0, sizeof(l_fp));
 -      memset((char *)&estdelay, 0, sizeof(l_fp));
 -      memset((char *)&estjitter, 0, sizeof(l_fp));
 -      memset((char *)&estdisp, 0, sizeof(l_fp));
 +      clock_name[0] = '\0';
 +      ZERO(estoffset);
 +      ZERO(estdelay);
 +      ZERO(estjitter);
 +      ZERO(estdisp);
  
        while (nextvar(&datalen, &data, &name, &value)) {
 -              sockaddr_u dum_store;
 -
 -              i = findvar(name, peer_var, 1);
 -              if (i == 0)
 -                      continue;       /* don't know this one */
 -              switch (i) {
 -                      case CP_SRCADR:
 -                      if (decodenetnum(value, &srcadr)) {
 -                              havevar[HAVE_SRCADR] = 1;
 +              if (!strcmp("srcadr", name) ||
 +                  !strcmp("peeradr", name)) {
 +                      if (!decodenetnum(value, &srcadr))
 +                              fprintf(stderr, "malformed %s=%s\n",
 +                                      name, value);
 +              } else if (!strcmp("srchost", name)) {
 +                      if (pvl == peervarlist) {
 +                              len = strlen(value);
 +                              if (2 < len &&
 +                                  (size_t)len < sizeof(clock_name)) {
 +                                      /* strip quotes */
 +                                      value++;
 +                                      len -= 2;
 +                                      memcpy(clock_name, value, len);
 +                                      clock_name[len] = '\0';
 +                                      have_srchost = TRUE;
 +                              }
                        }
 -                      break;
 -                      case CP_DSTADR:
 +              } else if (!strcmp("dstadr", name)) {
                        if (decodenetnum(value, &dum_store)) {
                                type = decodeaddrtype(&dum_store);
+                               havevar[HAVE_DSTADR] = 1;
+                               dstadr = dum_store;
                                if (pvl == opeervarlist) {
-                                       dstadr = dum_store;
-                                       dstadr_refid = stoa(&dstadr);
+                                       dstadr_refid = trunc_left(stoa(&dstadr), 15);
                                }
                        }
 -                      break;
 -                      case CP_REFID:
 +              } else if (!strcmp("hmode", name)) {
 +                      decodeint(value, &hmode);
 +              } else if (!strcmp("refid", name)) {
                        if (pvl == peervarlist) {
 -                              havevar[HAVE_REFID] = 1;
 -                              if (*value == '\0') {
 +                              drlen = strlen(value);
 +                              if (0 == drlen) {
                                        dstadr_refid = "";
 -                              } else if (strlen(value) <= 4) {
 -                                      refid_string[0] = '.';
 -                                      (void) strcpy(&refid_string[1], value);
 -                                      i = strlen(refid_string);
 -                                      refid_string[i] = '.';
 -                                      refid_string[i+1] = '\0';
 -                                      dstadr_refid = refid_string;
 +                              } else if (drlen <= 4) {
 +                                      ZERO(u32);
 +                                      memcpy(&u32, value, drlen);
 +                                      dstadr_refid = refid_str(u32, 1);
-                               } else if (decodenetnum(value, &dstadr)) {
-                                       dstadr_refid =
-                                           refnumtoa(&dstadr);
+                               } else if (decodenetnum(value, &refidadr)) {
+                                       if (SOCK_UNSPEC(&refidadr))
+                                               dstadr_refid = "0.0.0.0";
+                                       else if (ISREFCLOCKADR(&refidadr))
+                                               dstadr_refid =
+                                                   refnumtoa(&refidadr);
+                                       else
+                                               dstadr_refid =
+                                                   stoa(&refidadr);
+                               } else {
+                                       havevar[HAVE_REFID] = 0;
                                }
                        }
 -                      break;
 -                      case CP_STRATUM:
 -                      if (decodeuint(value, &stratum))
 -                              havevar[HAVE_STRATUM] = 1;
 -                      break;
 -                      case CP_HPOLL:
 -                      if (decodeint(value, &hpoll)) {
 -                              havevar[HAVE_HPOLL] = 1;
 -                              if (hpoll < 0)
 -                                      hpoll = NTP_MINPOLL;
 -                      }
 -                      break;
 -                      case CP_PPOLL:
 -                      if (decodeint(value, &ppoll)) {
 -                              havevar[HAVE_PPOLL] = 1;
 -                              if (ppoll < 0)
 -                                      ppoll = NTP_MINPOLL;
 -                      }
 -                      break;
 -                      case CP_REACH:
 -                      if (decodeuint(value, &reach))
 -                              havevar[HAVE_REACH] = 1;
 -                      break;
 -                      case CP_DELAY:
 -                      if (decodetime(value, &estdelay))
 -                              havevar[HAVE_DELAY] = 1;
 -                      break;
 -                      case CP_OFFSET:
 -                      if (decodetime(value, &estoffset))
 -                              havevar[HAVE_OFFSET] = 1;
 -                      break;
 -                      case CP_JITTER:
 -                      if (pvl == peervarlist)
 -                              if (decodetime(value, &estjitter))
 -                                      havevar[HAVE_JITTER] = 1;
 -                      break;
 -                      case CP_DISPERSION:
 -                      if (decodetime(value, &estdisp))
 -                              havevar[HAVE_DISPERSION] = 1;
 -                      break;
 -                      case CP_REC:
 -                      if (decodets(value, &rec))
 -                              havevar[HAVE_REC] = 1;
 -                      break;
 -                      case CP_SRCPORT:
 -                      if (decodeuint(value, &srcport))
 -                              havevar[HAVE_SRCPORT] = 1;
 -                      break;
 -                      case CP_REFTIME:
 -                      havevar[HAVE_REFTIME] = 1;
 +              } else if (!strcmp("stratum", name)) {
 +                      decodeuint(value, &stratum);
 +              } else if (!strcmp("hpoll", name)) {
 +                      if (decodeint(value, &hpoll) && hpoll < 0)
 +                              hpoll = NTP_MINPOLL;
 +              } else if (!strcmp("ppoll", name)) {
 +                      if (decodeint(value, &ppoll) && ppoll < 0)
 +                              ppoll = NTP_MINPOLL;
 +              } else if (!strcmp("reach", name)) {
 +                      decodeuint(value, &reach);
 +              } else if (!strcmp("delay", name)) {
 +                      decodetime(value, &estdelay);
 +              } else if (!strcmp("offset", name)) {
 +                      decodetime(value, &estoffset);
 +              } else if (!strcmp("jitter", name)) {
 +                      if (pvl == peervarlist &&
 +                          decodetime(value, &estjitter))
 +                              have_jitter = 1;
 +              } else if (!strcmp("rootdisp", name) ||
 +                         !strcmp("dispersion", name)) {
 +                      decodetime(value, &estdisp);
 +              } else if (!strcmp("rec", name)) {
 +                      decodets(value, &rec);
 +              } else if (!strcmp("srcport", name) ||
 +                         !strcmp("peerport", name)) {
 +                      decodeuint(value, &srcport);
 +              } else if (!strcmp("reftime", name)) {
                        if (!decodets(value, &reftime))
                                L_CLR(&reftime);
 -                      break;
 -                      default:
 -                      break;
                }
        }
  
                c = flash3[CTL_PEER_STATVAL(rstatus) & 0x7];
        else
                c = flash2[CTL_PEER_STATVAL(rstatus) & 0x3];
-       if (numhosts > 1)
-               fprintf(fp, "%-*s ", (int)maxhostlen, currenthost);
+       if (numhosts > 1) {
+               if (peervarlist == pvl && havevar[HAVE_DSTADR]) {
+                       serverlocal = nntohost_col(&dstadr,
+                           (size_t)min(LIB_BUFLENGTH - 1, maxhostlen),
+                           TRUE);
+               } else {
+                       if (currenthostisnum)
+                               serverlocal = trunc_left(currenthost,
+                                                        maxhostlen);
+                       else
+                               serverlocal = currenthost;
+               }
 -              fprintf(fp, "%-*s ", maxhostlen, serverlocal);
++              fprintf(fp, "%-*s ", (int)maxhostlen, serverlocal);
+       }
        if (AF_UNSPEC == af || AF(&srcadr) == af) {
 -              strncpy(clock_name, nntohost(&srcadr), sizeof(clock_name));             
 +              if (!have_srchost)
 +                      strlcpy(clock_name, nntohost(&srcadr),
 +                              sizeof(clock_name));
                fprintf(fp, "%c%-15.15s ", c, clock_name);
                drlen = strlen(dstadr_refid);
                makeascii(drlen, dstadr_refid, fp);
@@@ -1817,13 -1719,15 +1844,15 @@@ dopeers
                return;
  
        for (i = 0; i < numhosts; ++i) {
-               if (getnetnum(chosts[i], &netnum, fullname, af))
-                       if ((int)strlen(fullname) > maxhostlen)
-                               maxhostlen = strlen(fullname);
+               if (getnetnum(chosts[i], &netnum, fullname, af)) {
+                       name_or_num = nntohost(&netnum);
+                       sl = strlen(name_or_num);
+                       maxhostlen = max(maxhostlen, (int)sl);
+               }
        }
        if (numhosts > 1)
 -              fprintf(fp, "%-*.*s ", maxhostlen, maxhostlen,
 +              fprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
-                       "server");
+                       "server (local)");
        fprintf(fp,
                "     remote           refid      st t when poll reach   delay   offset  jitter\n");
        if (numhosts > 1)
diff --cc ntpq/ntpq.c
index 14b5958785970394a0f609cbb0b816e0bda8e516,bc1acc61ed7bdf16ff4ba410794853d06ac56760..b465f87a18b88667d1cc5baf8a6ac8304be4e68a
@@@ -577,15 -688,16 +578,18 @@@ openhost
                return 0;
        }
  
 -      if (!showhostnames || ai->ai_canonname == NULL) {
 -              strncpy(temphost, 
 -                      stoa((sockaddr_u *)ai->ai_addr),
 -                      LENHOSTNAME);
 +      INSIST(ai != NULL);
 +      ZERO(addr);
 +      octets = min(sizeof(addr), ai->ai_addrlen);
 +      memcpy(&addr, ai->ai_addr, octets);
 +
-       if (ai->ai_canonname == NULL)
++      if (ai->ai_canonname == NULL) {
 +              strlcpy(temphost, stoa(&addr), sizeof(temphost));
-       else
+               currenthostisnum = TRUE;
+       } else {
 -              strncpy(temphost, ai->ai_canonname, LENHOSTNAME);
 +              strlcpy(temphost, ai->ai_canonname, sizeof(temphost));
+               currenthostisnum = FALSE;
+       }
 -      temphost[LENHOSTNAME-1] = '\0';
  
        if (debug > 2)
                printf("Opening host %s\n", temphost);
@@@ -1743,12 -1881,39 +1747,39 @@@ nntohost
        sockaddr_u *netnum
        )
  {
-       if (!showhostnames || SOCK_UNSPEC(netnum))
-               return stoa(netnum);
-       else if (ISREFCLOCKADR(netnum))
-               return refnumtoa(netnum);
-       else
-               return socktohost(netnum);
+       return nntohost_col(netnum, LIB_BUFLENGTH - 1, FALSE);
+ }
+ /*
+  * nntohost_col - convert network number to host name in fixed width.
+  *              This routine enforces the showhostnames setting.
+  *              When displaying hostnames longer than the width,
+  *              the first part of the hostname is displayed.  When
+  *              displaying numeric addresses longer than the width,
+  *              Such as IPv6 addresses, the caller decides whether
+  *              the first or last of the numeric address is used.
+  */
 -char *
++const char *
+ nntohost_col(
+       sockaddr_u *    addr,
+       size_t          width,
+       int             preserve_lowaddrbits
+       )
+ {
+       const char *    out;
 -      if (!showhostnames) {
++      if (!showhostnames || SOCK_UNSPEC(netnum)) {
+               if (preserve_lowaddrbits)
+                       out = trunc_left(stoa(addr), width);
+               else
+                       out = trunc_right(stoa(addr), width);
+       } else if (ISREFCLOCKADR(addr)) {
+               out = refnumtoa(addr);
+       } else {
+               out = trunc_right(socktohost(addr), width);
+       }
+       return out;
  }
  
  
diff --cc ntpq/ntpq.h
index 243a54afe7a8b83731c5fcad9070cdc2f29dca8f,77d5ce7f9afb33e6d1e6c0b1b690bcf9cfea02d7..eb12be6fcf1532677145b5ab76cd9b2653b24889
@@@ -1,16 -1,12 +1,17 @@@
  /*
   * ntpq.h - definitions of interest to ntpq
   */
 +#ifdef HAVE_UNISTD_H
 +# include <unistd.h>
 +#endif
  #include "ntp_fp.h"
  #include "ntp.h"
 -#include "ntp_control.h"
 +#include "ntp_stdlib.h"
  #include "ntp_string.h"
  #include "ntp_malloc.h"
 +#include "ntp_assert.h"
 +#include "ntp_control.h"
+ #include "lib_strbuf.h"
  
  /*
   * Maximum number of arguments
@@@ -126,17 -87,19 +127,20 @@@ extern   void    asciize         (int, char *, FIL
  extern        int     getnetnum       (const char *, sockaddr_u *, char *, int);
  extern        void    sortassoc       (void);
  extern        void    show_error_msg  (int, associd_t);
 -extern        int     doquery         (int, associd_t, int, int, char *,
 +extern        int     dogetassoc      (FILE *);
 +extern        int     doquery         (int, associd_t, int, int, const char *,
                                 u_short *, int *, const char **);
 -extern        int     doqueryex       (int, associd_t, int, int, char *,
 +extern        int     doqueryex       (int, associd_t, int, int, const char *,
                                 u_short *, int *, const char **, int);
 -extern        char *  nntohost        (sockaddr_u *);
 -extern        char *  nntohost_col    (sockaddr_u *, size_t, int);
 +extern        const char * nntohost   (sockaddr_u *);
++extern        const char * nntohost_col (sockaddr_u *, size_t, int);
 +extern        const char * nntohostp  (sockaddr_u *);
  extern        int     decodets        (char *, l_fp *);
  extern        int     decodeuint      (char *, u_long *);
  extern        int     nextvar         (int *, const char **, char **, char **);
  extern        int     decodetime      (char *, l_fp *);
  extern        void    printvars       (int, const char *, int, int, int, FILE *);
  extern        int     decodeint       (char *, long *);
 -extern        int     findvar         (char *, struct ctl_var *, int code);
  extern        void    makeascii       (int, const char *, FILE *);
+ extern        char *  trunc_left      (const char *, size_t);
+ extern        char *  trunc_right     (const char *, size_t);