From: Piotrek Zadroga Date: Wed, 19 Apr 2023 14:04:42 +0000 (+0200) Subject: [#2536] Changing nits X-Git-Tag: Kea-2.3.8~173 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26dc6077fcb5b15869f75e90cb3c169a0e28fe3c;p=thirdparty%2Fkea.git [#2536] Changing nits --- diff --git a/src/lib/dhcp/option4_dnr.cc b/src/lib/dhcp/option4_dnr.cc index d1c4232f6d..f517273d05 100644 --- a/src/lib/dhcp/option4_dnr.cc +++ b/src/lib/dhcp/option4_dnr.cc @@ -151,13 +151,13 @@ Option4Dnr::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) { std::string Option4Dnr::toText(int indent) const { std::ostringstream stream; - std::string in(indent, ' '); // base indentation - stream << in << "type=" << type_ << "(V4_DNR), " + std::string in(indent, ' '); // base indentation + stream << in << "type=" << type_ << "(V4_DNR), " << "len=" << (len() - getHeaderLen()); int i = 0; - for(const DnrInstance& dnr_instance : dnr_instances_) { - stream << ", DNR Instance " << ++i << "(Instance len=" - << dnr_instance.getDnrInstanceDataLength() << ", " + for (const DnrInstance& dnr_instance : dnr_instances_) { + stream << ", DNR Instance " << ++i + << "(Instance len=" << dnr_instance.getDnrInstanceDataLength() << ", " << dnr_instance.getDnrInstanceAsText() << ")"; } return (stream.str()); @@ -167,7 +167,8 @@ uint16_t Option4Dnr::len() const { uint16_t len = OPTION4_HDR_LEN; for (const DnrInstance& dnr_instance : dnr_instances_) { - len += dnr_instance.getDnrInstanceDataLength() + dnr_instance.getDnrInstanceDataLengthSize(); + len += dnr_instance.getDnrInstanceDataLength() + + dnr_instance.getDnrInstanceDataLengthSize(); } return (len); } @@ -177,6 +178,24 @@ Option4Dnr::addDnrInstance(DnrInstance& dnr_instance) { dnr_instances_.push_back(dnr_instance); } +DnrInstance::DnrInstance(Option::Universe universe, + const uint16_t service_priority, + const std::string& adn, + const DnrInstance::AddressContainer& ip_addresses, + const std::string& svc_params) + : universe_(universe), service_priority_(service_priority), ip_addresses_(ip_addresses), + svc_params_(svc_params) { + setAdn(adn); + checkFields(); +} + +DnrInstance::DnrInstance(Option::Universe universe, + const uint16_t service_priority, + const std::string& adn) + : universe_(universe), service_priority_(service_priority) { + setAdn(adn); +} + void DnrInstance::packAdn(util::OutputBuffer& buf) const { if (!adn_) { @@ -321,7 +340,8 @@ DnrInstance::checkSvcParams(bool from_wire_data) { } if (key_val.size() == 2) { - // tbd Check value syntax + // For now we skip Check of value syntax. + // This is up to customer to configure this correctly. std::string value = key_val[1]; } } @@ -347,13 +367,12 @@ DnrInstance::checkFields() { } adn_only_mode_ = false; const uint8_t addr_field_len = (universe_ == Option::V4) ? V4ADDRESS_LEN : V6ADDRESS_LEN; - const uint16_t max_addr_len = (universe_ == Option::V4) - ? std::numeric_limits::max() - : std::numeric_limits::max(); + const uint16_t max_addr_len = (universe_ == Option::V4) ? std::numeric_limits::max() : + std::numeric_limits::max(); auto addr_len = ip_addresses_.size() * addr_field_len; if (addr_len > max_addr_len) { - isc_throw(OutOfRange, - "Given IP addresses length " << addr_len << " is bigger than MAX " << max_addr_len); + isc_throw(OutOfRange, "Given IP addresses length " << addr_len << " is bigger than MAX " + << max_addr_len); } addr_length_ = addr_len; if (universe_ == Option::V4) { @@ -368,29 +387,11 @@ DnrInstance::getLogPrefix() const { ("DHCPv6 Encrypted DNS Option (" + std::to_string(D6O_V6_DNR) + ")"); } -DnrInstance::DnrInstance(Option::Universe universe, - const uint16_t service_priority, - const std::string& adn, - const DnrInstance::AddressContainer& ip_addresses, - const std::string& svc_params) - : universe_(universe), service_priority_(service_priority), - ip_addresses_(ip_addresses), svc_params_(svc_params) { - setAdn(adn); - checkFields(); -} - -DnrInstance::DnrInstance(Option::Universe universe, - const uint16_t service_priority, - const std::string& adn) - : universe_(universe), service_priority_(service_priority){ - setAdn(adn); -} - std::string DnrInstance::getDnrInstanceAsText() const { - std::string text = "service_priority=" + std::to_string(service_priority_) + ", " - + "adn_length=" + std::to_string(adn_length_) + ", " - + "adn='" + getAdnAsText() + "'"; + std::string text = "service_priority=" + std::to_string(service_priority_) + ", " + + "adn_length=" + std::to_string(adn_length_) + ", " + "adn='" + + getAdnAsText() + "'"; if (!adn_only_mode_) { text += ", addr_length=" + std::to_string(addr_length_) + ", address(es):"; for (const auto& address : ip_addresses_) { diff --git a/src/lib/dhcp/option6_dnr.cc b/src/lib/dhcp/option6_dnr.cc index 77bcd19d85..8dfbac510d 100644 --- a/src/lib/dhcp/option6_dnr.cc +++ b/src/lib/dhcp/option6_dnr.cc @@ -141,8 +141,8 @@ Option6Dnr::unpack(OptionBufferConstIter begin, OptionBufferConstIter end) { std::string Option6Dnr::toText(int indent) const { std::ostringstream stream; - std::string in(indent, ' '); // base indentation - stream << in << "type=" << type_ << "(V6_DNR), " + std::string in(indent, ' '); // base indentation + stream << in << "type=" << type_ << "(V6_DNR), " << "len=" << (len() - getHeaderLen()) << ", " << getDnrInstanceAsText(); return (stream.str()); }