summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMukund Sivaraman <muks@isc.org>2013-03-28 03:48:35 +0100
committerMukund Sivaraman <muks@isc.org>2013-03-28 03:48:37 +0100
commit29ec8dce0f9312be9cddb3712fbd107fb62e33d3 (patch)
tree695b68942528bc8eeafaa8f56e02920d20bb2d4c
parent[2387] Unify NSEC3PARAM string and lexer constructor tests (diff)
downloadkea-29ec8dce0f9312be9cddb3712fbd107fb62e33d3.tar.xz
kea-29ec8dce0f9312be9cddb3712fbd107fb62e33d3.zip
[2387] Unify code from MX constructors
This is an offshoot from #2391. There's no need to create yet another ticket for it.
-rw-r--r--src/lib/dns/rdata/generic/mx_15.cc17
-rw-r--r--src/lib/dns/rdata/generic/mx_15.h3
2 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/dns/rdata/generic/mx_15.cc b/src/lib/dns/rdata/generic/mx_15.cc
index 12ada97d89..ae9978e377 100644
--- a/src/lib/dns/rdata/generic/mx_15.cc
+++ b/src/lib/dns/rdata/generic/mx_15.cc
@@ -68,15 +68,7 @@ MX::MX(const std::string& mx_str) :
MasterLexer lexer;
lexer.pushSource(ss);
- const uint32_t num =
- lexer.getNextToken(MasterToken::NUMBER).getNumber();
- if (num > 65535) {
- isc_throw(InvalidRdataText, "Invalid MX preference in: "
- << mx_str);
- }
- preference_ = static_cast<uint16_t>(num);
-
- mxname_ = createNameFromLexer(lexer, NULL);
+ constructFromLexer(lexer, NULL);
if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) {
isc_throw(InvalidRdataText, "extra input text for MX: "
@@ -108,8 +100,13 @@ MX::MX(const std::string& mx_str) :
/// is non-absolute.
MX::MX(MasterLexer& lexer, const Name* origin,
MasterLoader::Options, MasterLoaderCallbacks&) :
- preference_(0), mxname_(".")
+ preference_(0), mxname_(Name::ROOT_NAME())
{
+ constructFromLexer(lexer, origin);
+}
+
+void
+MX::constructFromLexer(MasterLexer& lexer, const Name* origin) {
const uint32_t num = lexer.getNextToken(MasterToken::NUMBER).getNumber();
if (num > 65535) {
isc_throw(InvalidRdataText, "Invalid MX preference: " << num);
diff --git a/src/lib/dns/rdata/generic/mx_15.h b/src/lib/dns/rdata/generic/mx_15.h
index 1381f18b05..84e7112b3a 100644
--- a/src/lib/dns/rdata/generic/mx_15.h
+++ b/src/lib/dns/rdata/generic/mx_15.h
@@ -42,6 +42,9 @@ public:
uint16_t getMXPref() const;
private:
+ void constructFromLexer(isc::dns::MasterLexer& lexer,
+ const isc::dns::Name* origin);
+
/// Note: this is a prototype version; we may reconsider
/// this representation later.
uint16_t preference_;