BIND 10 #2087: add LabelSequence::getOffsetData() method
BIND 10 Development
do-not-reply at isc.org
Sun Jul 15 18:08:03 UTC 2012
#2087: add LabelSequence::getOffsetData() method
-------------------------------------+-------------------------------------
Reporter: | Owner: muks
jinmei | Status: reviewing
Type: task | Milestone:
Priority: | Sprint-20120717
medium | Resolution:
Component: | Sensitive: 0
libdns++ | Sub-Project: DNS
Keywords: | Estimated Difficulty: 4
Defect Severity: N/A | Total Hours: 0
Feature Depending on Ticket: |
scalable inmemory |
Add Hours to Ticket: 0 |
Internal?: 0 |
-------------------------------------+-------------------------------------
Comment (by muks):
Replying to [comment:9 jelte]:
> if you pull out data and offsets, you cannot use them to create a new
labelsequence, or at least, not one with the same properties as the one
you got the data from; the isAbsolute() property is 'reset' to true in the
new object (because of the way that property is stored/checked). This
could potentially also change comparison behaviour
The code that uses this data would have to be careful about it. We could
add a constructor argument (bool not_absolute), something like this:
{{{
diff --git a/src/lib/dns/labelsequence.cc b/src/lib/dns/labelsequence.cc
index 7627571..31a7bd8 100644
--- a/src/lib/dns/labelsequence.cc
+++ b/src/lib/dns/labelsequence.cc
@@ -25,11 +25,13 @@ namespace dns {
LabelSequence::LabelSequence(const uint8_t* data,
const uint8_t* offsets,
- size_t offsets_size) : data_(data),
+ size_t offsets_size,
+ bool not_absolute) : data_(data),
offsets_(offsets),
offsets_size_(offsets_size),
first_label_(0),
-
last_label_(offsets_size_)
+
last_label_(offsets_size_),
+
init_not_absolute_(not_absolute)
{
if (data == NULL || offsets == NULL) {
isc_throw(BadValue, "Null pointer passed to LabelSequence
constructor");
@@ -214,7 +216,7 @@ LabelSequence::stripRight(size_t i) {
bool
LabelSequence::isAbsolute() const {
- return (last_label_ == offsets_size_);
+ return ((last_label_ == offsets_size_) && (!init_not_absolute_));
}
size_t
diff --git a/src/lib/dns/labelsequence.h b/src/lib/dns/labelsequence.h
index 48f3241..d5efd27 100644
--- a/src/lib/dns/labelsequence.h
+++ b/src/lib/dns/labelsequence.h
@@ -60,7 +60,8 @@ public:
offsets_(ls.offsets_),
offsets_size_(ls.offsets_size_),
first_label_(ls.first_label_),
- last_label_(ls.last_label_)
+ last_label_(ls.last_label_),
+
init_not_absolute_(ls.init_not_absolute_)
{}
/// \brief Constructs a LabelSequence for the given name
@@ -76,7 +77,8 @@ public:
offsets_(&name.offsets_[0]),
offsets_size_(name.offsets_.size()),
first_label_(0),
- last_label_(name.getLabelCount())
+ last_label_(name.getLabelCount()),
+ init_not_absolute_(false)
{}
/// \brief Constructs a LabelSequence for the given data
@@ -96,7 +98,8 @@ public:
/// \param offsets_size The size of the offsets data
LabelSequence(const uint8_t* data,
const uint8_t* offsets,
- size_t offsets_size);
+ size_t offsets_size,
+ bool not_absolute = false);
/// \brief Return the wire-format data for this LabelSequence
///
@@ -257,6 +260,7 @@ private:
size_t offsets_size_;
size_t first_label_;
size_t last_label_;
+ const bool init_not_absolute_;
};
}}}
Let's discuss and if we want this, we'll implement it in a separate
ticket.
--
Ticket URL: <http://bind10.isc.org/ticket/2087#comment:10>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development
More information about the bind10-tickets
mailing list