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
// Copyright (C) 2018-2024 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/.

#include <config.h>

#include <cc/dhcp_config_error.h>
#include <process/config_ctl_parser.h>
#include <database/dbaccess_parser.h>
#include <cstdint><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <string><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

using namespace isc;
using namespace isc::data;

namespace isc {
namespace process {

ConfigControlInfoPtr
ConfigControlParser::parse(const data::ConstElementPtr& config_control) {
    ConfigControlInfoPtr ctl_info(new ConfigControlInfo());

    try {
        if (config_control->contains("config-databases")) {

            auto elem = config_control->get("config-databases");
            if (elem->getType() != Element::list) {
                isc_throw (ConfigError, "config-databases must be a list ("
                           << elem->getPosition() << ")");
            }

            const std::vector<data::ElementPtr>& db_list = elem->listValue();
            for (auto const& db : db_list) {
                db::DbAccessParser parser;
                std::string access_string;
                parser.parse(access_string, db);
                /// @todo do we still need access_string for this at all?
                /// can't we just use params directly and get rid of the
                /// string now that DatabaseConnection::toElement(map) exists?
                ctl_info->addConfigDatabase(access_string);
            }
        }

        if (config_control->contains("config-fetch-wait-time")) {
            auto config_fetch_wait_time = getInteger(config_control,
                                                     "config-fetch-wait-time",
                                                     0, 65535);
            ctl_info->setConfigFetchWaitTime(static_cast<uint16_t>(config_fetch_wait_time));
        }

    } catch (const isc::ConfigError&) {
        // Position was already added
        throw;
    } catch (const std::exception& ex) {
        isc_throw(ConfigError, ex.what() << " ("
                  << config_control->getPosition() << ")");
    }

    return (ctl_info);
}

} // end of namespace isc::process
} // end of namespace isc