/// sequence will be
/// - 2 bytes of opaque data (which corresponds to the MX preference)
/// - a domain name (which corresponds to the MX name)
+///
/// If the encoded data contain multiple MX RDATAs, the same type of
/// sequence continues for the number of RDATAs. Note that the opaque
-/// data field does not always correspond to a specific RDATA field
+/// data field does not always corresponds to a specific RDATA field
/// as is the 2-byte preference field of MX. For example, the field
-/// sequence for an SOA RDATA in terms of `RdataEncoder` will be:
+/// sequence for an SOA RDATA in terms of RdataEncoder will be:
/// - a domain name (which corresponds to the SOA MNAME)
/// - a domain name (which corresponds to the SOA RNAME)
/// - 20 bytes of opaque data (for the rest of fields)
/// \brief Call next() until the end.
///
/// This is just convenience method to iterate through all the data.
- /// It calls next until it reaches the end (it does not rewind before,
+ /// It calls next until it reaches the end (it does not rewind beforehand,
/// therefore if you already called next() yourself, it does not start
/// at the beginning).
void iterate() {
- while (next() != RRSET_BOUNDARY) { }
+ while (next() != RRSET_BOUNDARY) {}
}
+
/// \brief Call next() until the end of current rdata.
///
/// This is a convenience method to iterate until the end of current
/// \return If there was Rdata to iterate through.
bool iterateRdata() {
while (true) {
- switch(next()) {
+ switch (next()) {
case NO_BOUNDARY: break;
case RDATA_BOUNDARY: return (true);
case RRSET_BOUNDARY: return (false);
/// This is almost the same as iterate(), but it iterates through the
/// RRSig data instead.
void iterateAllSigs() {
- while (nextSig() != RRSET_BOUNDARY) { }
+ while (nextSig() != RRSET_BOUNDARY) {}
}
/// \brief Iterate through the current RRSig Rdata.
/// In practice, this should process one DATA field.
bool iterateSingleSig() {
while (true) {
- switch(nextSig()) {
+ switch (nextSig()) {
case NO_BOUNDARY: break;
case RDATA_BOUNDARY: return (true);
case RRSET_BOUNDARY: return (false);
// from encoded representation of each RDATA.
void
renderNameField(MessageRenderer* renderer, bool additional_required,
- const LabelSequence& labels, unsigned attributes)
+ const LabelSequence& labels, RdataNameAttributes attributes)
{
EXPECT_EQ(additional_required, (attributes & NAMEATTR_ADDITIONAL) != 0);
renderer->writeName(labels, (attributes & NAMEATTR_COMPRESSIBLE) != 0);
}
void
-renderDataField(MessageRenderer* renderer, const void* data,
- size_t data_len)
-{
+renderDataField(MessageRenderer* renderer, const void* data, size_t data_len) {
renderer->writeData(data, data_len);
}
class RdataSerializationTest : public ::testing::Test {
protected:
RdataSerializationTest() : a_rdata_(createRdata(RRType::A(), RRClass::IN(),
- "192.0.2.53")),
+ "192.0.2.53")),
aaaa_rdata_(createRdata(RRType::AAAA(), RRClass::IN(),
"2001:db8::53")),
rrsig_rdata_(createRdata(
// Used across more classes and scopes. But it's just uninteresting
// constant.
-const Name &dummyName2() {
- static Name result("example.com");
+const Name& dummyName2() {
+ static const Name result("example.com");
return (result);
}
boost::bind(renderNameField, &renderer,
additionalRequired(rrtype), _1, _2),
boost::bind(renderDataField, &renderer, _1, _2));
- while (reader.next() != RdataReader::RRSET_BOUNDARY) { }
+ while (reader.next() != RdataReader::RRSET_BOUNDARY) {}
renderer.writeName(dummyName2());
- while (reader.nextSig() != RdataReader::RRSET_BOUNDARY) { }
+ while (reader.nextSig() != RdataReader::RRSET_BOUNDARY) {}
}
};
class RewindAndDecode {
private:
static void writeName(MessageRenderer** renderer,
- const LabelSequence& labels, unsigned attributes)
+ const LabelSequence& labels,
+ RdataNameAttributes attributes)
{
(*renderer)->writeName(labels,
(attributes & NAMEATTR_COMPRESSIBLE) != 0);
boost::bind(renderDataField, &renderer, _1, _2));
size_t actual_count = 0;
while (reader.iterateRdata()) {
- actual_count ++;
+ ++actual_count;
}
EXPECT_EQ(rdata_count, actual_count);
actual_count = 0;
renderer.writeName(dummyName2());
while (reader.iterateSingleSig()) {
- actual_count ++;
+ ++actual_count;
}
EXPECT_EQ(sig_count, actual_count);
}
DecoderStyles;
// Each decoder style must contain a decode() method. Such method is expected
// to decode the passed data, first render the Rdata into the passed renderer,
-// then write the dummyName2() there and write the RRSig data after that. It may
-// do other checks too.
+// then write the dummyName2() there and write the RRSig data after that.
+// It may do other checks too.
//
// There are some slight differences to how to do the decoding, that's why we
// have the typed test.