summaryrefslogtreecommitdiffstats
path: root/src/lib/d2srv/d2_simple_parser.h
blob: 49f0d8a4ba1e7cf94c0473ef6d314a96d4344a25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (C) 2017-2021 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef D2_SIMPLE_PARSER_H
#define D2_SIMPLE_PARSER_H

#include <cc/simple_parser.h>
#include <d2srv/d2_cfg_mgr.h>

namespace isc {
namespace d2 {

/// @brief SimpleParser specialized for D2
///
/// This class is a @ref isc::data::SimpleParser dedicated to D2.
/// In particular, it contains all the default values and names of the
/// parameters that are to be derived (inherited) between scopes.
/// For the actual values, see @file d2_simple_parser.cc
class D2SimpleParser : public data::SimpleParser {
public:

    /// @brief Sets all defaults for D2 configuration
    ///
    /// This method sets global and element defaults.
    ///
    /// @param global scope to be filled in with defaults.
    /// @return number of default values added
    static size_t setAllDefaults(data::ElementPtr global);

    // see d2_simple_parser.cc for comments for those parameters
    static const data::SimpleDefaults D2_GLOBAL_DEFAULTS;

    // Defaults for tsig-keys list elements, TSIGKeyInfos
    static const data::SimpleDefaults TSIG_KEY_DEFAULTS;

    // Defaults for <forward|reverse>-ddns elements, DdnsDomainListMgrs
    static const data::SimpleDefaults DDNS_DOMAIN_MGR_DEFAULTS;

    // Defaults for ddns-domains list elements, DdnsDomains
    static const data::SimpleDefaults DDNS_DOMAIN_DEFAULTS;

    // Defaults for dns-servers list elements, DnsServerInfos
    static const data::SimpleDefaults DNS_SERVER_DEFAULTS;

    /// @brief Adds default values to a DDNS Domain element
    ///
    /// Adds the scalar default values to the given DDNS domain
    /// element, and then adds the DNS Server defaults to the domain's
    /// server list, "dns-servers".
    ///
    /// @param domain DDNS domain element to which defaults should be added
    /// @param domain_defaults list of default values from which to add
    /// @return returns the number of default values added
    static size_t setDdnsDomainDefaults(data::ElementPtr domain,
                                        const data::SimpleDefaults&
                                        domain_defaults);

    /// @brief Adds default values to a DDNS Domain List Manager
    ///
    /// This function looks for the named DDNS domain manager element within
    /// the given element tree.  If it is found, it adds the scalar default
    /// values to the manager element and then adds the DDNS Domain defaults
    /// to its domain list, "ddns-domains".  If the manager element is not
    /// found, then an empty map entry is added for it, thus defaulting the
    /// manager to "disabled".
    ///
    /// @param global element tree containing the DDNS domain manager element
    /// to which defaults should be
    /// added
    /// @param mgr_name name of the manager element within the element tree
    /// (e.g. "forward-ddns", "reverse-ddns")
    /// @param mgr_defaults list of default values from which to add
    /// @return returns the number of default values added
    static size_t setManagerDefaults(data::ElementPtr global,
                                     const std::string& mgr_name,
                                     const data::SimpleDefaults& mgr_defaults);

    /// @brief Parses the whole D2 configuration
    ///
    /// @param ctx - parsed information will be stored here
    /// @param config - Element tree structure that holds configuration
    /// @param check_only - if true the configuration is verified only, not applied
    ///
    /// @throw ConfigError if any issues are encountered.
    void parse(const D2CfgContextPtr& ctx,
               const isc::data::ConstElementPtr& config,
               bool check_only);
};

};
};

#endif