domain_name_.reset(new isc::dns::Name(domain_name));
domain_name_type_ = domain_name[domain_name.length() - 1] == '.' ?
Option4ClientFqdn::FULL : Option4ClientFqdn::PARTIAL;
- }
+ }
}
Option4ClientFqdn::Option4ClientFqdn(const uint8_t flag, const Rcode& rcode)
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
+#include <dhcp/dhcp4.h>
#include <dhcp/dhcp6.h>
#include <dhcp/option4_addrlst.h>
+#include <dhcp/option4_client_fqdn.h>
#include <dhcp/option6_addrlst.h>
#include <dhcp/option6_ia.h>
#include <dhcp/option6_iaaddr.h>
// for IA_NA and IA_PD above.
return (factoryIAAddr6(type, begin, end));
}
+ } else {
+ if ((code_ == DHO_FQDN) && haveFqdn4Format()) {
+ return (OptionPtr(new Option4ClientFqdn(begin, end)));
+ }
}
}
return (OptionPtr(new OptionCustom(*this, u, begin, end)));
return (haveIAx6Format(OPT_IPV6_ADDRESS_TYPE));
}
+bool
+OptionDefinition::haveFqdn4Format() const {
+ return (haveType(OPT_RECORD_TYPE) &&
+ record_fields_.size() == 4 &&
+ record_fields_[0] == OPT_UINT8_TYPE &&
+ record_fields_[1] == OPT_UINT8_TYPE &&
+ record_fields_[2] == OPT_UINT8_TYPE &&
+ record_fields_[3] == OPT_FQDN_TYPE);
+}
+
template<typename T>
T OptionDefinition::lexicalCastWithRangeCheck(const std::string& value_str) const {
// Lexical cast in case of our data types make sense only
/// @return true if specified format is IAADDR option format.
bool haveIAAddr6Format() const;
+ /// @brief Check if option has format of the DHCPv4 Client FQDN
+ /// %Option.
+ ///
+ /// The encoding of the domain-name carried by the FQDN option is
+ /// conditional and is specified in the flags field of the option.
+ /// The domain-name can be encoded in the ASCII format or canonical
+ /// wire format. The ASCII format is deprecated, therefore canonical
+ /// format is selected for the FQDN option definition and this function
+ /// returns true if the option definition comprises the domain-name
+ /// field encoded in canonical format.
+ ///
+ /// @return true if option has the format of DHCPv4 Client FQDN
+ /// %Option.
+ bool haveFqdn4Format() const;
+
/// @brief Option factory.
///
/// This function creates an instance of DHCP option using
// RFC 1035, section 3.1. The latter could be handled
// by OPT_FQDN_TYPE but we can't use it here because
// clients may request ASCII encoding.
-RECORD_DECL(FQDN_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_STRING_TYPE);
+RECORD_DECL(FQDN_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_UINT8_TYPE,
+ OPT_FQDN_TYPE);
/// @brief Definitions of standard DHCPv4 options.
const OptionDefParams OPTION_DEF_PARAMS4[] = {
#include <dhcp/dhcp6.h>
#include <dhcp/libdhcp++.h>
#include <dhcp/option4_addrlst.h>
+#include <dhcp/option4_client_fqdn.h>
#include <dhcp/option6_addrlst.h>
#include <dhcp/option6_ia.h>
#include <dhcp/option6_iaaddr.h>
LibDhcpTest::testStdOptionDefs4(DHO_USER_CLASS, begin, end,
typeid(Option));
- LibDhcpTest::testStdOptionDefs4(DHO_FQDN, begin, end,
- typeid(OptionCustom));
+ LibDhcpTest::testStdOptionDefs4(DHO_FQDN, begin, begin + 3,
+ typeid(Option4ClientFqdn));
LibDhcpTest::testStdOptionDefs4(DHO_DHCP_AGENT_OPTIONS, begin, end,
typeid(Option), "dhcp-agent-options-space");