• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*	$NetBSD: res_debug.c,v 1.13 2012/06/25 22:32:45 abs Exp $	*/
2 
3 /*
4  * Portions Copyright (C) 2004, 2005, 2008, 2009  Internet Systems Consortium, Inc. ("ISC")
5  * Portions Copyright (C) 1996-2003  Internet Software Consortium.
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /*
21  * Copyright (c) 1985
22  *    The Regents of the University of California.  All rights reserved.
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  * 1. Redistributions of source code must retain the above copyright
28  *    notice, this list of conditions and the following disclaimer.
29  * 2. Redistributions in binary form must reproduce the above copyright
30  *    notice, this list of conditions and the following disclaimer in the
31  *    documentation and/or other materials provided with the distribution.
32  * 3. All advertising materials mentioning features or use of this software
33  *    must display the following acknowledgement:
34  * 	This product includes software developed by the University of
35  * 	California, Berkeley and its contributors.
36  * 4. Neither the name of the University nor the names of its contributors
37  *    may be used to endorse or promote products derived from this software
38  *    without specific prior written permission.
39  *
40  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
41  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
44  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50  * SUCH DAMAGE.
51  */
52 
53 /*
54  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
55  *
56  * Permission to use, copy, modify, and distribute this software for any
57  * purpose with or without fee is hereby granted, provided that the above
58  * copyright notice and this permission notice appear in all copies, and that
59  * the name of Digital Equipment Corporation not be used in advertising or
60  * publicity pertaining to distribution of the document or software without
61  * specific, written prior permission.
62  *
63  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
64  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
65  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
66  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
67  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
68  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
69  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
70  * SOFTWARE.
71  */
72 
73 /*
74  * Portions Copyright (c) 1995 by International Business Machines, Inc.
75  *
76  * International Business Machines, Inc. (hereinafter called IBM) grants
77  * permission under its copyrights to use, copy, modify, and distribute this
78  * Software with or without fee, provided that the above copyright notice and
79  * all paragraphs of this notice appear in all copies, and that the name of IBM
80  * not be used in connection with the marketing of any product incorporating
81  * the Software or modifications thereof, without specific, written prior
82  * permission.
83  *
84  * To the extent it has a right to do so, IBM grants an immunity from suit
85  * under its patents, if any, for the use, sale or manufacture of products to
86  * the extent that such products are used for performing Domain Name System
87  * dynamic updates in TCP/IP networks by means of the Software.  No immunity is
88  * granted for any product per se or for any other function of any product.
89  *
90  * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
91  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
92  * PARTICULAR PURPOSE.  IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
93  * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
94  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
95  * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
96  */
97 
98 #define LOG_TAG "resolv"
99 
100 #include "res_debug.h"
101 
102 #include <sys/param.h>
103 #include <sys/socket.h>
104 
105 #include <arpa/inet.h>
106 #include <arpa/nameser.h>
107 #include <netinet/in.h>
108 
109 #include <aidl/android/net/IDnsResolver.h>
110 #include <android-base/logging.h>
111 #include <android-base/stringprintf.h>
112 #include <ctype.h>
113 #include <errno.h>
114 #include <inttypes.h>
115 #include <math.h>
116 #include <netdb.h>
117 #include <netdutils/Slice.h>
118 #include <stdlib.h>
119 #include <string.h>
120 #include <strings.h>
121 #include <time.h>
122 
123 #include "resolv_private.h"
124 
125 // Default to disabling verbose logging unless overridden by Android.bp
126 // for debuggable builds.
127 //
128 // NOTE: Verbose resolver logs could contain PII -- do NOT enable in production builds
129 #ifndef RESOLV_ALLOW_VERBOSE_LOGGING
130 #define RESOLV_ALLOW_VERBOSE_LOGGING 0
131 #endif
132 
133 using android::base::StringAppendF;
134 using android::netdutils::Slice;
135 
136 struct res_sym {
137     int number;            /* Identifying number, like T_MX */
138     const char* name;      /* Its symbolic name, like "MX" */
139     const char* humanname; /* Its fun name, like "mail exchanger" */
140 };
141 
do_section(ns_msg * handle,ns_sect section)142 static void do_section(ns_msg* handle, ns_sect section) {
143     int n, rrnum = 0;
144     int buflen = 2048;
145     ns_rr rr;
146     std::string s;
147 
148     /*
149      * Print answer records.
150      */
151     for (;;) {
152         if (ns_parserr(handle, section, rrnum, &rr)) {
153             if (errno != ENODEV) StringAppendF(&s, "ns_parserr: %s", strerror(errno));
154             LOG(VERBOSE) << s;
155             return;
156         }
157         if (rrnum == 0) {
158             int opcode = ns_msg_getflag(*handle, ns_f_opcode);
159             StringAppendF(&s, ";; %s SECTION:\n", p_section(section, opcode));
160         }
161         if (section == ns_s_qd)
162             StringAppendF(&s, ";;\t%s, type = %s, class = %s\n", ns_rr_name(rr),
163                           p_type(ns_rr_type(rr)), p_class(ns_rr_class(rr)));
164         else if (section == ns_s_ar && ns_rr_type(rr) == ns_t_opt) {
165             size_t rdatalen;
166             uint16_t optcode, optlen;
167 
168             rdatalen = ns_rr_rdlen(rr);
169             StringAppendF(&s, "; EDNS: version: %" PRIu32 ", udp=%u, flags=%" PRIu32 "\n",
170                           (rr.ttl >> 16) & 0xff, ns_rr_class(rr), rr.ttl & 0xffff);
171             const uint8_t* cp = ns_rr_rdata(rr);
172             while (rdatalen <= ns_rr_rdlen(rr) && rdatalen >= 4) {
173                 int i;
174 
175                 GETSHORT(optcode, cp);
176                 GETSHORT(optlen, cp);
177 
178                 if (optcode == NS_OPT_NSID) {
179                     StringAppendF(&s, "; NSID: ");
180                     if (optlen == 0) {
181                         StringAppendF(&s, "; NSID\n");
182                     } else {
183                         StringAppendF(&s, "; NSID: ");
184                         for (i = 0; i < optlen; i++) {
185                             StringAppendF(&s, "%02x ", cp[i]);
186                         }
187                         StringAppendF(&s, " (");
188                         for (i = 0; i < optlen; i++) {
189                             StringAppendF(&s, "%c", isprint(cp[i]) ? cp[i] : '.');
190                         }
191                         StringAppendF(&s, ")\n");
192                     }
193                 } else {
194                     if (optlen == 0) {
195                         StringAppendF(&s, "; OPT=%u\n", optcode);
196                     } else {
197                         StringAppendF(&s, "; OPT=%u: ", optcode);
198                         for (i = 0; i < optlen; i++) {
199                             StringAppendF(&s, "%02x ", cp[i]);
200                         }
201                         StringAppendF(&s, " (");
202                         for (i = 0; i < optlen; i++) {
203                             StringAppendF(&s, "%c", isprint(cp[i]) ? cp[i] : '.');
204                         }
205                         StringAppendF(&s, ")\n");
206                     }
207                 }
208                 rdatalen -= 4 + optlen;
209                 cp += optlen;
210             }
211         } else {
212             auto buf = std::make_unique<char[]>(buflen);
213             n = ns_sprintrr(handle, &rr, NULL, NULL, buf.get(), (uint32_t)buflen);
214             if (n < 0) {
215                 if (errno == ENOSPC) {
216                     if (buflen < 131072) {
217                         buflen += 1024;
218                         continue;
219                     } else {
220                         StringAppendF(&s, "buflen over 131072");
221                         PLOG(VERBOSE) << s;
222                         return;
223                     }
224                 }
225                 StringAppendF(&s, "ns_sprintrr failed");
226                 PLOG(VERBOSE) << s;
227                 return;
228             }
229             StringAppendF(&s, ";; %s\n", buf.get());
230         }
231         rrnum++;
232     }
233 }
234 
235 /*
236  * Print the contents of a query.
237  * This is intended to be primarily a debugging routine.
238  */
res_pquery(const uint8_t * msg,int len)239 void res_pquery(const uint8_t* msg, int len) {
240     if (!WOULD_LOG(VERBOSE)) return;
241 
242     ns_msg handle;
243     int qdcount, ancount, nscount, arcount;
244     uint32_t opcode, rcode, id;
245 
246     if (ns_initparse(msg, len, &handle) < 0) {
247         PLOG(VERBOSE) << "ns_initparse failed";
248         return;
249     }
250     opcode = ns_msg_getflag(handle, ns_f_opcode);
251     rcode = ns_msg_getflag(handle, ns_f_rcode);
252     id = ns_msg_id(handle);
253     qdcount = ns_msg_count(handle, ns_s_qd);
254     ancount = ns_msg_count(handle, ns_s_an);
255     nscount = ns_msg_count(handle, ns_s_ns);
256     arcount = ns_msg_count(handle, ns_s_ar);
257 
258     /*
259      * Print header fields.
260      */
261     std::string s;
262     StringAppendF(&s, ";; ->>HEADER<<- opcode: %s, status: %s, id: %d\n", _res_opcodes[opcode],
263                   p_rcode((int)rcode), id);
264     StringAppendF(&s, ";; flags:");
265     if (ns_msg_getflag(handle, ns_f_qr)) StringAppendF(&s, " qr");
266     if (ns_msg_getflag(handle, ns_f_aa)) StringAppendF(&s, " aa");
267     if (ns_msg_getflag(handle, ns_f_tc)) StringAppendF(&s, " tc");
268     if (ns_msg_getflag(handle, ns_f_rd)) StringAppendF(&s, " rd");
269     if (ns_msg_getflag(handle, ns_f_ra)) StringAppendF(&s, " ra");
270     if (ns_msg_getflag(handle, ns_f_z)) StringAppendF(&s, " ??");
271     if (ns_msg_getflag(handle, ns_f_ad)) StringAppendF(&s, " ad");
272     if (ns_msg_getflag(handle, ns_f_cd)) StringAppendF(&s, " cd");
273     StringAppendF(&s, "; %s: %d", p_section(ns_s_qd, (int)opcode), qdcount);
274     StringAppendF(&s, ", %s: %d", p_section(ns_s_an, (int)opcode), ancount);
275     StringAppendF(&s, ", %s: %d", p_section(ns_s_ns, (int)opcode), nscount);
276     StringAppendF(&s, ", %s: %d", p_section(ns_s_ar, (int)opcode), arcount);
277 
278     LOG(VERBOSE) << s;
279 
280     /*
281      * Print the various sections.
282      */
283     do_section(&handle, ns_s_qd);
284     do_section(&handle, ns_s_an);
285     do_section(&handle, ns_s_ns);
286     do_section(&handle, ns_s_ar);
287 
288     LOG(VERBOSE) << "Hex dump:";
289     LOG(VERBOSE) << android::netdutils::toHex(Slice(const_cast<uint8_t*>(msg), len), 32);
290 }
291 
292 /*
293  * Names of RR classes and qclasses.  Classes and qclasses are the same, except
294  * that C_ANY is a qclass but not a class.  (You can ask for records of class
295  * C_ANY, but you can't have any records of that class in the database.)
296  */
297 static const struct res_sym p_class_syms[] = {
298         {C_IN, "IN", (char*) 0},     {C_CHAOS, "CH", (char*) 0},  {C_CHAOS, "CHAOS", (char*) 0},
299         {C_HS, "HS", (char*) 0},     {C_HS, "HESIOD", (char*) 0}, {C_ANY, "ANY", (char*) 0},
300         {C_NONE, "NONE", (char*) 0}, {C_IN, (char*) 0, (char*) 0}};
301 
302 /*
303  * Names of message sections.
304  */
305 static const struct res_sym p_default_section_syms[] = {{ns_s_qd, "QUERY", (char*) 0},
306                                                         {ns_s_an, "ANSWER", (char*) 0},
307                                                         {ns_s_ns, "AUTHORITY", (char*) 0},
308                                                         {ns_s_ar, "ADDITIONAL", (char*) 0},
309                                                         {0, (char*) 0, (char*) 0}};
310 
311 static const struct res_sym p_update_section_syms[] = {{S_ZONE, "ZONE", (char*) 0},
312                                                        {S_PREREQ, "PREREQUISITE", (char*) 0},
313                                                        {S_UPDATE, "UPDATE", (char*) 0},
314                                                        {S_ADDT, "ADDITIONAL", (char*) 0},
315                                                        {0, (char*) 0, (char*) 0}};
316 
317 /*
318  * Names of RR types and qtypes.  Types and qtypes are the same, except
319  * that T_ANY is a qtype but not a type.  (You can ask for records of type
320  * T_ANY, but you can't have any records of that type in the database.)
321  */
322 const struct res_sym p_type_syms[] = {
323         {ns_t_a, "A", "address"},
324         {ns_t_ns, "NS", "name server"},
325         {ns_t_md, "MD", "mail destination (deprecated)"},
326         {ns_t_mf, "MF", "mail forwarder (deprecated)"},
327         {ns_t_cname, "CNAME", "canonical name"},
328         {ns_t_soa, "SOA", "start of authority"},
329         {ns_t_mb, "MB", "mailbox"},
330         {ns_t_mg, "MG", "mail group member"},
331         {ns_t_mr, "MR", "mail rename"},
332         {ns_t_null, "NULL", "null"},
333         {ns_t_wks, "WKS", "well-known service (deprecated)"},
334         {ns_t_ptr, "PTR", "domain name pointer"},
335         {ns_t_hinfo, "HINFO", "host information"},
336         {ns_t_minfo, "MINFO", "mailbox information"},
337         {ns_t_mx, "MX", "mail exchanger"},
338         {ns_t_txt, "TXT", "text"},
339         {ns_t_rp, "RP", "responsible person"},
340         {ns_t_afsdb, "AFSDB", "DCE or AFS server"},
341         {ns_t_x25, "X25", "X25 address"},
342         {ns_t_isdn, "ISDN", "ISDN address"},
343         {ns_t_rt, "RT", "router"},
344         {ns_t_nsap, "NSAP", "nsap address"},
345         {ns_t_nsap_ptr, "NSAP_PTR", "domain name pointer"},
346         {ns_t_sig, "SIG", "signature"},
347         {ns_t_key, "KEY", "key"},
348         {ns_t_px, "PX", "mapping information"},
349         {ns_t_gpos, "GPOS", "geographical position (withdrawn)"},
350         {ns_t_aaaa, "AAAA", "IPv6 address"},
351         {ns_t_loc, "LOC", "location"},
352         {ns_t_nxt, "NXT", "next valid name (unimplemented)"},
353         {ns_t_eid, "EID", "endpoint identifier (unimplemented)"},
354         {ns_t_nimloc, "NIMLOC", "NIMROD locator (unimplemented)"},
355         {ns_t_srv, "SRV", "server selection"},
356         {ns_t_atma, "ATMA", "ATM address (unimplemented)"},
357         {ns_t_naptr, "NAPTR", "naptr"},
358         {ns_t_kx, "KX", "key exchange"},
359         {ns_t_cert, "CERT", "certificate"},
360         {ns_t_a6, "A", "IPv6 address (experminental)"},
361         {ns_t_dname, "DNAME", "non-terminal redirection"},
362         {ns_t_opt, "OPT", "opt"},
363         {ns_t_apl, "apl", "apl"},
364         {ns_t_ds, "DS", "delegation signer"},
365         {ns_t_sshfp, "SSFP", "SSH fingerprint"},
366         {ns_t_ipseckey, "IPSECKEY", "IPSEC key"},
367         {ns_t_rrsig, "RRSIG", "rrsig"},
368         {ns_t_nsec, "NSEC", "nsec"},
369         {ns_t_dnskey, "DNSKEY", "DNS key"},
370         {ns_t_dhcid, "DHCID", "dynamic host configuration identifier"},
371         {ns_t_nsec3, "NSEC3", "nsec3"},
372         {ns_t_nsec3param, "NSEC3PARAM", "NSEC3 parameters"},
373         {ns_t_hip, "HIP", "host identity protocol"},
374         {ns_t_spf, "SPF", "sender policy framework"},
375         {ns_t_tkey, "TKEY", "tkey"},
376         {ns_t_tsig, "TSIG", "transaction signature"},
377         {ns_t_ixfr, "IXFR", "incremental zone transfer"},
378         {ns_t_axfr, "AXFR", "zone transfer"},
379         {ns_t_zxfr, "ZXFR", "compressed zone transfer"},
380         {ns_t_mailb, "MAILB", "mailbox-related data (deprecated)"},
381         {ns_t_maila, "MAILA", "mail agent (deprecated)"},
382         {ns_t_naptr, "NAPTR", "URN Naming Authority"},
383         {ns_t_kx, "KX", "Key Exchange"},
384         {ns_t_cert, "CERT", "Certificate"},
385         {ns_t_a6, "A6", "IPv6 Address"},
386         {ns_t_dname, "DNAME", "dname"},
387         {ns_t_sink, "SINK", "Kitchen Sink (experimental)"},
388         {ns_t_opt, "OPT", "EDNS Options"},
389         {ns_t_any, "ANY", "\"any\""},
390         {ns_t_dlv, "DLV", "DNSSEC look-aside validation"},
391         {0, NULL, NULL}};
392 
393 /*
394  * Names of DNS rcodes.
395  */
396 static const struct res_sym p_rcode_syms[] = {{ns_r_noerror, "NOERROR", "no error"},
397                                               {ns_r_formerr, "FORMERR", "format error"},
398                                               {ns_r_servfail, "SERVFAIL", "server failed"},
399                                               {ns_r_nxdomain, "NXDOMAIN", "no such domain name"},
400                                               {ns_r_notimpl, "NOTIMP", "not implemented"},
401                                               {ns_r_refused, "REFUSED", "refused"},
402                                               {ns_r_yxdomain, "YXDOMAIN", "domain name exists"},
403                                               {ns_r_yxrrset, "YXRRSET", "rrset exists"},
404                                               {ns_r_nxrrset, "NXRRSET", "rrset doesn't exist"},
405                                               {ns_r_notauth, "NOTAUTH", "not authoritative"},
406                                               {ns_r_notzone, "NOTZONE", "Not in zone"},
407                                               {ns_r_max, "", ""},
408                                               {ns_r_badsig, "BADSIG", "bad signature"},
409                                               {ns_r_badkey, "BADKEY", "bad key"},
410                                               {ns_r_badtime, "BADTIME", "bad time"},
411                                               {0, NULL, NULL}};
412 
sym_ntos(const struct res_sym * syms,int number,int * success)413 static const char* sym_ntos(const struct res_sym* syms, int number, int* success) {
414     static char unname[20];
415 
416     for (; syms->name != 0; syms++) {
417         if (number == syms->number) {
418             if (success) *success = 1;
419             return (syms->name);
420         }
421     }
422 
423     snprintf(unname, sizeof(unname), "%d", number); /* XXX nonreentrant */
424     if (success) *success = 0;
425     return (unname);
426 }
427 
428 /*
429  * Return a string for the type.
430  */
p_type(int type)431 const char* p_type(int type) {
432     int success;
433     const char* result;
434     static char typebuf[20];
435 
436     result = sym_ntos(p_type_syms, type, &success);
437     if (success) return (result);
438     if (type < 0 || type > 0xffff) return ("BADTYPE");
439     snprintf(typebuf, sizeof(typebuf), "TYPE%d", type);
440     return (typebuf);
441 }
442 
443 /*
444  * Return a string for the type.
445  */
p_section(int section,int opcode)446 const char* p_section(int section, int opcode) {
447     const struct res_sym* symbols;
448 
449     switch (opcode) {
450         case ns_o_update:
451             symbols = p_update_section_syms;
452             break;
453         default:
454             symbols = p_default_section_syms;
455             break;
456     }
457     return (sym_ntos(symbols, section, (int*) 0));
458 }
459 
460 /*
461  * Return a mnemonic for class.
462  */
p_class(int cl)463 const char* p_class(int cl) {
464     int success;
465     const char* result;
466     static char classbuf[20];
467 
468     result = sym_ntos(p_class_syms, cl, &success);
469     if (success) return (result);
470     if (cl < 0 || cl > 0xffff) return ("BADCLASS");
471     snprintf(classbuf, sizeof(classbuf), "CLASS%d", cl);
472     return (classbuf);
473 }
474 
475 /*
476  * Return a string for the rcode.
477  */
p_rcode(int rcode)478 const char* p_rcode(int rcode) {
479     return (sym_ntos(p_rcode_syms, rcode, (int*) 0));
480 }
481 
resolv_set_log_severity(uint32_t logSeverity)482 int resolv_set_log_severity(uint32_t logSeverity) {
483     switch (logSeverity) {
484         case aidl::android::net::IDnsResolver::DNS_RESOLVER_LOG_VERBOSE:
485             logSeverity = android::base::VERBOSE;
486             // *** enable verbose logging only when DBG is set. It prints sensitive data ***
487             if (RESOLV_ALLOW_VERBOSE_LOGGING == false) {
488                 logSeverity = android::base::DEBUG;
489                 LOG(ERROR) << "Refusing to set VERBOSE logging in non-debuggable build";
490                 // TODO: Return EACCES then callers could know if the log
491                 // severity is acceptable
492             }
493             break;
494         case aidl::android::net::IDnsResolver::DNS_RESOLVER_LOG_DEBUG:
495             logSeverity = android::base::DEBUG;
496             break;
497         case aidl::android::net::IDnsResolver::DNS_RESOLVER_LOG_INFO:
498             logSeverity = android::base::INFO;
499             break;
500         case aidl::android::net::IDnsResolver::DNS_RESOLVER_LOG_WARNING:
501             logSeverity = android::base::WARNING;
502             break;
503         case aidl::android::net::IDnsResolver::DNS_RESOLVER_LOG_ERROR:
504             logSeverity = android::base::ERROR;
505             break;
506         default:
507             LOG(ERROR) << __func__ << ": invalid log severity: " << logSeverity;
508             return -EINVAL;
509     }
510     android::base::SetMinimumLogSeverity(static_cast<android::base::LogSeverity>(logSeverity));
511     return 0;
512 }
513