Commit fc2b2f8f authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3035] Added a function to return the number of labels in the FQDN.

parent 1d58f76d
......@@ -105,7 +105,6 @@ public:
template<typename T>
void addArrayDataField(const T value) {
checkArrayType();
OptionDataType data_type = definition_.getType();
if (OptionDataTypeTraits<T>::type != data_type) {
isc_throw(isc::dhcp::InvalidDataType,
......
......@@ -227,6 +227,16 @@ OptionDataTypeUtil::writeFqdn(const std::string& fqdn,
}
}
unsigned int
OptionDataTypeUtil::getLabelCount(const std::string& text_name) {
try {
isc::dns::Name name(text_name);
return (name.getLabelCount());
} catch (const isc::Exception& ex) {
isc_throw(BadDataTypeCast, ex.what());
}
}
std::string
OptionDataTypeUtil::readString(const std::vector<uint8_t>& buf) {
std::string value;
......
......@@ -375,6 +375,14 @@ public:
std::vector<uint8_t>& buf,
const bool downcase = false);
/// @brief Return the number of labels in the Name.
///
/// @param text_name A text representation of the name.
///
/// @return A number of labels in the provided name.
/// @throw isc::BadCast if provided name is malformed.
static unsigned int getLabelCount(const std::string& text_name);
/// @brief Read string value from a buffer.
///
/// @param buf input buffer.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment