Browse Source

[3036] Added function which creates an on-wire format of the domain-name.

Marcin Siodelski 11 years ago
parent
commit
b74b04e194
2 changed files with 23 additions and 12 deletions
  1. 16 12
      src/lib/dhcp/option6_client_fqdn.cc
  2. 7 0
      src/lib/dhcp/option6_client_fqdn.h

+ 16 - 12
src/lib/dhcp/option6_client_fqdn.cc

@@ -280,6 +280,20 @@ Option6ClientFqdn::getDomainName() const {
 }
 
 void
+Option6ClientFqdn::packDomainName(isc::util::OutputBuffer& buf) const {
+    // Domain name, encoded as a set of labels.
+    isc::dns::LabelSequence labels(*impl_->domain_name_);
+    if (labels.getDataLength() > 0) {
+        size_t read_len = 0;
+        const uint8_t* data = labels.getData(&read_len);
+        if (impl_->domain_name_type_ == PARTIAL) {
+            --read_len;
+        }
+        buf.writeData(data, read_len);
+    }
+}
+
+void
 Option6ClientFqdn::setDomainName(const std::string& domain_name,
                                  const DomainNameType domain_name_type) {
     impl_->setDomainName(domain_name, domain_name_type);
@@ -301,18 +315,8 @@ Option6ClientFqdn::pack(isc::util::OutputBuffer& buf) {
     packHeader(buf);
     // Flags field.
     buf.writeUint8(impl_->flags_);
-    // Domain name, encoded as a set of labels.
-    isc::dns::LabelSequence labels(*impl_->domain_name_);
-    if (labels.getDataLength() > 0) {
-        size_t read_len = 0;
-        const uint8_t* data = labels.getData(&read_len);
-        if (impl_->domain_name_type_ == PARTIAL) {
-            --read_len;
-        }
-        buf.writeData(data, read_len);
-    }
-
-
+    // Domain name.
+    packDomainName(buf);
 }
 
 void

+ 7 - 0
src/lib/dhcp/option6_client_fqdn.h

@@ -182,6 +182,13 @@ public:
     /// @return domain-name in the text format.
     std::string getDomainName() const;
 
+    /// @brief Writes domain-name in the wire format into a buffer.
+    ///
+    /// The data being written are appended at the end of the buffer.
+    ///
+    /// @param [out] buf buffer where domain-name will be written.
+    void packDomainName(isc::util::OutputBuffer& buf) const;
+
     /// @brief Set new domain-name.
     ///
     /// @param domain_name domain name field value in the text format.