[svn] commit: r3036 - /branches/trac351/src/lib/dns/message.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Sep 28 02:15:20 UTC 2010


Author: jinmei
Date: Tue Sep 28 02:15:13 2010
New Revision: 3036

Log:
cleanup: unified duplicate code

Modified:
    branches/trac351/src/lib/dns/message.cc

Modified: branches/trac351/src/lib/dns/message.cc
==============================================================================
--- branches/trac351/src/lib/dns/message.cc (original)
+++ branches/trac351/src/lib/dns/message.cc Tue Sep 28 02:15:13 2010
@@ -183,6 +183,7 @@
 #endif
 
     void init();
+    void setOpcode(const Opcode& opcode);
     int parseQuestion(InputBuffer& buffer);
     int parseSection(const Section& section, InputBuffer& buffer);
 };
@@ -218,6 +219,12 @@
     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 @@
         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 @@
 
     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();




More information about the bind10-changes mailing list