Loading getaddrinfo.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -1439,6 +1439,11 @@ static int dns_getaddrinfo(const char* name, const addrinfo* pai, setMdnsFlag(name, &(res.flags)); if (isMdnsResolution(res.flags)) { q.qclass |= C_UNICAST; q2.qclass |= C_UNICAST; } int he; if (res_searchN(name, &q, &res, &he) < 0) { // Return h_errno (he) to catch more detailed errors rather than EAI_NODATA. Loading gethnamaddr.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -631,7 +631,8 @@ static int dns_gethtbyname(ResState* res, const char* name, int addr_type, getna auto buf = std::make_unique<querybuf>(); int he; n = res_nsearch(res, name, C_IN, type, buf->buf, (int)sizeof(buf->buf), &he); const unsigned qclass = isMdnsResolution(res->flags) ? C_IN | C_UNICAST : C_IN; n = res_nsearch(res, name, qclass, type, buf->buf, (int)sizeof(buf->buf), &he); if (n < 0) { LOG(DEBUG) << __func__ << ": res_nsearch failed (" << n << ")"; // Return h_errno (he) to catch more detailed errors rather than EAI_NODATA. Loading res_cache.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -260,6 +260,7 @@ static time_t _time_now(void) { #define DNS_TYPE_ALL "\00\0377" /* big-endian decimal 255 */ #define DNS_CLASS_IN "\00\01" /* big-endian decimal 1 */ #define MDNS_CLASS_UNICAST_IN "\200\01" /* big-endian decimal 32769 */ struct DnsPacket { const uint8_t* base; Loading Loading @@ -374,7 +375,8 @@ static int _dnsPacket_checkQR(DnsPacket* packet) { return 0; } /* CLASS must be IN */ if (!_dnsPacket_checkBytes(packet, 2, DNS_CLASS_IN)) { if (!_dnsPacket_checkBytes(packet, 2, DNS_CLASS_IN) && !_dnsPacket_checkBytes(packet, 2, MDNS_CLASS_UNICAST_IN)) { LOG(INFO) << __func__ << ": unsupported CLASS"; return 0; } Loading resolv_private.h +2 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,8 @@ union sockaddr_union { }; constexpr int MAXPACKET = 8 * 1024; const unsigned C_UNICAST = 0x8000; // unicast-response bit for MDNS struct ResState { ResState(const android_net_context* netcontext, android::net::NetworkDnsEventReported* dnsEvent) : netid(netcontext->dns_netid), Loading tests/dns_responder/dns_responder.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -979,8 +979,10 @@ bool DNSResponder::makeResponse(DNSHeader* header, int protocol, char* response, bool DNSResponder::makeResponseFromAddressOrHostname(DNSHeader* header, char* response, size_t* response_len) const { const unsigned unicast_bit = 0x8000; // unicast-response bit for MDNS for (const DNSQuestion& question : header->questions) { if (question.qclass != ns_class::ns_c_in && question.qclass != ns_class::ns_c_any) { if (question.qclass != ns_class::ns_c_in && question.qclass != ns_class::ns_c_any && question.qclass != (unicast_bit | ns_class::ns_c_in)) { LOG(INFO) << "unsupported question class " << question.qclass; return makeErrorResponse(header, ns_rcode::ns_r_notimpl, response, response_len); } Loading Loading
getaddrinfo.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -1439,6 +1439,11 @@ static int dns_getaddrinfo(const char* name, const addrinfo* pai, setMdnsFlag(name, &(res.flags)); if (isMdnsResolution(res.flags)) { q.qclass |= C_UNICAST; q2.qclass |= C_UNICAST; } int he; if (res_searchN(name, &q, &res, &he) < 0) { // Return h_errno (he) to catch more detailed errors rather than EAI_NODATA. Loading
gethnamaddr.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -631,7 +631,8 @@ static int dns_gethtbyname(ResState* res, const char* name, int addr_type, getna auto buf = std::make_unique<querybuf>(); int he; n = res_nsearch(res, name, C_IN, type, buf->buf, (int)sizeof(buf->buf), &he); const unsigned qclass = isMdnsResolution(res->flags) ? C_IN | C_UNICAST : C_IN; n = res_nsearch(res, name, qclass, type, buf->buf, (int)sizeof(buf->buf), &he); if (n < 0) { LOG(DEBUG) << __func__ << ": res_nsearch failed (" << n << ")"; // Return h_errno (he) to catch more detailed errors rather than EAI_NODATA. Loading
res_cache.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -260,6 +260,7 @@ static time_t _time_now(void) { #define DNS_TYPE_ALL "\00\0377" /* big-endian decimal 255 */ #define DNS_CLASS_IN "\00\01" /* big-endian decimal 1 */ #define MDNS_CLASS_UNICAST_IN "\200\01" /* big-endian decimal 32769 */ struct DnsPacket { const uint8_t* base; Loading Loading @@ -374,7 +375,8 @@ static int _dnsPacket_checkQR(DnsPacket* packet) { return 0; } /* CLASS must be IN */ if (!_dnsPacket_checkBytes(packet, 2, DNS_CLASS_IN)) { if (!_dnsPacket_checkBytes(packet, 2, DNS_CLASS_IN) && !_dnsPacket_checkBytes(packet, 2, MDNS_CLASS_UNICAST_IN)) { LOG(INFO) << __func__ << ": unsupported CLASS"; return 0; } Loading
resolv_private.h +2 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,8 @@ union sockaddr_union { }; constexpr int MAXPACKET = 8 * 1024; const unsigned C_UNICAST = 0x8000; // unicast-response bit for MDNS struct ResState { ResState(const android_net_context* netcontext, android::net::NetworkDnsEventReported* dnsEvent) : netid(netcontext->dns_netid), Loading
tests/dns_responder/dns_responder.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -979,8 +979,10 @@ bool DNSResponder::makeResponse(DNSHeader* header, int protocol, char* response, bool DNSResponder::makeResponseFromAddressOrHostname(DNSHeader* header, char* response, size_t* response_len) const { const unsigned unicast_bit = 0x8000; // unicast-response bit for MDNS for (const DNSQuestion& question : header->questions) { if (question.qclass != ns_class::ns_c_in && question.qclass != ns_class::ns_c_any) { if (question.qclass != ns_class::ns_c_in && question.qclass != ns_class::ns_c_any && question.qclass != (unicast_bit | ns_class::ns_c_in)) { LOG(INFO) << "unsupported question class " << question.qclass; return makeErrorResponse(header, ns_rcode::ns_r_notimpl, response, response_len); } Loading