Commit 2a907b2c authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

cleanup: unified duplicate code

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac351@3036 e5f2f494-b856-4b98-b285-d166d9295462
parent 5ec15e6a
......@@ -183,6 +183,7 @@ public:
#endif
void init();
void setOpcode(const Opcode& opcode);
int parseQuestion(InputBuffer& buffer);
int parseSection(const Section& section, InputBuffer& buffer);
};
......@@ -218,6 +219,12 @@ MessageImpl::init() {
rrsets_[sectionCodeToId(Section::ADDITIONAL())].clear();
}
void
MessageImpl::setOpcode(const Opcode& opcode) {
opcode_placeholder_ = opcode;
opcode_ = &opcode_placeholder_;
}
Message::Message(Mode mode) :
impl_(new MessageImpl(mode))
{}
......@@ -320,8 +327,7 @@ Message::setOpcode(const Opcode& opcode) {
isc_throw(InvalidMessageOperation,
"setOpcode performed in non-render mode");
}
impl_->opcode_placeholder_ = opcode;
impl_->opcode_ = &impl_->opcode_placeholder_;
impl_->setOpcode(opcode);
}
unsigned int
......@@ -547,9 +553,7 @@ Message::parseHeader(InputBuffer& buffer) {
impl_->qid_ = buffer.readUint16();
const uint16_t codes_and_flags = buffer.readUint16();
impl_->opcode_placeholder_ =
Opcode((codes_and_flags & OPCODE_MASK) >> OPCODE_SHIFT);
impl_->opcode_ = &impl_->opcode_placeholder_;
impl_->setOpcode(Opcode((codes_and_flags & OPCODE_MASK) >> OPCODE_SHIFT));
impl_->rcode_ = rcodes[(codes_and_flags & RCODE_MASK)];
impl_->flags_ = (codes_and_flags & FLAG_MASK);
impl_->counts_[Section::QUESTION().getCode()] = buffer.readUint16();
......
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