]> git.ozlabs.org Git - ppp.git/blob - pppd/options.h
CI: Updated the 'checkout' actions that were using Node.js 16 to Node.js 20. (#489)
[ppp.git] / pppd / options.h
1 /*
2  * options.h - header declarations for option processing for PPP.
3  *
4  * Copyright (c) 2000-2002 Paul Mackerras. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. The name(s) of the authors of this software must not be used to
14  *    endorse or promote products derived from this software without
15  *    prior written permission.
16  *
17  * 3. Redistributions of any form whatsoever must retain the following
18  *    acknowledgment:
19  *    "This product includes software developed by Paul Mackerras
20  *     <paulus@samba.org>".
21  *
22  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
23  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
25  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
26  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
27  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
28  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29  */
30
31 #ifndef PPP_OPTIONS_H
32 #define PPP_OPTIONS_H
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 enum opt_type {
39         o_special_noarg,
40         o_special,
41         o_bool,
42         o_int,
43         o_uint32,
44         o_string,
45         o_wild
46 };
47
48 struct option {
49         char    *name;          /* name of the option */
50         enum opt_type type;
51         void    *addr;
52         char    *description;
53         unsigned int flags;
54         void    *addr2;
55         int     upper_limit;
56         int     lower_limit;
57         const char *source;
58         short int priority;
59         short int winner;
60 };
61
62 typedef struct option option_t;
63
64 /* Values for flags */
65 #define OPT_VALUE       0xff    /* mask for presupplied value */
66 #define OPT_HEX         0x100   /* int option is in hex */
67 #define OPT_NOARG       0x200   /* option doesn't take argument */
68 #define OPT_OR          0x400   /* for u32, OR in argument to value */
69 #define OPT_INC         0x400   /* for o_int, increment value */
70 #define OPT_A2OR        0x800   /* for o_bool, OR arg to *(u_char *)addr2 */
71 #define OPT_PRIV        0x1000  /* privileged option */
72 #define OPT_STATIC      0x2000  /* string option goes into static array */
73 #define OPT_NOINCR      0x2000  /* for o_int, value mustn't be increased */
74 #define OPT_LLIMIT      0x4000  /* check value against lower limit */
75 #define OPT_ULIMIT      0x8000  /* check value against upper limit */
76 #define OPT_LIMITS      (OPT_LLIMIT|OPT_ULIMIT)
77 #define OPT_ZEROOK      0x10000 /* 0 value is OK even if not within limits */
78 #define OPT_HIDE        0x10000 /* for o_string, print value as ?????? */
79 #define OPT_A2LIST      0x20000 /* for o_special, keep list of values */
80 #define OPT_A2CLRB      0x20000 /* o_bool, clr val bits in *(u_char *)addr2 */
81 #define OPT_ZEROINF     0x40000 /* with OPT_NOINCR, 0 == infinity */
82 #define OPT_PRIO        0x80000 /* process option priorities for this option */
83 #define OPT_PRIOSUB     0x100000 /* subsidiary member of priority group */
84 #define OPT_ALIAS       0x200000 /* option is alias for previous option */
85 #define OPT_A2COPY      0x400000 /* addr2 -> second location to rcv value */
86 #define OPT_ENABLE      0x800000 /* use *addr2 as enable for option */
87 #define OPT_A2CLR       0x1000000 /* clear *(bool *)addr2 */
88 #define OPT_PRIVFIX     0x2000000 /* user can't override if set by root */
89 #define OPT_INITONLY    0x4000000 /* option can only be set in init phase */
90 #define OPT_DEVEQUIV    0x8000000 /* equiv to device name */
91 #define OPT_DEVNAM      (OPT_INITONLY | OPT_DEVEQUIV)
92 #define OPT_A2PRINTER   0x10000000 /* *addr2 printer_func to print option */
93 #define OPT_A2STRVAL    0x20000000 /* *addr2 points to current string value */
94 #define OPT_NOPRINT     0x40000000 /* don't print this option at all */
95
96 #define OPT_VAL(x)      ((x) & OPT_VALUE)
97
98 /* Values for priority */
99 #define OPRIO_DEFAULT   0       /* a default value */
100 #define OPRIO_CFGFILE   1       /* value from a configuration file */
101 #define OPRIO_CMDLINE   2       /* value from the command line */
102 #define OPRIO_SECFILE   3       /* value from options in a secrets file */
103 #define OPRIO_ROOT      100     /* added to priority if OPT_PRIVFIX && root */
104
105 /* Add additional supported options by e.g. plug-in */
106 void ppp_add_options(struct option *options);
107
108 /* Parse options from an options file */
109 int ppp_options_from_file(char *filename, int must_exist, int check_prot,
110                        int privileged);
111
112 /* Simplified number_option for decimal ints */
113 int ppp_int_option(char *name, int *value);
114
115 /* Print an error message about an option */
116 void ppp_option_error(char *fmt, ...);
117
118
119 #ifdef __cplusplus
120 }
121 #endif
122
123 #endif // PPP_OPTIONS_H