BIND 10 trac2169, updated. 7d7e5269d57451191c0aef1b127d292d3615fe2c Merge branch 'master' into trac2169

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Sep 5 13:27:16 UTC 2012


The branch, trac2169 has been updated
       via  7d7e5269d57451191c0aef1b127d292d3615fe2c (commit)
       via  4f42de9d8aefb697c2a0eb85ae3125030a3f77f8 (commit)
       via  0050740b21f115c54527b6942d98136988833ced (commit)
       via  f19d17588e04cabe4688e9b7bbde82f699b4a021 (commit)
       via  b697417cb99a38a6f03ff0e76dc90a5955951c3a (commit)
       via  0669a4f48c5e6918ee1ab4cf40ce9b74e8169ba0 (commit)
       via  de315c3ed326c7b7b9c395d85f3ec30177ee4772 (commit)
       via  b58cbbe6f9d7edb3faf27cfc841c0c8055edec8f (commit)
       via  1d6fc8b4e8b24289d831952516be306ad14a18de (commit)
       via  e57068e6d3d73906644384bb44b767a86bdd8cf8 (commit)
       via  94d72340d2f47c9e40de4acf7726dedf40f2c212 (commit)
      from  3378f9b44d6d8a5cceedd9b9f6177d77985a01bf (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 -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 src/bin/msgq/b10-msgq.8                  |    6 ++--
 src/lib/datasrc/rbtree.h                 |   35 ++++++++++++++++++++
 src/lib/datasrc/tests/rbtree_unittest.cc |   53 ++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 4 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/msgq/b10-msgq.8 b/src/bin/msgq/b10-msgq.8
index 37b5228..b318491 100644
--- a/src/bin/msgq/b10-msgq.8
+++ b/src/bin/msgq/b10-msgq.8
@@ -2,12 +2,12 @@
 .\"     Title: b10-msgq
 .\"    Author: [see the "AUTHORS" section]
 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
-.\"      Date: August 4, 2010
+.\"      Date: June 25, 2012
 .\"    Manual: BIND10
 .\"    Source: BIND10
 .\"  Language: English
 .\"
-.TH "B10\-MSGQ" "8" "August 4, 2010" "BIND10" "BIND10"
+.TH "B10\-MSGQ" "8" "June 25, 2012" "BIND10" "BIND10"
 .\" -----------------------------------------------------------------
 .\" * set default formatting
 .\" -----------------------------------------------------------------
@@ -87,8 +87,6 @@ is assigned a unique identifier \-\- this is the local name\&. The commands it h
 .sp
 .RE
 .PP
-It listens on 127\&.0\&.0\&.1\&.
-.PP
 The
 \fBb10\-msgq\fR
 daemon may be cleanly stopped by sending the SIGTERM signal to the process\&. This shutdown does not notify the subscribers\&.
diff --git a/src/lib/datasrc/rbtree.h b/src/lib/datasrc/rbtree.h
index 38086db..083c52a 100644
--- a/src/lib/datasrc/rbtree.h
+++ b/src/lib/datasrc/rbtree.h
@@ -221,6 +221,26 @@ public:
         return (dns::LabelSequence(getLabelsData()));
     }
 
+    /// \brief Return the absolute label sequence of the node.
+    ///
+    /// This method returns the label sequence corresponding to the full
+    /// name of the node; i.e. the entire name as it appears in the zone.
+    ///
+    /// It takes the (partial) name of the node itself, and extends it
+    /// with all upper nodes.
+    ///
+    /// \note Care must be taken with the buffer that is used here; this
+    /// method overwrites its data, so it should not be associated with
+    /// any other LabelSequence during the lifetime of the LabelSequence
+    /// returned by this method. See LabelSequence::extend(), which is used
+    /// by this method.
+    ///
+    /// \param buf A data buffer where the label sequence will be built.
+    ///            The data in this buffer will be overwritten by this call.
+    /// \return A LabelSequence with the absolute name of this node.
+    isc::dns::LabelSequence getAbsoluteLabels(
+        uint8_t buf[isc::dns::LabelSequence::MAX_SERIALIZED_LENGTH]) const;
+
     /// \brief Return the data stored in this node.
     ///
     /// You should not delete the data, it is handled by shared pointers.
@@ -503,6 +523,21 @@ RBNode<T>::getUpperNode() const {
 }
 
 template <typename T>
+isc::dns::LabelSequence
+RBNode<T>::getAbsoluteLabels(
+    uint8_t buf[isc::dns::LabelSequence::MAX_SERIALIZED_LENGTH]) const
+{
+    isc::dns::LabelSequence result(getLabels(), buf);
+    const RBNode<T>* upper = getUpperNode();
+    while (upper != NULL) {
+        result.extend(upper->getLabels(), buf);
+        upper = upper->getUpperNode();
+    }
+
+    return (result);
+}
+
+template <typename T>
 const RBNode<T>*
 RBNode<T>::abstractSuccessor(typename RBNode<T>::RBNodePtr RBNode<T>::*left,
                              typename RBNode<T>::RBNodePtr RBNode<T>::*right)
diff --git a/src/lib/datasrc/tests/rbtree_unittest.cc b/src/lib/datasrc/tests/rbtree_unittest.cc
index 1d08fed..918495e 100644
--- a/src/lib/datasrc/tests/rbtree_unittest.cc
+++ b/src/lib/datasrc/tests/rbtree_unittest.cc
@@ -104,6 +104,7 @@ protected:
     RBTree<int>& rbtree_expose_empty_node;
     RBNode<int>* rbtnode;
     const RBNode<int>* crbtnode;
+    uint8_t buf[LabelSequence::MAX_SERIALIZED_LENGTH];
 };
 
 TEST_F(RBTreeTest, nodeCount) {
@@ -419,6 +420,11 @@ TEST_F(RBTreeTest, chainLevel) {
               tree.find(node_name, &crbtnode, chain));
     EXPECT_EQ(1, chain.getLevelCount());
 
+    // Check the name of the found node (should have '.' as both non-absolute
+    // and absolute name
+    EXPECT_EQ(".", crbtnode->getLabels().toText());
+    EXPECT_EQ(".", crbtnode->getAbsoluteLabels(buf).toText());
+
     /*
      * Now creating a possibly deepest tree with MAX_LABELS levels.
      * it should look like:
@@ -442,6 +448,12 @@ TEST_F(RBTreeTest, chainLevel) {
         EXPECT_EQ(RBTree<int>::EXACTMATCH,
                   tree.find(node_name, &crbtnode, found_chain));
         EXPECT_EQ(i, found_chain.getLevelCount());
+
+        // The non-absolute name should only have the first label
+        EXPECT_EQ("a", crbtnode->getLabels().toText());
+        // But the absolute name should have all labels
+        EXPECT_EQ(node_name.toText(),
+                  crbtnode->getAbsoluteLabels(buf).toText());
     }
 
     // Confirm the last inserted name has the possible maximum length with
@@ -988,4 +1000,45 @@ TEST_F(RBTreeTest, root) {
               root.find(Name("example.com"), &crbtnode));
     EXPECT_EQ(rbtnode, crbtnode);
 }
+
+TEST_F(RBTreeTest, getAbsoluteLabels) {
+    // The full absolute names of the nodes in the tree
+    // with the addition of the explicit root node
+    const char* const domain_names[] = {
+        "c", "b", "a", "x.d.e.f", "z.d.e.f", "g.h", "i.g.h", "o.w.y.d.e.f",
+        "j.z.d.e.f", "p.w.y.d.e.f", "q.w.y.d.e.f", "k.g.h"};
+    // The names of the nodes themselves, as they end up in the tree
+    const char* const first_labels[] = {
+        "c", "b", "a", "x", "z", "g.h", "i", "o",
+        "j", "p", "q", "k"};
+
+    const int name_count = sizeof(domain_names) / sizeof(domain_names[0]);
+    for (int i = 0; i < name_count; ++i) {
+        EXPECT_EQ(RBTree<int>::EXACTMATCH, rbtree.find(Name(domain_names[i]),
+                  &crbtnode));
+
+        // First make sure the names themselves are not absolute
+        const LabelSequence ls(crbtnode->getLabels());
+        EXPECT_EQ(first_labels[i], ls.toText());
+        EXPECT_FALSE(ls.isAbsolute());
+
+        // Now check the absolute names
+        const LabelSequence abs_ls(crbtnode->getAbsoluteLabels(buf));
+        EXPECT_EQ(Name(domain_names[i]).toText(), abs_ls.toText());
+        EXPECT_TRUE(abs_ls.isAbsolute());
+    }
+
+    // Explicitly add and find a root node, to see that getAbsoluteLabels
+    // also works when getLabels() already returns an absolute LabelSequence
+    rbtree.insert(mem_sgmt_, Name("."), &rbtnode);
+    rbtnode->setData(RBNode<int>::NodeDataPtr(new int(1)));
+
+    EXPECT_EQ(RBTree<int>::EXACTMATCH, rbtree.find(Name("."), &crbtnode));
+
+    EXPECT_TRUE(crbtnode->getLabels().isAbsolute());
+    EXPECT_EQ(".", crbtnode->getLabels().toText());
+    EXPECT_TRUE(crbtnode->getAbsoluteLabels(buf).isAbsolute());
+    EXPECT_EQ(".", crbtnode->getAbsoluteLabels(buf).toText());
+}
+
 }



More information about the bind10-changes mailing list