xref: /openbsd/usr.bin/dig/lib/isccfg/namedconf.c (revision 73471bf0)
1 /*
2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14  * PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /*! \file */
18 #include <stdlib.h>
19 
20 #include <isccfg/cfg.h>
21 #include <isccfg/grammar.h>
22 
23 /*%
24  * Forward declarations of static functions.
25  */
26 
27 static cfg_type_t cfg_type_key;
28 
29 /*%
30  * Clauses that can be found within the 'key' statement.
31  */
32 static cfg_clausedef_t
33 key_clauses[] = {
34 	{ "algorithm", &cfg_type_astring, 0 },
35 	{ "secret", &cfg_type_sstring, 0 },
36 	{ NULL, NULL, 0 }
37 };
38 
39 static cfg_clausedef_t *
40 key_clausesets[] = {
41 	key_clauses,
42 	NULL
43 };
44 static cfg_type_t cfg_type_key = {
45 	"key", cfg_parse_named_map, &cfg_rep_map, key_clausesets
46 };
47 
48 /*%
49  * rndc
50  */
51 
52 static cfg_clausedef_t
53 rndckey_clauses[] = {
54 	{ "key", &cfg_type_key, 0 },
55 	{ NULL, NULL, 0 }
56 };
57 
58 static cfg_clausedef_t *
59 rndckey_clausesets[] = {
60 	rndckey_clauses,
61 	NULL
62 };
63 
64 /*
65  * session.key has exactly the same syntax as rndc.key, but it's defined
66  * separately for clarity (and so we can extend it someday, if needed).
67  */
68 cfg_type_t cfg_type_sessionkey = {
69 	"sessionkey", cfg_parse_mapbody, &cfg_rep_map, rndckey_clausesets
70 };
71 
72