15 const std::map<std::string, int>
16 CfgGlobals::nameToIndex = {
18 {
"valid-lifetime", VALID_LIFETIME },
19 {
"min-valid-lifetime", MIN_VALID_LIFETIME },
20 {
"max-valid-lifetime", MAX_VALID_LIFETIME },
21 {
"renew-timer", RENEW_TIMER },
22 {
"rebind-timer", REBIND_TIMER },
23 {
"decline-probation-period", DECLINE_PROBATION_PERIOD },
24 {
"dhcp4o6-port", DHCP4O6_PORT },
26 {
"server-tag", SERVER_TAG },
27 {
"reservation-mode", RESERVATION_MODE },
28 {
"reservations-global", RESERVATIONS_GLOBAL },
29 {
"reservations-in-subnet", RESERVATIONS_IN_SUBNET },
30 {
"reservations-out-of-pool", RESERVATIONS_OUT_OF_POOL },
31 {
"calculate-tee-times", CALCULATE_TEE_TIMES },
32 {
"t1-percent", T1_PERCENT },
33 {
"t2-percent", T2_PERCENT },
34 {
"hostname-char-set", HOSTNAME_CHAR_SET },
35 {
"hostname-char-replacement", HOSTNAME_CHAR_REPLACEMENT },
36 {
"ddns-send-updates", DDNS_SEND_UPDATES },
37 {
"ddns-override-no-update", DDNS_OVERRIDE_NO_UPDATE },
38 {
"ddns-override-client-update", DDNS_OVERRIDE_CLIENT_UPDATE },
39 {
"ddns-replace-client-name", DDNS_REPLACE_CLIENT_NAME },
40 {
"ddns-generated-prefix", DDNS_GENERATED_PREFIX },
41 {
"ddns-qualifying-suffix", DDNS_QUALIFYING_SUFFIX },
42 {
"store-extended-info", STORE_EXTENDED_INFO },
43 {
"statistic-default-sample-count", STATISTIC_DEFAULT_SAMPLE_COUNT },
44 {
"statistic-default-sample-age", STATISTIC_DEFAULT_SAMPLE_AGE },
45 {
"cache-threshold", CACHE_THRESHOLD },
46 {
"cache-max-age", CACHE_MAX_AGE },
47 {
"early-global-reservations-lookup", EARLY_GLOBAL_RESERVATIONS_LOOKUP },
48 {
"ip-reservations-unique", IP_RESERVATIONS_UNIQUE },
49 {
"reservations-lookup-first", RESERVATIONS_LOOKUP_FIRST },
50 {
"ddns-update-on-renew", DDNS_UPDATE_ON_RENEW },
51 {
"ddns-use-conflict-resolution", DDNS_USE_CONFLICT_RESOLUTION },
52 {
"parked-packet-limit", PARKED_PACKET_LIMIT },
53 {
"allocator", ALLOCATOR },
56 {
"echo-client-id", ECHO_CLIENT_ID },
57 {
"match-client-id", MATCH_CLIENT_ID },
58 {
"authoritative", AUTHORITATIVE },
59 {
"next-server", NEXT_SERVER },
60 {
"server-hostname", SERVER_HOSTNAME },
61 {
"boot-file-name", BOOT_FILE_NAME },
64 {
"data-directory", DATA_DIRECTORY },
65 {
"preferred-lifetime", PREFERRED_LIFETIME },
66 {
"min-preferred-lifetime", MIN_PREFERRED_LIFETIME },
67 {
"max-preferred-lifetime", MAX_PREFERRED_LIFETIME },
68 {
"pd-allocator", PD_ALLOCATOR }
73 struct CfgGlobalsChecks {
76 if (CfgGlobals::nameToIndex.size() != CfgGlobals::SIZE) {
77 isc_throw(Unexpected,
"CfgGlobals::nameToIndex has " 78 << CfgGlobals::nameToIndex.size()
79 <<
" elements (expected " << CfgGlobals::SIZE <<
")");
83 std::vector<std::string> names;
84 names.resize(CfgGlobals::SIZE);
85 for (
auto it = CfgGlobals::nameToIndex.cbegin();
86 it != CfgGlobals::nameToIndex.cend(); ++it) {
88 if ((idx < 0) || (idx >= CfgGlobals::SIZE)) {
89 isc_throw(Unexpected,
"invalid index " << idx
90 <<
" for name " << it->first);
92 if (!names[idx].empty()) {
93 isc_throw(Unexpected,
"duplicated names for " << idx
94 <<
" got " << names[idx]);
96 names[idx] = it->first;
100 for (
int idx = 0; idx < CfgGlobals::SIZE; ++idx) {
101 if (names[idx].empty()) {
102 isc_throw(Unexpected,
"missing name for " << idx);
108 CfgGlobalsChecks check;
111 CfgGlobals::CfgGlobals() : values_(SIZE) {
120 return (
get(it->second));
137 set(it->second, value);
161 int idx = it->second;
164 map.insert(make_pair(it->first, value));
174 int idx = it->second;
177 result->set(it->first, value);
static const std::map< std::string, int > nameToIndex
Name to index map.
boost::shared_ptr< Element > ElementPtr
std::vector< isc::data::ConstElementPtr > values_
Vectors of values.
std::map< std::string, isc::data::ConstElementPtr > MapType
Type of name and value map.
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
const MapType valuesMap() const
Returns configured parameters as a map.
boost::shared_ptr< const Element > ConstElementPtr
void clear()
Clear configured parameter values.
Defines the logger used by the top-level component of kea-lfc.
void set(const std::string &name, isc::data::ConstElementPtr value)
Set a configured parameter value by name.
isc::data::ConstElementPtr get(const std::string &name) const
Get a configured parameter value by name.
A generic exception that is thrown if a parameter given to a method would refer to or modify out-of-r...
A generic exception that is thrown when an object can not be found.
isc::data::ElementPtr toElement() const
Unparse configured global parameters.