From: Mukund Sivaraman Date: Thu, 28 Mar 2013 02:48:35 +0000 (+0530) Subject: [2387] Unify code from MX constructors X-Git-Tag: bind10-1.2.0beta1-release~481^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29ec8dce0f9312be9cddb3712fbd107fb62e33d3;p=thirdparty%2Fkea.git [2387] Unify code from MX constructors This is an offshoot from #2391. There's no need to create yet another ticket for it. --- 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(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_;