BIND 10 trac1140, updated. acb5dff4449286422f23a7d5867b3bd792c888e5 [1140] TXT&SPF re-done to isolate the implementation details in txt_like.h from rdataclass.h using private pointers
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Aug 15 11:22:29 UTC 2011
The branch, trac1140 has been updated
via acb5dff4449286422f23a7d5867b3bd792c888e5 (commit)
from 69eb1a250699f481427c2d12abf14314fee9e6eb (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 acb5dff4449286422f23a7d5867b3bd792c888e5
Author: Dima Volodin <dvv at isc.org>
Date: Mon Aug 15 07:19:24 2011 -0400
[1140] TXT&SPF re-done to isolate the implementation details in
txt_like.h from rdataclass.h using private pointers
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/Makefile.am | 2 +
src/lib/dns/rdata/generic/detail/txt_like.h | 28 ++++-----
.../dns/rdata/generic/{cname_5.cc => spf_99.cc} | 65 +++++++++++---------
src/lib/dns/rdata/generic/spf_99.h | 24 +++++---
.../dns/rdata/generic/{cname_5.cc => txt_16.cc} | 65 +++++++++++---------
src/lib/dns/rdata/generic/txt_16.h | 24 +++++---
6 files changed, 120 insertions(+), 88 deletions(-)
copy src/lib/dns/rdata/generic/{cname_5.cc => spf_99.cc} (53%)
copy src/lib/dns/rdata/generic/{cname_5.cc => txt_16.cc} (53%)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/Makefile.am b/src/lib/dns/Makefile.am
index 56444bd..10a731f 100644
--- a/src/lib/dns/Makefile.am
+++ b/src/lib/dns/Makefile.am
@@ -50,7 +50,9 @@ EXTRA_DIST += rdata/generic/rrsig_46.cc
EXTRA_DIST += rdata/generic/rrsig_46.h
EXTRA_DIST += rdata/generic/soa_6.cc
EXTRA_DIST += rdata/generic/soa_6.h
+EXTRA_DIST += rdata/generic/spf_99.cc
EXTRA_DIST += rdata/generic/spf_99.h
+EXTRA_DIST += rdata/generic/txt_16.cc
EXTRA_DIST += rdata/generic/txt_16.h
EXTRA_DIST += rdata/hs_4/a_1.cc
EXTRA_DIST += rdata/hs_4/a_1.h
diff --git a/src/lib/dns/rdata/generic/detail/txt_like.h b/src/lib/dns/rdata/generic/detail/txt_like.h
index 0f18c8a..f740cbc 100644
--- a/src/lib/dns/rdata/generic/detail/txt_like.h
+++ b/src/lib/dns/rdata/generic/detail/txt_like.h
@@ -23,24 +23,22 @@
using namespace std;
using namespace isc::util;
-template<uint16_t typeCode>class TXT_LIKE : public Rdata {
+template<class Type, uint16_t typeCode>class TXTLikeImpl {
public:
- TXT_LIKE(InputBuffer& buffer, size_t rdata_len) {
+ TXTLikeImpl(InputBuffer& buffer, size_t rdata_len) {
if (rdata_len > MAX_RDLENGTH) {
isc_throw(InvalidRdataLength, "RDLENGTH too large: " << rdata_len);
}
if (rdata_len == 0) { // note that this couldn't happen in the loop.
- isc_throw(DNSMessageFORMERR, "Error in parsing " +
- RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+ isc_throw(DNSMessageFORMERR, "Error in parsing " << RRType(typeCode) <<
" RDATA: 0-length character string");
}
do {
const uint8_t len = buffer.readUint8();
if (rdata_len < len + 1) {
- isc_throw(DNSMessageFORMERR, "Error in parsing " +
- RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+ isc_throw(DNSMessageFORMERR, "Error in parsing " << RRType(typeCode) <<
" RDATA: character string length is too large: " << static_cast<int>(len));
}
vector<uint8_t> data(len + 1);
@@ -52,7 +50,7 @@ public:
} while (rdata_len > 0);
}
- explicit TXT_LIKE(const std::string& txtstr) {
+ explicit TXTLikeImpl(const std::string& txtstr) {
// TBD: this is a simple, incomplete implementation that only supports
// a single character-string.
@@ -65,13 +63,13 @@ public:
}
if (length > MAX_CHARSTRING_LEN) {
- isc_throw(CharStringTooLong, RRParamRegistry::getRegistry().codeToTypeText(typeCode)
- + " RDATA construction from text: string length is too long: " << length);
+ isc_throw(CharStringTooLong, RRType(typeCode) <<
+ " RDATA construction from text: string length is too long: " << length);
}
// TBD: right now, we don't support escaped characters
if (txtstr.find('\\') != string::npos) {
- isc_throw(InvalidRdataText, RRParamRegistry::getRegistry().codeToTypeText(typeCode) +
+ isc_throw(InvalidRdataText, RRType(typeCode) <<
" RDATA from text: escaped character is currently not supported: " << txtstr);
}
@@ -83,8 +81,8 @@ public:
string_list_.push_back(data);
}
- TXT_LIKE(const TXT_LIKE& other) :
- Rdata(), string_list_(other.string_list_)
+ TXTLikeImpl(const TXTLikeImpl& other) :
+ string_list_(other.string_list_)
{}
void
@@ -129,16 +127,14 @@ public:
}
int
- compare(const Rdata& other) const {
- const TXT_LIKE& other_txt = dynamic_cast<const TXT_LIKE&>(other);
-
+ compare(const TXTLikeImpl& other) const {
// This implementation is not efficient. Revisit this (TBD).
OutputBuffer this_buffer(0);
toWire(this_buffer);
size_t this_len = this_buffer.getLength();
OutputBuffer other_buffer(0);
- other_txt.toWire(other_buffer);
+ other.toWire(other_buffer);
const size_t other_len = other_buffer.getLength();
const size_t cmplen = min(this_len, other_len);
diff --git a/src/lib/dns/rdata/generic/spf_99.cc b/src/lib/dns/rdata/generic/spf_99.cc
new file mode 100644
index 0000000..492de98
--- /dev/null
+++ b/src/lib/dns/rdata/generic/spf_99.cc
@@ -0,0 +1,87 @@
+// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <stdint.h>
+#include <string.h>
+
+#include <string>
+#include <vector>
+
+#include <util/buffer.h>
+#include <dns/exceptions.h>
+#include <dns/messagerenderer.h>
+#include <dns/rdata.h>
+#include <dns/rdataclass.h>
+
+using namespace std;
+using namespace isc::util;
+
+// BEGIN_ISC_NAMESPACE
+// BEGIN_RDATA_NAMESPACE
+
+#include <dns/rdata/generic/detail/txt_like.h>
+
+SPF&
+SPF::operator=(const SPF& source) {
+ if (impl_ == source.impl_) {
+ return (*this);
+ }
+
+ SPFImpl* newimpl = new SPFImpl(*source.impl_);
+ delete impl_;
+ impl_ = newimpl;
+
+ return (*this);
+}
+
+SPF::~SPF() {
+ delete impl_;
+}
+
+SPF::SPF(InputBuffer& buffer, size_t rdata_len) :
+ impl_(new SPFImpl(buffer, rdata_len))
+{}
+
+SPF::SPF(const std::string& txtstr) :
+ impl_(new SPFImpl(txtstr))
+{}
+
+SPF::SPF(const SPF& other) :
+ Rdata(), impl_(new SPFImpl(*other.impl_))
+{}
+
+void
+SPF::toWire(OutputBuffer& buffer) const {
+ impl_->toWire(buffer);
+}
+
+void
+SPF::toWire(AbstractMessageRenderer& renderer) const {
+ impl_->toWire(renderer);
+}
+
+string
+SPF::toText() const {
+ return (impl_->toText());
+}
+
+int
+SPF::compare(const Rdata& other) const {
+ const SPF& other_txt = dynamic_cast<const SPF&>(other);
+
+ return (impl_->compare(*other_txt.impl_));
+}
+
+// END_RDATA_NAMESPACE
+// END_ISC_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/spf_99.h b/src/lib/dns/rdata/generic/spf_99.h
index dfccec2..c42bfac 100644
--- a/src/lib/dns/rdata/generic/spf_99.h
+++ b/src/lib/dns/rdata/generic/spf_99.h
@@ -14,16 +14,13 @@
// BEGIN_HEADER_GUARD
+#include <stdint.h>
+
#include <string>
+#include <vector>
-#include <dns/name.h>
#include <dns/rdata.h>
-#include <util/buffer.h>
-#include <dns/exceptions.h>
-#include <dns/messagerenderer.h>
-#include <dns/rrparamregistry.h>
-
// BEGIN_ISC_NAMESPACE
// BEGIN_COMMON_DECLARATIONS
@@ -31,9 +28,20 @@
// BEGIN_RDATA_NAMESPACE
-#include <dns/rdata/generic/detail/txt_like.h>
+template<class Type, uint16_t typeCode> class TXTLikeImpl;
+
+class SPF : public Rdata {
+public:
+ // BEGIN_COMMON_MEMBERS
+ // END_COMMON_MEMBERS
+
+ SPF& operator=(const SPF& source);
+ ~SPF();
-typedef TXT_LIKE<99> SPF;
+private:
+ typedef TXTLikeImpl<SPF, 16> SPFImpl;
+ SPFImpl* impl_;
+};
// END_RDATA_NAMESPACE
// END_ISC_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/txt_16.cc b/src/lib/dns/rdata/generic/txt_16.cc
new file mode 100644
index 0000000..418bc05
--- /dev/null
+++ b/src/lib/dns/rdata/generic/txt_16.cc
@@ -0,0 +1,87 @@
+// Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <stdint.h>
+#include <string.h>
+
+#include <string>
+#include <vector>
+
+#include <util/buffer.h>
+#include <dns/exceptions.h>
+#include <dns/messagerenderer.h>
+#include <dns/rdata.h>
+#include <dns/rdataclass.h>
+
+using namespace std;
+using namespace isc::util;
+
+// BEGIN_ISC_NAMESPACE
+// BEGIN_RDATA_NAMESPACE
+
+#include <dns/rdata/generic/detail/txt_like.h>
+
+TXT&
+TXT::operator=(const TXT& source) {
+ if (impl_ == source.impl_) {
+ return (*this);
+ }
+
+ TXTImpl* newimpl = new TXTImpl(*source.impl_);
+ delete impl_;
+ impl_ = newimpl;
+
+ return (*this);
+}
+
+TXT::~TXT() {
+ delete impl_;
+}
+
+TXT::TXT(InputBuffer& buffer, size_t rdata_len) :
+ impl_(new TXTImpl(buffer, rdata_len))
+{}
+
+TXT::TXT(const std::string& txtstr) :
+ impl_(new TXTImpl(txtstr))
+{}
+
+TXT::TXT(const TXT& other) :
+ Rdata(), impl_(new TXTImpl(*other.impl_))
+{}
+
+void
+TXT::toWire(OutputBuffer& buffer) const {
+ impl_->toWire(buffer);
+}
+
+void
+TXT::toWire(AbstractMessageRenderer& renderer) const {
+ impl_->toWire(renderer);
+}
+
+string
+TXT::toText() const {
+ return (impl_->toText());
+}
+
+int
+TXT::compare(const Rdata& other) const {
+ const TXT& other_txt = dynamic_cast<const TXT&>(other);
+
+ return (impl_->compare(*other_txt.impl_));
+}
+
+// END_RDATA_NAMESPACE
+// END_ISC_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/txt_16.h b/src/lib/dns/rdata/generic/txt_16.h
index 7075837..d99d69b 100644
--- a/src/lib/dns/rdata/generic/txt_16.h
+++ b/src/lib/dns/rdata/generic/txt_16.h
@@ -14,16 +14,13 @@
// BEGIN_HEADER_GUARD
+#include <stdint.h>
+
#include <string>
+#include <vector>
-#include <dns/name.h>
#include <dns/rdata.h>
-#include <util/buffer.h>
-#include <dns/exceptions.h>
-#include <dns/messagerenderer.h>
-#include <dns/rrparamregistry.h>
-
// BEGIN_ISC_NAMESPACE
// BEGIN_COMMON_DECLARATIONS
@@ -31,9 +28,20 @@
// BEGIN_RDATA_NAMESPACE
-#include <dns/rdata/generic/detail/txt_like.h>
+template<class Type, uint16_t typeCode> class TXTLikeImpl;
+
+class TXT : public Rdata {
+public:
+ // BEGIN_COMMON_MEMBERS
+ // END_COMMON_MEMBERS
+
+ TXT& operator=(const TXT& source);
+ ~TXT();
-typedef TXT_LIKE<16> TXT;
+private:
+ typedef TXTLikeImpl<TXT, 16> TXTImpl;
+ TXTImpl* impl_;
+};
// END_RDATA_NAMESPACE
// END_ISC_NAMESPACE
More information about the bind10-changes
mailing list