• Home
  • Raw
  • Download

Lines Matching refs:header

414     Header& header = *reinterpret_cast<Header*>(buffer);  in write()  local
416 header.id = htons(id); in write()
418 header.flags0 = (qr << 7) | (opcode << 3) | (aa << 2) | (tr << 1) | rd; in write()
423 header.flags1 = (ad << 5) | rcode; in write()
425 header.qdcount = htons(questions.size()); in write()
426 header.ancount = htons(answers.size()); in write()
427 header.nscount = htons(authorities.size()); in write()
428 header.arcount = htons(additionals.size()); in write()
466 const auto& header = *reinterpret_cast<const Header*>(buffer); in readHeader() local
468 id = ntohs(header.id); in readHeader()
470 qr = header.flags0 >> 7; in readHeader()
471 opcode = (header.flags0 >> 3) & 0x0F; in readHeader()
472 aa = (header.flags0 >> 2) & 1; in readHeader()
473 tr = (header.flags0 >> 1) & 1; in readHeader()
474 rd = header.flags0 & 1; in readHeader()
476 ra = header.flags1 >> 7; in readHeader()
477 ad = (header.flags1 >> 5) & 1; in readHeader()
478 rcode = header.flags1 & 0xF; in readHeader()
480 *qdcount = ntohs(header.qdcount); in readHeader()
481 *ancount = ntohs(header.ancount); in readHeader()
482 *nscount = ntohs(header.nscount); in readHeader()
483 *arcount = ntohs(header.arcount); in readHeader()
506 const DNSHeader& header) { in addMappingDnsHeader() argument
508 dnsheader_mappings_[{name, type}] = header; in addMappingDnsHeader()
701 bool DNSResponder::hasOptPseudoRR(DNSHeader* header) const { in hasOptPseudoRR()
702 if (header->additionals.empty()) return false; in hasOptPseudoRR()
705 auto found = std::find_if(header->additionals.begin(), header->additionals.end(), in hasOptPseudoRR()
707 return found != header->additionals.end(); in hasOptPseudoRR()
741 DNSHeader header; in handleDNSRequest() local
742 const char* cur = header.read(buffer, buffer_end); in handleDNSRequest()
748 if (header.qr) { in handleDNSRequest()
752 if (header.opcode != ns_opcode::ns_o_query) { in handleDNSRequest()
754 return makeErrorResponse(&header, ns_rcode::ns_r_notimpl, response, response_len); in handleDNSRequest()
756 if (header.questions.empty()) { in handleDNSRequest()
758 return makeErrorResponse(&header, ns_rcode::ns_r_formerr, response, response_len); in handleDNSRequest()
760 if (!header.answers.empty()) { in handleDNSRequest()
761 LOG(INFO) << "already " << header.answers.size() << " answers present in query"; in handleDNSRequest()
762 return makeErrorResponse(&header, ns_rcode::ns_r_formerr, response, response_len); in handleDNSRequest()
767 return makeErrorResponse(&header, ns_rcode::ns_r_formerr, response, response_len); in handleDNSRequest()
770 if (!header.additionals.empty() && edns_ != Edns::ON) { in handleDNSRequest()
775 return makeErrorResponse(&header, ns_rcode::ns_r_formerr, response, response_len); in handleDNSRequest()
782 for (const DNSQuestion& question : header.questions) { in handleDNSRequest()
795 return makeErrorResponse(&header, error_rcode_, response, response_len); in handleDNSRequest()
801 return makeResponse(&header, protocol, response, response_len); in handleDNSRequest()
901 bool DNSResponder::writePacket(const DNSHeader* header, char* response, in writePacket() argument
903 char* response_cur = header->write(response, response + *response_len); in writePacket()
911 bool DNSResponder::makeErrorResponse(DNSHeader* header, ns_rcode rcode, char* response, in makeErrorResponse() argument
913 header->answers.clear(); in makeErrorResponse()
914 header->authorities.clear(); in makeErrorResponse()
915 header->additionals.clear(); in makeErrorResponse()
916 header->rcode = rcode; in makeErrorResponse()
917 header->qr = true; in makeErrorResponse()
918 return writePacket(header, response, response_len); in makeErrorResponse()
921 bool DNSResponder::makeTruncatedResponse(DNSHeader* header, char* response, in makeTruncatedResponse() argument
926 header->answers.clear(); in makeTruncatedResponse()
927 header->authorities.clear(); in makeTruncatedResponse()
928 header->additionals.clear(); in makeTruncatedResponse()
929 header->qr = true; in makeTruncatedResponse()
930 header->tr = true; in makeTruncatedResponse()
931 return writePacket(header, response, response_len); in makeTruncatedResponse()
934 bool DNSResponder::makeResponse(DNSHeader* header, int protocol, char* response, in makeResponse() argument
942 ret = makeResponseFromDnsHeader(header, buffer, &buffer_len); in makeResponse()
945 ret = makeResponseFromBinaryPacket(header, buffer, &buffer_len); in makeResponse()
949 ret = makeResponseFromAddressOrHostname(header, buffer, &buffer_len); in makeResponse()
964 !hasOptPseudoRR(header) /* non-EDNS */) { in makeResponse()
967 return makeTruncatedResponse(header, response, response_len); in makeResponse()
979 bool DNSResponder::makeResponseFromAddressOrHostname(DNSHeader* header, char* response, in makeResponseFromAddressOrHostname() argument
981 for (const DNSQuestion& question : header->questions) { in makeResponseFromAddressOrHostname()
984 return makeErrorResponse(header, ns_rcode::ns_r_notimpl, response, response_len); in makeResponseFromAddressOrHostname()
987 if (!addAnswerRecords(question, &header->answers)) { in makeResponseFromAddressOrHostname()
988 return makeErrorResponse(header, ns_rcode::ns_r_servfail, response, response_len); in makeResponseFromAddressOrHostname()
991 header->qr = true; in makeResponseFromAddressOrHostname()
992 return writePacket(header, response, response_len); in makeResponseFromAddressOrHostname()
995 bool DNSResponder::makeResponseFromDnsHeader(DNSHeader* header, char* response, in makeResponseFromDnsHeader() argument
1004 const std::vector<DNSQuestion>& questions = header->questions; in makeResponseFromDnsHeader()
1007 return makeErrorResponse(header, ns_rcode::ns_r_notimpl, response, response_len); in makeResponseFromDnsHeader()
1012 return makeErrorResponse(header, ns_rcode::ns_r_notimpl, response, response_len); in makeResponseFromDnsHeader()
1020 const unsigned id = header->id; in makeResponseFromDnsHeader()
1021 const bool rd = header->rd; in makeResponseFromDnsHeader()
1024 *header = it->second; in makeResponseFromDnsHeader()
1026 header->id = id; in makeResponseFromDnsHeader()
1027 header->rd = rd; in makeResponseFromDnsHeader()
1036 header->qr = true; in makeResponseFromDnsHeader()
1038 return writePacket(header, response, response_len); in makeResponseFromDnsHeader()
1041 bool DNSResponder::makeResponseFromBinaryPacket(DNSHeader* header, char* response, in makeResponseFromBinaryPacket() argument
1048 if (!header->write(&queryKey)) return false; in makeResponseFromBinaryPacket()
1063 reinterpret_cast<uint16_t*>(response)[0] = htons(header->id); // bytes 0-1: id in makeResponseFromBinaryPacket()
1074 header->qr = true; in makeResponseFromBinaryPacket()
1075 return writePacket(header, response, response_len); in makeResponseFromBinaryPacket()
1193 DNSHeader header; in handleQuery() local
1194 const char* cur = header.read(response, response_end); in handleQuery()