mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 06:25:34 +00:00
[#3141] config parsers boilerplate
This commit is contained in:
@@ -48,6 +48,11 @@ Option4Dnr::pack(OutputBuffer& buf, bool check) const {
|
|||||||
|
|
||||||
void
|
void
|
||||||
Option4Dnr::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
|
Option4Dnr::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
|
||||||
|
if (convenient_notation_) {
|
||||||
|
// parse convenient notation
|
||||||
|
std::string config_txt = std::string(begin, end);
|
||||||
|
parseConfigData(config_txt);
|
||||||
|
} else {
|
||||||
setData(begin, end);
|
setData(begin, end);
|
||||||
while (begin != end) {
|
while (begin != end) {
|
||||||
DnrInstance dnr_instance(V4);
|
DnrInstance dnr_instance(V4);
|
||||||
@@ -85,6 +90,7 @@ Option4Dnr::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
|
|||||||
|
|
||||||
addDnrInstance(dnr_instance);
|
addDnrInstance(dnr_instance);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
@@ -119,6 +125,11 @@ Option4Dnr::addDnrInstance(DnrInstance& dnr_instance) {
|
|||||||
dnr_instances_.push_back(dnr_instance);
|
dnr_instances_.push_back(dnr_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Option4Dnr::parseConfigData(const std::string& config_txt) {
|
||||||
|
// TBD
|
||||||
|
}
|
||||||
|
|
||||||
const std::unordered_set<std::string> DnrInstance::FORBIDDEN_SVC_PARAMS = {"ipv4hint", "ipv6hint"};
|
const std::unordered_set<std::string> DnrInstance::FORBIDDEN_SVC_PARAMS = {"ipv4hint", "ipv6hint"};
|
||||||
|
|
||||||
DnrInstance::DnrInstance(Option::Universe universe)
|
DnrInstance::DnrInstance(Option::Universe universe)
|
||||||
|
@@ -546,6 +546,17 @@ private:
|
|||||||
/// @brief Flag stating whether the %Option was constructed with a convenient notation string,
|
/// @brief Flag stating whether the %Option was constructed with a convenient notation string,
|
||||||
/// that needs custom parsing, or binary data.
|
/// that needs custom parsing, or binary data.
|
||||||
bool convenient_notation_;
|
bool convenient_notation_;
|
||||||
|
|
||||||
|
/// @brief Parses a convenient notation of the option data, which may be used in config.
|
||||||
|
///
|
||||||
|
/// As an alternative to the binary format,
|
||||||
|
/// we provide convenience option definition as a string in format:
|
||||||
|
/// TBD
|
||||||
|
///
|
||||||
|
/// @param config_txt convenient notation of the option data received as string
|
||||||
|
///
|
||||||
|
/// @throw BadValue Thrown in case parser found wrong format of received string.
|
||||||
|
void parseConfigData(const std::string& config_txt);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A pointer to the @c OptionDnr4 object.
|
/// A pointer to the @c OptionDnr4 object.
|
||||||
|
@@ -55,6 +55,11 @@ Option6Dnr::packAddresses(util::OutputBuffer& buf) const {
|
|||||||
|
|
||||||
void
|
void
|
||||||
Option6Dnr::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
|
Option6Dnr::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
|
||||||
|
if (convenient_notation_) {
|
||||||
|
// parse convenient notation
|
||||||
|
std::string config_txt = std::string(begin, end);
|
||||||
|
parseConfigData(config_txt);
|
||||||
|
} else {
|
||||||
if (std::distance(begin, end) < getMinimalLength()) {
|
if (std::distance(begin, end) < getMinimalLength()) {
|
||||||
isc_throw(OutOfRange, getLogPrefix()
|
isc_throw(OutOfRange, getLogPrefix()
|
||||||
<< "data truncated to size " << std::distance(begin, end));
|
<< "data truncated to size " << std::distance(begin, end));
|
||||||
@@ -80,6 +85,7 @@ Option6Dnr::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) {
|
|||||||
|
|
||||||
// SvcParams (variable length) field is last.
|
// SvcParams (variable length) field is last.
|
||||||
unpackSvcParams(begin, end);
|
unpackSvcParams(begin, end);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
@@ -143,5 +149,10 @@ Option6Dnr::unpackAddresses(OptionBufferConstIter& begin, OptionBufferConstIter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Option6Dnr::parseConfigData(const std::string& config_txt){
|
||||||
|
// TBD
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dhcp
|
} // namespace dhcp
|
||||||
} // namespace isc
|
} // namespace isc
|
||||||
|
@@ -146,6 +146,17 @@ private:
|
|||||||
/// @brief Flag stating whether the %Option was constructed with a convenient notation string,
|
/// @brief Flag stating whether the %Option was constructed with a convenient notation string,
|
||||||
/// that needs custom parsing, or binary data.
|
/// that needs custom parsing, or binary data.
|
||||||
bool convenient_notation_;
|
bool convenient_notation_;
|
||||||
|
|
||||||
|
/// @brief Parses a convenient notation of the option data, which may be used in config.
|
||||||
|
///
|
||||||
|
/// As an alternative to the binary format,
|
||||||
|
/// we provide convenience option definition as a string in format:
|
||||||
|
/// TBD
|
||||||
|
///
|
||||||
|
/// @param config_txt convenient notation of the option data received as string
|
||||||
|
///
|
||||||
|
/// @throw BadValue Thrown in case parser found wrong format of received string.
|
||||||
|
void parseConfigData(const std::string& config_txt);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A pointer to the @c Option6Dnr object.
|
/// A pointer to the @c Option6Dnr object.
|
||||||
|
Reference in New Issue
Block a user