]> CyberLeo.Net >> Repos - FreeBSD/releng/10.3.git/blob - contrib/ntp/sntp/sntp-opts.h
Fix multiple vulnerabilities in ntp. [SA-18:02.ntp]
[FreeBSD/releng/10.3.git] / contrib / ntp / sntp / sntp-opts.h
1 /*
2  *  EDIT THIS FILE WITH CAUTION  (sntp-opts.h)
3  *
4  *  It has been AutoGen-ed  February 27, 2018 at 10:25:31 AM by AutoGen 5.18.5
5  *  From the definitions    sntp-opts.def
6  *  and the template file   options
7  *
8  * Generated from AutoOpts 41:0:16 templates.
9  *
10  *  AutoOpts is a copyrighted work.  This header file is not encumbered
11  *  by AutoOpts licensing, but is provided under the licensing terms chosen
12  *  by the sntp author or copyright holder.  AutoOpts is
13  *  licensed under the terms of the LGPL.  The redistributable library
14  *  (``libopts'') is licensed under the terms of either the LGPL or, at the
15  *  users discretion, the BSD license.  See the AutoOpts and/or libopts sources
16  *  for details.
17  *
18  * The sntp program is copyrighted and licensed
19  * under the following terms:
20  *
21  *  Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.
22  *  This is free software. It is licensed for use, modification and
23  *  redistribution under the terms of the NTP License, copies of which
24  *  can be seen at:
25  *    <http://ntp.org/license>
26  *    <http://opensource.org/licenses/ntp-license.php>
27  *
28  *  Permission to use, copy, modify, and distribute this software and its
29  *  documentation for any purpose with or without fee is hereby granted,
30  *  provided that the above copyright notice appears in all copies and that
31  *  both the copyright notice and this permission notice appear in
32  *  supporting documentation, and that the name The University of Delaware not be used in
33  *  advertising or publicity pertaining to distribution of the software
34  *  without specific, written prior permission. The University of Delaware and Network Time Foundation makes no
35  *  representations about the suitability this software for any purpose. It
36  *  is provided "as is" without express or implied warranty.
37  */
38 /**
39  *  This file contains the programmatic interface to the Automated
40  *  Options generated for the sntp program.
41  *  These macros are documented in the AutoGen info file in the
42  *  "AutoOpts" chapter.  Please refer to that doc for usage help.
43  */
44 #ifndef AUTOOPTS_SNTP_OPTS_H_GUARD
45 #define AUTOOPTS_SNTP_OPTS_H_GUARD 1
46 #include "config.h"
47 #include <autoopts/options.h>
48
49 /**
50  *  Ensure that the library used for compiling this generated header is at
51  *  least as new as the version current when the header template was released
52  *  (not counting patch version increments).  Also ensure that the oldest
53  *  tolerable version is at least as old as what was current when the header
54  *  template was released.
55  */
56 #define AO_TEMPLATE_VERSION 167936
57 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
58  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
59 # error option template version mismatches autoopts/options.h header
60   Choke Me.
61 #endif
62
63 /**
64  *  Enumeration of each option type for sntp
65  */
66 typedef enum {
67     INDEX_OPT_IPV4             =  0,
68     INDEX_OPT_IPV6             =  1,
69     INDEX_OPT_AUTHENTICATION   =  2,
70     INDEX_OPT_BROADCAST        =  3,
71     INDEX_OPT_CONCURRENT       =  4,
72     INDEX_OPT_DEBUG_LEVEL      =  5,
73     INDEX_OPT_SET_DEBUG_LEVEL  =  6,
74     INDEX_OPT_GAP              =  7,
75     INDEX_OPT_KOD              =  8,
76     INDEX_OPT_KEYFILE          =  9,
77     INDEX_OPT_LOGFILE          = 10,
78     INDEX_OPT_STEPLIMIT        = 11,
79     INDEX_OPT_NTPVERSION       = 12,
80     INDEX_OPT_USERESERVEDPORT  = 13,
81     INDEX_OPT_STEP             = 14,
82     INDEX_OPT_SLEW             = 15,
83     INDEX_OPT_TIMEOUT          = 16,
84     INDEX_OPT_WAIT             = 17,
85     INDEX_OPT_VERSION          = 18,
86     INDEX_OPT_HELP             = 19,
87     INDEX_OPT_MORE_HELP        = 20,
88     INDEX_OPT_SAVE_OPTS        = 21,
89     INDEX_OPT_LOAD_OPTS        = 22
90 } teOptIndex;
91 /** count of all options for sntp */
92 #define OPTION_CT    23
93 /** sntp version */
94 #define SNTP_VERSION       "4.2.8p11"
95 /** Full sntp version text */
96 #define SNTP_FULL_VERSION  "sntp 4.2.8p11"
97
98 /**
99  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
100  *  option name (as in the teOptIndex enumeration above).
101  *  e.g. HAVE_OPT(IPV4)
102  */
103 #define         DESC(n) (sntpOptions.pOptDesc[INDEX_OPT_## n])
104 /** 'true' if an option has been specified in any way */
105 #define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
106 /** The string argument to an option. The argument type must be \"string\". */
107 #define      OPT_ARG(n) (DESC(n).optArg.argString)
108 /** Mask the option state revealing how an option was specified.
109  *  It will be one and only one of \a OPTST_SET, \a OPTST_PRESET,
110  * \a OPTST_DEFINED, \a OPTST_RESET or zero.
111  */
112 #define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
113 /** Count of option's occurrances *on the command line*. */
114 #define    COUNT_OPT(n) (DESC(n).optOccCt)
115 /** mask of \a OPTST_SET and \a OPTST_DEFINED. */
116 #define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
117 /** 'true' if \a HAVE_OPT would yield 'false'. */
118 #define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
119 /** 'true' if OPTST_DISABLED bit not set. */
120 #define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
121 /** number of stacked option arguments.
122  *  Valid only for stacked option arguments. */
123 #define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
124 /** stacked argument vector.
125  *  Valid only for stacked option arguments. */
126 #define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
127 /** Reset an option. */
128 #define    CLEAR_OPT(n) STMTS( \
129                 DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
130                 if ((DESC(n).fOptState & OPTST_INITENABLED) == 0) \
131                     DESC(n).fOptState |= OPTST_DISABLED; \
132                 DESC(n).optCookie = NULL )
133 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
134 /**
135  *  Enumeration of sntp exit codes
136  */
137 typedef enum {
138     SNTP_EXIT_SUCCESS         = 0,
139     SNTP_EXIT_FAILURE         = 1,
140     SNTP_EXIT_USAGE_ERROR     = 64,
141     SNTP_EXIT_NO_CONFIG_INPUT = 66,
142     SNTP_EXIT_LIBOPTS_FAILURE = 70
143 }   sntp_exit_code_t;
144 /** @} */
145 /**
146  *  Make sure there are no #define name conflicts with the option names
147  */
148 #ifndef     NO_OPTION_NAME_WARNINGS
149 # ifdef    IPV4
150 #  warning undefining IPV4 due to option name conflict
151 #  undef   IPV4
152 # endif
153 # ifdef    IPV6
154 #  warning undefining IPV6 due to option name conflict
155 #  undef   IPV6
156 # endif
157 # ifdef    AUTHENTICATION
158 #  warning undefining AUTHENTICATION due to option name conflict
159 #  undef   AUTHENTICATION
160 # endif
161 # ifdef    BROADCAST
162 #  warning undefining BROADCAST due to option name conflict
163 #  undef   BROADCAST
164 # endif
165 # ifdef    CONCURRENT
166 #  warning undefining CONCURRENT due to option name conflict
167 #  undef   CONCURRENT
168 # endif
169 # ifdef    DEBUG_LEVEL
170 #  warning undefining DEBUG_LEVEL due to option name conflict
171 #  undef   DEBUG_LEVEL
172 # endif
173 # ifdef    SET_DEBUG_LEVEL
174 #  warning undefining SET_DEBUG_LEVEL due to option name conflict
175 #  undef   SET_DEBUG_LEVEL
176 # endif
177 # ifdef    GAP
178 #  warning undefining GAP due to option name conflict
179 #  undef   GAP
180 # endif
181 # ifdef    KOD
182 #  warning undefining KOD due to option name conflict
183 #  undef   KOD
184 # endif
185 # ifdef    KEYFILE
186 #  warning undefining KEYFILE due to option name conflict
187 #  undef   KEYFILE
188 # endif
189 # ifdef    LOGFILE
190 #  warning undefining LOGFILE due to option name conflict
191 #  undef   LOGFILE
192 # endif
193 # ifdef    STEPLIMIT
194 #  warning undefining STEPLIMIT due to option name conflict
195 #  undef   STEPLIMIT
196 # endif
197 # ifdef    NTPVERSION
198 #  warning undefining NTPVERSION due to option name conflict
199 #  undef   NTPVERSION
200 # endif
201 # ifdef    USERESERVEDPORT
202 #  warning undefining USERESERVEDPORT due to option name conflict
203 #  undef   USERESERVEDPORT
204 # endif
205 # ifdef    STEP
206 #  warning undefining STEP due to option name conflict
207 #  undef   STEP
208 # endif
209 # ifdef    SLEW
210 #  warning undefining SLEW due to option name conflict
211 #  undef   SLEW
212 # endif
213 # ifdef    TIMEOUT
214 #  warning undefining TIMEOUT due to option name conflict
215 #  undef   TIMEOUT
216 # endif
217 # ifdef    WAIT
218 #  warning undefining WAIT due to option name conflict
219 #  undef   WAIT
220 # endif
221 #else  /* NO_OPTION_NAME_WARNINGS */
222 # undef IPV4
223 # undef IPV6
224 # undef AUTHENTICATION
225 # undef BROADCAST
226 # undef CONCURRENT
227 # undef DEBUG_LEVEL
228 # undef SET_DEBUG_LEVEL
229 # undef GAP
230 # undef KOD
231 # undef KEYFILE
232 # undef LOGFILE
233 # undef STEPLIMIT
234 # undef NTPVERSION
235 # undef USERESERVEDPORT
236 # undef STEP
237 # undef SLEW
238 # undef TIMEOUT
239 # undef WAIT
240 #endif  /*  NO_OPTION_NAME_WARNINGS */
241
242 /**
243  *  Interface defines for specific options.
244  * @{
245  */
246 #define VALUE_OPT_IPV4           '4'
247 #define VALUE_OPT_IPV6           '6'
248 #define VALUE_OPT_AUTHENTICATION 'a'
249
250 #define OPT_VALUE_AUTHENTICATION (DESC(AUTHENTICATION).optArg.argInt)
251 #define VALUE_OPT_BROADCAST      'b'
252 #define VALUE_OPT_CONCURRENT     'c'
253 #define VALUE_OPT_DEBUG_LEVEL    'd'
254 #define VALUE_OPT_SET_DEBUG_LEVEL 'D'
255
256 #define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
257 #define VALUE_OPT_GAP            'g'
258
259 #define OPT_VALUE_GAP            (DESC(GAP).optArg.argInt)
260 #define VALUE_OPT_KOD            'K'
261 #define VALUE_OPT_KEYFILE        'k'
262 #define VALUE_OPT_LOGFILE        'l'
263 #define VALUE_OPT_STEPLIMIT      'M'
264
265 #define OPT_VALUE_STEPLIMIT      (DESC(STEPLIMIT).optArg.argInt)
266 #define VALUE_OPT_NTPVERSION     'o'
267
268 #define OPT_VALUE_NTPVERSION     (DESC(NTPVERSION).optArg.argInt)
269 #define VALUE_OPT_USERESERVEDPORT 'r'
270 #define VALUE_OPT_STEP           'S'
271 #define VALUE_OPT_SLEW           's'
272 #define VALUE_OPT_TIMEOUT        't'
273
274 #define OPT_VALUE_TIMEOUT        (DESC(TIMEOUT).optArg.argInt)
275 #define VALUE_OPT_WAIT           0x1001
276
277 #define SET_OPT_WAIT   STMTS( \
278         DESC(WAIT).optActualIndex = 17; \
279         DESC(WAIT).optActualValue = VALUE_OPT_WAIT; \
280         DESC(WAIT).fOptState &= OPTST_PERSISTENT_MASK; \
281         DESC(WAIT).fOptState |= OPTST_SET )
282 #define DISABLE_OPT_WAIT   STMTS( \
283         DESC(WAIT).fOptState &= OPTST_PERSISTENT_MASK; \
284         DESC(WAIT).fOptState |= OPTST_SET | OPTST_DISABLED; \
285         DESC(WAIT).optArg.argString = NULL )
286 /** option flag (value) for help-value option */
287 #define VALUE_OPT_HELP          '?'
288 /** option flag (value) for more-help-value option */
289 #define VALUE_OPT_MORE_HELP     '!'
290 /** option flag (value) for version-value option */
291 #define VALUE_OPT_VERSION       0x1002
292 /** option flag (value) for save-opts-value option */
293 #define VALUE_OPT_SAVE_OPTS     '>'
294 /** option flag (value) for load-opts-value option */
295 #define VALUE_OPT_LOAD_OPTS     '<'
296 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
297         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
298         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
299         DESC(SAVE_OPTS).optArg.argString = (char const*)(a))
300 /*
301  *  Interface defines not associated with particular options
302  */
303 #define ERRSKIP_OPTERR  STMTS(sntpOptions.fOptSet &= ~OPTPROC_ERRSTOP)
304 #define ERRSTOP_OPTERR  STMTS(sntpOptions.fOptSet |= OPTPROC_ERRSTOP)
305 #define RESTART_OPT(n)  STMTS( \
306                 sntpOptions.curOptIdx = (n); \
307                 sntpOptions.pzCurOpt  = NULL )
308 #define START_OPT       RESTART_OPT(1)
309 #define USAGE(c)        (*sntpOptions.pUsageProc)(&sntpOptions, c)
310
311 #ifdef  __cplusplus
312 extern "C" {
313 #endif
314
315
316 /* * * * * *
317  *
318  *  Declare the sntp option descriptor.
319  */
320 extern tOptions sntpOptions;
321
322 #if defined(ENABLE_NLS)
323 # ifndef _
324 #   include <stdio.h>
325 #   ifndef HAVE_GETTEXT
326       extern char * gettext(char const *);
327 #   else
328 #     include <libintl.h>
329 #   endif
330
331 # ifndef ATTRIBUTE_FORMAT_ARG
332 #   define ATTRIBUTE_FORMAT_ARG(_a)
333 # endif
334
335 static inline char* aoGetsText(char const* pz) ATTRIBUTE_FORMAT_ARG(1);
336 static inline char* aoGetsText(char const* pz) {
337     if (pz == NULL) return NULL;
338     return (char*)gettext(pz);
339 }
340 #   define _(s)  aoGetsText(s)
341 # endif /* _() */
342
343 # define OPT_NO_XLAT_CFG_NAMES  STMTS(sntpOptions.fOptSet |= \
344                                     OPTPROC_NXLAT_OPT_CFG;)
345 # define OPT_NO_XLAT_OPT_NAMES  STMTS(sntpOptions.fOptSet |= \
346                                     OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
347
348 # define OPT_XLAT_CFG_NAMES     STMTS(sntpOptions.fOptSet &= \
349                                   ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
350 # define OPT_XLAT_OPT_NAMES     STMTS(sntpOptions.fOptSet &= \
351                                   ~OPTPROC_NXLAT_OPT;)
352
353 #else   /* ENABLE_NLS */
354 # define OPT_NO_XLAT_CFG_NAMES
355 # define OPT_NO_XLAT_OPT_NAMES
356
357 # define OPT_XLAT_CFG_NAMES
358 # define OPT_XLAT_OPT_NAMES
359
360 # ifndef _
361 #   define _(_s)  _s
362 # endif
363 #endif  /* ENABLE_NLS */
364
365 #ifdef  __cplusplus
366 }
367 #endif
368 #endif /* AUTOOPTS_SNTP_OPTS_H_GUARD */
369
370 /* sntp-opts.h ends here */