BIND 10 trac3082, updated. cf24637df0959a2b68f2bde161790a73e3270abd [3082] Return instance of the Option4ClientFqdn for option 81.

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Aug 12 10:02:26 UTC 2013


The branch, trac3082 has been updated
       via  cf24637df0959a2b68f2bde161790a73e3270abd (commit)
       via  1596f2ccf2273eb5be25ff92ab196f9bd714c0c4 (commit)
      from  b2a59752080f1aa7dbcfd677c5bfb8f65239c4c1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cf24637df0959a2b68f2bde161790a73e3270abd
Author: Marcin Siodelski <marcin at isc.org>
Date:   Mon Aug 12 12:01:56 2013 +0200

    [3082] Return instance of the Option4ClientFqdn for option 81.

commit 1596f2ccf2273eb5be25ff92ab196f9bd714c0c4
Author: Marcin Siodelski <marcin at isc.org>
Date:   Mon Aug 12 11:10:12 2013 +0200

    [3082] Minor: editorial changes in the doxygen doc.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dhcp/option4_client_fqdn.cc      |    2 +-
 src/lib/dhcp/option4_client_fqdn.h       |   19 ++++++++++---------
 src/lib/dhcp/option_definition.cc        |   16 ++++++++++++++++
 src/lib/dhcp/option_definition.h         |   15 +++++++++++++++
 src/lib/dhcp/std_option_defs.h           |    3 ++-
 src/lib/dhcp/tests/libdhcp++_unittest.cc |    5 +++--
 6 files changed, 47 insertions(+), 13 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/option4_client_fqdn.cc b/src/lib/dhcp/option4_client_fqdn.cc
index 3e797d5..eb97522 100644
--- a/src/lib/dhcp/option4_client_fqdn.cc
+++ b/src/lib/dhcp/option4_client_fqdn.cc
@@ -237,7 +237,7 @@ Option4ClientFqdnImpl::parseASCIIDomainName(OptionBufferConstIter first,
         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)
diff --git a/src/lib/dhcp/option4_client_fqdn.h b/src/lib/dhcp/option4_client_fqdn.h
index 980706a..d16b47b 100644
--- a/src/lib/dhcp/option4_client_fqdn.h
+++ b/src/lib/dhcp/option4_client_fqdn.h
@@ -65,7 +65,7 @@ class Option4ClientFqdnImpl;
 /// where:
 /// - N flag specifies whether server should (0) or should not (1) perform DNS
 ///  Update,
-/// - E flag indicates encoding of the Domain Name field. If this flag is set to 1
+/// - E flag specifies encoding of the Domain Name field. If this flag is set to 1
 /// it indicates canonical wire format without compression. 0 indicates the deprecated
 /// ASCII format.
 /// - O flag is set by the server to indicate that it has overridden client's
@@ -79,17 +79,18 @@ class Option4ClientFqdnImpl;
 /// Domain names being carried by DHCPv4 Client Fqdn %Option can be fully
 /// qualified or partial. Partial domain names are encoded similar to the
 /// fully qualified domain names, except that they lack terminating zero
-/// at the end of their wire representation (or dot in case of ASCII encoding).
-/// It is also accepted to create an/ instance of this option which has empty
-/// domain-name. Clients use empty domain-names to indicate that server should
-/// generate complete fully qualified domain-name.
+/// at the end of their wire representation (or lack of dot at the end, in
+/// case of ASCII encoding). It is also accepted to create an instance of
+/// this option which has empty domain-name. Clients use empty domain-names
+/// to indicate that server should generate complete fully qualified domain-name.
 ///
 /// @warning: The RFC4702 section 2.3.1 states that the clients and servers
-/// should use character sets specified in RFC952, section 2.1. This class doesn't
-/// detect the character set violation for ASCII encoded domain-name. This could
-/// be implemented in the future but it is not important for two reasons:
+/// should use character sets specified in RFC952, section 2.1 for ASCII-encoded
+/// domain-names. This class doesn't detect the character set violation for
+/// ASCII-encoded domain-name. It could be implemented in the future but it is not
+/// important now for two reasons:
 /// - ASCII encoding is deprecated
-/// - clients SHOULD obey restrictions but if they don't server may still
+/// - clients SHOULD obey restrictions but if they don't, server may still
 ///   process the option
 ///
 /// RFC 4702 mandates that the DHCP client sets RCODE1 and RCODE2 to 0 and that
diff --git a/src/lib/dhcp/option_definition.cc b/src/lib/dhcp/option_definition.cc
index bf2c5fb..1b87bff 100644
--- a/src/lib/dhcp/option_definition.cc
+++ b/src/lib/dhcp/option_definition.cc
@@ -12,8 +12,10 @@
 // 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>
@@ -184,6 +186,10 @@ OptionDefinition::optionFactory(Option::Universe u, uint16_t type,
                     // 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)));
@@ -341,6 +347,16 @@ OptionDefinition::haveIAAddr6Format() const {
     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
diff --git a/src/lib/dhcp/option_definition.h b/src/lib/dhcp/option_definition.h
index dcfc3c7..0472d01 100644
--- a/src/lib/dhcp/option_definition.h
+++ b/src/lib/dhcp/option_definition.h
@@ -275,6 +275,21 @@ public:
     /// @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
diff --git a/src/lib/dhcp/std_option_defs.h b/src/lib/dhcp/std_option_defs.h
index 9bd19a1..00acdab 100644
--- a/src/lib/dhcp/std_option_defs.h
+++ b/src/lib/dhcp/std_option_defs.h
@@ -62,7 +62,8 @@ struct OptionDefParams {
 // 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[] = {
diff --git a/src/lib/dhcp/tests/libdhcp++_unittest.cc b/src/lib/dhcp/tests/libdhcp++_unittest.cc
index d523158..e4d723f 100644
--- a/src/lib/dhcp/tests/libdhcp++_unittest.cc
+++ b/src/lib/dhcp/tests/libdhcp++_unittest.cc
@@ -18,6 +18,7 @@
 #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>
@@ -733,8 +734,8 @@ TEST_F(LibDhcpTest, stdOptionDefs4) {
     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");



More information about the bind10-changes mailing list