Browse Source

[master] Merge remote-tracking branch 'origin/trac2151'

Jelte Jansen 12 years ago
parent
commit
f77fcfce01
2 changed files with 21 additions and 0 deletions
  1. 15 0
      src/lib/dns/labelsequence.h
  2. 6 0
      src/lib/dns/tests/labelsequence_unittest.cc

+ 15 - 0
src/lib/dns/labelsequence.h

@@ -53,6 +53,14 @@ public:
     static const size_t MAX_SERIALIZED_LENGTH =
         Name::MAX_WIRE + Name::MAX_LABELS + 1;
 
+    ///
+    /// \name Well-known LabelSequence constants
+    ///
+    //@{
+    /// Wildcard label ("*")
+    static const LabelSequence& WILDCARD();
+    //@}
+
     /// \brief Constructs a LabelSequence for the given name
     ///
     /// \note The associated Name MUST remain in scope during the lifetime
@@ -410,6 +418,13 @@ private:
 std::ostream&
 operator<<(std::ostream& os, const LabelSequence& label_sequence);
 
+inline const LabelSequence&
+LabelSequence::WILDCARD() {
+    static const uint8_t wildcard_buf[4] = { 0x01, 0x00, 0x01, '*' };
+    static const LabelSequence wild_ls(wildcard_buf);
+    return (wild_ls);
+}
+
 } // end namespace dns
 } // end namespace isc
 

+ 6 - 0
src/lib/dns/tests/labelsequence_unittest.cc

@@ -1174,4 +1174,10 @@ TEST_F(ExtendableLabelSequenceTest, extendBadData) {
     check_equal(full_ls2, els);
 }
 
+// Check the static fixed 'wildcard' LabelSequence
+TEST(WildCardLabelSequence, wildcard) {
+    ASSERT_FALSE(LabelSequence::WILDCARD().isAbsolute());
+    ASSERT_EQ("*", LabelSequence::WILDCARD().toText());
+}
+
 }