Commit 63eca991 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[1396] Fix width of TTL field

parent 6f177a3d
......@@ -141,7 +141,7 @@ getLengthHelper(size_t* rlength, size_t rr_count, uint16_t name_labels_size,
rrlen += name_labels_size;
rrlen += 2; // TYPE field
rrlen += 2; // CLASS field
rrlen += 2; // TTL field
rrlen += 4; // TTL field
rrlen += 2; // RDLENGTH field
*rlength = 0;
......
......@@ -338,30 +338,30 @@ TEST_F(TreeNodeRRsetTest, getLength) {
// www.example.com = 1 + 3 + 1 + 7 + 1 + 3 + 1 = 17 octets
// TYPE field = 2 octets
// CLASS field = 2 octets
// TTL field = 2 octets
// TTL field = 4 octets
// RDLENGTH field = 2 octets
// A RDATA = 4 octets
// Total = 17 + 2 + 2 + 2 + 2 + 4 = 29 octets
// Total = 17 + 2 + 2 + 4 + 2 + 4 = 31 octets
// RRSIG RR
// www.example.com = 1 + 4 + 1 + 7 + 1 + 3 + 1 = 17 octets
// TYPE field = 2 octets
// CLASS field = 2 octets
// TTL field = 2 octets
// TTL field = 4 octets
// RDLENGTH field = 2 octets
// RRSIG RDATA = 18 + [1 + 7 + 1 + 3 + 1 (example.com)] + 3 (base64
// decode of FAKE) octets
// Total = 17 + 2 + 2 + 2 + 2 + 34 = 59 octets
// Total = 17 + 2 + 2 + 4 + 2 + 34 = 61 octets
// 1. with RRSIG, DNSSEC not OK
// ` 2 A RRs + 0 RRSIG RRs
const TreeNodeRRset rrset1(rrclass_, www_node_, a_rdataset_, false);
EXPECT_EQ(29 + 29, rrset1.getLength());
EXPECT_EQ(31 + 31, rrset1.getLength());
// 2. with RRSIG, DNSSEC OK
// ` 2 A RRs + 1 RRSIG RR
const TreeNodeRRset rrset2(rrclass_, www_node_, a_rdataset_, true);
EXPECT_EQ(29 + 29 + 59, rrset2.getLength());
EXPECT_EQ(31 + 31 + 61, rrset2.getLength());
}
TEST_F(TreeNodeRRsetTest, toWire) {
......
......@@ -53,15 +53,15 @@ class TestModuleSpec(unittest.TestCase):
# test.example.com = 1 + 4 + 1 + 7 + 1 + 3 + 1 = 18 octets
# TYPE field = 2 octets
# CLASS field = 2 octets
# TTL field = 2 octets
# TTL field = 4 octets
# RDLENGTH field = 2 octets
# Total = 18 + 2 + 2 + 2 + 2 = 26 octets
self.assertEqual(26, self.rrset_any_a_empty.get_length())
# Total = 18 + 2 + 2 + 4 + 2 = 28 octets
self.assertEqual(28, self.rrset_any_a_empty.get_length())
# Single A RR:
# 26 octets (above) + 4 octets (A RDATA) = 30 octets
# 28 octets (above) + 4 octets (A RDATA) = 32 octets
# With 2 A RRs:
self.assertEqual(30 + 30, self.rrset_a.get_length())
self.assertEqual(32 + 32, self.rrset_a.get_length())
def test_get_name(self):
self.assertEqual(self.test_name, self.rrset_a.get_name())
......
......@@ -306,7 +306,7 @@ BasicRRset::getLength() const {
length += getName().getLength();
length += 2; // TYPE field
length += 2; // CLASS field
length += 2; // TTL field
length += 4; // TTL field
length += 2; // RDLENGTH field (=0 in wire format)
return (length);
......@@ -320,7 +320,7 @@ BasicRRset::getLength() const {
rrlen += getName().getLength();
rrlen += 2; // TYPE field
rrlen += 2; // CLASS field
rrlen += 2; // TTL field
rrlen += 4; // TTL field
rrlen += 2; // RDLENGTH field
rrlen += it->getCurrent().getLength();
......
......@@ -212,20 +212,20 @@ TEST_F(RRsetTest, getLength) {
// test.example.com = 1 + 4 + 1 + 7 + 1 + 3 + 1 = 18 octets
// TYPE field = 2 octets
// CLASS field = 2 octets
// TTL field = 2 octets
// TTL field = 4 octets
// RDLENGTH field = 2 octets
// Total = 18 + 2 + 2 + 2 + 2 = 26 octets
EXPECT_EQ(26, rrset_any_a_empty.getLength());
EXPECT_EQ(26, rrset_none_a_empty.getLength());
// Total = 18 + 2 + 2 + 4 + 2 = 28 octets
EXPECT_EQ(28, rrset_any_a_empty.getLength());
EXPECT_EQ(28, rrset_none_a_empty.getLength());
// RRset with single RDATA
// 26 (above) + 4 octets (A RDATA) = 30 octets
// 28 (above) + 4 octets (A RDATA) = 32 octets
rrset_a_empty.addRdata(in::A("192.0.2.1"));
EXPECT_EQ(30, rrset_a_empty.getLength());
EXPECT_EQ(32, rrset_a_empty.getLength());
// 2 A RRs
rrset_a_empty.addRdata(in::A("192.0.2.2"));
EXPECT_EQ(60, rrset_a_empty.getLength());
EXPECT_EQ(32 + 32, rrset_a_empty.getLength());
}
TEST_F(RRsetTest, toWireBuffer) {
......@@ -395,32 +395,32 @@ TEST_F(RRsetRRSIGTest, getLength) {
// test.example.com = 1 + 4 + 1 + 7 + 1 + 3 + 1 = 18 octets
// TYPE field = 2 octets
// CLASS field = 2 octets
// TTL field = 2 octets
// TTL field = 4 octets
// RDLENGTH field = 2 octets
// A RDATA = 4 octets
// Total = 18 + 2 + 2 + 2 + 2 + 4 = 30 octets
// Total = 18 + 2 + 2 + 4 + 2 + 4 = 32 octets
// 2 A RRs
EXPECT_EQ(60, rrset_a->getLength());
EXPECT_EQ(32 + 32, rrset_a->getLength());
// RRSIG
// test.example.com = 1 + 4 + 1 + 7 + 1 + 3 + 1 = 18 octets
// TYPE field = 2 octets
// CLASS field = 2 octets
// TTL field = 2 octets
// TTL field = 4 octets
// RDLENGTH field = 2 octets
// RRSIG RDATA = 40 octets
// Total = 18 + 2 + 2 + 2 + 2 + 40 = 66 octets
// Total = 18 + 2 + 2 + 4 + 2 + 40 = 68 octets
RRsetPtr my_rrsig(new RRset(test_name, RRClass::IN(),
RRType::RRSIG(), RRTTL(3600)));
my_rrsig->addRdata(generic::RRSIG("A 4 3 3600 "
"20000101000000 20000201000000 "
"12345 example.com. FAKEFAKEFAKE"));
EXPECT_EQ(66, my_rrsig->getLength());
EXPECT_EQ(68, my_rrsig->getLength());
// RRset with attached RRSIG
rrset_a->addRRsig(my_rrsig);
EXPECT_EQ(60 + 66, rrset_a->getLength());
EXPECT_EQ(32 + 32 + 68, rrset_a->getLength());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment