]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3036] Added function which creates an on-wire format of the domain-name.
authorMarcin Siodelski <marcin@isc.org>
Tue, 23 Jul 2013 19:53:45 +0000 (21:53 +0200)
committerMarcin Siodelski <marcin@isc.org>
Tue, 23 Jul 2013 19:53:45 +0000 (21:53 +0200)
src/lib/dhcp/option6_client_fqdn.cc
src/lib/dhcp/option6_client_fqdn.h

index 1a1ba5d583535b4eef9aa45eaaaca7a153aaa982..5fcb81d6e7452be997e8c27e5e1f1062e5c005a7 100644 (file)
@@ -279,6 +279,20 @@ Option6ClientFqdn::getDomainName() const {
     return ("");
 }
 
+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) {
@@ -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
index bc139e3098d1a5bb26044a6bdada4e2ee43c89cb..8815273b4db4d0e4bc49ef809d3285839513b30e 100644 (file)
@@ -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.