2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[trac117] cleanup for the helper function, documented it.

This commit is contained in:
JINMEI Tatuya
2011-02-16 16:18:25 -08:00
parent a9944090a8
commit cf0dac64cd
4 changed files with 23 additions and 6 deletions

View File

@@ -27,12 +27,14 @@ namespace generic {
namespace detail {
namespace nsec {
void
buildRRTypeBitmap(const char* const rrtype_name,
const size_t total_len, vector<uint8_t>& typebits)
checkRRTypeBitmaps(const char* const rrtype_name,
const vector<uint8_t>& typebits)
{
int len = 0;
bool first = true;
unsigned int block, lastblock = 0;
const size_t total_len = typebits.size();
for (int i = 0; i < total_len; i += len) {
if (i + 2 > total_len) {
isc_throw(DNSMessageFORMERR, rrtype_name <<

View File

@@ -22,8 +22,23 @@ namespace rdata {
namespace generic {
namespace detail {
namespace nsec {
void buildRRTypeBitmap(const char* const rrtype_name,
const size_t total_len, std::vector<uint8_t>& typebits);
/// Check if a given "type bitmap" for NSEC/NSEC3 is valid.
///
/// This helper function checks given wire format data (stored in a
/// \c std::vector) is a valid type bitmaps used for the NSEC and NSEC3 RRs
/// according to RFC4034 and RFC5155. The validation logic is the same
/// for these two RRs, so a unified check function is provided.
/// This function is essentially private and is only expected to be called
/// from the \c NSEC and \c NSEC3 class implementations.
///
/// \exception DNSMessageFORMERR The bitmap is not valid.
///
/// \param rrtype_name Either "NSEC" or "NSEC3"; used as part of exception
/// messages.
/// \param typebits The type bitmaps in wire format. The size of vector
/// is the total length of the bitmaps.
void checkRRTypeBitmaps(const char* const rrtype_name,
const std::vector<uint8_t>& typebits);
}
}
}

View File

@@ -182,7 +182,7 @@ NSEC3::NSEC3(InputBuffer& buffer, size_t rdata_len) {
vector<uint8_t> typebits(rdata_len);
buffer.readData(&typebits[0], rdata_len);
buildRRTypeBitmap("NSEC3", rdata_len, typebits);
checkRRTypeBitmaps("NSEC3", typebits);
impl_ = new NSEC3Impl(hashalg, flags, iterations, salt, next, typebits);
}

View File

@@ -105,7 +105,7 @@ NSEC::NSEC(InputBuffer& buffer, size_t rdata_len) {
vector<uint8_t> typebits(rdata_len);
buffer.readData(&typebits[0], rdata_len);
buildRRTypeBitmap("NSEC", rdata_len, typebits);
checkRRTypeBitmaps("NSEC", typebits);
impl_ = new NSECImpl(nextname, typebits);
}