Commit e47b08e8 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2427] Basic $ORIGIN handling

parent 8fd5cc45
......@@ -55,6 +55,7 @@ public:
MasterLoader::Options options) :
lexer_(),
zone_origin_(zone_origin),
active_origin_(zone_origin),
zone_class_(zone_class),
callbacks_(callbacks),
add_callback_(add_callback),
......@@ -138,13 +139,23 @@ public:
pushSource(filename);
}
void doOrigin() {
// Parse and create the new origin. It is relative to the previous
// one.
const MasterToken::StringRegion&
name_string(lexer_.getNextToken(MasterToken::QSTRING).
getStringRegion());
active_origin_ = Name(name_string.beg, name_string.len,
&active_origin_);
// Make sure there's the EOLN
eatUntilEOL(true);
}
void handleDirective(const char* directive, size_t length) {
if (iequals(directive, "INCLUDE")) {
doInclude();
} else if (iequals(directive, "ORIGIN")) {
// TODO: Implement
isc_throw(isc::NotImplemented,
"Origin directive not implemented yet");
doOrigin();
} else if (iequals(directive, "TTL")) {
// TODO: Implement
isc_throw(isc::NotImplemented,
......@@ -187,6 +198,8 @@ public:
private:
MasterLexer lexer_;
const Name zone_origin_;
Name active_origin_; // The origin used during parsing
// (modifiable by $ORIGIN)
const RRClass zone_class_;
MasterLoaderCallbacks callbacks_;
AddRRCallback add_callback_;
......@@ -255,7 +268,7 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
}
const Name name(name_string.beg, name_string.len,
&zone_origin_);
&active_origin_);
// TODO: Some more flexibility. We don't allow omitting
// anything yet
......@@ -275,7 +288,7 @@ MasterLoader::MasterLoaderImpl::loadIncremental(size_t count_limit) {
const rdata::RdataPtr data(rdata::createRdata(rrtype, rrclass,
lexer_,
&zone_origin_,
&active_origin_,
options_,
callbacks_));
// In case we get NULL, it means there was error creating
......
......@@ -201,7 +201,7 @@ TEST_F(MasterLoaderTest, origin) {
const string input =
"@ 1H IN A 192.0.2.1\n" +
directive + " sub.example.org.\n"
"www 1H IN A 192.0.2.1\n" +
"\"www\" 1H IN A 192.0.2.1\n" +
// Relative name in the origin
directive + " relative\n"
"@ 1H IN A 192.0.2.1\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment