1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Removed DNSResourceRecord. Records in DNS are now managed completely by DNS::Resource.

This commit is contained in:
Matias Fontanini
2014-01-21 22:56:53 -03:00
parent 6d7e06535a
commit c5404a6111
8 changed files with 236 additions and 702 deletions

View File

@@ -107,8 +107,8 @@
../include/dot11/../dot11/../endianness.h \
../include/dot11/../dot11/../internals.h \
../include/dot11/../dot11/../ip_address.h \
../include/dot11/../dot11/../hw_address.h \
../include/dot11/../dot11/../ipv6_address.h \
../include/dot11/../dot11/../hw_address.h \
../include/dot11/../dot11/../small_uint.h \
../include/dot11/../dot11/../hw_address.h \
../include/dot11/../dot11/../endianness.h \
@@ -174,10 +174,10 @@
../include/dot11/../dot11/../ip_address.h:
../include/dot11/../dot11/../hw_address.h:
../include/dot11/../dot11/../ipv6_address.h:
../include/dot11/../dot11/../hw_address.h:
../include/dot11/../dot11/../small_uint.h:
../include/dot11/../dot11/../hw_address.h:
@@ -270,7 +270,7 @@
../include/exceptions.h:
../src/dns.o: ../src/dns.cpp ../include/dns.h ../include/macros.h \
../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \
../include/endianness.h ../include/dns_record.h ../include/ip_address.h \
../include/endianness.h ../include/ip_address.h \
../include/ipv6_address.h ../include/exceptions.h ../include/rawpdu.h
../include/dns.h:
@@ -285,8 +285,6 @@
../include/endianness.h:
../include/dns_record.h:
../include/ip_address.h:
../include/ipv6_address.h:
@@ -294,19 +292,6 @@
../include/exceptions.h:
../include/rawpdu.h:
../src/dns_record.o: ../src/dns_record.cpp ../include/dns_record.h \
../include/cxxstd.h ../include/macros.h ../include/endianness.h \
../include/exceptions.h
../include/dns_record.h:
../include/cxxstd.h:
../include/macros.h:
../include/endianness.h:
../include/exceptions.h:
../src/dot11/dot11_assoc.o: ../src/dot11/dot11_assoc.cpp \
../include/dot11/dot11_assoc.h ../include/dot11/../config.h \
../include/dot11/../dot11/dot11_mgmt.h \
@@ -1976,7 +1961,16 @@
../include/exceptions.h:
../src/rsn_information.o: ../src/rsn_information.cpp \
../include/rsn_information.h ../include/endianness.h ../include/macros.h \
../include/exceptions.h
../include/exceptions.h ../include/dot11/dot11_base.h \
../include/dot11/../config.h ../include/dot11/../pdu.h \
../include/dot11/../macros.h ../include/dot11/../cxxstd.h \
../include/dot11/../exceptions.h ../include/dot11/../pdu_option.h \
../include/dot11/../endianness.h ../include/dot11/../internals.h \
../include/dot11/../constants.h ../include/dot11/../pdu.h \
../include/dot11/../hw_address.h ../include/dot11/../ip_address.h \
../include/dot11/../ipv6_address.h ../include/dot11/../small_uint.h \
../include/dot11/../hw_address.h ../include/dot11/../endianness.h \
../include/dot11/../cxxstd.h ../include/dot11/../macros.h
../include/rsn_information.h:
@@ -1985,6 +1979,44 @@
../include/macros.h:
../include/exceptions.h:
../include/dot11/dot11_base.h:
../include/dot11/../config.h:
../include/dot11/../pdu.h:
../include/dot11/../macros.h:
../include/dot11/../cxxstd.h:
../include/dot11/../exceptions.h:
../include/dot11/../pdu_option.h:
../include/dot11/../endianness.h:
../include/dot11/../internals.h:
../include/dot11/../constants.h:
../include/dot11/../pdu.h:
../include/dot11/../hw_address.h:
../include/dot11/../ip_address.h:
../include/dot11/../ipv6_address.h:
../include/dot11/../small_uint.h:
../include/dot11/../hw_address.h:
../include/dot11/../endianness.h:
../include/dot11/../cxxstd.h:
../include/dot11/../macros.h:
../src/sll.o: ../src/sll.cpp ../include/sll.h ../include/pdu.h \
../include/macros.h ../include/cxxstd.h ../include/exceptions.h \
../include/endianness.h ../include/hw_address.h ../include/internals.h \
@@ -2063,7 +2095,7 @@
../include/dot11/../exceptions.h ../include/dot11/../endianness.h \
../include/dot11/../macros.h ../include/dot11/../internals.h \
../include/dot11/../ip_address.h ../include/dot11/../cxxstd.h \
../include/dot11/../hw_address.h ../include/dot11/../ipv6_address.h \
../include/dot11/../ipv6_address.h ../include/dot11/../hw_address.h \
../include/dot11/../small_uint.h ../include/dot11/../hw_address.h \
../include/dot11/../endianness.h ../include/dot11/../cxxstd.h \
../include/dot11/../macros.h ../include/ethernetII.h \
@@ -2111,10 +2143,10 @@
../include/dot11/../cxxstd.h:
../include/dot11/../hw_address.h:
../include/dot11/../ipv6_address.h:
../include/dot11/../hw_address.h:
../include/dot11/../small_uint.h:
../include/dot11/../hw_address.h:
@@ -2524,10 +2556,9 @@ src/dhcpv6.o: src/dhcpv6.cpp ../include/dhcpv6.h ../include/pdu.h \
../include/ip_address.h:
src/dns.o: src/dns.cpp ../include/dns.h ../include/macros.h \
../include/pdu.h ../include/cxxstd.h ../include/exceptions.h \
../include/endianness.h ../include/dns_record.h \
../include/ipv6_address.h ../include/utils.h ../include/ip_address.h \
../include/ipv6_address.h ../include/hw_address.h ../include/internals.h \
../include/constants.h
../include/endianness.h ../include/ipv6_address.h ../include/utils.h \
../include/ip_address.h ../include/ipv6_address.h \
../include/hw_address.h ../include/internals.h ../include/constants.h
../include/dns.h:
@@ -2541,8 +2572,6 @@ src/dns.o: src/dns.cpp ../include/dns.h ../include/macros.h \
../include/endianness.h:
../include/dns_record.h:
../include/ipv6_address.h:
../include/utils.h:
@@ -4889,8 +4918,8 @@ src/wep_decrypt.o: src/wep_decrypt.cpp ../include/config.h \
../include/dot11/../dot11/../endianness.h \
../include/dot11/../dot11/../internals.h \
../include/dot11/../dot11/../ip_address.h \
../include/dot11/../dot11/../hw_address.h \
../include/dot11/../dot11/../ipv6_address.h \
../include/dot11/../dot11/../hw_address.h \
../include/dot11/../dot11/../small_uint.h \
../include/dot11/../dot11/../hw_address.h \
../include/dot11/../dot11/../endianness.h \
@@ -4957,10 +4986,10 @@ src/wep_decrypt.o: src/wep_decrypt.cpp ../include/config.h \
../include/dot11/../dot11/../ip_address.h:
../include/dot11/../dot11/../hw_address.h:
../include/dot11/../dot11/../ipv6_address.h:
../include/dot11/../dot11/../hw_address.h:
../include/dot11/../dot11/../small_uint.h:
../include/dot11/../dot11/../hw_address.h:

View File

@@ -119,7 +119,9 @@ TEST_F(DNSTest, ConstructorFromBuffer2) {
if(i == 0) {
dns.add_query(DNS::Query("google.com", DNS::A, DNS::IN));
dns.add_query(DNS::Query("google.com", DNS::MX, DNS::IN));
dns.add_answer("google.com", DNS::make_info(DNS::MX, DNS::IN, 0x762), std::string("alt5.aspmx.l.google.com"));
dns.add_answer(
DNS::Resource("google.com", "alt5.aspmx.l.google.com", DNS::MX, DNS::IN, 0x762)
);
}
}
}
@@ -243,8 +245,12 @@ TEST_F(DNSTest, Question) {
TEST_F(DNSTest, Answers) {
DNS dns;
dns.add_answer("www.example.com", DNS::make_info(DNS::A, DNS::IN, 0x762), IPv4Address("127.0.0.1"));
dns.add_answer("www.example2.com", DNS::make_info(DNS::MX, DNS::IN, 0x762), std::string("mail.example.com"));
dns.add_answer(
DNS::Resource("www.example.com", "127.0.0.1", DNS::A, DNS::IN, 0x762)
);
dns.add_answer(
DNS::Resource("www.example2.com", "mail.example.com", DNS::MX, DNS::IN, 0x762)
);
ASSERT_EQ(dns.answers_count(), 2);
@@ -269,9 +275,13 @@ TEST_F(DNSTest, Answers) {
TEST_F(DNSTest, Authority) {
DNS dns;
std::string encoded = DNS::encode_domain_name("carlos.example.com");
dns.add_authority("www.example.com", DNS::make_info(DNS::CNAME, DNS::IN, 0x762), (const uint8_t*)encoded.c_str(), encoded.size());
dns.add_authority("www.example.com", DNS::make_info(DNS::CNAME, DNS::IN, 0x762), (const uint8_t*)encoded.c_str(), encoded.size());
const char *domain = "carlos.example.com";
dns.add_authority(
DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
);
dns.add_authority(
DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
);
ASSERT_EQ(dns.authority_count(), 2);
@@ -281,7 +291,7 @@ TEST_F(DNSTest, Authority) {
EXPECT_EQ("www.example.com", it->dname());
EXPECT_EQ(it->type(), DNS::CNAME);
EXPECT_EQ(it->ttl(), 0x762U);
EXPECT_EQ(it->data(), "carlos.example.com");
EXPECT_EQ(it->data(), domain);
EXPECT_EQ(it->query_class(), DNS::IN);
}
}
@@ -289,9 +299,13 @@ TEST_F(DNSTest, Authority) {
TEST_F(DNSTest, Additional) {
DNS dns;
std::string encoded = DNS::encode_domain_name("carlos.example.com");
dns.add_additional("www.example.com", DNS::make_info(DNS::CNAME, DNS::IN, 0x762), (const uint8_t*)encoded.c_str(), encoded.size());
dns.add_additional("www.example.com", DNS::make_info(DNS::CNAME, DNS::IN, 0x762), (const uint8_t*)encoded.c_str(), encoded.size());
const char *domain = "carlos.example.com";
dns.add_additional(
DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
);
dns.add_additional(
DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
);
ASSERT_EQ(dns.additional_count(), 2);
@@ -300,15 +314,19 @@ TEST_F(DNSTest, Additional) {
EXPECT_EQ("www.example.com", it->dname());
EXPECT_EQ(it->type(), DNS::CNAME);
EXPECT_EQ(it->ttl(), 0x762U);
EXPECT_EQ(it->data(), "carlos.example.com");
EXPECT_EQ(it->data(), domain);
EXPECT_EQ(it->query_class(), DNS::IN);
}
}
TEST_F(DNSTest, AnswersWithSameName) {
DNS dns;
dns.add_answer("www.example.com", DNS::make_info(DNS::A, DNS::IN, 0x762), IPv4Address("127.0.0.1"));
dns.add_answer("www.example.com", DNS::make_info(DNS::A, DNS::IN, 0x762), IPv4Address("127.0.0.2"));
dns.add_answer(
DNS::Resource("www.example.com", "127.0.0.1", DNS::A, DNS::IN, 0x762)
);
dns.add_answer(
DNS::Resource("www.example.com", "127.0.0.2", DNS::A, DNS::IN, 0x762)
);
ASSERT_EQ(dns.answers_count(), 2);
DNS::resources_type resources = dns.answers();
for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) {
@@ -322,8 +340,12 @@ TEST_F(DNSTest, AnswersWithSameName) {
TEST_F(DNSTest, AnswersV6) {
DNS dns;
dns.add_answer("www.example.com", DNS::make_info(DNS::AAAA, DNS::IN, 0x762), IPv6Address("f9a8:239::1:1"));
dns.add_answer("www.example.com", DNS::make_info(DNS::AAAA, DNS::IN, 0x762), IPv6Address("f9a8:239::1:1"));
dns.add_answer(
DNS::Resource("www.example.com", "f9a8:239::1:1", DNS::AAAA, DNS::IN, 0x762)
);
dns.add_answer(
DNS::Resource("www.example.com", "f9a8:239::1:1", DNS::AAAA, DNS::IN, 0x762)
);
ASSERT_EQ(dns.answers_count(), 2);
DNS::resources_type resources = dns.answers();
@@ -341,9 +363,13 @@ TEST_F(DNSTest, ItAintGonnaCorrupt) {
EXPECT_EQ(dns.questions_count(), 1);
EXPECT_EQ(dns.answers_count(), 5);
std::string encoded = DNS::encode_domain_name("carlos.example.com");
dns.add_additional("www.example.com", DNS::make_info(DNS::CNAME, DNS::IN, 0x762), (const uint8_t*)encoded.c_str(), encoded.size());
dns.add_authority("www.example.com", DNS::make_info(DNS::CNAME, DNS::IN, 0x762), (const uint8_t*)encoded.c_str(), encoded.size());
const char *domain = "carlos.example.com";
dns.add_additional(
DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
);
dns.add_authority(
DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762)
);
dns.add_query(DNS::Query("google.com", DNS::A, DNS::IN));
DNS::queries_type queries(dns.queries());
@@ -376,7 +402,7 @@ TEST_F(DNSTest, ItAintGonnaCorrupt) {
EXPECT_EQ("www.example.com", it->dname());
EXPECT_EQ(it->type(), DNS::CNAME);
EXPECT_EQ(it->ttl(), 0x762U);
EXPECT_EQ(it->data(), "carlos.example.com");
EXPECT_EQ(it->data(), domain);
EXPECT_EQ(it->query_class(), DNS::IN);
}
@@ -388,7 +414,7 @@ TEST_F(DNSTest, ItAintGonnaCorrupt) {
EXPECT_EQ("www.example.com", it->dname());
EXPECT_EQ(it->type(), DNS::CNAME);
EXPECT_EQ(it->ttl(), 0x762U);
EXPECT_EQ(it->data(), "carlos.example.com");
EXPECT_EQ(it->data(), domain);
EXPECT_EQ(it->query_class(), DNS::IN);
}
}