2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[#521,!270] Addressed review comments.

This commit is contained in:
Marcin Siodelski
2019-03-11 14:57:58 +01:00
parent a810e0bc74
commit 8edf2fb253
2 changed files with 15 additions and 7 deletions

View File

@@ -602,17 +602,21 @@ MySqlConfigBackendImpl::processOptionRow(const Option::Universe& universe,
code = (*(first_binding + 1))->getInteger<uint16_t>(); code = (*(first_binding + 1))->getInteger<uint16_t>();
} }
// Option can be stored as a blob or formatted value in the configuration.
std::vector<uint8_t> blob;
if (!(*(first_binding + 2))->amNull()) {
blob = (*(first_binding + 2))->getBlob();
}
OptionBuffer buf(blob.begin(), blob.end());
// Get formatted value if available. // Get formatted value if available.
std::string formatted_value = (*(first_binding + 3))->getStringOrDefault(""); std::string formatted_value = (*(first_binding + 3))->getStringOrDefault("");
OptionPtr option(new Option(universe, code, buf.begin(), buf.end())); OptionPtr option(new Option(universe, code));
// If we don't have a formatted value, check for a blob. Add it to the
// option if it exists.
if (formatted_value.empty()) {
std::vector<uint8_t> blob;
if (!(*(first_binding + 2))->amNull()) {
blob = (*(first_binding + 2))->getBlob();
}
option->setData(blob.begin(), blob.end());
}
// Check if the option is persistent. // Check if the option is persistent.
bool persistent = static_cast<bool>((*(first_binding + 5))->getIntegerOrDefault<uint8_t>(0)); bool persistent = static_cast<bool>((*(first_binding + 5))->getIntegerOrDefault<uint8_t>(0));

View File

@@ -84,6 +84,10 @@ GenericBackendTest::testOptionsEquivalent(const OptionDescriptor& ref_option,
// Compare the on-wire data. // Compare the on-wire data.
EXPECT_EQ(ref_option_buf_vec, tested_option_buf_vec); EXPECT_EQ(ref_option_buf_vec, tested_option_buf_vec);
} else {
// If the formatted value is non-empty the buffer should be empty.
EXPECT_TRUE(tested_option.option_->getData().empty());
} }
// Compare other members of the @c OptionDescriptor, e.g. the // Compare other members of the @c OptionDescriptor, e.g. the