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