Delete dump_bytes() and its helper functions
This change removes dump_bytes() as well as bprint_* functions
which are used for debugging purpose. Instead, use netdutils Slice
for hex dump since it's simpler and safer.
Log example from res_pquery():
V resolv : ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37806
V resolv : ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
V resolv : ;; QUERY SECTION:
V resolv : ;; google.com, type = A, class = IN
V resolv :
V resolv : ;; ANSWER SECTION:
V resolv : ;; google.com. 4m59s IN A X.X.X.X
V resolv :
V resolv :
V resolv : ;; ADDITIONAL SECTION:
V resolv : ; EDNS: version: 0, udp=512, flags=8000
V resolv :
V resolv : Hex dump:
V resolv : 93ae8180000100010000000106676f6f676c6503636f6d0000010001c00c0001
V resolv : 00010000012b0004acd9a06e0000290200000080000000
For debugging, we can use scapy to parse the hex dump:
pkt = "93ae8180000100010000000106676f6f676c6503636f6d0000010001c00c000100010000012b0004acd9a06e0000290200000080000000"
DNS(pkt.decode("hex")).show2()
Bug: 130686826
Bug: 139332724
Test: adb shell service call dnsresolver 10 i32 0 &&
atest --include-subdirs packages/modules/DnsResolver
Test: debugging logs were printed correctly
Test: No PII logs are revealed in default log severity
Change-Id: Ia298ff3e4ce5c9ff42a1a84cf3e34a7bda818519
diff --git a/res_debug.h b/res_debug.h
index 2ba31d4..cb47b90 100644
--- a/res_debug.h
+++ b/res_debug.h
@@ -16,6 +16,16 @@
#pragma once
-#include <cinttypes>
+#include <sys/types.h>
+
+// TODO: use netdutils::Slice for (msg, len).
+void res_pquery(const u_char* msg, int len);
+
+// Thread-unsafe functions returning pointers to static buffers :-(
+// TODO: switch all res_debug to std::string
+const char* p_type(int type);
+const char* p_section(int section, int opcode);
+const char* p_class(int cl);
+const char* p_rcode(int rcode);
int resolv_set_log_severity(uint32_t logSeverity);