1 // Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") 2 // 3 // This Source Code Form is subject to the terms of the Mozilla Public 4 // License, v. 2.0. If a copy of the MPL was not distributed with this 5 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 #include <cc/data.h> 8 #include <cc/stamped_value.h> 9 #include <dhcpsrv/parsers/dhcp_parsers.h> 10 #include <exceptions/exceptions.h> 11 12 #include <stdint.h> 13 #include <string> 14 15 #ifndef DHCP4_CONFIG_PARSER_H 16 #define DHCP4_CONFIG_PARSER_H 17 18 /// @todo: This header file and its .cc counterpart are very similar between 19 /// DHCPv4 and DHCPv6. They should be merged. A ticket #2355. 20 21 namespace isc { 22 namespace dhcp { 23 24 class Dhcpv4Srv; 25 26 /// @brief Configure DHCPv4 server (@c Dhcpv4Srv) with a set of configuration 27 /// values. 28 /// 29 /// This function parses configuration information stored in @c config_set 30 /// and configures the @c server by applying the configuration to it. 31 /// It provides the strong exception guarantee as long as the underlying 32 /// derived class implementations of @c DhcpConfigParser meet the assumption, 33 /// that is, it ensures that either configuration is fully applied or the 34 /// state of the server is intact. 35 /// 36 /// If a syntax or semantics level error happens during the configuration 37 /// (such as malformed configuration or invalid configuration parameter), 38 /// this function returns appropriate error code. 39 /// 40 /// This function is called every time a new configuration is received. The 41 /// extra parameter is a reference to DHCPv4 server component. It is currently 42 /// not used and CfgMgr::instance() is accessed instead. 43 /// 44 /// Test-only mode added. If check_only flag is set to true, the configuration 45 /// is parsed, but the actual change is not applied. The goal is to have 46 /// the ability to test configuration. 47 /// 48 /// This method does not throw. It catches all exceptions and returns them as 49 /// reconfiguration statuses. It may return the following response codes: 50 /// 0 - configuration successful 51 /// 1 - malformed configuration (parsing failed) 52 /// 2 - commit failed (parsing was successful, but failed to store the 53 /// values in to server's configuration) 54 /// 55 /// @param config_set a new configuration (JSON) for DHCPv4 server 56 /// @param check_only whether this configuration is for testing only 57 /// @return answer that contains result of reconfiguration 58 isc::data::ConstElementPtr 59 configureDhcp4Server(Dhcpv4Srv&, 60 isc::data::ConstElementPtr config_set, 61 bool check_only = false); 62 63 } // namespace dhcp 64 } // namespace isc 65 66 #endif // DHCP4_CONFIG_PARSER_H 67