xref: /freebsd/contrib/ntp/sntp/sntp-opts.def (revision 09100258)
1ea906c41SOllivier Robert/* -*- Mode: Text -*- */
2ea906c41SOllivier Robert
3ea906c41SOllivier Robertautogen definitions options;
4ea906c41SOllivier Robert
5ea906c41SOllivier Robert#include autogen-version.def
62b15cb3dSCy Schubert#include copyright.def
7ea906c41SOllivier Robert
8ea906c41SOllivier Robertprog-name      = "sntp";
92b15cb3dSCy Schubertprog-title	= "standard Simple Network Time Protocol client program";
102b15cb3dSCy Schubertargument	= '[ hostname-or-IP ...]';
112b15cb3dSCy Schubert
122b15cb3dSCy Schubert#include homerc.def
132b15cb3dSCy Schubert
14ea906c41SOllivier Robertlong-opts;
15ea906c41SOllivier Robert
16ea906c41SOllivier Robertconfig-header	= "config.h";
17ea906c41SOllivier Robert
18ea906c41SOllivier Robertenvironrc;
19ea906c41SOllivier Robert
20ea906c41SOllivier Robert#include version.def
21ea906c41SOllivier Robert
22ea906c41SOllivier Robertflag = {
23ea906c41SOllivier Robert  name		= ipv4;
24ea906c41SOllivier Robert  value		= 4;
252b15cb3dSCy Schubert  flags-cant	= ipv6;
26ea906c41SOllivier Robert  descrip	= "Force IPv4 DNS name resolution";
27ea906c41SOllivier Robert  doc		= <<- _EndOfDoc_
282b15cb3dSCy Schubert	Force DNS resolution of the following host names on the command line
29ea906c41SOllivier Robert	to the IPv4 namespace.
30ea906c41SOllivier Robert	_EndOfDoc_;
31ea906c41SOllivier Robert};
32ea906c41SOllivier Robert
33ea906c41SOllivier Robertflag = {
34ea906c41SOllivier Robert  name		= ipv6;
35ea906c41SOllivier Robert  value		= 6;
362b15cb3dSCy Schubert  flags-cant	= ipv4;
37ea906c41SOllivier Robert  descrip	= "Force IPv6 DNS name resolution";
38ea906c41SOllivier Robert  doc		= <<- _EndOfDoc_
392b15cb3dSCy Schubert	Force DNS resolution of the following host names on the command line
40ea906c41SOllivier Robert	to the IPv6 namespace.
41ea906c41SOllivier Robert	_EndOfDoc_;
42ea906c41SOllivier Robert};
43ea906c41SOllivier Robert
44ea906c41SOllivier Robertflag = {
452b15cb3dSCy Schubert  name		= authentication;
46ea906c41SOllivier Robert  value		= a;
472b15cb3dSCy Schubert  descrip	= "Enable authentication with the key @var{auth-keynumber}";
482b15cb3dSCy Schubert  arg-type	= number;
492b15cb3dSCy Schubert  arg-name	= "auth-keynumber";
502b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
512b15cb3dSCy Schubert	Enable authentication using the key specified in this option's
522b15cb3dSCy Schubert	argument.  The argument of this option is the @option{keyid}, a
532b15cb3dSCy Schubert	number specified in the @option{keyfile} as this key's identifier.
542b15cb3dSCy Schubert	See the @option{keyfile} option (@option{-k}) for more details.
552b15cb3dSCy Schubert	_EndOfDoc_;
562b15cb3dSCy Schubert};
572b15cb3dSCy Schubert
582b15cb3dSCy Schubertflag = {
592b15cb3dSCy Schubert  name		= broadcast;
602b15cb3dSCy Schubert  value		= b;
612b15cb3dSCy Schubert  descrip	= "Listen to the address specified for broadcast time sync";
622b15cb3dSCy Schubert  arg-type	= string;
632b15cb3dSCy Schubert  arg-name	= "broadcast-address";
642b15cb3dSCy Schubert  max		 = NOLIMIT;
652b15cb3dSCy Schubert  stack-arg;
662b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
672b15cb3dSCy Schubert	If specified @code{sntp} will listen to the specified address
682b15cb3dSCy Schubert	for NTP broadcasts.  The default maximum wait time
692b15cb3dSCy Schubert	can (and probably should) be modified with @option{-t}.
702b15cb3dSCy Schubert	_EndOfDoc_;
712b15cb3dSCy Schubert};
722b15cb3dSCy Schubert
732b15cb3dSCy Schubertflag = {
742b15cb3dSCy Schubert  name	 	= concurrent;
752b15cb3dSCy Schubert  value		= c;
762b15cb3dSCy Schubert  descrip	= "Concurrently query all IPs returned for host-name";
772b15cb3dSCy Schubert  arg-type	= string;
782b15cb3dSCy Schubert  arg-name	= "host-name";
792b15cb3dSCy Schubert  max		= NOLIMIT;
802b15cb3dSCy Schubert  stack-arg;
812b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
822b15cb3dSCy Schubert	Requests from an NTP "client" to a "server" should never be sent
832b15cb3dSCy Schubert	more rapidly than one every 2 seconds.  By default, any IPs returned
842b15cb3dSCy Schubert	as part of a DNS lookup are assumed to be for a single instance of
852b15cb3dSCy Schubert	@code{ntpd}, and therefore @code{sntp} will send queries to these IPs
862b15cb3dSCy Schubert	one after another, with a 2-second gap in between each query.
872b15cb3dSCy Schubert
882b15cb3dSCy Schubert	The @option{-c} or @option{--concurrent} flag says that any IPs
892b15cb3dSCy Schubert	returned for the DNS lookup of the supplied host-name are on
902b15cb3dSCy Schubert	different machines, so we can send concurrent queries.
912b15cb3dSCy Schubert	_EndOfDoc_;
922b15cb3dSCy Schubert};
932b15cb3dSCy Schubert
942b15cb3dSCy Schubert#include debug-opt.def
952b15cb3dSCy Schubert
962b15cb3dSCy Schubertflag = {
972b15cb3dSCy Schubert  name		= gap;
982b15cb3dSCy Schubert  value		= g;
992b15cb3dSCy Schubert  descrip	= "The gap (in milliseconds) between time requests";
1002b15cb3dSCy Schubert  arg-type	= number;
1012b15cb3dSCy Schubert  arg-name	= "milliseconds";
1022b15cb3dSCy Schubert  arg-default	= 50;
1032b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
1042b15cb3dSCy Schubert	Since we're only going to use the first valid response we get and
1052b15cb3dSCy Schubert	there is benefit to specifying a good number of servers to query,
1062b15cb3dSCy Schubert	separate the queries we send out by the specified number of
1072b15cb3dSCy Schubert	milliseconds.
1082b15cb3dSCy Schubert	_EndOfDoc_;
1092b15cb3dSCy Schubert};
1102b15cb3dSCy Schubert
1112b15cb3dSCy Schubertflag = {
1122b15cb3dSCy Schubert  name		= kod;
1132b15cb3dSCy Schubert  value		= K;
1142b15cb3dSCy Schubert  arg-type	= file;
1152b15cb3dSCy Schubert  arg-name	= "file-name";
1162b15cb3dSCy Schubert  arg-default	= "/var/db/ntp-kod";
1172b15cb3dSCy Schubert  descrip	= "KoD history filename";
1182b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
1192b15cb3dSCy Schubert	Specifies the filename to be used for the persistent history of KoD
1202b15cb3dSCy Schubert	responses received from servers.  If the file does not exist, a
1212b15cb3dSCy Schubert	warning message will be displayed.  The file will not be created.
1222b15cb3dSCy Schubert	_EndOfDoc_;
1232b15cb3dSCy Schubert};
1242b15cb3dSCy Schubert
1252b15cb3dSCy Schubertflag = {
1262b15cb3dSCy Schubert  name		= keyfile;
1272b15cb3dSCy Schubert  value		= k;
1282b15cb3dSCy Schubert  descrip	= "Look in this file for the key specified with @option{-a}";
1292b15cb3dSCy Schubert  arg-type	= file;
1302b15cb3dSCy Schubert  arg-name	= "file-name";
131*09100258SXin LI  arg-default	= "/etc/ntp.keys";
1322b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
1332b15cb3dSCy Schubert	This option specifies the keyfile.
1342b15cb3dSCy Schubert	@code{sntp} will search for the key specified with @option{-a}
1352b15cb3dSCy Schubert	@file{keyno} in this file.  See @command{ntp.keys(5)} for more
1362b15cb3dSCy Schubert	information.
1372b15cb3dSCy Schubert	_EndOfDoc_;
1382b15cb3dSCy Schubert};
1392b15cb3dSCy Schubert
1402b15cb3dSCy Schubertflag = {
1412b15cb3dSCy Schubert  name		= logfile;
1422b15cb3dSCy Schubert  value		= l;
1432b15cb3dSCy Schubert  arg-type	= file;
1442b15cb3dSCy Schubert  arg-name	= "file-name";
1452b15cb3dSCy Schubert  descrip	= "Log to specified logfile";
1462b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
1472b15cb3dSCy Schubert	This option causes the client to write log messages to the specified
1482b15cb3dSCy Schubert	@file{logfile}.
1492b15cb3dSCy Schubert	_EndOfDoc_;
1502b15cb3dSCy Schubert};
1512b15cb3dSCy Schubert
1522b15cb3dSCy Schubertflag = {
1532b15cb3dSCy Schubert  name		= steplimit;
1542b15cb3dSCy Schubert  value		= M;
1552b15cb3dSCy Schubert  arg-type	= number;
1562b15cb3dSCy Schubert  arg-range	= "0->";
1572b15cb3dSCy Schubert  descrip	= "Adjustments less than @var{steplimit} msec will be slewed";
1582b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
1592b15cb3dSCy Schubert	If the time adjustment is less than @file{steplimit} milliseconds,
1602b15cb3dSCy Schubert	slew the amount using @command{adjtime(2)}.  Otherwise, step the
1612b15cb3dSCy Schubert	correction using @command{settimeofday(2)}.  The default value is 0,
1622b15cb3dSCy Schubert	which means all adjustments will be stepped.  This is a feature, as
1632b15cb3dSCy Schubert	different situations demand different values.
1642b15cb3dSCy Schubert	_EndOfDoc_;
1652b15cb3dSCy Schubert};
1662b15cb3dSCy Schubert
1672b15cb3dSCy Schubertflag = {
1682b15cb3dSCy Schubert  name		= ntpversion;
1692b15cb3dSCy Schubert  value		= o;
1702b15cb3dSCy Schubert  descrip	= "Send @var{int} as our NTP protocol version";
1712b15cb3dSCy Schubert  arg-type	= number;
1722b15cb3dSCy Schubert  arg-default	= 4;
1732b15cb3dSCy Schubert  arg-range	= "0->7";
1742b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
1752b15cb3dSCy Schubert	When sending requests to a remote server, tell them we are running
1762b15cb3dSCy Schubert	NTP protocol version @file{ntpversion} .
1772b15cb3dSCy Schubert	_EndOfDoc_;
1782b15cb3dSCy Schubert};
1792b15cb3dSCy Schubert
1802b15cb3dSCy Schubertflag = {
1812b15cb3dSCy Schubert  name		= usereservedport;
1822b15cb3dSCy Schubert  value		= r;
1832b15cb3dSCy Schubert  descrip	= "Use the NTP Reserved Port (port 123)";
1842b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
1852b15cb3dSCy Schubert	Use port 123, which is reserved for NTP, for our network
1862b15cb3dSCy Schubert	communications.
1872b15cb3dSCy Schubert	_EndOfDoc_;
1882b15cb3dSCy Schubert};
1892b15cb3dSCy Schubert
1902b15cb3dSCy Schubertflag = {
1912b15cb3dSCy Schubert  name		= step;
1922b15cb3dSCy Schubert  value		= S;
1932b15cb3dSCy Schubert  descrip	= "OK to 'step' the time with @command{settimeofday(2)}";
194ea906c41SOllivier Robert  doc		= <<- _EndOfDoc_
195ea906c41SOllivier Robert	_EndOfDoc_;
196ea906c41SOllivier Robert};
197ea906c41SOllivier Robert
1982b15cb3dSCy Schubertflag = {
1992b15cb3dSCy Schubert  name		= slew;
2002b15cb3dSCy Schubert  value		= s;
2012b15cb3dSCy Schubert  descrip	= "OK to 'slew' the time with @command{adjtime(2)}";
2022b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
2032b15cb3dSCy Schubert	_EndOfDoc_;
2042b15cb3dSCy Schubert};
205ea906c41SOllivier Robert
2062b15cb3dSCy Schubert
2072b15cb3dSCy Schubertflag = {
2082b15cb3dSCy Schubert  name		= timeout;
2092b15cb3dSCy Schubert  value		= t;
2102b15cb3dSCy Schubert  descrip	= "The number of seconds to wait for responses";
2112b15cb3dSCy Schubert  arg-type	= number;
2122b15cb3dSCy Schubert  arg-name	= "seconds";
2132b15cb3dSCy Schubert  arg-default	= 5;
2142b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
2152b15cb3dSCy Schubert	When waiting for a reply, @code{sntp} will wait the number
2162b15cb3dSCy Schubert	of seconds specified before giving up.  The default should be
2172b15cb3dSCy Schubert	more than enough for a unicast response.  If @code{sntp} is
2182b15cb3dSCy Schubert	only waiting for a broadcast response a longer timeout is
2192b15cb3dSCy Schubert	likely needed.
2202b15cb3dSCy Schubert	_EndOfDoc_;
2212b15cb3dSCy Schubert};
2222b15cb3dSCy Schubert
2232b15cb3dSCy Schubertflag = {
2242b15cb3dSCy Schubert  name		= "wait";
2252b15cb3dSCy Schubert  descrip	= "Wait for pending replies (if not setting the time)";
2262b15cb3dSCy Schubert  disable	= no;
2272b15cb3dSCy Schubert  enabled;
2282b15cb3dSCy Schubert  settable;
2292b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
2302b15cb3dSCy Schubert	If we are not setting the time, wait for all pending responses.
2312b15cb3dSCy Schubert	_EndOfDoc_;
2322b15cb3dSCy Schubert};
2332b15cb3dSCy Schubert
2342b15cb3dSCy Schubert/* explain: Additional information whenever the usage routine is invoked */
2352b15cb3dSCy Schubertexplain = <<- _END_EXPLAIN
2362b15cb3dSCy Schubert	_END_EXPLAIN;
2372b15cb3dSCy Schubert
2382b15cb3dSCy Schubertdoc-section	= {
2392b15cb3dSCy Schubert  ds-type	= 'DESCRIPTION';
2402b15cb3dSCy Schubert  ds-format	= 'mdoc';
2412b15cb3dSCy Schubert  ds-text	= <<- _END_PROG_MDOC_DESCRIP
2422b15cb3dSCy Schubert.Nm
2432b15cb3dSCy Schubertcan be used as an SNTP client to query a NTP or SNTP server and either display
244ea906c41SOllivier Robertthe time or set the local system's time (given suitable privilege).  It can be
2452b15cb3dSCy Schubertrun as an interactive command or from a
2462b15cb3dSCy Schubert.Ic cron
247ea906c41SOllivier Robertjob.
2482b15cb3dSCy Schubert
2492b15cb3dSCy SchubertNTP (the Network Time Protocol) and SNTP (the Simple Network Time Protocol)
2502b15cb3dSCy Schubertare defined and described by RFC 5905.
2512b15cb3dSCy Schubert
2522b15cb3dSCy Schubert.Pp
253ea906c41SOllivier RobertThe default is to write the estimated correct local date and time (i.e. not
2542b15cb3dSCy SchubertUTC) to the standard output in a format like:
2552b15cb3dSCy Schubert
2562b15cb3dSCy Schubert.Ic "'1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 [host] IP sN'"
2572b15cb3dSCy Schubert
258ea906c41SOllivier Robertwhere the
2592b15cb3dSCy Schubert.Ic "'(+0800)'"
2602b15cb3dSCy Schubertmeans that to get to UTC from the reported local time one must
2612b15cb3dSCy Schubertadd 8 hours and 0 minutes,
2622b15cb3dSCy Schubertthe
2632b15cb3dSCy Schubert.Ic "'+4.567'"
2642b15cb3dSCy Schubertindicates the local clock is 4.567 seconds behind the correct time
2652b15cb3dSCy Schubert(so 4.567 seconds must be added to the local clock to get it to be correct).
2662b15cb3dSCy SchubertNote that the number of decimals printed for this value will change
2672b15cb3dSCy Schubertbased on the reported precision of the server.
2682b15cb3dSCy Schubert.Ic "'+/- 0.089'"
2692b15cb3dSCy Schubertis the reported
2702b15cb3dSCy Schubert.Em synchronization distance
2712b15cb3dSCy Schubert(in seconds), which represents the maximum error due to all causes.
2722b15cb3dSCy SchubertIf the server does not report valid data needed to calculate the
2732b15cb3dSCy Schubertsynchronization distance, this will be reported as
2742b15cb3dSCy Schubert.Ic "'+/- ?'" .
2752b15cb3dSCy SchubertIf the
2762b15cb3dSCy Schubert.Em host
2772b15cb3dSCy Schubertis different from the
2782b15cb3dSCy Schubert.Em IP ,
2792b15cb3dSCy Schubertboth will be displayed.
2802b15cb3dSCy SchubertOtherwise, only the
2812b15cb3dSCy Schubert.Em IP
2822b15cb3dSCy Schubertis displayed.
2832b15cb3dSCy SchubertFinally, the
2842b15cb3dSCy Schubert.Em stratum
285a25439b6SCy Schubertof the host is reported
286a25439b6SCy Schubertand the leap indicator is decoded and displayed.
2872b15cb3dSCy Schubert	_END_PROG_MDOC_DESCRIP;
2882b15cb3dSCy Schubert};
2892b15cb3dSCy Schubert
2902b15cb3dSCy Schubertdoc-section	= {
2912b15cb3dSCy Schubert  ds-type	= 'USAGE';
2922b15cb3dSCy Schubert  ds-format	= 'mdoc';
2932b15cb3dSCy Schubert  ds-text	= <<- _END_MDOC_USAGE
2942b15cb3dSCy Schubert.Bl -tag -width indent
2952b15cb3dSCy Schubert.It Li "sntp ntpserver.somewhere"
2962b15cb3dSCy Schubertis the simplest use of this program
2972b15cb3dSCy Schubertand can be run as an unprivileged command
2982b15cb3dSCy Schubertto check the current time and error in the local clock.
2992b15cb3dSCy Schubert.It Li "sntp -Ss -M 128 ntpserver.somewhere"
3002b15cb3dSCy SchubertWith suitable privilege,
3012b15cb3dSCy Schubertrun as a command
3022b15cb3dSCy Schubertor from a
3032b15cb3dSCy Schubert.Xr cron 8
3042b15cb3dSCy Schubertjob,
3052b15cb3dSCy Schubert.Ic "sntp -Ss -M 128 ntpserver.somewhere"
3062b15cb3dSCy Schubertwill request the time from the server,
3072b15cb3dSCy Schubertand if that server reports that it is synchronized
3082b15cb3dSCy Schubertthen if the offset adjustment is less than 128 milliseconds
3092b15cb3dSCy Schubertthe correction will be slewed,
3102b15cb3dSCy Schubertand if the correction is more than 128 milliseconds
3112b15cb3dSCy Schubertthe correction  will be stepped.
3122b15cb3dSCy Schubert.It Li "sntp -S ntpserver.somewhere"
3132b15cb3dSCy SchubertWith suitable privilege,
3142b15cb3dSCy Schubertrun as a command
3152b15cb3dSCy Schubertor from a
3162b15cb3dSCy Schubert.Xr cron 8
3172b15cb3dSCy Schubertjob,
3182b15cb3dSCy Schubert.Ic "sntp -S ntpserver.somewhere"
3192b15cb3dSCy Schubertwill set (step) the local clock from a synchronized specified server,
3202b15cb3dSCy Schubertlike the (deprecated)
3212b15cb3dSCy Schubert.Xr ntpdate 1ntpdatemdoc ,
3222b15cb3dSCy Schubertor
3232b15cb3dSCy Schubert.Xr rdate 8
3242b15cb3dSCy Schubertcommands.
3252b15cb3dSCy Schubert.El
3262b15cb3dSCy Schubert	_END_MDOC_USAGE;
3272b15cb3dSCy Schubert};
3282b15cb3dSCy Schubert
3292b15cb3dSCy Schubertdoc-section	= {
3302b15cb3dSCy Schubert  ds-type	= 'AUTHORS';
3312b15cb3dSCy Schubert  ds-format	= 'mdoc';
3322b15cb3dSCy Schubert  ds-text	= <<- _END_MDOC_AUTHORS
3332b15cb3dSCy Schubert.An "Johannes Maximilian Kuehn"
3342b15cb3dSCy Schubert.An "Harlan Stenn"
3352b15cb3dSCy Schubert.An "Dave Hart"
3362b15cb3dSCy Schubert	_END_MDOC_AUTHORS;
3372b15cb3dSCy Schubert};
338