]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2151] add well-known static wildcard labelsequence
authorJelte Jansen <jelte@isc.org>
Fri, 7 Sep 2012 15:20:28 +0000 (17:20 +0200)
committerJelte Jansen <jelte@isc.org>
Fri, 7 Sep 2012 15:20:28 +0000 (17:20 +0200)
src/lib/dns/labelsequence.h
src/lib/dns/tests/labelsequence_unittest.cc

index 545ce12133c55d3c4d8c8a252f31ea3668eaabb4..b9105506c1a71e061ee05ff58b2a2463997bb165 100644 (file)
@@ -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_LABEL();
+    //@}
+
     /// \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_LABEL() {
+    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
 
index 28f624aabde522dc966ad04bfeab9a0961b79cfd..06092c008ed99f438c7b89c60d2863c358e8d5fb 100644 (file)
@@ -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_LABEL().isAbsolute());
+    ASSERT_EQ("*", LabelSequence::WILDCARD_LABEL().toText());
+}
+
 }