1/* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16syntax = "proto2"; 17option optimize_for = LITE_RUNTIME; 18package android.net; 19 20enum EventType { 21 EVENT_UNKNOWN = 0; 22 EVENT_GETADDRINFO = 1; 23 EVENT_GETHOSTBYNAME = 2; 24 EVENT_GETHOSTBYADDR = 3; 25 EVENT_RES_NSEND = 4; 26} 27 28// The return value of the DNS resolver for each DNS lookups. 29// bionic/libc/include/netdb.h 30// system/netd/resolv/include/netd_resolv/resolv.h 31enum ReturnCode { 32 RC_EAI_NO_ERROR = 0; 33 RC_EAI_ADDRFAMILY = 1; 34 RC_EAI_AGAIN = 2; 35 RC_EAI_BADFLAGS = 3; 36 RC_EAI_FAIL = 4; 37 RC_EAI_FAMILY = 5; 38 RC_EAI_MEMORY = 6; 39 RC_EAI_NODATA = 7; 40 RC_EAI_NONAME = 8; 41 RC_EAI_SERVICE = 9; 42 RC_EAI_SOCKTYPE = 10; 43 RC_EAI_SYSTEM = 11; 44 RC_EAI_BADHINTS = 12; 45 RC_EAI_PROTOCOL = 13; 46 RC_EAI_OVERFLOW = 14; 47 RC_RESOLV_TIMEOUT = 255; 48 RC_EAI_MAX = 256; 49} 50 51enum NsRcode { 52 NS_R_NO_ERROR = 0; // No error occurred. 53 NS_R_FORMERR = 1; // Format error. 54 NS_R_SERVFAIL = 2; // Server failure. 55 NS_R_NXDOMAIN = 3; // Name error. 56 NS_R_NOTIMPL = 4; // Unimplemented. 57 NS_R_REFUSED = 5; // Operation refused. 58 // these are for BIND_UPDATE 59 NS_R_YXDOMAIN = 6; // Name exists 60 NS_R_YXRRSET = 7; // RRset exists 61 NS_R_NXRRSET = 8; // RRset does not exist 62 NS_R_NOTAUTH = 9; // Not authoritative for zone 63 NS_R_NOTZONE = 10; // Zone of record different from zone section 64 NS_R_MAX = 11; 65 // The following are EDNS extended rcodes 66 NS_R_BADVERS = 16; 67 // The following are TSIG errors 68 // NS_R_BADSIG = 16, 69 NS_R_BADKEY = 17; 70 NS_R_BADTIME = 18; 71} 72 73// Currently defined type values for resources and queries. 74enum NsType { 75 NS_T_INVALID = 0; // Cookie. 76 NS_T_A = 1; // Host address. 77 NS_T_NS = 2; // Authoritative server. 78 NS_T_MD = 3; // Mail destination. 79 NS_T_MF = 4; // Mail forwarder. 80 NS_T_CNAME = 5; // Canonical name. 81 NS_T_SOA = 6; // Start of authority zone. 82 NS_T_MB = 7; // Mailbox domain name. 83 NS_T_MG = 8; // Mail group member. 84 NS_T_MR = 9; // Mail rename name. 85 NS_T_NULL = 10; // Null resource record. 86 NS_T_WKS = 11; // Well known service. 87 NS_T_PTR = 12; // Domain name pointer. 88 NS_T_HINFO = 13; // Host information. 89 NS_T_MINFO = 14; // Mailbox information. 90 NS_T_MX = 15; // Mail routing information. 91 NS_T_TXT = 16; // Text strings. 92 NS_T_RP = 17; // Responsible person. 93 NS_T_AFSDB = 18; // AFS cell database. 94 NS_T_X25 = 19; // X_25 calling address. 95 NS_T_ISDN = 20; // ISDN calling address. 96 NS_T_RT = 21; // Router. 97 NS_T_NSAP = 22; // NSAP address. 98 NS_T_NSAP_PTR = 23; // Reverse NSAP lookup (deprecated). 99 NS_T_SIG = 24; // Security signature. 100 NS_T_KEY = 25; // Security key. 101 NS_T_PX = 26; // X.400 mail mapping. 102 NS_T_GPOS = 27; // Geographical position (withdrawn). 103 NS_T_AAAA = 28; // IPv6 Address. 104 NS_T_LOC = 29; // Location Information. 105 NS_T_NXT = 30; // Next domain (security). 106 NS_T_EID = 31; // Endpoint identifier. 107 NS_T_NIMLOC = 32; // Nimrod Locator. 108 NS_T_SRV = 33; // Server Selection. 109 NS_T_ATMA = 34; // ATM Address 110 NS_T_NAPTR = 35; // Naming Authority PoinTeR 111 NS_T_KX = 36; // Key Exchange 112 NS_T_CERT = 37; // Certification record 113 NS_T_A6 = 38; // IPv6 address (experimental) 114 NS_T_DNAME = 39; // Non-terminal DNAME 115 NS_T_SINK = 40; // Kitchen sink (experimentatl) 116 NS_T_OPT = 41; // EDNS0 option (meta-RR) 117 NS_T_APL = 42; // Address prefix list (RFC 3123) 118 NS_T_DS = 43; // Delegation Signer 119 NS_T_SSHFP = 44; // SSH Fingerprint 120 NS_T_IPSECKEY = 45; // IPSEC Key 121 NS_T_RRSIG = 46; // RRset Signature 122 NS_T_NSEC = 47; // Negative security 123 NS_T_DNSKEY = 48; // DNS Key 124 NS_T_DHCID = 49; // Dynamic host configuratin identifier 125 NS_T_NSEC3 = 50; // Negative security type 3 126 NS_T_NSEC3PARAM = 51; // Negative security type 3 parameters 127 NS_T_HIP = 55; // Host Identity Protocol 128 NS_T_SPF = 99; // Sender Policy Framework 129 NS_T_TKEY = 249; // Transaction key 130 NS_T_TSIG = 250; // Transaction signature. 131 NS_T_IXFR = 251; // Incremental zone transfer. 132 NS_T_AXFR = 252; // Transfer zone of authority. 133 NS_T_MAILB = 253; // Transfer mailbox records. 134 NS_T_MAILA = 254; // Transfer mail agent records. 135 NS_T_ANY = 255; // Wildcard match. 136 NS_T_ZXFR = 256; // BIND-specific, nonstandard. 137 NS_T_DLV = 32769; // DNSSEC look-aside validatation. 138 NS_T_MAX = 65536; 139} 140 141enum IpVersion { 142 IV_UNKNOWN = 0; 143 IV_IPV4 = 1; 144 IV_IPV6 = 2; 145} 146 147enum TransportType { 148 TT_UNKNOWN = 0; 149 TT_UDP = 1; 150 TT_TCP = 2; 151 TT_DOT = 3; 152} 153 154enum PrivateDnsModes { 155 PDM_UNKNOWN = 0; 156 PDM_OFF = 1; 157 PDM_OPPORTUNISTIC = 2; 158 PDM_STRICT = 3; 159} 160 161enum Transport { 162 // Indicates this network uses a Cellular transport. 163 TRANSPORT_DEFAULT = 0; // TRANSPORT_CELLULAR 164 // Indicates this network uses a Wi-Fi transport. 165 TRANSPORT_WIFI = 1; 166 // Indicates this network uses a Bluetooth transport. 167 TRANSPORT_BLUETOOTH = 2; 168 // Indicates this network uses an Ethernet transport. 169 TRANSPORT_ETHERNET = 3; 170 // Indicates this network uses a VPN transport. 171 TRANSPORT_VPN = 4; 172 // Indicates this network uses a Wi-Fi Aware transport. 173 TRANSPORT_WIFI_AWARE = 5; 174 // Indicates this network uses a LoWPAN transport. 175 TRANSPORT_LOWPAN = 6; 176} 177 178enum CacheStatus{ 179 // the cache can't handle that kind of queries. 180 // or the answer buffer is too small. 181 CS_UNSUPPORTED = 0; 182 // the cache doesn't know about this query. 183 CS_NOTFOUND = 1; 184 // the cache found the answer. 185 CS_FOUND = 2; 186 // Don't do anything on cache. 187 CS_SKIP = 3; 188} 189 190message DnsQueryEvent { 191 optional NsRcode rcode = 1; 192 193 optional NsType type = 2; 194 195 optional CacheStatus cache_hit = 3; 196 197 optional IpVersion ip_version = 4; 198 199 optional TransportType transport = 5; 200 201 // Number of DNS query retry times 202 optional int32 retry_times = 6; 203 204 // Ordinal number of name server. 205 optional int32 dns_server_count = 7; 206 207 // Used only by TCP and DOT. True for new connections. 208 optional bool connected = 8; 209 210 optional int32 latency_micros = 9; 211} 212 213message DnsQueryEvents { 214 repeated DnsQueryEvent dns_query_event = 1; 215} 216 217/** 218 * Logs a DNS lookup operation initiated by the system resolver on behalf of an application 219 * invoking native APIs such as getaddrinfo() or Java APIs such as Network#getAllByName(). 220 * 221 * The NetworkDnsEventReported message represents the entire lookup operation, which may 222 * result one or more queries to the recursive DNS resolvers. Those are individually logged 223 * in DnsQueryEvents to enable computing error rates and network latency and timeouts 224 * broken up by query type, transport, network interface, etc. 225 */ 226message NetworkDnsEventReported { 227 optional EventType event_type = 1; 228 229 optional ReturnCode return_code = 2; 230 231 // The latency in microseconds of the entire DNS lookup operation. 232 optional int32 latency_micros = 3; 233 234 // Only valid for event_type = EVENT_GETADDRINFO. 235 optional int32 hints_ai_flags = 4; 236 237 // Flags passed to android_res_nsend() defined in multinetwork.h 238 // Only valid for event_type = EVENT_RESNSEND. 239 optional int32 res_nsend_flags = 5; 240 241 optional Transport network_type = 6; 242 243 // The DNS over TLS mode on a specific netId. 244 optional PrivateDnsModes private_dns_modes = 7; 245 246 // Additional pass-through fields opaque to statsd. 247 // The DNS resolver Mainline module can add new fields here without requiring an OS update. 248 optional DnsQueryEvents dns_query_events = 8; 249}