Browse Source

[trac812] added some comments about int64 to uint48 conversion as suggested in review.

JINMEI Tatuya 14 years ago
parent
commit
daf48e8604
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/lib/dns/tsig.cc

+ 6 - 0
src/lib/dns/tsig.cc

@@ -112,6 +112,12 @@ TSIGContext::sign(const uint16_t qid, const void* const data,
     }
     }
 
 
     TSIGError error(TSIGError::NOERROR());
     TSIGError error(TSIGError::NOERROR());
+    // TSIG uses 48-bit unsigned integer to represent time signed.
+    // Since gettimeofdayWrapper() returns a 64-bit *signed* integer, we
+    // make sure it's stored in an unsigned 64-bit integer variable and
+    // represents a value in the expected range.  (In reality, however,
+    // gettimeofdayWrapper() will return a positive integer that will fit
+    // in 48 bits)
     const uint64_t now = (gettimeofdayWrapper() & 0x0000ffffffffffffULL);
     const uint64_t now = (gettimeofdayWrapper() & 0x0000ffffffffffffULL);
 
 
     // For responses adjust the error code.
     // For responses adjust the error code.