xref: /freebsd/contrib/ntp/sntp/sntp-opts.def (revision 2b15cb3d0922bd70ea592f0da9b4a5b167f4d53f)
1ea906c41SOllivier Robert/* -*- Mode: Text -*- */
2ea906c41SOllivier Robert
3ea906c41SOllivier Robertautogen definitions options;
4ea906c41SOllivier Robert
5ea906c41SOllivier Robert#include autogen-version.def
6*2b15cb3dSCy Schubert#include copyright.def
7ea906c41SOllivier Robert
8ea906c41SOllivier Robertprog-name      = "sntp";
9*2b15cb3dSCy Schubertprog-title	= "standard Simple Network Time Protocol client program";
10*2b15cb3dSCy Schubertargument	= '[ hostname-or-IP ...]';
11*2b15cb3dSCy Schubert
12*2b15cb3dSCy Schubert#include homerc.def
13*2b15cb3dSCy 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;
25*2b15cb3dSCy Schubert  flags-cant	= ipv6;
26ea906c41SOllivier Robert  descrip	= "Force IPv4 DNS name resolution";
27ea906c41SOllivier Robert  doc		= <<- _EndOfDoc_
28*2b15cb3dSCy 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;
36*2b15cb3dSCy Schubert  flags-cant	= ipv4;
37ea906c41SOllivier Robert  descrip	= "Force IPv6 DNS name resolution";
38ea906c41SOllivier Robert  doc		= <<- _EndOfDoc_
39*2b15cb3dSCy 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 = {
45*2b15cb3dSCy Schubert  name		= authentication;
46ea906c41SOllivier Robert  value		= a;
47*2b15cb3dSCy Schubert  descrip	= "Enable authentication with the key @var{auth-keynumber}";
48*2b15cb3dSCy Schubert  arg-type	= number;
49*2b15cb3dSCy Schubert  arg-name	= "auth-keynumber";
50*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
51*2b15cb3dSCy Schubert	Enable authentication using the key specified in this option's
52*2b15cb3dSCy Schubert	argument.  The argument of this option is the @option{keyid}, a
53*2b15cb3dSCy Schubert	number specified in the @option{keyfile} as this key's identifier.
54*2b15cb3dSCy Schubert	See the @option{keyfile} option (@option{-k}) for more details.
55*2b15cb3dSCy Schubert	_EndOfDoc_;
56*2b15cb3dSCy Schubert};
57*2b15cb3dSCy Schubert
58*2b15cb3dSCy Schubertflag = {
59*2b15cb3dSCy Schubert  name		= broadcast;
60*2b15cb3dSCy Schubert  value		= b;
61*2b15cb3dSCy Schubert  descrip	= "Listen to the address specified for broadcast time sync";
62*2b15cb3dSCy Schubert  arg-type	= string;
63*2b15cb3dSCy Schubert  arg-name	= "broadcast-address";
64*2b15cb3dSCy Schubert  max		 = NOLIMIT;
65*2b15cb3dSCy Schubert  stack-arg;
66*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
67*2b15cb3dSCy Schubert	If specified @code{sntp} will listen to the specified address
68*2b15cb3dSCy Schubert	for NTP broadcasts.  The default maximum wait time
69*2b15cb3dSCy Schubert	can (and probably should) be modified with @option{-t}.
70*2b15cb3dSCy Schubert	_EndOfDoc_;
71*2b15cb3dSCy Schubert};
72*2b15cb3dSCy Schubert
73*2b15cb3dSCy Schubertflag = {
74*2b15cb3dSCy Schubert  name	 	= concurrent;
75*2b15cb3dSCy Schubert  value		= c;
76*2b15cb3dSCy Schubert  descrip	= "Concurrently query all IPs returned for host-name";
77*2b15cb3dSCy Schubert  arg-type	= string;
78*2b15cb3dSCy Schubert  arg-name	= "host-name";
79*2b15cb3dSCy Schubert  max		= NOLIMIT;
80*2b15cb3dSCy Schubert  stack-arg;
81*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
82*2b15cb3dSCy Schubert	Requests from an NTP "client" to a "server" should never be sent
83*2b15cb3dSCy Schubert	more rapidly than one every 2 seconds.  By default, any IPs returned
84*2b15cb3dSCy Schubert	as part of a DNS lookup are assumed to be for a single instance of
85*2b15cb3dSCy Schubert	@code{ntpd}, and therefore @code{sntp} will send queries to these IPs
86*2b15cb3dSCy Schubert	one after another, with a 2-second gap in between each query.
87*2b15cb3dSCy Schubert
88*2b15cb3dSCy Schubert	The @option{-c} or @option{--concurrent} flag says that any IPs
89*2b15cb3dSCy Schubert	returned for the DNS lookup of the supplied host-name are on
90*2b15cb3dSCy Schubert	different machines, so we can send concurrent queries.
91*2b15cb3dSCy Schubert	_EndOfDoc_;
92*2b15cb3dSCy Schubert};
93*2b15cb3dSCy Schubert
94*2b15cb3dSCy Schubert#include debug-opt.def
95*2b15cb3dSCy Schubert
96*2b15cb3dSCy Schubertflag = {
97*2b15cb3dSCy Schubert  name		= gap;
98*2b15cb3dSCy Schubert  value		= g;
99*2b15cb3dSCy Schubert  descrip	= "The gap (in milliseconds) between time requests";
100*2b15cb3dSCy Schubert  arg-type	= number;
101*2b15cb3dSCy Schubert  arg-name	= "milliseconds";
102*2b15cb3dSCy Schubert  arg-default	= 50;
103*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
104*2b15cb3dSCy Schubert	Since we're only going to use the first valid response we get and
105*2b15cb3dSCy Schubert	there is benefit to specifying a good number of servers to query,
106*2b15cb3dSCy Schubert	separate the queries we send out by the specified number of
107*2b15cb3dSCy Schubert	milliseconds.
108*2b15cb3dSCy Schubert	_EndOfDoc_;
109*2b15cb3dSCy Schubert};
110*2b15cb3dSCy Schubert
111*2b15cb3dSCy Schubertflag = {
112*2b15cb3dSCy Schubert  name		= kod;
113*2b15cb3dSCy Schubert  value		= K;
114*2b15cb3dSCy Schubert  arg-type	= file;
115*2b15cb3dSCy Schubert  arg-name	= "file-name";
116*2b15cb3dSCy Schubert  arg-default	= "/var/db/ntp-kod";
117*2b15cb3dSCy Schubert  descrip	= "KoD history filename";
118*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
119*2b15cb3dSCy Schubert	Specifies the filename to be used for the persistent history of KoD
120*2b15cb3dSCy Schubert	responses received from servers.  If the file does not exist, a
121*2b15cb3dSCy Schubert	warning message will be displayed.  The file will not be created.
122*2b15cb3dSCy Schubert	_EndOfDoc_;
123*2b15cb3dSCy Schubert};
124*2b15cb3dSCy Schubert
125*2b15cb3dSCy Schubertflag = {
126*2b15cb3dSCy Schubert  name		= keyfile;
127*2b15cb3dSCy Schubert  value		= k;
128*2b15cb3dSCy Schubert  descrip	= "Look in this file for the key specified with @option{-a}";
129*2b15cb3dSCy Schubert  arg-type	= file;
130*2b15cb3dSCy Schubert  arg-name	= "file-name";
131*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
132*2b15cb3dSCy Schubert	This option specifies the keyfile.
133*2b15cb3dSCy Schubert	@code{sntp} will search for the key specified with @option{-a}
134*2b15cb3dSCy Schubert	@file{keyno} in this file.  See @command{ntp.keys(5)} for more
135*2b15cb3dSCy Schubert	information.
136*2b15cb3dSCy Schubert	_EndOfDoc_;
137*2b15cb3dSCy Schubert};
138*2b15cb3dSCy Schubert
139*2b15cb3dSCy Schubertflag = {
140*2b15cb3dSCy Schubert  name		= logfile;
141*2b15cb3dSCy Schubert  value		= l;
142*2b15cb3dSCy Schubert  arg-type	= file;
143*2b15cb3dSCy Schubert  arg-name	= "file-name";
144*2b15cb3dSCy Schubert  descrip	= "Log to specified logfile";
145*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
146*2b15cb3dSCy Schubert	This option causes the client to write log messages to the specified
147*2b15cb3dSCy Schubert	@file{logfile}.
148*2b15cb3dSCy Schubert	_EndOfDoc_;
149*2b15cb3dSCy Schubert};
150*2b15cb3dSCy Schubert
151*2b15cb3dSCy Schubertflag = {
152*2b15cb3dSCy Schubert  name		= steplimit;
153*2b15cb3dSCy Schubert  value		= M;
154*2b15cb3dSCy Schubert  arg-type	= number;
155*2b15cb3dSCy Schubert  arg-range	= "0->";
156*2b15cb3dSCy Schubert  descrip	= "Adjustments less than @var{steplimit} msec will be slewed";
157*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
158*2b15cb3dSCy Schubert	If the time adjustment is less than @file{steplimit} milliseconds,
159*2b15cb3dSCy Schubert	slew the amount using @command{adjtime(2)}.  Otherwise, step the
160*2b15cb3dSCy Schubert	correction using @command{settimeofday(2)}.  The default value is 0,
161*2b15cb3dSCy Schubert	which means all adjustments will be stepped.  This is a feature, as
162*2b15cb3dSCy Schubert	different situations demand different values.
163*2b15cb3dSCy Schubert	_EndOfDoc_;
164*2b15cb3dSCy Schubert};
165*2b15cb3dSCy Schubert
166*2b15cb3dSCy Schubertflag = {
167*2b15cb3dSCy Schubert  name		= ntpversion;
168*2b15cb3dSCy Schubert  value		= o;
169*2b15cb3dSCy Schubert  descrip	= "Send @var{int} as our NTP protocol version";
170*2b15cb3dSCy Schubert  arg-type	= number;
171*2b15cb3dSCy Schubert  arg-default	= 4;
172*2b15cb3dSCy Schubert  arg-range	= "0->7";
173*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
174*2b15cb3dSCy Schubert	When sending requests to a remote server, tell them we are running
175*2b15cb3dSCy Schubert	NTP protocol version @file{ntpversion} .
176*2b15cb3dSCy Schubert	_EndOfDoc_;
177*2b15cb3dSCy Schubert};
178*2b15cb3dSCy Schubert
179*2b15cb3dSCy Schubertflag = {
180*2b15cb3dSCy Schubert  name		= usereservedport;
181*2b15cb3dSCy Schubert  value		= r;
182*2b15cb3dSCy Schubert  descrip	= "Use the NTP Reserved Port (port 123)";
183*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
184*2b15cb3dSCy Schubert	Use port 123, which is reserved for NTP, for our network
185*2b15cb3dSCy Schubert	communications.
186*2b15cb3dSCy Schubert	_EndOfDoc_;
187*2b15cb3dSCy Schubert};
188*2b15cb3dSCy Schubert
189*2b15cb3dSCy Schubertflag = {
190*2b15cb3dSCy Schubert  name		= step;
191*2b15cb3dSCy Schubert  value		= S;
192*2b15cb3dSCy Schubert  descrip	= "OK to 'step' the time with @command{settimeofday(2)}";
193ea906c41SOllivier Robert  doc		= <<- _EndOfDoc_
194ea906c41SOllivier Robert	_EndOfDoc_;
195ea906c41SOllivier Robert};
196ea906c41SOllivier Robert
197*2b15cb3dSCy Schubertflag = {
198*2b15cb3dSCy Schubert  name		= slew;
199*2b15cb3dSCy Schubert  value		= s;
200*2b15cb3dSCy Schubert  descrip	= "OK to 'slew' the time with @command{adjtime(2)}";
201*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
202*2b15cb3dSCy Schubert	_EndOfDoc_;
203*2b15cb3dSCy Schubert};
204ea906c41SOllivier Robert
205*2b15cb3dSCy Schubert
206*2b15cb3dSCy Schubertflag = {
207*2b15cb3dSCy Schubert  name		= timeout;
208*2b15cb3dSCy Schubert  value		= t;
209*2b15cb3dSCy Schubert  descrip	= "The number of seconds to wait for responses";
210*2b15cb3dSCy Schubert  arg-type	= number;
211*2b15cb3dSCy Schubert  arg-name	= "seconds";
212*2b15cb3dSCy Schubert  arg-default	= 5;
213*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
214*2b15cb3dSCy Schubert	When waiting for a reply, @code{sntp} will wait the number
215*2b15cb3dSCy Schubert	of seconds specified before giving up.  The default should be
216*2b15cb3dSCy Schubert	more than enough for a unicast response.  If @code{sntp} is
217*2b15cb3dSCy Schubert	only waiting for a broadcast response a longer timeout is
218*2b15cb3dSCy Schubert	likely needed.
219*2b15cb3dSCy Schubert	_EndOfDoc_;
220*2b15cb3dSCy Schubert};
221*2b15cb3dSCy Schubert
222*2b15cb3dSCy Schubertflag = {
223*2b15cb3dSCy Schubert  name		= "wait";
224*2b15cb3dSCy Schubert  descrip	= "Wait for pending replies (if not setting the time)";
225*2b15cb3dSCy Schubert  disable	= no;
226*2b15cb3dSCy Schubert  enabled;
227*2b15cb3dSCy Schubert  settable;
228*2b15cb3dSCy Schubert  doc		= <<- _EndOfDoc_
229*2b15cb3dSCy Schubert	If we are not setting the time, wait for all pending responses.
230*2b15cb3dSCy Schubert	_EndOfDoc_;
231*2b15cb3dSCy Schubert};
232*2b15cb3dSCy Schubert
233*2b15cb3dSCy Schubert/* explain: Additional information whenever the usage routine is invoked */
234*2b15cb3dSCy Schubertexplain = <<- _END_EXPLAIN
235*2b15cb3dSCy Schubert	_END_EXPLAIN;
236*2b15cb3dSCy Schubert
237*2b15cb3dSCy Schubertdoc-section	= {
238*2b15cb3dSCy Schubert  ds-type	= 'DESCRIPTION';
239*2b15cb3dSCy Schubert  ds-format	= 'mdoc';
240*2b15cb3dSCy Schubert  ds-text	= <<- _END_PROG_MDOC_DESCRIP
241*2b15cb3dSCy Schubert.Nm
242*2b15cb3dSCy Schubertcan be used as an SNTP client to query a NTP or SNTP server and either display
243ea906c41SOllivier Robertthe time or set the local system's time (given suitable privilege).  It can be
244*2b15cb3dSCy Schubertrun as an interactive command or from a
245*2b15cb3dSCy Schubert.Ic cron
246ea906c41SOllivier Robertjob.
247*2b15cb3dSCy Schubert
248*2b15cb3dSCy SchubertNTP (the Network Time Protocol) and SNTP (the Simple Network Time Protocol)
249*2b15cb3dSCy Schubertare defined and described by RFC 5905.
250*2b15cb3dSCy Schubert
251*2b15cb3dSCy Schubert.Pp
252ea906c41SOllivier RobertThe default is to write the estimated correct local date and time (i.e. not
253*2b15cb3dSCy SchubertUTC) to the standard output in a format like:
254*2b15cb3dSCy Schubert
255*2b15cb3dSCy Schubert.Ic "'1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 [host] IP sN'"
256*2b15cb3dSCy Schubert
257ea906c41SOllivier Robertwhere the
258*2b15cb3dSCy Schubert.Ic "'(+0800)'"
259*2b15cb3dSCy Schubertmeans that to get to UTC from the reported local time one must
260*2b15cb3dSCy Schubertadd 8 hours and 0 minutes,
261*2b15cb3dSCy Schubertthe
262*2b15cb3dSCy Schubert.Ic "'+4.567'"
263*2b15cb3dSCy Schubertindicates the local clock is 4.567 seconds behind the correct time
264*2b15cb3dSCy Schubert(so 4.567 seconds must be added to the local clock to get it to be correct).
265*2b15cb3dSCy SchubertNote that the number of decimals printed for this value will change
266*2b15cb3dSCy Schubertbased on the reported precision of the server.
267*2b15cb3dSCy Schubert.Ic "'+/- 0.089'"
268*2b15cb3dSCy Schubertis the reported
269*2b15cb3dSCy Schubert.Em synchronization distance
270*2b15cb3dSCy Schubert(in seconds), which represents the maximum error due to all causes.
271*2b15cb3dSCy SchubertIf the server does not report valid data needed to calculate the
272*2b15cb3dSCy Schubertsynchronization distance, this will be reported as
273*2b15cb3dSCy Schubert.Ic "'+/- ?'" .
274*2b15cb3dSCy SchubertIf the
275*2b15cb3dSCy Schubert.Em host
276*2b15cb3dSCy Schubertis different from the
277*2b15cb3dSCy Schubert.Em IP ,
278*2b15cb3dSCy Schubertboth will be displayed.
279*2b15cb3dSCy SchubertOtherwise, only the
280*2b15cb3dSCy Schubert.Em IP
281*2b15cb3dSCy Schubertis displayed.
282*2b15cb3dSCy SchubertFinally, the
283*2b15cb3dSCy Schubert.Em stratum
284*2b15cb3dSCy Schubertof the host is reported.
285*2b15cb3dSCy Schubert	_END_PROG_MDOC_DESCRIP;
286*2b15cb3dSCy Schubert};
287*2b15cb3dSCy Schubert
288*2b15cb3dSCy Schubertdoc-section	= {
289*2b15cb3dSCy Schubert  ds-type	= 'USAGE';
290*2b15cb3dSCy Schubert  ds-format	= 'mdoc';
291*2b15cb3dSCy Schubert  ds-text	= <<- _END_MDOC_USAGE
292*2b15cb3dSCy Schubert.Bl -tag -width indent
293*2b15cb3dSCy Schubert.It Li "sntp ntpserver.somewhere"
294*2b15cb3dSCy Schubertis the simplest use of this program
295*2b15cb3dSCy Schubertand can be run as an unprivileged command
296*2b15cb3dSCy Schubertto check the current time and error in the local clock.
297*2b15cb3dSCy Schubert.It Li "sntp -Ss -M 128 ntpserver.somewhere"
298*2b15cb3dSCy SchubertWith suitable privilege,
299*2b15cb3dSCy Schubertrun as a command
300*2b15cb3dSCy Schubertor from a
301*2b15cb3dSCy Schubert.Xr cron 8
302*2b15cb3dSCy Schubertjob,
303*2b15cb3dSCy Schubert.Ic "sntp -Ss -M 128 ntpserver.somewhere"
304*2b15cb3dSCy Schubertwill request the time from the server,
305*2b15cb3dSCy Schubertand if that server reports that it is synchronized
306*2b15cb3dSCy Schubertthen if the offset adjustment is less than 128 milliseconds
307*2b15cb3dSCy Schubertthe correction will be slewed,
308*2b15cb3dSCy Schubertand if the correction is more than 128 milliseconds
309*2b15cb3dSCy Schubertthe correction  will be stepped.
310*2b15cb3dSCy Schubert.It Li "sntp -S ntpserver.somewhere"
311*2b15cb3dSCy SchubertWith suitable privilege,
312*2b15cb3dSCy Schubertrun as a command
313*2b15cb3dSCy Schubertor from a
314*2b15cb3dSCy Schubert.Xr cron 8
315*2b15cb3dSCy Schubertjob,
316*2b15cb3dSCy Schubert.Ic "sntp -S ntpserver.somewhere"
317*2b15cb3dSCy Schubertwill set (step) the local clock from a synchronized specified server,
318*2b15cb3dSCy Schubertlike the (deprecated)
319*2b15cb3dSCy Schubert.Xr ntpdate 1ntpdatemdoc ,
320*2b15cb3dSCy Schubertor
321*2b15cb3dSCy Schubert.Xr rdate 8
322*2b15cb3dSCy Schubertcommands.
323*2b15cb3dSCy Schubert.El
324*2b15cb3dSCy Schubert	_END_MDOC_USAGE;
325*2b15cb3dSCy Schubert};
326*2b15cb3dSCy Schubert
327*2b15cb3dSCy Schubertdoc-section	= {
328*2b15cb3dSCy Schubert  ds-type	= 'AUTHORS';
329*2b15cb3dSCy Schubert  ds-format	= 'mdoc';
330*2b15cb3dSCy Schubert  ds-text	= <<- _END_MDOC_AUTHORS
331*2b15cb3dSCy Schubert.An "Johannes Maximilian Kuehn"
332*2b15cb3dSCy Schubert.An "Harlan Stenn"
333*2b15cb3dSCy Schubert.An "Dave Hart"
334*2b15cb3dSCy Schubert	_END_MDOC_AUTHORS;
335*2b15cb3dSCy Schubert};
336