Ejemplo n.º 1
0
    DnsResponse(const DnsHeader& head) : data(head.data),
                                         start(data-sizeof(struct dns_header) + sizeof(struct udp)),
                                         availableBytes(head.dnsPayloadLength),
                                         lastAliasOffset(0)
    {
        // std::cout << "DNS USEFUL DATA LEN: " << availableBytes << "\n";

        for (int i=0; i < head.questionNumber; i++)
        {
            ptrdiff_t offset = data - start;

            uint8_t* new_data = NULL;
    
            // fill the cache

            cachedNames[offset] = getQueryName(data, &new_data);

			// std::cout << "[DnsResponse] Query name: " << cachedNames[offset] << "\n";

            lastAliasOffset = offset;
 
            data = new_data + 4;

            availableBytes -= 4; // read qtype and qclass
        }

        
        // std::cout << "Read questions, available bytes: " << availableBytes << "\n";

        
        for (int i=0; i < head.answerRecordNumber; i++)
        {
            parseRecord();
        }

        // std::cout << "Read answers, available bytes: " << availableBytes << "\n";

        for (int i=0; i < head.authRecordNumber; i++)
        {
            parseRecord();

            // std::cout << "ReadING auth, available bytes: " << availableBytes << "\n";
        }

        for (int i=0; i < head.additionalRecordNumber; i++)
        {
            parseRecord();
        }

        // std::cout << "End of parsing, availableBytes: " << availableBytes << "\n";
    }
Ejemplo n.º 2
0
TEST_F(QueryTests, test_get_column_family_name) {
  auto query = getOsqueryScheduledQuery();
  auto cf = Query("foobar", query);
  EXPECT_EQ(cf.getQueryName(), "foobar");
}