namedconf.c revision 603658ea65b34c4b57f154b1e2412b4f01866b6b
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley/*
5569e7de51513952d89f29de08049ed6bb054d6eAutomatic Updater * Copyright (C) 2001, 2002 Internet Software Consortium.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews *
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * copyright notice and this permission notice appear in all copies.
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley *
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley */
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley
be69d484434e10d920c4d8a8bb735356eb0c2cc8Evan Hunt/* $Id: namedconf.c,v 1.21 2003/04/17 03:26:58 marka Exp $ */
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence
e419f613d8591885df608cb73065921be07dd12eBob Halley#include <config.h>
e419f613d8591885df608cb73065921be07dd12eBob Halley
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <string.h>
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence
fca5f81ad69098ea8abba130c7f841c951ef91c2Bob Halley#include <isc/lex.h>
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#include <isc/result.h>
519b239fc4ef1e070e2da182a4ea559ae0152151Mark Andrews#include <isc/string.h>
e419f613d8591885df608cb73065921be07dd12eBob Halley#include <isc/util.h>
e419f613d8591885df608cb73065921be07dd12eBob Halley
9695ae1c24b168996e3a267855dc754971ccb32cBob Halley#include <isccfg/cfg.h>
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley#include <isccfg/grammar.h>
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews#include <isccfg/log.h>
1c776a2909632bc755f3fddd3b53addd792ab4d0Brian Wellington
e419f613d8591885df608cb73065921be07dd12eBob Halley#define TOKEN_STRING(pctx) (pctx->token.value.as_textregion.base)
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson/* Check a return value. */
e83cae7fa837e4757c687035d6f6c0900f152749Brian Wellington#define CHECK(op) \
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews do { result = (op); \
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews if (result != ISC_R_SUCCESS) goto cleanup; \
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews } while (0)
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington/* Clean up a configuration object if non-NULL. */
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley#define CLEANUP_OBJ(obj) \
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence do { if ((obj) != NULL) cfg_obj_destroy(pctx, &(obj)); } while (0)
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence/*
e419f613d8591885df608cb73065921be07dd12eBob Halley * Forward declarations of static functions.
e419f613d8591885df608cb73065921be07dd12eBob Halley */
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic isc_result_t
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsparse_enum_or_other(cfg_parser_t *pctx, const cfg_type_t *enumtype,
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews const cfg_type_t *othertype, cfg_obj_t **ret);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic isc_result_t
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsparse_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic isc_result_t
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updaterparse_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic void
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsprint_keyvalue(cfg_printer_t *pctx, cfg_obj_t *obj);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic void
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsdoc_keyvalue(cfg_printer_t *pctx, const cfg_type_t *type);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic void
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsdoc_optional_keyvalue(cfg_printer_t *pctx, const cfg_type_t *type);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_acl;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_addrmatchelt;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_bracketed_aml;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_bracketed_namesockaddrkeylist;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_bracketed_sockaddrlist;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_controls;
d2ef84e07b67e72a4bd9c729c6b8228067d17584Mark Andrewsstatic cfg_type_t cfg_type_controls_sockaddr;
d2ef84e07b67e72a4bd9c729c6b8228067d17584Mark Andrewsstatic cfg_type_t cfg_type_destinationlist;
d2ef84e07b67e72a4bd9c729c6b8228067d17584Mark Andrewsstatic cfg_type_t cfg_type_dialuptype;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_key;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_logfile;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_logging;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_logseverity;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_lwres;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_masterselement;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_nameportiplist;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_negated;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_notifytype;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_optional_class;
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrencestatic cfg_type_t cfg_type_optional_facility;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsstatic cfg_type_t cfg_type_optional_facility;
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halleystatic cfg_type_t cfg_type_optional_keyref;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_optional_port;
708383382ff1d3fdd27527e5d63120a3c6c6d3b3Francis Dupontstatic cfg_type_t cfg_type_options;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_portiplist;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_querysource4;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_querysource6;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_querysource;
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_type_t cfg_type_server;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_server_key_kludge;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_size;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_sizenodefault;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_sockaddr4wild;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_sockaddr6wild;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_view;
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_type_t cfg_type_viewopts;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_zone;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_zoneopts;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/* tkey-dhkey */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_tuplefielddef_t tkey_dhkey_fields[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "name", &cfg_type_qstring, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "keyid", &cfg_type_uint32, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { NULL, NULL, 0 }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_tkey_dhkey = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "tkey-dhkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews tkey_dhkey_fields
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews/* listen-on */
50105afc551903541608b11851d73278b23579a3Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_tuplefielddef_t listenon_fields[] = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "port", &cfg_type_optional_port, 0 },
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews { "acl", &cfg_type_bracketed_aml, 0 },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { NULL, NULL, 0 }
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_listenon = {
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence "listenon", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, listenon_fields };
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews/* acl */
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic cfg_tuplefielddef_t acl_fields[] = {
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington { "name", &cfg_type_astring, 0 },
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence { "value", &cfg_type_bracketed_aml, 0 },
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence { NULL, NULL, 0 }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
50105afc551903541608b11851d73278b23579a3Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_acl = {
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington "acl", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, acl_fields };
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence/* masters */
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellingtonstatic cfg_tuplefielddef_t masters_fields[] = {
664e11f0b14c78cef7cf6b8c70323a1da494e351Mark Andrews { "name", &cfg_type_astring, 0 },
664e11f0b14c78cef7cf6b8c70323a1da494e351Mark Andrews { "port", &cfg_type_optional_port, 0 },
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence { "addresses", &cfg_type_bracketed_namesockaddrkeylist, 0 },
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington { NULL, NULL, 0 }
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington};
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellingtonstatic cfg_type_t cfg_type_masters = {
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington "masters", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, masters_fields };
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson/*
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson * "sockaddrkeylist", a list of socket addresses with optional keys
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson * and an optional default port, as used in the masters option.
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * E.g.,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * "port 1234 { mymasters; 10.0.0.1 key foo; 1::2 port 69; }"
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_tuplefielddef_t namesockaddrkey_fields[] = {
50105afc551903541608b11851d73278b23579a3Mark Andrews { "masterselement", &cfg_type_masterselement, 0 },
50105afc551903541608b11851d73278b23579a3Mark Andrews { "key", &cfg_type_optional_keyref, 0 },
50105afc551903541608b11851d73278b23579a3Mark Andrews { NULL, NULL, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrewsstatic cfg_type_t cfg_type_namesockaddrkey = {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews "namesockaddrkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews namesockaddrkey_fields
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews};
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_bracketed_namesockaddrkeylist = {
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews "bracketed_namesockaddrkeylist", cfg_parse_bracketed_list,
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list, &cfg_type_namesockaddrkey
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrewsstatic cfg_tuplefielddef_t namesockaddrkeylist_fields[] = {
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews { "port", &cfg_type_optional_port, 0 },
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews { "addresses", &cfg_type_bracketed_namesockaddrkeylist, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { NULL, NULL, 0 }
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews};
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_namesockaddrkeylist = {
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews "sockaddrkeylist", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews namesockaddrkeylist_fields
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews};
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley/*
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley * A list of socket addresses with an optional default port,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley * as used in the also-notify option. E.g.,
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington * "port 1234 { 10.0.0.1; 1::2 port 69; }"
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington */
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic cfg_tuplefielddef_t portiplist_fields[] = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "port", &cfg_type_optional_port, 0 },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "addresses", &cfg_type_bracketed_sockaddrlist, 0 },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { NULL, NULL, 0 }
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley};
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellingtonstatic cfg_type_t cfg_type_portiplist = {
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff "portiplist", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff portiplist_fields
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff};
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff/*
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley * A public key, as in the "pubkey" statement.
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley */
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic cfg_tuplefielddef_t pubkey_fields[] = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "flags", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "protocol", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "algorithm", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "key", &cfg_type_qstring, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { NULL, NULL, 0 }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_pubkey = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "pubkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, pubkey_fields };
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews/*
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * A list of RR types, used in grant statements.
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * Note that the old parser allows quotes around the RR type names.
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_rrtypelist = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "rrtypelist", cfg_parse_spacelist, cfg_print_spacelist, cfg_doc_terminal,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews &cfg_rep_list, &cfg_type_astring
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews};
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrewsstatic const char *mode_enums[] = { "grant", "deny", NULL };
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrewsstatic cfg_type_t cfg_type_mode = {
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews "mode", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews &mode_enums
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews};
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrewsstatic const char *matchtype_enums[] = {
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews "name", "subdomain", "wildcard", "self", NULL };
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrewsstatic cfg_type_t cfg_type_matchtype = {
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews "matchtype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews &matchtype_enums
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews};
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews/*
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews * A grant statement, used in the update policy.
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews */
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrewsstatic cfg_tuplefielddef_t grant_fields[] = {
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews { "mode", &cfg_type_mode, 0 },
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews { "identity", &cfg_type_astring, 0 }, /* domain name */
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews { "matchtype", &cfg_type_matchtype, 0 },
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews { "name", &cfg_type_astring, 0 }, /* domain name */
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews { "types", &cfg_type_rrtypelist, 0 },
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews { NULL, NULL, 0 }
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews};
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrewsstatic cfg_type_t cfg_type_grant = {
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews "grant", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, grant_fields };
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrewsstatic cfg_type_t cfg_type_updatepolicy = {
72dbc7216aae3626a66e6154443be219f5edcaf0Mark Andrews "update_policy", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews &cfg_rep_list, &cfg_type_grant
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews/*
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews * A view statement.
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews */
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsstatic cfg_tuplefielddef_t view_fields[] = {
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "name", &cfg_type_astring, 0 },
7d211b458fed36326b9e125b9d74089f9dccc140Mark Andrews { "class", &cfg_type_optional_class, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "options", &cfg_type_viewopts, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { NULL, NULL, 0 }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsstatic cfg_type_t cfg_type_view = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "view", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, view_fields };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews * A zone statement.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsstatic cfg_tuplefielddef_t zone_fields[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "name", &cfg_type_astring, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "class", &cfg_type_optional_class, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "options", &cfg_type_zoneopts, 0 },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { NULL, NULL, 0 }
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews};
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsstatic cfg_type_t cfg_type_zone = {
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews "zone", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, zone_fields };
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews/*
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews * A "category" clause in the "logging" statement.
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews */
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrewsstatic cfg_tuplefielddef_t category_fields[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "name", &cfg_type_astring, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "destinations", &cfg_type_destinationlist,0 },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { NULL, NULL, 0 }
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews};
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsstatic cfg_type_t cfg_type_category = {
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews "category", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple, category_fields };
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews/*
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews * A trusted key, as used in the "trusted-keys" statement.
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews */
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsstatic cfg_tuplefielddef_t trustedkey_fields[] = {
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews { "name", &cfg_type_astring, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "flags", &cfg_type_uint32, 0 },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "protocol", &cfg_type_uint32, 0 },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "algorithm", &cfg_type_uint32, 0 },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "key", &cfg_type_qstring, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { NULL, NULL, 0 }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_trustedkey = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "trustedkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews trustedkey_fields
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
7d211b458fed36326b9e125b9d74089f9dccc140Mark Andrewsstatic keyword_type_t wild_class_kw = { "class", &cfg_type_ustring };
7d211b458fed36326b9e125b9d74089f9dccc140Mark Andrews
7d211b458fed36326b9e125b9d74089f9dccc140Mark Andrewsstatic cfg_type_t cfg_type_optional_wild_class = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "optional_wild_class", parse_optional_keyvalue, print_keyvalue,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews doc_optional_keyvalue, &cfg_rep_string, &wild_class_kw
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic keyword_type_t wild_type_kw = { "type", &cfg_type_ustring };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_optional_wild_type = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "optional_wild_type", parse_optional_keyvalue,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews print_keyvalue, doc_optional_keyvalue, &cfg_rep_string, &wild_type_kw
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic keyword_type_t wild_name_kw = { "name", &cfg_type_qstring };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_optional_wild_name = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "optional_wild_name", parse_optional_keyvalue,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews print_keyvalue, doc_optional_keyvalue, &cfg_rep_string, &wild_name_kw
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * An rrset ordering element.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_tuplefielddef_t rrsetorderingelement_fields[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "class", &cfg_type_optional_wild_class, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "type", &cfg_type_optional_wild_type, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "name", &cfg_type_optional_wild_name, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "order", &cfg_type_ustring, 0 }, /* must be literal "order" */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "ordering", &cfg_type_ustring, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { NULL, NULL, 0 }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_rrsetorderingelement = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "rrsetorderingelement", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews rrsetorderingelement_fields
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * A global or view "check-names" option. Note that the zone
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * "check-names" option has a different syntax.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_tuplefielddef_t checknames_fields[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "type", &cfg_type_ustring, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "mode", &cfg_type_ustring, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { NULL, NULL, 0 }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_checknames = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "checknames", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews checknames_fields
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_bracketed_sockaddrlist = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "bracketed_sockaddrlist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_list, &cfg_type_sockaddr
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_rrsetorder = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "rrsetorder", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_list, &cfg_type_rrsetorderingelement
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsstatic keyword_type_t port_kw = { "port", &cfg_type_uint32 };
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_optional_port = {
ff380b05fec3746934c74b78bb44f641d2acb359Francis Dupont "optional_port", parse_optional_keyvalue, print_keyvalue,
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews doc_optional_keyvalue, &cfg_rep_uint32, &port_kw
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington/* A list of keys, as in the "key" clause of the controls statement. */
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellingtonstatic cfg_type_t cfg_type_keylist = {
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington "keylist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list,
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington &cfg_type_astring
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellingtonstatic cfg_type_t cfg_type_trustedkeys = {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington "trusted-keys", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list,
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington &cfg_type_trustedkey
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington};
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellingtonstatic const char *forwardtype_enums[] = { "first", "only", NULL };
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graffstatic cfg_type_t cfg_type_forwardtype = {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington "forwardtype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington &forwardtype_enums
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington};
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrewsstatic const char *zonetype_enums[] = {
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews "master", "slave", "stub", "hint", "forward", NULL };
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrewsstatic cfg_type_t cfg_type_zonetype = {
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews "zonetype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews &zonetype_enums
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews};
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic const char *loglevel_enums[] = {
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington "critical", "error", "warning", "notice", "info", "dynamic", NULL };
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellingtonstatic cfg_type_t cfg_type_loglevel = {
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington "loglevel", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson &loglevel_enums
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington};
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrewsstatic const char *transferformat_enums[] = {
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews "many-answers", "one-answer", NULL };
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafssonstatic cfg_type_t cfg_type_transferformat = {
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington "transferformat", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington &transferformat_enums
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington};
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington/*
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington * The special keyword "none", as used in the pid-file option.
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington */
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellingtonstatic void
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellingtonprint_none(cfg_printer_t *pctx, cfg_obj_t *obj) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews UNUSED(obj);
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington cfg_print_chars(pctx, "none", 4);
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington}
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafssonstatic cfg_type_t cfg_type_none = {
18b7133679efa8f60fd4e396c628576f3f416b3eBrian Wellington "none", NULL, print_none, NULL, &cfg_rep_void, NULL
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington};
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington/*
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington * A quoted string or the special keyword "none". Used in the pid-file option.
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic isc_result_t
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonparse_qstringornone(cfg_parser_t *pctx, const cfg_type_t *type,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_obj_t **ret)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews{
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington isc_result_t result;
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews if (pctx->token.type == isc_tokentype_string &&
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews strcasecmp(TOKEN_STRING(pctx), "none") == 0)
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews return (cfg_create_obj(pctx, &cfg_type_none, ret));
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cfg_ungettoken(pctx);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews return (cfg_parse_qstring(pctx, type, ret));
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington cleanup:
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (result);
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington}
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic void
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsdoc_qstringornone(cfg_printer_t *pctx, const cfg_type_t *type) {
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington UNUSED(type);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington cfg_print_chars(pctx, "( <quoted_string> | none )", 26);
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington}
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellingtonstatic cfg_type_t cfg_type_qstringornone = {
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington "qstringornone", parse_qstringornone, NULL, doc_qstringornone, NULL, NULL };
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington/*
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington * keyword hostname
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington */
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrewsstatic void
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrewsprint_hostname(cfg_printer_t *pctx, cfg_obj_t *obj) {
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews UNUSED(obj);
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews cfg_print_chars(pctx, "hostname", 4);
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews}
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_hostname = {
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington "hostname", NULL, print_hostname, NULL, &cfg_rep_boolean, NULL
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington};
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington/*
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * "server-id" arguement.
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington */
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrewsstatic isc_result_t
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrewsparse_serverid(cfg_parser_t *pctx, const cfg_type_t *type,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_obj_t **ret)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews{
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews isc_result_t result;
50105afc551903541608b11851d73278b23579a3Mark Andrews CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
50105afc551903541608b11851d73278b23579a3Mark Andrews if (pctx->token.type == isc_tokentype_string &&
50105afc551903541608b11851d73278b23579a3Mark Andrews strcasecmp(TOKEN_STRING(pctx), "none") == 0)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (cfg_create_obj(pctx, &cfg_type_none, ret));
a05f23d07e1b60a1d88119678111a47014480611Mark Andrews if (pctx->token.type == isc_tokentype_string &&
a05f23d07e1b60a1d88119678111a47014480611Mark Andrews strcasecmp(TOKEN_STRING(pctx), "hostname") == 0) {
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington return (cfg_create_obj(pctx, &cfg_type_hostname, ret));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
a05f23d07e1b60a1d88119678111a47014480611Mark Andrews cfg_ungettoken(pctx);
a05f23d07e1b60a1d88119678111a47014480611Mark Andrews return (cfg_parse_qstring(pctx, type, ret));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cleanup:
664e11f0b14c78cef7cf6b8c70323a1da494e351Mark Andrews return (result);
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington}
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellingtonstatic void
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafssondoc_serverid(cfg_printer_t *pctx, const cfg_type_t *type) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews UNUSED(type);
18b7133679efa8f60fd4e396c628576f3f416b3eBrian Wellington cfg_print_chars(pctx, "( <quoted_string> | none | hostname )", 26);
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington}
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellingtonstatic cfg_type_t cfg_type_serverid = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "serverid", parse_serverid, NULL, doc_serverid, NULL, NULL };
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews/*
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington * Port list.
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic isc_result_t
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsparse_port(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews isc_result_t result;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews UNUSED(type);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews CHECK(cfg_parse_uint32(pctx, NULL, ret));
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews if ((*ret)->value.uint32 > 0xffff) {
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cfg_parser_error(pctx, CFG_LOG_NEAR, "invalid port");
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cfg_obj_destroy(pctx, ret);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews result = ISC_R_RANGE;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews }
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cleanup:
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (result);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews}
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_port = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "port", parse_port, NULL, cfg_doc_terminal,
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews NULL, NULL
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_bracketed_portlist = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "bracketed_sockaddrlist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews &cfg_rep_list, &cfg_type_port
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews/*
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * Clauses that can be found within the top level of the named.conf
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington * file only.
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews */
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrewsstatic cfg_clausedef_t
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrewsnamedconf_clauses[] = {
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews { "options", &cfg_type_options, 0 },
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews { "controls", &cfg_type_controls, CFG_CLAUSEFLAG_MULTI },
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews { "acl", &cfg_type_acl, CFG_CLAUSEFLAG_MULTI },
7d116211ec7b063891130f191e3ed437b45dba70Mark Andrews { "masters", &cfg_type_masters, CFG_CLAUSEFLAG_MULTI },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "logging", &cfg_type_logging, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "view", &cfg_type_view, CFG_CLAUSEFLAG_MULTI },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "lwres", &cfg_type_lwres, CFG_CLAUSEFLAG_MULTI },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { NULL, NULL, 0 }
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews/*
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews * Clauses that can occur at the top level or in the view
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews * statement, but not in the options block.
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_clausedef_t
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsnamedconf_or_view_clauses[] = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "key", &cfg_type_key, CFG_CLAUSEFLAG_MULTI },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "zone", &cfg_type_zone, CFG_CLAUSEFLAG_MULTI },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "server", &cfg_type_server, CFG_CLAUSEFLAG_MULTI },
8d414d155953f89a4eff40f16878438a8c9228f3Mark Andrews { "trusted-keys", &cfg_type_trustedkeys, CFG_CLAUSEFLAG_MULTI },
8d414d155953f89a4eff40f16878438a8c9228f3Mark Andrews { NULL, NULL, 0 }
be69d484434e10d920c4d8a8bb735356eb0c2cc8Evan Hunt};
be69d484434e10d920c4d8a8bb735356eb0c2cc8Evan Hunt
8d414d155953f89a4eff40f16878438a8c9228f3Mark Andrews/*
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews * Clauses that can be found within the 'options' statement.
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews */
8d414d155953f89a4eff40f16878438a8c9228f3Mark Andrewsstatic cfg_clausedef_t
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsoptions_clauses[] = {
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "avoid-v4-udp-ports", &cfg_type_bracketed_portlist, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "avoid-v6-udp-ports", &cfg_type_bracketed_portlist, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "blackhole", &cfg_type_bracketed_aml, 0 },
8d414d155953f89a4eff40f16878438a8c9228f3Mark Andrews { "coresize", &cfg_type_size, 0 },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "datasize", &cfg_type_size, 0 },
664e11f0b14c78cef7cf6b8c70323a1da494e351Mark Andrews { "deallocate-on-exit", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "directory", &cfg_type_qstring, CFG_CLAUSEFLAG_CALLBACK },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "dump-file", &cfg_type_qstring, 0 },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "fake-iquery", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "files", &cfg_type_size, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "has-old-clients", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "heartbeat-interval", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "host-statistics", &cfg_type_boolean, CFG_CLAUSEFLAG_NOTIMP },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "hostname", &cfg_type_qstringornone, 0 },
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater { "interface-interval", &cfg_type_uint32, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "listen-on", &cfg_type_listenon, CFG_CLAUSEFLAG_MULTI },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "listen-on-v6", &cfg_type_listenon, CFG_CLAUSEFLAG_MULTI },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "match-mapped-addresses", &cfg_type_boolean, 0 },
664e11f0b14c78cef7cf6b8c70323a1da494e351Mark Andrews { "memstatistics-file", &cfg_type_qstring, 0 },
664e11f0b14c78cef7cf6b8c70323a1da494e351Mark Andrews { "multiple-cnames", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "named-xfer", &cfg_type_qstring, CFG_CLAUSEFLAG_OBSOLETE },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "pid-file", &cfg_type_qstringornone, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "port", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "recursing-file", &cfg_type_qstring, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "random-device", &cfg_type_qstring, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "recursive-clients", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "serial-queries", &cfg_type_uint32, CFG_CLAUSEFLAG_OBSOLETE },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "serial-query-rate", &cfg_type_uint32, 0 },
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews { "server-id", &cfg_type_serverid, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "stacksize", &cfg_type_size, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "statistics-file", &cfg_type_qstring, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "statistics-interval", &cfg_type_uint32, CFG_CLAUSEFLAG_NYI },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "tcp-clients", &cfg_type_uint32, 0 },
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington { "tcp-listen-queue", &cfg_type_uint32, 0 },
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington { "tkey-dhkey", &cfg_type_tkey_dhkey, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "tkey-gssapi-credential", &cfg_type_qstring, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "tkey-domain", &cfg_type_qstring, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "transfers-per-ns", &cfg_type_uint32, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "transfers-in", &cfg_type_uint32, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "transfers-out", &cfg_type_uint32, 0 },
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington { "treat-cr-as-space", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington { "use-id-pool", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington { "use-ixfr", &cfg_type_boolean, 0 },
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington { "version", &cfg_type_qstringornone, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { NULL, NULL, 0 }
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington};
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington/*
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington * Clauses that can be found within the 'view' statement,
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff * with defaults in the 'options' statement.
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington */
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellingtonstatic cfg_clausedef_t
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellingtonview_clauses[] = {
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington { "allow-recursion", &cfg_type_bracketed_aml, 0 },
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington { "allow-v6-synthesis", &cfg_type_bracketed_aml,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CFG_CLAUSEFLAG_OBSOLETE },
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington { "sortlist", &cfg_type_bracketed_aml, 0 },
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington { "topology", &cfg_type_bracketed_aml, CFG_CLAUSEFLAG_NOTIMP },
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington { "auth-nxdomain", &cfg_type_boolean, CFG_CLAUSEFLAG_NEWDEFAULT },
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson { "minimal-responses", &cfg_type_boolean, 0 },
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington { "recursion", &cfg_type_boolean, 0 },
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews { "rrset-order", &cfg_type_rrsetorder, 0 },
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews { "provide-ixfr", &cfg_type_boolean, 0 },
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews { "request-ixfr", &cfg_type_boolean, 0 },
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson { "fetch-glue", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson { "rfc2308-type1", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI },
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington { "additional-from-auth", &cfg_type_boolean, 0 },
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington { "additional-from-cache", &cfg_type_boolean, 0 },
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington /*
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington * Note that the query-source option syntax is different
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington * from the other -source options.
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "query-source", &cfg_type_querysource4, 0 },
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington { "query-source-v6", &cfg_type_querysource6, 0 },
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington { "cleaning-interval", &cfg_type_uint32, 0 },
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson { "min-roots", &cfg_type_uint32, CFG_CLAUSEFLAG_NOTIMP },
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson { "lame-ttl", &cfg_type_uint32, 0 },
18b7133679efa8f60fd4e396c628576f3f416b3eBrian Wellington { "max-ncache-ttl", &cfg_type_uint32, 0 },
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington { "max-cache-ttl", &cfg_type_uint32, 0 },
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington { "transfer-format", &cfg_type_transferformat, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "max-cache-size", &cfg_type_sizenodefault, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "check-names", &cfg_type_checknames,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_NOTIMP },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "cache-file", &cfg_type_qstring, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "suppress-initial-notify", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "preferred-glue", &cfg_type_astring, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "dual-stack-servers", &cfg_type_nameportiplist, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "edns-udp-size", &cfg_type_uint32, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { NULL, NULL, 0 }
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews/*
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * Clauses that can be found within the 'view' statement only.
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_clausedef_t
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsview_only_clauses[] = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "match-clients", &cfg_type_bracketed_aml, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "match-destinations", &cfg_type_bracketed_aml, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "match-recursive-only", &cfg_type_boolean, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { NULL, NULL, 0 }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews/*
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * Clauses that can be found in a 'zone' statement,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * with defaults in the 'view' or 'options' statement.
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_clausedef_t
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewszone_clauses[] = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "allow-query", &cfg_type_bracketed_aml, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "allow-transfer", &cfg_type_bracketed_aml, 0 },
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington { "allow-update-forwarding", &cfg_type_bracketed_aml, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "allow-notify", &cfg_type_bracketed_aml, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "notify", &cfg_type_notifytype, 0 },
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews { "notify-source", &cfg_type_sockaddr4wild, 0 },
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews { "notify-source-v6", &cfg_type_sockaddr6wild, 0 },
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews { "also-notify", &cfg_type_portiplist, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "dialup", &cfg_type_dialuptype, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "forward", &cfg_type_forwardtype, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "forwarders", &cfg_type_portiplist, 0 },
664e11f0b14c78cef7cf6b8c70323a1da494e351Mark Andrews { "ixfr-from-differences", &cfg_type_boolean, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "maintain-ixfr-base", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
50105afc551903541608b11851d73278b23579a3Mark Andrews { "max-ixfr-log-size", &cfg_type_size, CFG_CLAUSEFLAG_OBSOLETE },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "max-journal-size", &cfg_type_sizenodefault, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "max-transfer-time-in", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "max-transfer-time-out", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "max-transfer-idle-in", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "max-transfer-idle-out", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "max-retry-time", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "min-retry-time", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "max-refresh-time", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "min-refresh-time", &cfg_type_uint32, 0 },
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington { "multi-master", &cfg_type_boolean, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "sig-validity-interval", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "transfer-source", &cfg_type_sockaddr4wild, 0 },
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington { "transfer-source-v6", &cfg_type_sockaddr6wild, 0 },
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington { "alt-transfer-source", &cfg_type_sockaddr4wild, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { "alt-transfer-source-v6", &cfg_type_sockaddr6wild, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "use-alt-transfer-source", &cfg_type_boolean, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "zone-statistics", &cfg_type_boolean, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "key-directory", &cfg_type_qstring, 0 },
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews { NULL, NULL, 0 }
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews/*
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * Clauses that can be found in a 'zone' statement
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * only.
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews */
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic cfg_clausedef_t
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonzone_only_clauses[] = {
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews { "type", &cfg_type_zonetype, 0 },
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington { "allow-update", &cfg_type_bracketed_aml, 0 },
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews { "file", &cfg_type_qstring, 0 },
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 { "ixfr-base", &cfg_type_qstring, CFG_CLAUSEFLAG_OBSOLETE },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "ixfr-tmp-file", &cfg_type_qstring, CFG_CLAUSEFLAG_OBSOLETE },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "masters", &cfg_type_namesockaddrkeylist, 0 },
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews { "pubkey", &cfg_type_pubkey,
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_OBSOLETE },
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington { "update-policy", &cfg_type_updatepolicy, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "database", &cfg_type_astring, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews /*
4e259c5a2321e994708fb1fe04cd4da30aa3b612Mark Andrews * Note that the format of the check-names option is different between
4e259c5a2321e994708fb1fe04cd4da30aa3b612Mark Andrews * the zone options and the global/view options. Ugh.
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews */
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews { "check-names", &cfg_type_ustring, CFG_CLAUSEFLAG_NOTIMP },
c70908209ee26c51a8e7242a56fdb73847249728Brian Wellington { NULL, NULL, 0 }
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson};
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
c70908209ee26c51a8e7242a56fdb73847249728Brian Wellington/* The top-level named.conf syntax. */
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic cfg_clausedef_t *
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrewsnamedconf_clausesets[] = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews namedconf_clauses,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews namedconf_or_view_clauses,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews NULL
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian WellingtonLIBISCCFG_EXTERNAL_DATA cfg_type_t cfg_type_namedconf = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews "namedconf", cfg_parse_mapbody, cfg_print_mapbody, cfg_doc_mapbody,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews &cfg_rep_map, namedconf_clausesets
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
d1cbf714097e900ed1703529584d3e1a50e8a4a8Brian Wellington/* The "options" statement syntax. */
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic cfg_clausedef_t *
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsoptions_clausesets[] = {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington options_clauses,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews view_clauses,
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews zone_clauses,
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews NULL
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_type_t cfg_type_options = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews "options", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, options_clausesets };
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews/* The "view" statement syntax. */
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_clausedef_t *
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsview_clausesets[] = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews view_only_clauses,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews namedconf_or_view_clauses,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews view_clauses,
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews zone_clauses,
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews NULL
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews};
638fe804a524ee0c028863c0301b999c79de7651Mark Andrewsstatic cfg_type_t cfg_type_viewopts = {
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews "view", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, view_clausesets };
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews/* The "zone" statement syntax. */
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic cfg_clausedef_t *
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrewszone_clausesets[] = {
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews zone_only_clauses,
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews zone_clauses,
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews NULL
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews};
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrewsstatic cfg_type_t cfg_type_zoneopts = {
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews "zoneopts", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, zone_clausesets };
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews/*
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews * Clauses that can be found within the 'key' statement.
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews */
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrewsstatic cfg_clausedef_t
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrewskey_clauses[] = {
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews { "algorithm", &cfg_type_astring, 0 },
676619a22fbc760875adb00b58aaef6a22ced18aMark Andrews { "secret", &cfg_type_astring, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { NULL, NULL, 0 }
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_clausedef_t *
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewskey_clausesets[] = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews key_clauses,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews NULL
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_type_t cfg_type_key = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews "key", cfg_parse_named_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, key_clausesets };
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews/*
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * Clauses that can be found in a 'server' statement.
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews */
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_clausedef_t
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsserver_clauses[] = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "bogus", &cfg_type_boolean, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "provide-ixfr", &cfg_type_boolean, 0 },
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews { "request-ixfr", &cfg_type_boolean, 0 },
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson { "support-ixfr", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "transfers", &cfg_type_uint32, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "transfer-format", &cfg_type_transferformat, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "keys", &cfg_type_server_key_kludge, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "edns", &cfg_type_boolean, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { NULL, NULL, 0 }
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_clausedef_t *
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonserver_clausesets[] = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews server_clauses,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews NULL
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_type_t cfg_type_server = {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington "server", cfg_parse_addressed_map, cfg_print_map, cfg_doc_map, &cfg_rep_map,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews server_clausesets
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews/*
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * Clauses that can be found in a 'channel' clause in the
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * 'logging' statement.
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews *
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * These have some additional constraints that need to be
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * checked after parsing:
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * - There must exactly one of file/syslog/null/stderr
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews *
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews */
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_clausedef_t
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewschannel_clauses[] = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews /* Destinations. We no longer require these to be first. */
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "file", &cfg_type_logfile, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "syslog", &cfg_type_optional_facility, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "null", &cfg_type_void, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "stderr", &cfg_type_void, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews /* Options. We now accept these for the null channel, too. */
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "severity", &cfg_type_logseverity, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "print-time", &cfg_type_boolean, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { "print-severity", &cfg_type_boolean, 0 },
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews { "print-category", &cfg_type_boolean, 0 },
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews { NULL, NULL, 0 }
95b484c9580d06eb2f9735a22e9841389c2859baMark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_clausedef_t *
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewschannel_clausesets[] = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews channel_clauses,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews NULL
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic cfg_type_t cfg_type_channel = {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews "channel", cfg_parse_named_map, cfg_print_map, cfg_doc_map,
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington &cfg_rep_map, channel_clausesets
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/* A list of log destination, used in the "category" clause. */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_destinationlist = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "destinationlist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_list, &cfg_type_astring };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * Clauses that can be found in a 'logging' statement.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_clausedef_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewslogging_clauses[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "channel", &cfg_type_channel, CFG_CLAUSEFLAG_MULTI },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "category", &cfg_type_category, CFG_CLAUSEFLAG_MULTI },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { NULL, NULL, 0 }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_clausedef_t *
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewslogging_clausesets[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews logging_clauses,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews NULL
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_logging = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "logging", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, logging_clausesets };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_unitstring(char *str, isc_resourcevalue_t *valuep) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews char *endp;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews unsigned int len;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_uint64_t value;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_uint64_t unit;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews value = isc_string_touint64(str, &endp, 10);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (*endp == 0) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews *valuep = value;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews len = strlen(str);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (len < 2 || endp[1] != '\0')
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (ISC_R_FAILURE);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews switch (str[len - 1]) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews case 'k':
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews case 'K':
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews unit = 1024;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews break;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews case 'm':
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews case 'M':
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews unit = 1024 * 1024;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews break;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews case 'g':
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews case 'G':
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews unit = 1024 * 1024 * 1024;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews break;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews default:
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (ISC_R_FAILURE);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (value > ISC_UINT64_MAX / unit)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (ISC_R_FAILURE);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews *valuep = value * unit;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_sizeval(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_result_t result;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_obj_t *obj = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_uint64_t val;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews UNUSED(type);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_gettoken(pctx, 0));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (pctx->token.type != isc_tokentype_string) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = ISC_R_UNEXPECTEDTOKEN;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews goto cleanup;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(parse_unitstring(TOKEN_STRING(pctx), &val));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_create_obj(pctx, &cfg_type_uint64, &obj));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews obj->value.uint64 = val;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews *ret = obj;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (ISC_R_SUCCESS);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cleanup:
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_parser_error(pctx, CFG_LOG_NEAR, "expected integer and optional unit");
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * A size value (number + optional unit).
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_sizeval = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "sizeval", parse_sizeval, cfg_print_uint64, cfg_doc_terminal,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_uint64, NULL };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * A size, "unlimited", or "default".
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_size(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (parse_enum_or_other(pctx, type, &cfg_type_sizeval, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic const char *size_enums[] = { "unlimited", "default", NULL };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_size = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "size", parse_size, cfg_print_ustring, cfg_doc_terminal,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_string, size_enums
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * A size or "unlimited", but not "default".
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic const char *sizenodefault_enums[] = { "unlimited", NULL };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_sizenodefault = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "size_no_default", parse_size, cfg_print_ustring, cfg_doc_terminal,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_string, sizenodefault_enums
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * optional_keyvalue
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_maybe_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_boolean_t optional, cfg_obj_t **ret)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews{
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_result_t result;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_obj_t *obj = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews const keyword_type_t *kw = type->of;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_peektoken(pctx, 0));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (pctx->token.type == isc_tokentype_string &&
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews strcasecmp(TOKEN_STRING(pctx), kw->name) == 0) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_gettoken(pctx, 0));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(kw->type->parse(pctx, kw->type, &obj));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews obj->type = type; /* XXX kludge */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews } else {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (optional) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_parse_void(pctx, NULL, &obj));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews } else {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_parser_error(pctx, CFG_LOG_NEAR, "expected '%s'",
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews kw->name);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = ISC_R_UNEXPECTEDTOKEN;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews goto cleanup;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews *ret = obj;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cleanup:
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_enum_or_other(cfg_parser_t *pctx, const cfg_type_t *enumtype,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews const cfg_type_t *othertype, cfg_obj_t **ret)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews{
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_result_t result;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_peektoken(pctx, 0));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (pctx->token.type == isc_tokentype_string &&
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_is_enum(TOKEN_STRING(pctx), enumtype->of)) {
ff380b05fec3746934c74b78bb44f641d2acb359Francis Dupont CHECK(cfg_parse_enum(pctx, enumtype, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews } else {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_parse_obj(pctx, othertype, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cleanup:
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic void
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsdoc_enum_or_other(cfg_printer_t *pctx, const cfg_type_t *type) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_doc_terminal(pctx, type);
ff380b05fec3746934c74b78bb44f641d2acb359Francis Dupont#if 0 /* XXX */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_print_chars(pctx, "( ", 2);...
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews#endif
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (parse_maybe_optional_keyvalue(pctx, type, ISC_FALSE, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_optional_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (parse_maybe_optional_keyvalue(pctx, type, ISC_TRUE, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic void
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsprint_keyvalue(cfg_printer_t *pctx, cfg_obj_t *obj) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews const keyword_type_t *kw = obj->type->of;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_print_cstr(pctx, kw->name);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_print_chars(pctx, " ", 1);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews kw->type->print(pctx, obj);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic void
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsdoc_keyvalue(cfg_printer_t *pctx, const cfg_type_t *type) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews const keyword_type_t *kw = type->of;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_print_cstr(pctx, kw->name);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_print_chars(pctx, " ", 1);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_doc_obj(pctx, kw->type);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic void
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsdoc_optional_keyvalue(cfg_printer_t *pctx, const cfg_type_t *type) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews const keyword_type_t *kw = type->of;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_print_chars(pctx, "[ ", 2);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_print_cstr(pctx, kw->name);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_print_chars(pctx, " ", 1);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_doc_obj(pctx, kw->type);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_print_chars(pctx, " ]", 2);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic const char *dialup_enums[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "notify", "notify-passive", "refresh", "passive", NULL };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_dialup_type(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_dialuptype = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "dialuptype", parse_dialup_type, cfg_print_ustring, doc_enum_or_other,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_string, dialup_enums
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic const char *notify_enums[] = { "explicit", NULL };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_notify_type(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_notifytype = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "notifytype", parse_notify_type, cfg_print_ustring, doc_enum_or_other,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_string, notify_enums,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic keyword_type_t key_kw = { "key", &cfg_type_astring };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark AndrewsLIBISCCFG_EXTERNAL_DATA cfg_type_t cfg_type_keyref = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "keyref", parse_keyvalue, print_keyvalue, doc_keyvalue,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_string, &key_kw
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_optional_keyref = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "optional_keyref", parse_optional_keyvalue, print_keyvalue,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews doc_optional_keyvalue, &cfg_rep_string, &key_kw
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
708383382ff1d3fdd27527e5d63120a3c6c6d3b3Francis Dupont
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * A "controls" statement is represented as a map with the multivalued
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * "inet" and "unix" clauses. Inet controls are tuples; unix controls
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * are cfg_unsupported_t objects.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic keyword_type_t controls_allow_kw = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "allow", &cfg_type_bracketed_aml };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_controls_allow = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "controls_allow", parse_keyvalue,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews print_keyvalue, doc_keyvalue,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_list, &controls_allow_kw
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic keyword_type_t controls_keys_kw = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "keys", &cfg_type_keylist };
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_controls_keys = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "controls_keys", parse_optional_keyvalue,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews print_keyvalue, doc_optional_keyvalue,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews &cfg_rep_list, &controls_keys_kw
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_tuplefielddef_t inetcontrol_fields[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "address", &cfg_type_controls_sockaddr, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "allow", &cfg_type_controls_allow, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "keys", &cfg_type_controls_keys, 0 },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { NULL, NULL, 0 }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_inetcontrol = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "inetcontrol", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews inetcontrol_fields
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_clausedef_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewscontrols_clauses[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "inet", &cfg_type_inetcontrol, CFG_CLAUSEFLAG_MULTI },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { "unix", &cfg_type_unsupported,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CFG_CLAUSEFLAG_MULTI|CFG_CLAUSEFLAG_NOTIMP },
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews { NULL, NULL, 0 }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_clausedef_t *
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewscontrols_clausesets[] = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews controls_clauses,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews NULL
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_controls = {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews "controls", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, &controls_clausesets
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews};
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * An optional class, as used in view and zone statements.
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews */
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_optional_class(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_result_t result;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews UNUSED(type);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_peektoken(pctx, 0));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (pctx->token.type == isc_tokentype_string)
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_parse_obj(pctx, &cfg_type_ustring, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews else
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_parse_obj(pctx, &cfg_type_void, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cleanup:
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews return (result);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews}
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic cfg_type_t cfg_type_optional_class = {
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews "optional_class", parse_optional_class, NULL, cfg_doc_terminal,
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews NULL, NULL
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellingtonstatic isc_result_t
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellingtonparse_querysource(cfg_parser_t *pctx, int flags, cfg_obj_t **ret) {
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington isc_result_t result;
216030f2849b0812910fbc1817ca17208a112663Mark Andrews cfg_obj_t *obj = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_netaddr_t netaddr;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews in_port_t port;
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington unsigned int have_address = 0;
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews unsigned int have_port = 0;
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if ((flags & CFG_ADDR_V4OK) != 0)
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington isc_netaddr_any(&netaddr);
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington else if ((flags & CFG_ADDR_V6OK) != 0)
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington isc_netaddr_any6(&netaddr);
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington else
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews INSIST(0);
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington
b0d31c78bc24080d4c470a8bd98862375f6e3055Mark Andrews port = 0;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington CHECK(cfg_create_obj(pctx, &cfg_type_querysource, &obj));
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington for (;;) {
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington CHECK(cfg_peektoken(pctx, 0));
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson if (pctx->token.type == isc_tokentype_string) {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington if (strcasecmp(TOKEN_STRING(pctx),
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews "address") == 0)
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews {
e2c3f8059e77a8e11c4378d22e5d8e78b423a28fMark Andrews /* read "address" */
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson CHECK(cfg_gettoken(pctx, 0));
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington CHECK(cfg_parse_rawaddr(pctx,
b0d31c78bc24080d4c470a8bd98862375f6e3055Mark Andrews flags | CFG_ADDR_WILDOK,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews &netaddr));
f15af68028adc665d3bdddf955fc52bad83f0514Brian Wellington have_address++;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else if (strcasecmp(TOKEN_STRING(pctx), "port") == 0)
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews /* read "port" */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_gettoken(pctx, 0));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_parse_rawport(pctx,
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington CFG_ADDR_WILDOK,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews &port));
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews have_port++;
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater } else {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews cfg_parser_error(pctx, CFG_LOG_NEAR,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews "expected 'address' or 'port'");
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington return (ISC_R_UNEXPECTEDTOKEN);
4e259c5a2321e994708fb1fe04cd4da30aa3b612Mark Andrews }
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews } else
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews break;
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews }
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater if (have_address > 1 || have_port > 1 ||
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews have_address + have_port == 0) {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews cfg_parser_error(pctx, 0, "expected one address and/or port");
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews return (ISC_R_UNEXPECTEDTOKEN);
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews }
1ea2595e1b33cc63ea73ee1d54b580b717d7d155Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews isc_sockaddr_fromnetaddr(&obj->value.sockaddr, &netaddr, port);
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews *ret = obj;
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews return (ISC_R_SUCCESS);
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews cleanup:
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews cfg_parser_error(pctx, CFG_LOG_NEAR, "invalid query source");
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews CLEANUP_OBJ(obj);
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews return (result);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews}
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsstatic isc_result_t
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrewsparse_querysource4(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews UNUSED(type);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (parse_querysource(pctx, CFG_ADDR_V4OK, ret));
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews}
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic isc_result_t
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsparse_querysource6(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews UNUSED(type);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews return (parse_querysource(pctx, CFG_ADDR_V6OK, ret));
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews}
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic void
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellingtonprint_querysource(cfg_printer_t *pctx, cfg_obj_t *obj) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews isc_netaddr_t na;
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington isc_netaddr_fromsockaddr(&na, &obj->value.sockaddr);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_print_chars(pctx, "address ", 8);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_print_rawaddr(pctx, &na);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington cfg_print_chars(pctx, " port ", 6);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington cfg_print_rawuint(pctx, isc_sockaddr_getport(&obj->value.sockaddr));
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington}
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellingtonstatic cfg_type_t cfg_type_querysource4 = {
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington "querysource4", parse_querysource4, NULL, cfg_doc_terminal,
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington NULL, NULL
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_querysource6 = {
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews "querysource6", parse_querysource6, NULL, cfg_doc_terminal,
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews NULL, NULL
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_querysource = {
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews "querysource", NULL, print_querysource, NULL, &cfg_rep_sockaddr, NULL };
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews/* addrmatchelt */
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic isc_result_t
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsparse_addrmatchelt(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews isc_result_t result;
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews UNUSED(type);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews if (pctx->token.type == isc_tokentype_string ||
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews pctx->token.type == isc_tokentype_qstring) {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews if (pctx->token.type == isc_tokentype_string &&
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews (strcasecmp(TOKEN_STRING(pctx), "key") == 0)) {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CHECK(cfg_parse_obj(pctx, &cfg_type_keyref, ret));
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews } else {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews if (cfg_lookingat_netaddr(pctx, CFG_ADDR_V4OK |
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CFG_ADDR_V4PREFIXOK |
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CFG_ADDR_V6OK))
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington CHECK(cfg_parse_netprefix(pctx, NULL, ret));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_parse_astring(pctx, NULL, ret));
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else if (pctx->token.type == isc_tokentype_special) {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews if (pctx->token.value.as_char == '{') {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews /* Nested match list. */
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CHECK(cfg_parse_obj(pctx, &cfg_type_bracketed_aml, ret));
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews } else if (pctx->token.value.as_char == '!') {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CHECK(cfg_gettoken(pctx, 0)); /* read "!" */
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CHECK(cfg_parse_obj(pctx, &cfg_type_negated, ret));
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews } else {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews goto bad;
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews }
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews } else {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews bad:
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews cfg_parser_error(pctx, CFG_LOG_NEAR,
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews "expected IP match list element");
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews return (ISC_R_UNEXPECTEDTOKEN);
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews }
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews cleanup:
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews return (result);
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews}
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews/*
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews * A negated address match list element (like "! 10.0.0.1").
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews * Somewhat sneakily, the caller is expected to parse the
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews * "!", but not to print it.
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews */
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrewsstatic cfg_tuplefielddef_t negated_fields[] = {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews { "value", &cfg_type_addrmatchelt, 0 },
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews { NULL, NULL, 0 }
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews};
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrewsstatic void
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrewsprint_negated(cfg_printer_t *pctx, cfg_obj_t *obj) {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews cfg_print_chars(pctx, "!", 1);
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews cfg_print_tuple(pctx, obj);
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews}
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrewsstatic cfg_type_t cfg_type_negated = {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews "negated", cfg_parse_tuple, print_negated, NULL, &cfg_rep_tuple,
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews &negated_fields
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews};
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews/* An address match list element */
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrewsstatic cfg_type_t cfg_type_addrmatchelt = {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews "address_match_element", parse_addrmatchelt, NULL, cfg_doc_terminal,
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews NULL, NULL
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater};
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews/* A bracketed address match list */
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrewsstatic cfg_type_t cfg_type_bracketed_aml = {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews "bracketed_aml", cfg_parse_bracketed_list, cfg_print_bracketed_list,
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews cfg_doc_bracketed_list, &cfg_rep_list, &cfg_type_addrmatchelt
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews};
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews/*
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews * The socket address syntax in the "controls" statement is silly.
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews * It allows both socket address families, but also allows "*",
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews * whis is gratuitously interpreted as the IPv4 wildcard address.
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews */
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrewsstatic unsigned int controls_sockaddr_flags =
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CFG_ADDR_V4OK | CFG_ADDR_V6OK | CFG_ADDR_WILDOK;
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrewsstatic cfg_type_t cfg_type_controls_sockaddr = {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews "controls_sockaddr", cfg_parse_sockaddr, cfg_print_sockaddr,
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews cfg_doc_sockaddr, &cfg_rep_sockaddr, &controls_sockaddr_flags
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews};
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews/*
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews * Handle the special kludge syntax of the "keys" clause in the "server"
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews * statement, which takes a single key with or without braces and semicolon.
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews */
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrewsstatic isc_result_t
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrewsparse_server_key_kludge(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews{
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews isc_result_t result;
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews isc_boolean_t braces = ISC_FALSE;
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews UNUSED(type);
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews /* Allow opening brace. */
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CHECK(cfg_peektoken(pctx, 0));
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews if (pctx->token.type == isc_tokentype_special &&
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews pctx->token.value.as_char == '{') {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews result = cfg_gettoken(pctx, 0);
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater braces = ISC_TRUE;
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater }
1bfe8851c0a2eb1d7e15556bfa21291cd62ee2bcMark Andrews
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater CHECK(cfg_parse_obj(pctx, &cfg_type_astring, ret));
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews if (braces) {
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews /* Skip semicolon if present. */
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CHECK(cfg_peektoken(pctx, 0));
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews if (pctx->token.type == isc_tokentype_special &&
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews pctx->token.value.as_char == ';')
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CHECK(cfg_gettoken(pctx, 0));
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews CHECK(cfg_parse_special(pctx, '}'));
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews }
6fac7ff1f9ec9c3873d3b55c5079fa79aba1f146Mark Andrews cleanup:
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (result);
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington}
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_server_key_kludge = {
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews "server_key", parse_server_key_kludge, NULL, cfg_doc_terminal,
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews NULL, NULL
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews/*
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews * An optional logging facility.
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews */
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic isc_result_t
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsparse_optional_facility(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews{
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_result_t result;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews UNUSED(type);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews if (pctx->token.type == isc_tokentype_string ||
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews pctx->token.type == isc_tokentype_qstring) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_parse_obj(pctx, &cfg_type_astring, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews } else {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews CHECK(cfg_parse_obj(pctx, &cfg_type_void, ret));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cleanup:
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (result);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews}
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_optional_facility = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "optional_facility", parse_optional_facility, NULL, cfg_doc_terminal,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews NULL, NULL };
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews/*
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington * A log severity. Return as a string, except "debug N",
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews * which is returned as a keyword object.
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews */
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic keyword_type_t debug_kw = { "debug", &cfg_type_uint32 };
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_debuglevel = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "debuglevel", parse_keyvalue,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews print_keyvalue, doc_keyvalue,
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington &cfg_rep_uint32, &debug_kw
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington};
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic isc_result_t
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsparse_logseverity(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews isc_result_t result;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews UNUSED(type);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_peektoken(pctx, 0));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (pctx->token.type == isc_tokentype_string &&
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews strcasecmp(TOKEN_STRING(pctx), "debug") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_gettoken(pctx, 0)); /* read "debug" */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_peektoken(pctx, ISC_LEXOPT_NUMBER));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (pctx->token.type == isc_tokentype_number) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_parse_uint32(pctx, NULL, ret));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else {
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington /*
613efcd8fbd0d1ce0d0afd1ac85d95cf85bffc27Brian Wellington * The debug level is optional and defaults to 1.
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews * This makes little sense, but we support it for
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews * compatibility with BIND 8.
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_create_obj(pctx, &cfg_type_uint32, ret));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews (*ret)->value.uint32 = 1;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews (*ret)->type = &cfg_type_debuglevel; /* XXX kludge */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else {
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington CHECK(cfg_parse_obj(pctx, &cfg_type_loglevel, ret));
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington }
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cleanup:
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (result);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews}
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_logseverity = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "log_severity", parse_logseverity, NULL, cfg_doc_terminal,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews NULL, NULL };
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews/*
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * The "file" clause of the "channel" statement.
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews * This is yet another special case.
5be3685b0e57677c0cc03113099cb8f99f9a070bMark Andrews */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellingtonstatic const char *logversions_enums[] = { "unlimited", NULL };
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellingtonstatic isc_result_t
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsparse_logversions(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson return (parse_enum_or_other(pctx, type, &cfg_type_uint32, ret));
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson}
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafssonstatic cfg_type_t cfg_type_logversions = {
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson "logversions", parse_logversions, cfg_print_ustring, cfg_doc_terminal,
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington &cfg_rep_string, logversions_enums
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson};
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrewsstatic cfg_tuplefielddef_t logfile_fields[] = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "file", &cfg_type_qstring, 0 },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "versions", &cfg_type_logversions, 0 },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "size", &cfg_type_size, 0 },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { NULL, NULL, 0 }
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews};
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellingtonstatic isc_result_t
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellingtonparse_logfile(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington isc_result_t result;
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington cfg_obj_t *obj = NULL;
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington const cfg_tuplefielddef_t *fields = type->of;
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington CHECK(cfg_create_tuple(pctx, type, &obj));
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley /* Parse the mandatory "file" field */
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley CHECK(cfg_parse_obj(pctx, fields[0].type, &obj->value.tuple[0]));
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
feb40fc5f911d0b2050fb9fd34950a52930b981dBrian Wellington /* Parse "versions" and "size" fields in any order. */
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley for (;;) {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley CHECK(cfg_peektoken(pctx, 0));
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley if (pctx->token.type == isc_tokentype_string) {
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence CHECK(cfg_gettoken(pctx, 0));
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley if (strcasecmp(TOKEN_STRING(pctx),
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "versions") == 0 &&
5c29047792191d6141f69b2684314d0b762fedebBrian Wellington obj->value.tuple[1] == NULL) {
5c29047792191d6141f69b2684314d0b762fedebBrian Wellington CHECK(cfg_parse_obj(pctx, fields[1].type,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley &obj->value.tuple[1]));
feb40fc5f911d0b2050fb9fd34950a52930b981dBrian Wellington } else if (strcasecmp(TOKEN_STRING(pctx),
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "size") == 0 &&
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley obj->value.tuple[2] == NULL) {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington CHECK(cfg_parse_obj(pctx, fields[2].type,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley &obj->value.tuple[2]));
63bf060be4ff2a7ade02fd86abb98694a5afc250Brian Wellington } else {
63bf060be4ff2a7ade02fd86abb98694a5afc250Brian Wellington break;
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington }
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington } else {
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington break;
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington }
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington }
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington /* Create void objects for missing optional values. */
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington if (obj->value.tuple[1] == NULL)
c50936eb40263b65ebf6afe4e6556e2dc67c10e4Brian Wellington CHECK(cfg_parse_void(pctx, NULL, &obj->value.tuple[1]));
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington if (obj->value.tuple[2] == NULL)
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley CHECK(cfg_parse_void(pctx, NULL, &obj->value.tuple[2]));
c50936eb40263b65ebf6afe4e6556e2dc67c10e4Brian Wellington
368b37b616234fce3d23099eb180f1dd38e1fb62Mark Andrews *ret = obj;
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley return (ISC_R_SUCCESS);
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley cleanup:
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley CLEANUP_OBJ(obj);
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley return (result);
feb40fc5f911d0b2050fb9fd34950a52930b981dBrian Wellington}
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington
c50936eb40263b65ebf6afe4e6556e2dc67c10e4Brian Wellingtonstatic void
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellingtonprint_logfile(cfg_printer_t *pctx, cfg_obj_t *obj) {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley cfg_print_obj(pctx, obj->value.tuple[0]); /* file */
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley if (obj->value.tuple[1]->type->print != cfg_print_void) {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley cfg_print_chars(pctx, " versions ", 10);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cfg_print_obj(pctx, obj->value.tuple[1]);
708383382ff1d3fdd27527e5d63120a3c6c6d3b3Francis Dupont }
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews if (obj->value.tuple[2]->type->print != cfg_print_void) {
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington cfg_print_chars(pctx, " size ", 6);
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews cfg_print_obj(pctx, obj->value.tuple[2]);
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley }
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉}
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic cfg_type_t cfg_type_logfile = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "log_file", parse_logfile, print_logfile, cfg_doc_terminal,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley &cfg_rep_tuple, logfile_fields
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington};
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington/* An IPv4/IPv6 address with optional port, "*" accepted as wildcard. */
3fb1637c9265cc593973326ae193783413f68699Tatuya JINMEI 神明達哉static unsigned int sockaddr4wild_flags = CFG_ADDR_WILDOK | CFG_ADDR_V4OK;
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic cfg_type_t cfg_type_sockaddr4wild = {
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington "sockaddr4wild", cfg_parse_sockaddr, cfg_print_sockaddr,
e407562a75eb93073bb72089cced150d7ffe4d4fTatuya JINMEI 神明達哉 cfg_doc_sockaddr, &cfg_rep_sockaddr, &sockaddr4wild_flags
a9ba7e65644c50e1549b38150ba8d4787e1fe643Brian Wellington};
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic unsigned int sockaddr6wild_flags = CFG_ADDR_WILDOK | CFG_ADDR_V6OK;
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic cfg_type_t cfg_type_sockaddr6wild = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "v6addrportwild", cfg_parse_sockaddr, cfg_print_sockaddr, cfg_doc_sockaddr,
78951552dccf0d0004d61072bbc71fa4b1aab30fAndreas Gustafsson &cfg_rep_sockaddr, &sockaddr6wild_flags
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
78951552dccf0d0004d61072bbc71fa4b1aab30fAndreas Gustafsson/*
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews * lwres
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews */
78951552dccf0d0004d61072bbc71fa4b1aab30fAndreas Gustafsson
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_tuplefielddef_t lwres_view_fields[] = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "name", &cfg_type_astring, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "class", &cfg_type_optional_class, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { NULL, NULL, 0 }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_lwres_view = {
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews "lwres_view", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, &cfg_rep_tuple,
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews lwres_view_fields
49960a74b5d82d000c281af09d7c668bdd1671a1Automatic Updater};
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrewsstatic cfg_type_t cfg_type_lwres_searchlist = {
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews "lwres_searchlist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews &cfg_rep_list, &cfg_type_astring };
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrewsstatic cfg_clausedef_t
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrewslwres_clauses[] = {
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews { "listen-on", &cfg_type_portiplist, 0 },
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews { "view", &cfg_type_lwres_view, 0 },
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews { "search", &cfg_type_lwres_searchlist, 0 },
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews { "ndots", &cfg_type_uint32, 0 },
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews { NULL, NULL, 0 }
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews};
50df1ec60af410fca6b7a85d5c85e8f31bb13bc3Mark Andrews
a9ba7e65644c50e1549b38150ba8d4787e1fe643Brian Wellingtonstatic cfg_clausedef_t *
a9ba7e65644c50e1549b38150ba8d4787e1fe643Brian Wellingtonlwres_clausesets[] = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley lwres_clauses,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley NULL
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley};
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrewsstatic cfg_type_t cfg_type_lwres = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "lwres", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, lwres_clausesets };
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley/*
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley * rndc
77c67dfb2607618f5e7940486daebafd42a502abBrian Wellington */
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic cfg_clausedef_t
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellingtonrndcconf_options_clauses[] = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "default-server", &cfg_type_astring, 0 },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "default-key", &cfg_type_astring, 0 },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "default-port", &cfg_type_uint32, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { NULL, NULL, 0 }
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_clausedef_t *
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsrndcconf_options_clausesets[] = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews rndcconf_options_clauses,
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington NULL
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington};
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic cfg_type_t cfg_type_rndcconf_options = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "rndcconf_options", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map,
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington rndcconf_options_clausesets
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington};
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellingtonstatic cfg_clausedef_t
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonrndcconf_server_clauses[] = {
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington { "key", &cfg_type_astring, 0 },
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington { "port", &cfg_type_uint32, 0 },
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington { NULL, NULL, 0 }
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington};
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellingtonstatic cfg_clausedef_t *
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellingtonrndcconf_server_clausesets[] = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley rndcconf_server_clauses,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley NULL
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley};
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonstatic cfg_type_t cfg_type_rndcconf_server = {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington "rndcconf_server", cfg_parse_named_map, cfg_print_map, cfg_doc_map, &cfg_rep_map,
77c67dfb2607618f5e7940486daebafd42a502abBrian Wellington rndcconf_server_clausesets
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley};
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic cfg_clausedef_t
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleyrndcconf_clauses[] = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "key", &cfg_type_key, CFG_CLAUSEFLAG_MULTI },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "server", &cfg_type_rndcconf_server, CFG_CLAUSEFLAG_MULTI },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { "options", &cfg_type_rndcconf_options, 0 },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { NULL, NULL, 0 }
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley};
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic cfg_clausedef_t *
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleyrndcconf_clausesets[] = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley rndcconf_clauses,
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews NULL
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian WellingtonLIBISCCFG_EXTERNAL_DATA cfg_type_t cfg_type_rndcconf = {
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington "rndcconf", cfg_parse_mapbody, cfg_print_mapbody, cfg_doc_mapbody,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley &cfg_rep_map, rndcconf_clausesets
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley};
1bfe8851c0a2eb1d7e15556bfa21291cd62ee2bcMark Andrews
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic cfg_clausedef_t
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellingtonrndckey_clauses[] = {
d6643ef587324e40d8bda63e9f80be8141e101edBrian Wellington { "key", &cfg_type_key, 0 },
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley { NULL, NULL, 0 }
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley};
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic cfg_clausedef_t *
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleyrndckey_clausesets[] = {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley rndckey_clauses,
77c67dfb2607618f5e7940486daebafd42a502abBrian Wellington NULL
77c67dfb2607618f5e7940486daebafd42a502abBrian Wellington};
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian WellingtonLIBISCCFG_EXTERNAL_DATA cfg_type_t cfg_type_rndckey = {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington "rndckey", cfg_parse_mapbody, cfg_print_mapbody, cfg_doc_mapbody,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley &cfg_rep_map, rndckey_clausesets
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley};
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic cfg_tuplefielddef_t nameport_fields[] = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { "name", &cfg_type_astring, 0 },
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews { "port", &cfg_type_optional_port, 0 },
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews { NULL, NULL, 0 }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic cfg_type_t cfg_type_nameport = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "nameport", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews &cfg_rep_tuple, nameport_fields
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic void
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellingtondoc_sockaddrnameport(cfg_printer_t *pctx, const cfg_type_t *type) {
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington UNUSED(type);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_print_chars(pctx, "( ", 2);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_print_cstr(pctx, "<quoted_string>");
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrews cfg_print_chars(pctx, " ", 1);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_print_cstr(pctx, "[port <integer>]");
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews cfg_print_chars(pctx, " | ", 3);
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews cfg_print_cstr(pctx, "<ipv4_address>");
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_print_chars(pctx, " ", 1);
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington cfg_print_cstr(pctx, "[port <integer>]");
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington cfg_print_chars(pctx, " | ", 3);
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington cfg_print_cstr(pctx, "<ipv6_address>");
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_print_chars(pctx, " ", 1);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_print_cstr(pctx, "[port <integer>]");
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews cfg_print_chars(pctx, " )", 2);
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington}
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellingtonstatic isc_result_t
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellingtonparse_sockaddrnameport(cfg_parser_t *pctx, const cfg_type_t *type,
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington cfg_obj_t **ret)
368b37b616234fce3d23099eb180f1dd38e1fb62Mark Andrews{
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews isc_result_t result;
f1263d2aa405087e74caf001cd443079f50ee903Mark Andrews cfg_obj_t *obj = NULL;
f1263d2aa405087e74caf001cd443079f50ee903Mark Andrews UNUSED(type);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (pctx->token.type == isc_tokentype_string ||
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews pctx->token.type == isc_tokentype_qstring) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (cfg_lookingat_netaddr(pctx, CFG_ADDR_V4OK | CFG_ADDR_V6OK))
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_parse_sockaddr(pctx, &cfg_type_sockaddr, ret));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews else {
f1263d2aa405087e74caf001cd443079f50ee903Mark Andrews const cfg_tuplefielddef_t *fields =
f1263d2aa405087e74caf001cd443079f50ee903Mark Andrews cfg_type_nameport.of;
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington CHECK(cfg_create_tuple(pctx, &cfg_type_nameport,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews &obj));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_parse_obj(pctx, fields[0].type,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews &obj->value.tuple[0]));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews CHECK(cfg_parse_obj(pctx, fields[1].type,
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington &obj->value.tuple[1]));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews *ret = obj;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews obj = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews } else {
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cfg_parser_error(pctx, CFG_LOG_NEAR,
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews "expected IP address or hostname");
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews return (ISC_R_UNEXPECTEDTOKEN);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews }
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cleanup:
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews CLEANUP_OBJ(obj);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews return (result);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews}
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrewsstatic cfg_type_t cfg_type_sockaddrnameport = {
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews "sockaddrnameport_element", parse_sockaddrnameport, NULL,
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews doc_sockaddrnameport, NULL, NULL
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrewsstatic cfg_type_t cfg_type_bracketed_sockaddrnameportlist = {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews "bracketed_sockaddrnameportlist", cfg_parse_bracketed_list,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_print_bracketed_list, cfg_doc_bracketed_list,
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews &cfg_rep_list, &cfg_type_sockaddrnameport
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews/*
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * A list of socket addresses or name with an optional default port,
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews * as used in the dual-stack-servers option. E.g.,
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews * "port 1234 { dual-stack-servers.net; 10.0.0.1; 1::2 port 69; }"
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews */
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrewsstatic cfg_tuplefielddef_t nameportiplist_fields[] = {
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews { "port", &cfg_type_optional_port, 0 },
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews { "addresses", &cfg_type_bracketed_sockaddrnameportlist, 0 },
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews { NULL, NULL, 0 }
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews};
cc7d91bd5c6b9be5a3c67a99112b885602c24873Mark Andrews
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrewsstatic cfg_type_t cfg_type_nameportiplist = {
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews "nameportiplist", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple,
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews &cfg_rep_tuple, nameportiplist_fields
fabf2ee6b01ee06a0de940b83d53cf57f9f79265Mark Andrews};
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews/*
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews * masters element.
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews */
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrews
35541328a8c18ba1f984300dfe30ec8713c90031Mark Andrewsstatic void
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsdoc_masterselement(cfg_printer_t *pctx, const cfg_type_t *type) {
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington UNUSED(type);
25496cebadd170fd5fae2aabf0469eef551259aaBrian Wellington cfg_print_chars(pctx, "( ", 2);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cfg_print_cstr(pctx, "<masters>");
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_print_chars(pctx, " | ", 3);
3ce4b8b03ebd017c1d1b320429219ba91e705ea4Andreas Gustafsson cfg_print_cstr(pctx, "<ipv4_address>");
3ce4b8b03ebd017c1d1b320429219ba91e705ea4Andreas Gustafsson cfg_print_chars(pctx, " ", 1);
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cfg_print_cstr(pctx, "[port <integer>]");
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cfg_print_chars(pctx, " | ", 3);
3ce4b8b03ebd017c1d1b320429219ba91e705ea4Andreas Gustafsson cfg_print_cstr(pctx, "<ipv6_address>");
60ab03125c137c48a6b2ed6df1d2c8657757e09dMark Andrews cfg_print_chars(pctx, " ", 1);
3ce4b8b03ebd017c1d1b320429219ba91e705ea4Andreas Gustafsson cfg_print_cstr(pctx, "[port <integer>]");
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington cfg_print_chars(pctx, " )", 2);
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley}
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic isc_result_t
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrewsparse_masterselement(cfg_parser_t *pctx, const cfg_type_t *type,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley cfg_obj_t **ret)
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley{
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley isc_result_t result;
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley cfg_obj_t *obj = NULL;
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley UNUSED(type);
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley CHECK(cfg_peektoken(pctx, CFG_LEXOPT_QSTRING));
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson if (pctx->token.type == isc_tokentype_string ||
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence pctx->token.type == isc_tokentype_qstring) {
78951552dccf0d0004d61072bbc71fa4b1aab30fAndreas Gustafsson if (cfg_lookingat_netaddr(pctx, CFG_ADDR_V4OK | CFG_ADDR_V6OK))
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence CHECK(cfg_parse_sockaddr(pctx, &cfg_type_sockaddr, ret));
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson else
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson CHECK(cfg_parse_astring(pctx, &cfg_type_astring, ret));
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson } else {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley cfg_parser_error(pctx, CFG_LOG_NEAR,
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley "expected IP address or masters name");
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson return (ISC_R_UNEXPECTEDTOKEN);
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson }
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson cleanup:
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson CLEANUP_OBJ(obj);
93c786e0924aeca2c258e32355349e6ae60a0f72Andreas Gustafsson return (result);
368b37b616234fce3d23099eb180f1dd38e1fb62Mark Andrews}
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellingtonstatic cfg_type_t cfg_type_masterselement = {
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington "masters_element", parse_masterselement, NULL,
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington doc_masterselement, NULL, NULL
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington};
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington