Browse Source

[2377] Handle relative names

Tested at least on the domain names. There is no known Rdata type
implementation handling relative names right now.
Michal 'vorner' Vaner 12 years ago
parent
commit
42b0cb7bc7
2 changed files with 8 additions and 6 deletions
  1. 7 5
      src/lib/dns/master_loader.cc
  2. 1 1
      src/lib/dns/tests/testdata/example.org

+ 7 - 5
src/lib/dns/master_loader.cc

@@ -77,9 +77,11 @@ public:
             // Return the last token, as it was not empty
             lexer_.ungetToken();
 
-            const string name_string(getString());
+            const MasterToken::StringRegion
+                name_string(lexer_.getNextToken(MasterToken::QSTRING).
+                            getStringRegion());
             // TODO $ handling
-            const Name name(name_string); // TODO: Origin
+            const Name name(name_string.beg, name_string.len, &zone_origin_);
             // TODO: Some more flexibility. We don't allow omitting anything yet
 
             // The parameters
@@ -87,9 +89,9 @@ public:
             const RRClass rrclass(getString());
             const RRType rrtype(getString());
 
-            // TODO: Origin handling
             const rdata::RdataPtr data(rdata::createRdata(rrtype, rrclass,
-                                                          lexer_, NULL,
+                                                          lexer_,
+                                                          &zone_origin_,
                                                           options_,
                                                           callbacks_));
             // In case we get NULL, it means there was error creating
@@ -108,7 +110,7 @@ public:
 
 private:
     MasterLexer lexer_;
-    const Name& zone_origin_;
+    const Name zone_origin_;
     const RRClass zone_class_;
     MasterLoaderCallbacks callbacks_;
     AddRRCallback add_callback_;

+ 1 - 1
src/lib/dns/tests/testdata/example.org

@@ -11,4 +11,4 @@ example.org.        3600    IN  NS ns1.example.org.
 
 
 ; Some empty lines here. They are to make sure the loader can skip them.
-www.example.org.    3600    IN  A 192.0.2.1
+www                 3600    IN  A 192.0.2.1 ; Test a relative name as well.