summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ntp/scripts
diff options
context:
space:
mode:
authorroberto <roberto@FreeBSD.org>2004-07-20 15:44:32 +0000
committerroberto <roberto@FreeBSD.org>2004-07-20 15:44:32 +0000
commiteac3f226bba60fc68883240347410cfd4136e343 (patch)
tree6bdcfb48e637477e8605a8680d6b792e62d4d4b0 /usr.sbin/ntp/scripts
parent66b0c5ee1050efae95b630c55b23eb4b866554d3 (diff)
downloadFreeBSD-src-eac3f226bba60fc68883240347410cfd4136e343.zip
FreeBSD-src-eac3f226bba60fc68883240347410cfd4136e343.tar.gz
Update our ntpd to the long awaited 4.2.0 version.
This bring us several things: - updated drivers - IPv6 support at last - ntp-genkeys is replaced by ntp-keygen - ntptrace is now a script (courtesy of John Hay) - lots of renamed files from .htm to .html (while I prefer .html, I find the change a bit gratuitous) - still no manpages :( Please test and report. Commit very much helped by: GNU arch (http://gnuarch.org/)
Diffstat (limited to 'usr.sbin/ntp/scripts')
-rwxr-xr-xusr.sbin/ntp/scripts/mkver2
-rw-r--r--usr.sbin/ntp/scripts/ntptrace62
2 files changed, 63 insertions, 1 deletions
diff --git a/usr.sbin/ntp/scripts/mkver b/usr.sbin/ntp/scripts/mkver
index a418146..d54386d 100755
--- a/usr.sbin/ntp/scripts/mkver
+++ b/usr.sbin/ntp/scripts/mkver
@@ -6,7 +6,7 @@ PROG=${1-UNKNOWN}
ConfStr="$PROG"
-ConfStr="$ConfStr 4.1.1b"
+ConfStr="$ConfStr 4.2.0"
case "$CSET" in
'') ;;
diff --git a/usr.sbin/ntp/scripts/ntptrace b/usr.sbin/ntp/scripts/ntptrace
new file mode 100644
index 0000000..8a895c4
--- /dev/null
+++ b/usr.sbin/ntp/scripts/ntptrace
@@ -0,0 +1,62 @@
+#! /usr/local/bin/perl -w
+#
+# $FreeBSD$
+
+# John Hay -- John.Hay@icomtek.csir.co.za / jhay@FreeBSD.org
+
+use Socket;
+use Getopt::Std;
+use vars qw($opt_n);
+
+$ntpq = "ntpq";
+
+getopts('n');
+
+$dodns = 1;
+$dodns = 0 if (defined($opt_n));
+
+$host = shift;
+$host ||= "127.0.0.1";
+
+for (;;) {
+ $stratum = 255;
+ $cmd = "$ntpq -n -c rv $host";
+ open(PH, $cmd . "|") || die "failed to start command $cmd: $!";
+ while (<PH>) {
+ $stratum = $1 if (/stratum=(\d+)/);
+ $peer = $1 if (/peer=(\d+)/);
+ # Very old servers report phase and not offset.
+ $offset = $1 if (/(?:offset|phase)=([^\s,]+)/);
+ $rootdelay = $1 if (/rootdelay=([^\s,]+)/);
+ $refid = $1 if (/refid=([^\s,]+)/);
+ }
+ close(PH) || die "$cmd failed";
+ last if ($stratum == 255);
+ $offset /= 1000;
+ $rootdelay /= 1000;
+ $dhost = $host;
+ # Only do lookups of IPv4 addresses. The standard lookup functions
+ # of perl only do IPv4 and I don't know if we should require extras.
+ if ($dodns && $host =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) {
+ $iaddr = inet_aton($host);
+ $name = (gethostbyaddr($iaddr, AF_INET))[0];
+ $dhost = $name if (defined($name));
+ }
+ printf("%s: stratum %d, offset %f, root distance %f",
+ $dhost, $stratum, $offset, $rootdelay);
+ printf(", refid '%s'", $refid) if ($stratum == 1);
+ printf("\n");
+ last if ($stratum == 0 || $stratum == 1 || $stratum == 16);
+ last if ($refid =~ /^127\.127\.\d{1,3}\.\d{1,3}$/);
+
+ $cmd = "$ntpq -n -c \"pstat $peer\" $host";
+ open(PH, $cmd . "|") || die "failed to start command $cmd: $!";
+ $thost = "";
+ while (<PH>) {
+ $thost = $1, last if (/srcadr=(\S+),/);
+ }
+ close(PH) || die "$cmd failed";
+ last if ($thost eq "");
+ $host = $thost;
+}
+
OpenPOWER on IntegriCloud