Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
e47b08e8
Commit
e47b08e8
authored
Dec 14, 2012
by
Michal 'vorner' Vaner
Browse files
[2427] Basic $ORIGIN handling
parent
8fd5cc45
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/master_loader.cc
View file @
e47b08e8
...
...
@@ -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
,
&
zon
e_origin_
);
&
activ
e_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_
,
&
zon
e_origin_
,
&
activ
e_origin_
,
options_
,
callbacks_
));
// In case we get NULL, it means there was error creating
...
...
src/lib/dns/tests/master_loader_unittest.cc
View file @
e47b08e8
...
...
@@ -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
"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment