summaryrefslogtreecommitdiffstats
path: root/src/gnutls-serv-options.h
blob: 0bbc97bb21b84c6cc57b87bb71df8daabb6222b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#include <stdbool.h>
#include <stdio.h>

#ifndef GNUTLS_SERV_OPTIONS_H_
#define GNUTLS_SERV_OPTIONS_H_ 1

struct gnutls_serv_list
{
  const char **args;
  unsigned int count;
};

struct gnutls_serv_options
{
  /* Options present in the command line */
  struct
  {
    bool debug;
    bool sni_hostname;
    bool sni_hostname_fatal;
    bool alpn;
    bool alpn_fatal;
    bool noticket;
    bool earlydata;
    bool maxearlydata;
    bool nocookie;
    bool generate;
    bool quiet;
    bool nodb;
    bool http;
    bool echo;
    bool crlf;
    bool udp;
    bool mtu;
    bool srtp_profiles;
    bool disable_client_cert;
    bool require_client_cert;
    bool verify_client_cert;
    bool compress_cert;
    bool heartbeat;
    bool x509fmtder;
    bool priority;
    bool dhparams;
    bool x509cafile;
    bool x509crlfile;
    bool pgpkeyfile;
    bool x509keyfile;
    bool x509certfile;
    bool rawpkkeyfile;
    bool rawpkfile;
    bool srppasswd;
    bool srppasswdconf;
    bool pskpasswd;
    bool pskhint;
    bool ocsp_response;
    bool ignore_ocsp_response_errors;
    bool port;
    bool list;
    bool provider;
    bool keymatexport;
    bool keymatexportsize;
    bool recordsize;
    bool httpdata;
    bool version;
    bool help;
    bool more_help;
  } present;

  /* Option arguments in raw string form */
  struct
  {
    const char *debug;
    const char *sni_hostname;
    const char *maxearlydata;
    const char *mtu;
    const char *srtp_profiles;
    const char *priority;
    const char *dhparams;
    const char *x509cafile;
    const char *x509crlfile;
    const char *pgpkeyfile;
    const char *srppasswd;
    const char *srppasswdconf;
    const char *pskpasswd;
    const char *pskhint;
    const char *port;
    const char *provider;
    const char *keymatexport;
    const char *keymatexportsize;
    const char *recordsize;
    const char *httpdata;
    const char *version;
  } arg;

  /* Option arguments parsed as integer */
  struct
  {
    int debug;
    int maxearlydata;
    int mtu;
    int port;
    int keymatexportsize;
    int recordsize;
  } value;

  /* Option arguments parsed as list */
  struct
  {
    struct gnutls_serv_list alpn;
    struct gnutls_serv_list compress_cert;
    struct gnutls_serv_list x509keyfile;
    struct gnutls_serv_list x509certfile;
    struct gnutls_serv_list rawpkkeyfile;
    struct gnutls_serv_list rawpkfile;
    struct gnutls_serv_list ocsp_response;
  } list;

  /* Option enablement status */
  struct
  {
    bool debug;
    bool sni_hostname;
    bool sni_hostname_fatal;
    bool alpn;
    bool alpn_fatal;
    bool noticket;
    bool earlydata;
    bool maxearlydata;
    bool nocookie;
    bool generate;
    bool quiet;
    bool nodb;
    bool http;
    bool echo;
    bool crlf;
    bool udp;
    bool mtu;
    bool srtp_profiles;
    bool disable_client_cert;
    bool require_client_cert;
    bool verify_client_cert;
    bool compress_cert;
    bool heartbeat;
    bool x509fmtder;
    bool priority;
    bool dhparams;
    bool x509cafile;
    bool x509crlfile;
    bool pgpkeyfile;
    bool x509keyfile;
    bool x509certfile;
    bool rawpkkeyfile;
    bool rawpkfile;
    bool srppasswd;
    bool srppasswdconf;
    bool pskpasswd;
    bool pskhint;
    bool ocsp_response;
    bool ignore_ocsp_response_errors;
    bool port;
    bool list;
    bool provider;
    bool keymatexport;
    bool keymatexportsize;
    bool recordsize;
    bool httpdata;
    bool version;
    bool help;
    bool more_help;
  } enabled;
};

#define HAVE_OPT(name) HAVE_OPT_ ## name
#define OPT_ARG(name) OPT_ARG_ ## name
#define ENABLED_OPT(name) ENABLED_OPT_ ## name
#define OPTS_COUNT(name) OPTS_COUNT_ ## name
#define OPTS_ARRAY(name) OPTS_ARRAY_ ## name
#define USAGE(status) usage (stdout, (status))

#define HAVE_OPT_DEBUG gnutls_serv_options.present.debug
#define HAVE_OPT_SNI_HOSTNAME gnutls_serv_options.present.sni_hostname
#define HAVE_OPT_SNI_HOSTNAME_FATAL gnutls_serv_options.present.sni_hostname_fatal
#define HAVE_OPT_ALPN gnutls_serv_options.present.alpn
#define HAVE_OPT_ALPN_FATAL gnutls_serv_options.present.alpn_fatal
#define HAVE_OPT_NOTICKET gnutls_serv_options.present.noticket
#define HAVE_OPT_EARLYDATA gnutls_serv_options.present.earlydata
#define HAVE_OPT_MAXEARLYDATA gnutls_serv_options.present.maxearlydata
#define HAVE_OPT_NOCOOKIE gnutls_serv_options.present.nocookie
#define HAVE_OPT_GENERATE gnutls_serv_options.present.generate
#define HAVE_OPT_QUIET gnutls_serv_options.present.quiet
#define HAVE_OPT_NODB gnutls_serv_options.present.nodb
#define HAVE_OPT_HTTP gnutls_serv_options.present.http
#define HAVE_OPT_ECHO gnutls_serv_options.present.echo
#define HAVE_OPT_CRLF gnutls_serv_options.present.crlf
#define HAVE_OPT_UDP gnutls_serv_options.present.udp
#define HAVE_OPT_MTU gnutls_serv_options.present.mtu
#define HAVE_OPT_SRTP_PROFILES gnutls_serv_options.present.srtp_profiles
#define HAVE_OPT_DISABLE_CLIENT_CERT gnutls_serv_options.present.disable_client_cert
#define HAVE_OPT_REQUIRE_CLIENT_CERT gnutls_serv_options.present.require_client_cert
#define HAVE_OPT_VERIFY_CLIENT_CERT gnutls_serv_options.present.verify_client_cert
#define HAVE_OPT_COMPRESS_CERT gnutls_serv_options.present.compress_cert
#define HAVE_OPT_HEARTBEAT gnutls_serv_options.present.heartbeat
#define HAVE_OPT_X509FMTDER gnutls_serv_options.present.x509fmtder
#define HAVE_OPT_PRIORITY gnutls_serv_options.present.priority
#define HAVE_OPT_DHPARAMS gnutls_serv_options.present.dhparams
#define HAVE_OPT_X509CAFILE gnutls_serv_options.present.x509cafile
#define HAVE_OPT_X509CRLFILE gnutls_serv_options.present.x509crlfile
#define HAVE_OPT_PGPKEYFILE gnutls_serv_options.present.pgpkeyfile
#define HAVE_OPT_X509KEYFILE gnutls_serv_options.present.x509keyfile
#define HAVE_OPT_X509CERTFILE gnutls_serv_options.present.x509certfile
#define HAVE_OPT_RAWPKKEYFILE gnutls_serv_options.present.rawpkkeyfile
#define HAVE_OPT_RAWPKFILE gnutls_serv_options.present.rawpkfile
#define HAVE_OPT_SRPPASSWD gnutls_serv_options.present.srppasswd
#define HAVE_OPT_SRPPASSWDCONF gnutls_serv_options.present.srppasswdconf
#define HAVE_OPT_PSKPASSWD gnutls_serv_options.present.pskpasswd
#define HAVE_OPT_PSKHINT gnutls_serv_options.present.pskhint
#define HAVE_OPT_OCSP_RESPONSE gnutls_serv_options.present.ocsp_response
#define HAVE_OPT_IGNORE_OCSP_RESPONSE_ERRORS gnutls_serv_options.present.ignore_ocsp_response_errors
#define HAVE_OPT_PORT gnutls_serv_options.present.port
#define HAVE_OPT_LIST gnutls_serv_options.present.list
#define HAVE_OPT_PROVIDER gnutls_serv_options.present.provider
#define HAVE_OPT_KEYMATEXPORT gnutls_serv_options.present.keymatexport
#define HAVE_OPT_KEYMATEXPORTSIZE gnutls_serv_options.present.keymatexportsize
#define HAVE_OPT_RECORDSIZE gnutls_serv_options.present.recordsize
#define HAVE_OPT_HTTPDATA gnutls_serv_options.present.httpdata
#define HAVE_OPT_VERSION gnutls_serv_options.present.version
#define HAVE_OPT_HELP gnutls_serv_options.present.help
#define HAVE_OPT_MORE_HELP gnutls_serv_options.present.more_help

#define OPT_ARG_DEBUG gnutls_serv_options.arg.debug
#define OPT_ARG_SNI_HOSTNAME gnutls_serv_options.arg.sni_hostname
#define OPT_ARG_SNI_HOSTNAME_FATAL gnutls_serv_options.arg.sni_hostname_fatal
#define OPT_ARG_ALPN gnutls_serv_options.arg.alpn
#define OPT_ARG_ALPN_FATAL gnutls_serv_options.arg.alpn_fatal
#define OPT_ARG_NOTICKET gnutls_serv_options.arg.noticket
#define OPT_ARG_EARLYDATA gnutls_serv_options.arg.earlydata
#define OPT_ARG_MAXEARLYDATA gnutls_serv_options.arg.maxearlydata
#define OPT_ARG_NOCOOKIE gnutls_serv_options.arg.nocookie
#define OPT_ARG_GENERATE gnutls_serv_options.arg.generate
#define OPT_ARG_QUIET gnutls_serv_options.arg.quiet
#define OPT_ARG_NODB gnutls_serv_options.arg.nodb
#define OPT_ARG_HTTP gnutls_serv_options.arg.http
#define OPT_ARG_ECHO gnutls_serv_options.arg.echo
#define OPT_ARG_CRLF gnutls_serv_options.arg.crlf
#define OPT_ARG_UDP gnutls_serv_options.arg.udp
#define OPT_ARG_MTU gnutls_serv_options.arg.mtu
#define OPT_ARG_SRTP_PROFILES gnutls_serv_options.arg.srtp_profiles
#define OPT_ARG_DISABLE_CLIENT_CERT gnutls_serv_options.arg.disable_client_cert
#define OPT_ARG_REQUIRE_CLIENT_CERT gnutls_serv_options.arg.require_client_cert
#define OPT_ARG_VERIFY_CLIENT_CERT gnutls_serv_options.arg.verify_client_cert
#define OPT_ARG_COMPRESS_CERT gnutls_serv_options.arg.compress_cert
#define OPT_ARG_HEARTBEAT gnutls_serv_options.arg.heartbeat
#define OPT_ARG_X509FMTDER gnutls_serv_options.arg.x509fmtder
#define OPT_ARG_PRIORITY gnutls_serv_options.arg.priority
#define OPT_ARG_DHPARAMS gnutls_serv_options.arg.dhparams
#define OPT_ARG_X509CAFILE gnutls_serv_options.arg.x509cafile
#define OPT_ARG_X509CRLFILE gnutls_serv_options.arg.x509crlfile
#define OPT_ARG_PGPKEYFILE gnutls_serv_options.arg.pgpkeyfile
#define OPT_ARG_X509KEYFILE gnutls_serv_options.arg.x509keyfile
#define OPT_ARG_X509CERTFILE gnutls_serv_options.arg.x509certfile
#define OPT_ARG_RAWPKKEYFILE gnutls_serv_options.arg.rawpkkeyfile
#define OPT_ARG_RAWPKFILE gnutls_serv_options.arg.rawpkfile
#define OPT_ARG_SRPPASSWD gnutls_serv_options.arg.srppasswd
#define OPT_ARG_SRPPASSWDCONF gnutls_serv_options.arg.srppasswdconf
#define OPT_ARG_PSKPASSWD gnutls_serv_options.arg.pskpasswd
#define OPT_ARG_PSKHINT gnutls_serv_options.arg.pskhint
#define OPT_ARG_OCSP_RESPONSE gnutls_serv_options.arg.ocsp_response
#define OPT_ARG_IGNORE_OCSP_RESPONSE_ERRORS gnutls_serv_options.arg.ignore_ocsp_response_errors
#define OPT_ARG_PORT gnutls_serv_options.arg.port
#define OPT_ARG_LIST gnutls_serv_options.arg.list
#define OPT_ARG_PROVIDER gnutls_serv_options.arg.provider
#define OPT_ARG_KEYMATEXPORT gnutls_serv_options.arg.keymatexport
#define OPT_ARG_KEYMATEXPORTSIZE gnutls_serv_options.arg.keymatexportsize
#define OPT_ARG_RECORDSIZE gnutls_serv_options.arg.recordsize
#define OPT_ARG_HTTPDATA gnutls_serv_options.arg.httpdata
#define OPT_ARG_VERSION gnutls_serv_options.arg.version
#define OPT_ARG_HELP gnutls_serv_options.arg.help
#define OPT_ARG_MORE_HELP gnutls_serv_options.arg.more_help

#define OPT_VALUE_DEBUG gnutls_serv_options.value.debug
#define OPT_VALUE_MAXEARLYDATA gnutls_serv_options.value.maxearlydata
#define OPT_VALUE_MTU gnutls_serv_options.value.mtu
#define OPT_VALUE_PORT gnutls_serv_options.value.port
#define OPT_VALUE_KEYMATEXPORTSIZE gnutls_serv_options.value.keymatexportsize
#define OPT_VALUE_RECORDSIZE gnutls_serv_options.value.recordsize

#define ENABLED_OPT_DEBUG gnutls_serv_options.enabled.debug
#define ENABLED_OPT_SNI_HOSTNAME gnutls_serv_options.enabled.sni_hostname
#define ENABLED_OPT_SNI_HOSTNAME_FATAL gnutls_serv_options.enabled.sni_hostname_fatal
#define ENABLED_OPT_ALPN gnutls_serv_options.enabled.alpn
#define ENABLED_OPT_ALPN_FATAL gnutls_serv_options.enabled.alpn_fatal
#define ENABLED_OPT_NOTICKET gnutls_serv_options.enabled.noticket
#define ENABLED_OPT_EARLYDATA gnutls_serv_options.enabled.earlydata
#define ENABLED_OPT_MAXEARLYDATA gnutls_serv_options.enabled.maxearlydata
#define ENABLED_OPT_NOCOOKIE gnutls_serv_options.enabled.nocookie
#define ENABLED_OPT_GENERATE gnutls_serv_options.enabled.generate
#define ENABLED_OPT_QUIET gnutls_serv_options.enabled.quiet
#define ENABLED_OPT_NODB gnutls_serv_options.enabled.nodb
#define ENABLED_OPT_HTTP gnutls_serv_options.enabled.http
#define ENABLED_OPT_ECHO gnutls_serv_options.enabled.echo
#define ENABLED_OPT_CRLF gnutls_serv_options.enabled.crlf
#define ENABLED_OPT_UDP gnutls_serv_options.enabled.udp
#define ENABLED_OPT_MTU gnutls_serv_options.enabled.mtu
#define ENABLED_OPT_SRTP_PROFILES gnutls_serv_options.enabled.srtp_profiles
#define ENABLED_OPT_DISABLE_CLIENT_CERT gnutls_serv_options.enabled.disable_client_cert
#define ENABLED_OPT_REQUIRE_CLIENT_CERT gnutls_serv_options.enabled.require_client_cert
#define ENABLED_OPT_VERIFY_CLIENT_CERT gnutls_serv_options.enabled.verify_client_cert
#define ENABLED_OPT_COMPRESS_CERT gnutls_serv_options.enabled.compress_cert
#define ENABLED_OPT_HEARTBEAT gnutls_serv_options.enabled.heartbeat
#define ENABLED_OPT_X509FMTDER gnutls_serv_options.enabled.x509fmtder
#define ENABLED_OPT_PRIORITY gnutls_serv_options.enabled.priority
#define ENABLED_OPT_DHPARAMS gnutls_serv_options.enabled.dhparams
#define ENABLED_OPT_X509CAFILE gnutls_serv_options.enabled.x509cafile
#define ENABLED_OPT_X509CRLFILE gnutls_serv_options.enabled.x509crlfile
#define ENABLED_OPT_PGPKEYFILE gnutls_serv_options.enabled.pgpkeyfile
#define ENABLED_OPT_X509KEYFILE gnutls_serv_options.enabled.x509keyfile
#define ENABLED_OPT_X509CERTFILE gnutls_serv_options.enabled.x509certfile
#define ENABLED_OPT_RAWPKKEYFILE gnutls_serv_options.enabled.rawpkkeyfile
#define ENABLED_OPT_RAWPKFILE gnutls_serv_options.enabled.rawpkfile
#define ENABLED_OPT_SRPPASSWD gnutls_serv_options.enabled.srppasswd
#define ENABLED_OPT_SRPPASSWDCONF gnutls_serv_options.enabled.srppasswdconf
#define ENABLED_OPT_PSKPASSWD gnutls_serv_options.enabled.pskpasswd
#define ENABLED_OPT_PSKHINT gnutls_serv_options.enabled.pskhint
#define ENABLED_OPT_OCSP_RESPONSE gnutls_serv_options.enabled.ocsp_response
#define ENABLED_OPT_IGNORE_OCSP_RESPONSE_ERRORS gnutls_serv_options.enabled.ignore_ocsp_response_errors
#define ENABLED_OPT_PORT gnutls_serv_options.enabled.port
#define ENABLED_OPT_LIST gnutls_serv_options.enabled.list
#define ENABLED_OPT_PROVIDER gnutls_serv_options.enabled.provider
#define ENABLED_OPT_KEYMATEXPORT gnutls_serv_options.enabled.keymatexport
#define ENABLED_OPT_KEYMATEXPORTSIZE gnutls_serv_options.enabled.keymatexportsize
#define ENABLED_OPT_RECORDSIZE gnutls_serv_options.enabled.recordsize
#define ENABLED_OPT_HTTPDATA gnutls_serv_options.enabled.httpdata
#define ENABLED_OPT_VERSION gnutls_serv_options.enabled.version
#define ENABLED_OPT_HELP gnutls_serv_options.enabled.help
#define ENABLED_OPT_MORE_HELP gnutls_serv_options.enabled.more_help

#define OPTS_COUNT_ALPN gnutls_serv_options.list.alpn.count
#define OPTS_COUNT_COMPRESS_CERT gnutls_serv_options.list.compress_cert.count
#define OPTS_COUNT_X509KEYFILE gnutls_serv_options.list.x509keyfile.count
#define OPTS_COUNT_X509CERTFILE gnutls_serv_options.list.x509certfile.count
#define OPTS_COUNT_RAWPKKEYFILE gnutls_serv_options.list.rawpkkeyfile.count
#define OPTS_COUNT_RAWPKFILE gnutls_serv_options.list.rawpkfile.count
#define OPTS_COUNT_OCSP_RESPONSE gnutls_serv_options.list.ocsp_response.count

#define OPTS_ARRAY_ALPN gnutls_serv_options.list.alpn.args
#define OPTS_ARRAY_COMPRESS_CERT gnutls_serv_options.list.compress_cert.args
#define OPTS_ARRAY_X509KEYFILE gnutls_serv_options.list.x509keyfile.args
#define OPTS_ARRAY_X509CERTFILE gnutls_serv_options.list.x509certfile.args
#define OPTS_ARRAY_RAWPKKEYFILE gnutls_serv_options.list.rawpkkeyfile.args
#define OPTS_ARRAY_RAWPKFILE gnutls_serv_options.list.rawpkfile.args
#define OPTS_ARRAY_OCSP_RESPONSE gnutls_serv_options.list.ocsp_response.args


extern struct gnutls_serv_options gnutls_serv_options;
int process_options (int argc, char **argv);
void usage (FILE *out, int status);

#endif /* GNUTLS_SERV_OPTIONS_H_ */
#define optionProcess(a,b,c) process_options(b,c)
#define STACKCT_OPT OPTS_COUNT
#define STACKLST_OPT OPTS_ARRAY