update dns message atom

Test: make statsd_testdrive
     ./out/host/linux-x86/bin/statsd_testdrive 116 => pass
Bug: 129463409
Change-Id: I267f97eacb2dd36b8ab26019f61d80fa0281678c
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index aeac546..7f09b60 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -41,6 +41,7 @@
 import "frameworks/base/core/proto/android/service/procstats_enum.proto";
 import "frameworks/base/core/proto/android/service/usb.proto";
 import "frameworks/base/core/proto/android/stats/connectivity/network_stack.proto";
+import "frameworks/base/core/proto/android/stats/connectivity/resolv_stats.proto";
 import "frameworks/base/core/proto/android/stats/enums.proto";
 import "frameworks/base/core/proto/android/stats/docsui/docsui_enums.proto";
 import "frameworks/base/core/proto/android/stats/devicepolicy/device_policy.proto";
@@ -4950,53 +4951,39 @@
 }
 
 /**
- * Logs the latency period(in microseconds) and the return code of
- * the DNS(Domain Name System) lookups.
- * These 4 methods(GETADDRINFO,GETHOSTBYNAME,GETHOSTBYADDR,RES_NSEND)
- * to get info(address or hostname) from DNS server(or DNS cache).
- * Logged from:
- *   /system/netd/server/DnsProxyListener.cpp
+ * Logs a DNS lookup operation initiated by the system resolver on behalf of an application
+ * invoking native APIs such as getaddrinfo() or Java APIs such as Network#getAllByName().
+ *
+ * The top-level message represents the entire lookup operation, which may result one or more
+ * queries to the recursive DNS resolvers. Those are individually logged in DnsQueryEvent to
+ * enable computing error rates and network latency and timeouts broken up by query type,
+ * transport, network interface, etc.
  */
 message NetworkDnsEventReported {
-    // The types of the DNS lookups, as defined in
-    //system/netd/server/binder/android/net/metrics/INetdEventListener.aidl
-    enum EventType {
-        EVENT_UNKNOWN = 0;
-        EVENT_GETADDRINFO = 1;
-        EVENT_GETHOSTBYNAME = 2;
-        EVENT_GETHOSTBYADDR = 3;
-        EVENT_RES_NSEND = 4;
-    }
-    optional EventType event_type = 1;
 
-    // The return value of the DNS resolver for each DNS lookups.
-    //bionic/libc/include/netdb.h
-    //system/netd/resolv/include/netd_resolv/resolv.h
-    enum ReturnCode {
-        EAI_NO_ERROR = 0;
-        EAI_ADDRFAMILY = 1;
-        EAI_AGAIN = 2;
-        EAI_BADFLAGS = 3;
-        EAI_FAIL = 4;
-        EAI_FAMILY = 5;
-        EAI_MEMORY = 6;
-        EAI_NODATA = 7;
-        EAI_NONAME = 8;
-        EAI_SERVICE = 9;
-        EAI_SOCKTYPE = 10;
-        EAI_SYSTEM = 11;
-        EAI_BADHINTS = 12;
-        EAI_PROTOCOL = 13;
-        EAI_OVERFLOW = 14;
-        RESOLV_TIMEOUT = 255;
-        EAI_MAX = 256;
-    }
-    optional ReturnCode return_code = 2;
+    optional android.stats.connectivity.EventType event_type = 1;
 
-    // The latency period(in microseconds) it took for this DNS lookup to complete.
+    optional android.stats.connectivity.ReturnCode return_code = 2;
+
+    // The latency in microseconds of the entire DNS lookup operation.
     optional int32 latency_micros = 3;
+
+    optional android.stats.connectivity.DnsQueryEventRe dns_query_event_re = 4 [(log_mode) = MODE_BYTES];
+
+    // ResNSend flags defined in android/multinetwork.h
+    optional int32 flags = 5;
+
+    optional android.net.NetworkCapabilitiesProto.Transport network_type = 6;
+
+    // The DNS over TLS mode on a specific netId.
+    optional android.stats.connectivity.PrivateDnsModes private_dns_modes = 7;
+
+    // Additional pass-through fields opaque to statsd.
+    // The DNS resolver Mainline module can add new fields here without requiring an OS update.
+    optional android.stats.connectivity.DnsCallEvent dns_call_event = 8 [(log_mode) = MODE_BYTES];
 }
 
+
 /**
  * Logs when a data stall event occurs.
  *
diff --git a/core/proto/android/stats/connectivity/resolv_stats.proto b/core/proto/android/stats/connectivity/resolv_stats.proto
new file mode 100644
index 0000000..43eb673
--- /dev/null
+++ b/core/proto/android/stats/connectivity/resolv_stats.proto
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+syntax = "proto2";
+package android.stats.connectivity;
+import "frameworks/base/core/proto/android/net/networkcapabilities.proto";
+
+enum EventType {
+    EVENT_UNKNOWN       = 0;
+    EVENT_GETADDRINFO   = 1;
+    EVENT_GETHOSTBYNAME = 2;
+    EVENT_GETHOSTBYADDR = 3;
+    EVENT_RES_NSEND     = 4;
+}
+
+enum PrivateDnsModes {
+    OFF           = 0;
+    OPPORTUNISTIC = 1;
+    STRICT        = 2;
+}
+// The return value of the DNS resolver for each DNS lookups.
+// bionic/libc/include/netdb.h
+// system/netd/resolv/include/netd_resolv/resolv.h
+enum ReturnCode {
+    RC_EAI_NO_ERROR   = 0;
+    RC_EAI_ADDRFAMILY = 1;
+    RC_EAI_AGAIN      = 2;
+    RC_EAI_BADFLAGS   = 3;
+    RC_EAI_FAIL       = 4;
+    RC_EAI_FAMILY     = 5;
+    RC_EAI_MEMORY     = 6;
+    RC_EAI_NODATA     = 7;
+    RC_EAI_NONAME     = 8;
+    RC_EAI_SERVICE    = 9;
+    RC_EAI_SOCKTYPE   = 10;
+    RC_EAI_SYSTEM     = 11;
+    RC_EAI_BADHINTS   = 12;
+    RC_EAI_PROTOCOL   = 13;
+    RC_EAI_OVERFLOW   = 14;
+    RC_RESOLV_TIMEOUT = 255;
+    RC_EAI_MAX        = 256;
+}
+
+
+enum NsRcode {
+    ns_r_noerror   = 0;    // No error occurred.
+    ns_r_formerr   = 1;    // Format error.
+    ns_r_servfail  = 2;   // Server failure.
+    ns_r_nxdomain  = 3;   // Name error.
+    ns_r_notimpl   = 4;    // Unimplemented.
+    ns_r_refused   = 5;    // Operation refused.
+    // these are for BIND_UPDATE
+    ns_r_yxdomain  = 6;   // Name exists
+    ns_r_yxrrset   = 7;    // RRset exists
+    ns_r_nxrrset   = 8;    // RRset does not exist
+    ns_r_notauth   = 9;    // Not authoritative for zone
+    ns_r_notzone   = 10;   // Zone of record different from zone section
+    ns_r_max       = 11;
+    // The following are EDNS extended rcodes
+    ns_r_badvers   = 16;
+    // The following are TSIG errors
+    //ns_r_badsig  = 16,
+    ns_r_badkey    = 17;
+    ns_r_badtime   = 18;
+}
+
+// Currently defined type values for resources and queries.
+enum NsType {
+    ns_t_invalid = 0;    // Cookie.
+    ns_t_a = 1;          // Host address.
+    ns_t_ns = 2;         // Authoritative server.
+    ns_t_md = 3;         // Mail destination.
+    ns_t_mf = 4;         // Mail forwarder.
+    ns_t_cname = 5;      // Canonical name.
+    ns_t_soa = 6;        // Start of authority zone.
+    ns_t_mb = 7;         // Mailbox domain name.
+    ns_t_mg = 8;         // Mail group member.
+    ns_t_mr = 9;         // Mail rename name.
+    ns_t_null = 10;      // Null resource record.
+    ns_t_wks = 11;       // Well known service.
+    ns_t_ptr = 12;       // Domain name pointer.
+    ns_t_hinfo = 13;     // Host information.
+    ns_t_minfo = 14;     // Mailbox information.
+    ns_t_mx = 15;        // Mail routing information.
+    ns_t_txt = 16;       // Text strings.
+    ns_t_rp = 17;        // Responsible person.
+    ns_t_afsdb = 18;     // AFS cell database.
+    ns_t_x25 = 19;       // X_25 calling address.
+    ns_t_isdn = 20;      // ISDN calling address.
+    ns_t_rt = 21;        // Router.
+    ns_t_nsap = 22;      // NSAP address.
+    ns_t_nsap_ptr = 23;  // Reverse NSAP lookup (deprecated).
+    ns_t_sig = 24;       // Security signature.
+    ns_t_key = 25;       // Security key.
+    ns_t_px = 26;        // X.400 mail mapping.
+    ns_t_gpos = 27;      // Geographical position (withdrawn).
+    ns_t_aaaa = 28;      // IPv6 Address.
+    ns_t_loc = 29;       // Location Information.
+    ns_t_nxt = 30;       // Next domain (security).
+    ns_t_eid = 31;       // Endpoint identifier.
+    ns_t_nimloc = 32;    // Nimrod Locator.
+    ns_t_srv = 33;       // Server Selection.
+    ns_t_atma = 34;      // ATM Address
+    ns_t_naptr = 35;     // Naming Authority PoinTeR
+    ns_t_kx = 36;        // Key Exchange
+    ns_t_cert = 37;      // Certification record
+    ns_t_a6 = 38;        // IPv6 address (experimental)
+    ns_t_dname = 39;     // Non-terminal DNAME
+    ns_t_sink = 40;      // Kitchen sink (experimentatl)
+    ns_t_opt = 41;       // EDNS0 option (meta-RR)
+    ns_t_apl = 42;       // Address prefix list (RFC 3123)
+    ns_t_ds = 43;        // Delegation Signer
+    ns_t_sshfp = 44;     // SSH Fingerprint
+    ns_t_ipseckey = 45;  // IPSEC Key
+    ns_t_rrsig = 46;     // RRset Signature
+    ns_t_nsec = 47;      // Negative security
+    ns_t_dnskey = 48;    // DNS Key
+    ns_t_dhcid = 49;     // Dynamic host configuratin identifier
+    ns_t_nsec3 = 50;     // Negative security type 3
+    ns_t_nsec3param = 51;// Negative security type 3 parameters
+    ns_t_hip = 55;       // Host Identity Protocol
+    ns_t_spf = 99;       // Sender Policy Framework
+    ns_t_tkey = 249;     // Transaction key
+    ns_t_tsig = 250;     // Transaction signature.
+    ns_t_ixfr = 251;     // Incremental zone transfer.
+    ns_t_axfr = 252;     // Transfer zone of authority.
+    ns_t_mailb = 253;    // Transfer mailbox records.
+    ns_t_maila = 254;    // Transfer mail agent records.
+    ns_t_any = 255;      // Wildcard match.
+    ns_t_zxfr = 256;     // BIND-specific, nonstandard.
+    ns_t_dlv = 32769;    // DNSSEC look-aside validatation.
+    ns_t_max = 65536;
+}
+
+enum IpVersion {
+   IPV4  = 0;
+   IPV6  = 1;
+   MIXED = 2;
+}
+
+enum TransportType {
+    UDP = 0;
+    TCP = 1;
+    DOT = 2;
+    DOT_UDP = 3;
+    DOT_TCP = 4;
+}
+
+message DnsQueryEvent {
+    optional NsRcode rrcode           = 1;
+    optional NsType rrtype            = 2;
+    optional bool cache_hit           = 3;
+    optional IpVersion ipversion      = 4;
+    optional TransportType transport  = 5;
+    optional int32 packet_retransmits = 6;  // Used only by the UDP transport
+    optional int32 reconnects         = 7;  // Used only by TCP and DOT
+    optional int32 latency_micros     = 8;
+    optional int32 active_experiments = 9;
+    optional android.net.NetworkCapabilitiesProto.Transport network_type = 10;
+}
+
+message DnsQueryEventRe {
+    repeated DnsQueryEvent dns_query_event = 1;
+}
+
+
+message DnsCallEvent {
+
+}
+