diff --git a/examples/dns_spoof.cpp b/examples/dns_spoof.cpp index 0ea4fa4..13cec50 100644 --- a/examples/dns_spoof.cpp +++ b/examples/dns_spoof.cpp @@ -37,8 +37,7 @@ using namespace Tins; PacketSender sender; -bool callback(const PDU& pdu) -{ +bool callback(const PDU& pdu) { // The packet probably looks like this: // // EthernetII / IP / UDP / RawPDU @@ -54,7 +53,7 @@ bool callback(const PDU& pdu) if (dns.type() == DNS::QUERY) { // Let's see if there's any query for an "A" record. for (const auto& query : dns.queries()) { - if (query.type() == DNS::A) { + if (query.query_type() == DNS::A) { // Here's one! Let's add an answer. dns.add_answer( DNS::Resource( diff --git a/examples/dns_stats.cpp b/examples/dns_stats.cpp index 0d4bda5..42740c1 100644 --- a/examples/dns_stats.cpp +++ b/examples/dns_stats.cpp @@ -128,8 +128,7 @@ private: map m_packet_info; }; -void dns_monitor::run(BaseSniffer& sniffer) -{ +void dns_monitor::run(BaseSniffer& sniffer) { sniffer.sniff_loop( bind( &dns_monitor::callback, @@ -139,8 +138,7 @@ void dns_monitor::run(BaseSniffer& sniffer) ); } -bool dns_monitor::callback(const PDU& pdu) -{ +bool dns_monitor::callback(const PDU& pdu) { auto now = clock_type::now(); auto dns = pdu.rfind_pdu().to(); auto info = make_packet_info(pdu, dns); @@ -170,8 +168,7 @@ bool dns_monitor::callback(const PDU& pdu) // hold the same DNS id as belonging to the same query. // // This function retrieves a tuple (addr, addr, id) that will achieve it. -auto dns_monitor::make_packet_info(const PDU& pdu, const DNS& dns) -> packet_info -{ +auto dns_monitor::make_packet_info(const PDU& pdu, const DNS& dns) -> packet_info { const auto& ip = pdu.rfind_pdu(); return make_tuple( // smallest address first diff --git a/include/tins/dns.h b/include/tins/dns.h index 83f1279..a7a500c 100644 --- a/include/tins/dns.h +++ b/include/tins/dns.h @@ -157,7 +157,7 @@ public: /** * \brief Struct that represent DNS queries. */ - class Query { + class query { public: /** * \brief Constructs a DNS query. @@ -166,13 +166,13 @@ public: * \param tp The query type. * \param cl The query class. */ - Query(const std::string& nm, QueryType tp, QueryClass cl) + query(const std::string& nm, QueryType tp, QueryClass cl) : name_(nm), type_(tp), qclass_(cl) {} /** * \brief Default constructs this Query. */ - Query() : type_(), qclass_() {} + query() : type_(), qclass_() {} /** * \brief Setter for the name field. @@ -188,7 +188,19 @@ public: * * \param tp The query type to be set. */ - void type(QueryType tp) { + void query_type(QueryType tp) { + type_ = tp; + } + + /** + * \brief Setter for the query type field. + * + * This method is deprecated. Use query::query_type + * + * \deprecated + * \sa query::query_type + */ + TINS_DEPRECATED(void type(QueryType tp)) { type_ = tp; } @@ -204,24 +216,42 @@ public: /** * \brief Getter for the name field. */ - const std::string& dname() const { return name_; } + const std::string& dname() const { + return name_; + } /** * \brief Getter for the query type field. */ - QueryType type() const { return type_; } + QueryType query_type() const { + return type_; + } + + /** + * \brief Getter for the query type field. + * + * This method is deprecated. Use query::query_type + * + * \deprecated + * \sa query::query_type + */ + TINS_DEPRECATED(QueryType type() const) { + return type_; + } /** * \brief Getter for the query class field. */ - QueryClass query_class() const { return qclass_; } + QueryClass query_class() const { + return qclass_; + } private: std::string name_; QueryType type_; QueryClass qclass_; }; - class Resource; + class resource; /** * \brief Class that represents a Start Of Authority record @@ -239,7 +269,7 @@ public: * \brief Constructs a SOA record from a DNS::resource * \param resource The resource from which to construct this record */ - soa_record(const DNS::Resource& resource); + soa_record(const DNS::resource& resource); /** * \brief Constructs a SOA record from a buffer @@ -392,7 +422,7 @@ public: /** * \brief Class that represent DNS resource records. */ - class Resource { + class resource { public: /** * Constructs a Resource object. @@ -404,7 +434,7 @@ public: * \param rclass The class of this record. * \param ttl The time-to-live of this record. */ - Resource(const std::string& dname, + resource(const std::string& dname, const std::string& data, uint16_t type, uint16_t rclass, @@ -413,7 +443,7 @@ public: : dname_(dname), data_(data), type_(type), qclass_(rclass), ttl_(ttl), preference_(preference) {} - Resource() : type_(), qclass_(), ttl_(), preference_() {} + resource() : type_(), qclass_(), ttl_(), preference_() {} /** * \brief Getter for the domain name field. @@ -435,10 +465,22 @@ public: /** * Getter for the query type field. */ - uint16_t type() const { + uint16_t query_type() const { return type_; } + /** + * \brief Getter for the query type field. + * + * This method is deprecated. Use resource::query_type + * + * \deprecated + * \sa resource::query_type + */ + TINS_DEPRECATED(uint16_t type() const) { + return type_; + } + /** * Getter for the query class field. */ @@ -495,14 +537,26 @@ public: } /** - * Setter for the type field. + * Setter for the query type field. */ - void type(uint16_t data) { + void query_type(uint16_t data) { type_ = data; } /** - * Setter for the class field. + * \brief Setter for the query type field. + * + * This method is deprecated. Use query::query_type + * + * \deprecated + * \sa resource::query_type + */ + TINS_DEPRECATED(void type(uint16_t data)) { + type_ = data; + } + + /** + * Setter for the query class field. */ void query_class(uint16_t data) { qclass_ = data; @@ -529,9 +583,12 @@ public: uint32_t ttl_; uint16_t preference_; }; + + TINS_DEPRECATED(typedef query Query); + TINS_DEPRECATED(typedef resource Resource); - typedef std::list queries_type; - typedef std::list resources_type; + typedef std::list queries_type; + typedef std::list resources_type; typedef IPv4Address address_type; typedef IPv6Address address_v6_type; @@ -802,28 +859,28 @@ public: * * \param query The query to be added. */ - void add_query(const Query& query); + void add_query(const query& query); /** * \brief Add an answer resource record. * * \param resource The resource to be added. */ - void add_answer(const Resource& resource); + void add_answer(const resource& resource); /** * \brief Add an authority resource record. * * \param resource The resource to be added. */ - void add_authority(const Resource& resource); + void add_authority(const resource& resource); /** * \brief Add an additional resource record. * * \param resource The resource to be added. */ - void add_additional(const Resource& resource); + void add_additional(const resource& resource); /** * \brief Getter for this PDU's DNS queries. @@ -934,7 +991,6 @@ private: authority, additional; } TINS_END_PACK; - typedef std::list QueriesType; typedef std::vector > sections_type; uint32_t compose_name(const uint8_t* ptr, char* out_ptr) const; @@ -952,7 +1008,7 @@ private: static void inline_convert_v4(uint32_t value, char* output); static bool contains_dname(uint16_t type); void write_serialization(uint8_t* buffer, uint32_t total_sz, const PDU* parent); - void add_record(const Resource& resource, const sections_type& sections); + void add_record(const resource& resource, const sections_type& sections); dns_header header_; byte_array records_data_; diff --git a/src/dns.cpp b/src/dns.cpp index 5a66ac2..f970ccc 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -163,7 +163,7 @@ bool DNS::contains_dname(uint16_t type) { return type == MX || type == CNAME || type == PTR || type == NS; } -void DNS::add_query(const Query& query) { +void DNS::add_query(const query& query) { string new_str = encode_domain_name(query.dname()); size_t previous_length = new_str.size(); // Epand the string to hold: Type (2 bytes) + Class (2 Bytes) @@ -173,7 +173,7 @@ void DNS::add_query(const Query& query) { (uint8_t*)&new_str[0] + previous_length, sizeof(uint16_t) * 2 ); - stream.write_be(query.type()); + stream.write_be(query.query_type()); stream.write_be(query.query_class()); uint32_t offset = static_cast(new_str.size()), threshold = answers_idx_; @@ -188,7 +188,7 @@ void DNS::add_query(const Query& query) { header_.questions = Endian::host_to_be(static_cast(questions_count() + 1)); } -void DNS::add_answer(const Resource& resource) { +void DNS::add_answer(const resource& resource) { sections_type sections; sections.push_back(make_pair(&authority_idx_, authority_count())); sections.push_back(make_pair(&additional_idx_, additional_count())); @@ -198,7 +198,7 @@ void DNS::add_answer(const Resource& resource) { ); } -void DNS::add_record(const Resource& resource, const sections_type& sections) { +void DNS::add_record(const resource& resource, const sections_type& sections) { // We need to check that the data provided is correct. Otherwise, the sections // will end up being inconsistent. IPv4Address v4_addr; @@ -207,22 +207,22 @@ void DNS::add_record(const Resource& resource, const sections_type& sections) { encoded_data; // By default the data size is the length of the data field. size_t data_size = resource.data().size(); - if (resource.type() == A) { + if (resource.query_type() == A) { v4_addr = resource.data(); data_size = 4; } - else if (resource.type() == AAAA) { + else if (resource.query_type() == AAAA) { v6_addr = resource.data(); data_size = IPv6Address::address_size; } - else if (contains_dname(resource.type())) { + else if (contains_dname(resource.query_type())) { encoded_data = encode_domain_name(resource.data()); data_size = encoded_data.size(); } size_t offset = buffer.size() + sizeof(uint16_t) * 3 + sizeof(uint32_t) + data_size, threshold = sections.empty() ? records_data_.size() :* sections.front().first; // Take into account the MX preference field - if (resource.type() == MX) { + if (resource.query_type() == MX) { offset += sizeof(uint16_t); } for (size_t i = 0; i < sections.size(); ++i) { @@ -241,17 +241,17 @@ void DNS::add_record(const Resource& resource, const sections_type& sections) { ); OutputMemoryStream stream(&records_data_[0] + threshold, offset); stream.write(buffer.begin(), buffer.end()); - stream.write_be(resource.type()); + stream.write_be(resource.query_type()); stream.write_be(resource.query_class()); stream.write_be(resource.ttl()); - stream.write_be(data_size + (resource.type() == MX ? 2 : 0)); - if (resource.type() == MX) { + stream.write_be(data_size + (resource.query_type() == MX ? 2 : 0)); + if (resource.query_type() == MX) { stream.write_be(resource.preference()); } - if (resource.type() == A) { + if (resource.query_type() == A) { stream.write(v4_addr); } - else if (resource.type() == AAAA) { + else if (resource.query_type() == AAAA) { stream.write(v6_addr); } else if (!encoded_data.empty()) { @@ -262,7 +262,7 @@ void DNS::add_record(const Resource& resource, const sections_type& sections) { } } -void DNS::add_authority(const Resource& resource) { +void DNS::add_authority(const resource& resource) { sections_type sections; sections.push_back(make_pair(&additional_idx_, additional_count())); add_record(resource, sections); @@ -271,7 +271,7 @@ void DNS::add_authority(const Resource& resource) { ); } -void DNS::add_additional(const Resource& resource){ +void DNS::add_additional(const resource& resource){ add_record(resource, sections_type()); header_.additional = Endian::host_to_be( additional_count() + 1 @@ -470,7 +470,7 @@ void DNS::convert_records(const uint8_t* ptr, break; } res.push_back( - Resource( + resource( dname, (used_small_buffer) ? small_addr_buf : data, type, @@ -544,7 +544,7 @@ DNS::queries_type DNS::queries() const { uint16_t query_type = stream.read_be(); uint16_t query_class = stream.read_be(); output.push_back( - Query(buffer, (QueryType)query_type, (QueryClass)query_class) + query(buffer, (QueryType)query_type, (QueryClass)query_class) ); } } @@ -618,7 +618,7 @@ DNS::soa_record::soa_record(const uint8_t* buffer, uint32_t total_sz) { init(buffer, total_sz); } -DNS::soa_record::soa_record(const DNS::Resource& resource) { +DNS::soa_record::soa_record(const DNS::resource& resource) { init((const uint8_t*)&resource.data()[0], resource.data().size()); } diff --git a/tests/src/dns.cpp b/tests/src/dns.cpp index fbe4840..dd72bed 100644 --- a/tests/src/dns.cpp +++ b/tests/src/dns.cpp @@ -16,8 +16,8 @@ public: dns_packet1[]; void test_equals(const DNS& dns1, const DNS& dns2); - void test_equals(const DNS::Query& q1, const DNS::Query& q2); - void test_equals(const DNS::Resource& q1, const DNS::Resource& q2); + void test_equals(const DNS::query& q1, const DNS::query& q2); + void test_equals(const DNS::resource& q1, const DNS::resource& q2); }; const uint8_t DNSTest::expected_packet[] = { @@ -66,16 +66,16 @@ void DNSTest::test_equals(const DNS& dns1, const DNS& dns2) { EXPECT_EQ(dns1.inner_pdu() != NULL, dns2.inner_pdu() != NULL); } -void DNSTest::test_equals(const DNS::Query& q1, const DNS::Query& q2) { +void DNSTest::test_equals(const DNS::query& q1, const DNS::query& q2) { EXPECT_EQ(q1.dname(), q2.dname()); - EXPECT_EQ(q1.type(), q2.type()); + EXPECT_EQ(q1.query_type(), q2.query_type()); EXPECT_EQ(q1.query_class(), q2.query_class()); } -void DNSTest::test_equals(const DNS::Resource& q1, const DNS::Resource& q2) { +void DNSTest::test_equals(const DNS::resource& q1, const DNS::resource& q2) { EXPECT_EQ(q1.dname(), q2.dname()); EXPECT_EQ(q1.data(), q2.data()); - EXPECT_EQ(q1.type(), q2.type()); + EXPECT_EQ(q1.query_type(), q2.query_type()); EXPECT_EQ(q1.query_class(), q2.query_class()); EXPECT_EQ(q1.ttl(), q2.ttl()); } @@ -95,13 +95,13 @@ TEST_F(DNSTest, ConstructorFromBuffer) { EXPECT_EQ(dns.questions_count(), 1); EXPECT_EQ(dns.answers_count(), 1); - std::list queries = dns.queries(); + std::list queries = dns.queries(); ASSERT_EQ(queries.size(), 1U); - test_equals(queries.front(), DNS::Query("www.example.com", DNS::A, DNS::IN)); + test_equals(queries.front(), DNS::query("www.example.com", DNS::A, DNS::IN)); - std::list answers = dns.answers(); + std::list answers = dns.answers(); ASSERT_EQ(answers.size(), 1U); - test_equals(answers.front(), DNS::Resource("www.example.com", "192.168.0.1", DNS::A, DNS::IN, 0x1234)); + test_equals(answers.front(), DNS::resource("www.example.com", "192.168.0.1", DNS::A, DNS::IN, 0x1234)); } TEST_F(DNSTest, ConstructorFromBuffer2) { @@ -113,7 +113,7 @@ TEST_F(DNSTest, ConstructorFromBuffer2) { DNS::queries_type queries(dns.queries()); for(DNS::queries_type::const_iterator it = queries.begin(); it != queries.end(); ++it) { EXPECT_EQ("google.com", it->dname()); - EXPECT_TRUE(it->type() == DNS::MX || it->type() == DNS::A); + EXPECT_TRUE(it->query_type() == DNS::MX || it->query_type() == DNS::A); EXPECT_EQ(it->query_class(), DNS::IN); } @@ -121,7 +121,7 @@ TEST_F(DNSTest, ConstructorFromBuffer2) { size_t resource_index = 0; for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_EQ("google.com", it->dname()); - EXPECT_EQ(DNS::MX, it->type()); + EXPECT_EQ(DNS::MX, it->query_type()); EXPECT_EQ(DNS::IN, it->query_class()); EXPECT_TRUE( it->data() == "alt1.aspmx.l.google.com" || @@ -141,10 +141,10 @@ TEST_F(DNSTest, ConstructorFromBuffer2) { } // Add some stuff and see if something gets broken 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_query(DNS::query("google.com", DNS::A, DNS::IN)); + dns.add_query(DNS::query("google.com", DNS::MX, DNS::IN)); dns.add_answer( - DNS::Resource("google.com", "alt5.aspmx.l.google.com", DNS::MX, DNS::IN, 0x762) + DNS::resource("google.com", "alt5.aspmx.l.google.com", DNS::MX, DNS::IN, 0x762) ); } } @@ -265,19 +265,19 @@ TEST_F(DNSTest, RCode) { TEST_F(DNSTest, Question) { DNS dns; - dns.add_query(DNS::Query("www.example.com", DNS::A, DNS::IN)); - dns.add_query(DNS::Query("www.example2.com", DNS::MX, DNS::IN)); + dns.add_query(DNS::query("www.example.com", DNS::A, DNS::IN)); + dns.add_query(DNS::query("www.example2.com", DNS::MX, DNS::IN)); ASSERT_EQ(dns.questions_count(), 2); DNS::queries_type queries(dns.queries()); for(DNS::queries_type::const_iterator it = queries.begin(); it != queries.end(); ++it) { EXPECT_TRUE(it->dname() == "www.example.com" || it->dname() == "www.example2.com"); if(it->dname() == "www.example.com") { - EXPECT_EQ(it->type(), DNS::A); + EXPECT_EQ(it->query_type(), DNS::A); EXPECT_EQ(it->query_class(), DNS::IN); } else if(it->dname() == "www.example2.com") { - EXPECT_EQ(it->type(), DNS::MX); + EXPECT_EQ(it->query_type(), DNS::MX); EXPECT_EQ(it->query_class(), DNS::IN); } } @@ -286,10 +286,10 @@ TEST_F(DNSTest, Question) { TEST_F(DNSTest, Answers) { DNS dns; dns.add_answer( - DNS::Resource("www.example.com", "127.0.0.1", DNS::A, DNS::IN, 0x762) + 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) + DNS::resource("www.example2.com", "mail.example.com", DNS::MX, DNS::IN, 0x762) ); ASSERT_EQ(dns.answers_count(), 2); @@ -298,13 +298,13 @@ TEST_F(DNSTest, Answers) { for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_TRUE(it->dname() == "www.example.com" || it->dname() == "www.example2.com"); if(it->dname() == "www.example.com") { - EXPECT_EQ(it->type(), DNS::A); + EXPECT_EQ(it->query_type(), DNS::A); EXPECT_EQ(it->ttl(), 0x762U); EXPECT_EQ(it->data(), "127.0.0.1"); EXPECT_EQ(it->query_class(), DNS::IN); } else if(it->dname() == "www.example2.com") { - EXPECT_EQ(it->type(), DNS::MX); + EXPECT_EQ(it->query_type(), DNS::MX); EXPECT_EQ(it->ttl(), 0x762U); EXPECT_EQ(it->data(), "mail.example.com"); EXPECT_EQ(it->query_class(), DNS::IN); @@ -317,10 +317,10 @@ TEST_F(DNSTest, Authority) { const char* domain = "carlos.example.com"; dns.add_authority( - DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762) + 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::resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762) ); ASSERT_EQ(dns.authority_count(), 2); @@ -329,7 +329,7 @@ TEST_F(DNSTest, Authority) { EXPECT_EQ(2ULL, resources.size()); for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_EQ("www.example.com", it->dname()); - EXPECT_EQ(it->type(), DNS::CNAME); + EXPECT_EQ(it->query_type(), DNS::CNAME); EXPECT_EQ(it->ttl(), 0x762U); EXPECT_EQ(it->data(), domain); EXPECT_EQ(it->query_class(), DNS::IN); @@ -341,10 +341,10 @@ TEST_F(DNSTest, Additional) { const char* domain = "carlos.example.com"; dns.add_additional( - DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762) + 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) + DNS::resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762) ); ASSERT_EQ(dns.additional_count(), 2); @@ -352,9 +352,9 @@ TEST_F(DNSTest, Additional) { DNS::resources_type resources = dns.additional(); for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_EQ("www.example.com", it->dname()); - EXPECT_EQ(it->type(), DNS::CNAME); EXPECT_EQ(it->ttl(), 0x762U); EXPECT_EQ(it->data(), domain); + EXPECT_EQ(it->query_type(), DNS::CNAME); EXPECT_EQ(it->query_class(), DNS::IN); } } @@ -362,18 +362,18 @@ TEST_F(DNSTest, Additional) { TEST_F(DNSTest, AnswersWithSameName) { DNS dns; dns.add_answer( - DNS::Resource("www.example.com", "127.0.0.1", DNS::A, DNS::IN, 0x762) + 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) + 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) { EXPECT_TRUE(it->data() == "127.0.0.1" || it->data() == "127.0.0.2"); EXPECT_EQ(it->dname(), "www.example.com"); - EXPECT_EQ(it->type(), DNS::A); EXPECT_EQ(it->ttl(), 0x762U); + EXPECT_EQ(it->query_type(), DNS::A); EXPECT_EQ(it->query_class(), DNS::IN); } } @@ -381,19 +381,19 @@ TEST_F(DNSTest, AnswersWithSameName) { TEST_F(DNSTest, AnswersV6) { DNS dns; dns.add_answer( - DNS::Resource("www.example.com", "f9a8:239::1:1", DNS::AAAA, DNS::IN, 0x762) + 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) + 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(); for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_EQ(it->dname(), "www.example.com"); - EXPECT_EQ(it->type(), DNS::AAAA); EXPECT_EQ(it->ttl(), 0x762U); EXPECT_EQ(it->data(), "f9a8:239::1:1"); + EXPECT_EQ(it->query_type(), DNS::AAAA); EXPECT_EQ(it->query_class(), DNS::IN); } } @@ -405,17 +405,17 @@ TEST_F(DNSTest, ItAintGonnaCorrupt) { const char* domain = "carlos.example.com"; dns.add_additional( - DNS::Resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762) + 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::resource("www.example.com", domain, DNS::CNAME, DNS::IN, 0x762) ); - dns.add_query(DNS::Query("google.com", DNS::A, DNS::IN)); + dns.add_query(DNS::query("google.com", DNS::A, DNS::IN)); DNS::queries_type queries(dns.queries()); for(DNS::queries_type::const_iterator it = queries.begin(); it != queries.end(); ++it) { EXPECT_EQ("google.com", it->dname()); - EXPECT_TRUE(it->type() == DNS::MX || it->type() == DNS::A); + EXPECT_TRUE(it->query_type() == DNS::MX || it->query_type() == DNS::A); EXPECT_EQ(it->query_class(), DNS::IN); } @@ -423,7 +423,7 @@ TEST_F(DNSTest, ItAintGonnaCorrupt) { DNS::resources_type resources = dns.answers(); for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_EQ("google.com", it->dname()); - EXPECT_EQ(DNS::MX, it->type()); + EXPECT_EQ(DNS::MX, it->query_type()); EXPECT_EQ(DNS::IN, it->query_class()); EXPECT_TRUE( it->data() == "alt1.aspmx.l.google.com" || @@ -440,7 +440,7 @@ TEST_F(DNSTest, ItAintGonnaCorrupt) { EXPECT_EQ(1ULL, resources.size()); for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_EQ("www.example.com", it->dname()); - EXPECT_EQ(it->type(), DNS::CNAME); + EXPECT_EQ(it->query_type(), DNS::CNAME); EXPECT_EQ(it->ttl(), 0x762U); EXPECT_EQ(it->data(), domain); EXPECT_EQ(it->query_class(), DNS::IN); @@ -452,7 +452,7 @@ TEST_F(DNSTest, ItAintGonnaCorrupt) { EXPECT_EQ(1ULL, resources.size()); for(DNS::resources_type::const_iterator it = resources.begin(); it != resources.end(); ++it) { EXPECT_EQ("www.example.com", it->dname()); - EXPECT_EQ(it->type(), DNS::CNAME); + EXPECT_EQ(it->query_type(), DNS::CNAME); EXPECT_EQ(it->ttl(), 0x762U); EXPECT_EQ(it->data(), domain); EXPECT_EQ(it->query_class(), DNS::IN); @@ -462,14 +462,14 @@ TEST_F(DNSTest, ItAintGonnaCorrupt) { TEST_F(DNSTest, MXPreferenceField) { DNS dns1; dns1.add_answer( - DNS::Resource("example.com", "mail.example.com", DNS::MX, DNS::IN, 0x762, 42) + DNS::resource("example.com", "mail.example.com", DNS::MX, DNS::IN, 0x762, 42) ); DNS::serialization_type buffer = dns1.serialize(); DNS dns2(&buffer[0], buffer.size()); DNS::resources_type answers = dns1.answers(); ASSERT_EQ(1, answers.size()); - const DNS::Resource& resource = *answers.begin(); + const DNS::resource& resource = *answers.begin(); EXPECT_EQ(42, resource.preference()); EXPECT_EQ("example.com", resource.dname()); } @@ -522,7 +522,7 @@ TEST_F(DNSTest, SOARecordFromBuffer) { DNS dns(raw, sizeof(raw)); ASSERT_EQ(1, dns.answers().size()); - DNS::Resource r(dns.answers().front()); + DNS::resource r(dns.answers().front()); DNS::soa_record soa(r); EXPECT_EQ("ns2.google.com", soa.mname()); EXPECT_EQ("dns-admin.google.com", soa.rname());