[svn] commit: r1076 - /trunk/src/lib/dns/cpp/rdata/generic/rrsig_46.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Mar 2 19:28:53 UTC 2010


Author: jinmei
Date: Tue Mar  2 19:28:53 2010
New Revision: 1076

Log:
cleanup:
 avoided using a hardocded magic number
 simplified RRType construction

Modified:
    trunk/src/lib/dns/cpp/rdata/generic/rrsig_46.cc

Modified: trunk/src/lib/dns/cpp/rdata/generic/rrsig_46.cc
==============================================================================
--- trunk/src/lib/dns/cpp/rdata/generic/rrsig_46.cc (original)
+++ trunk/src/lib/dns/cpp/rdata/generic/rrsig_46.cc Tue Mar  2 19:28:53 2010
@@ -39,6 +39,15 @@
 // BEGIN_ISC_NAMESPACE
 // BEGIN_RDATA_NAMESPACE
 
+namespace {
+// This is the minimum necessary length of all wire-format RRSIG RDATA:
+// - two 8-bit fields (algorithm and labels)
+// - two 16-bit fields (covered and tag)
+// - three 32-bit fields (original TTL, expire and inception)
+const size_t RRSIG_MINIMUM_LEN = 2 * sizeof(uint8_t) + 2 * sizeof(uint16_t) +
+    3 * sizeof(uint32_t);
+}
+
 struct RRSIGImpl {
     // straightforward representation of RRSIG RDATA fields
     RRSIGImpl(const RRType& covered, uint8_t algorithm, uint8_t labels,
@@ -100,12 +109,11 @@
 {
     size_t pos = buffer.getPosition();
 
-    if (rdata_len < 18) {
+    if (rdata_len < RRSIG_MINIMUM_LEN) {
         dns_throw(InvalidRdataLength, "RRSIG too short");
     }
 
-    uint16_t typecode = buffer.readUint16();
-    RRType covered(typecode);
+    RRType covered(buffer);
     uint8_t algorithm = buffer.readUint8();
     uint8_t labels = buffer.readUint8();
     uint32_t originalttl = buffer.readUint32();




More information about the bind10-changes mailing list