lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 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 | */ |
| 16 | syntax = "proto2"; |
| 17 | option optimize_for = LITE_RUNTIME; |
| 18 | package android.net; |
| 19 | |
| 20 | enum 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 |
| 31 | enum 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 | |
| 51 | enum 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; |
lifr | 2d0704c | 2019-06-26 10:55:09 +0800 | [diff] [blame] | 71 | NS_R_INTERNAL_ERROR = 254; |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 72 | NS_R_TIMEOUT = 255; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | // Currently defined type values for resources and queries. |
| 76 | enum NsType { |
| 77 | NS_T_INVALID = 0; // Cookie. |
| 78 | NS_T_A = 1; // Host address. |
| 79 | NS_T_NS = 2; // Authoritative server. |
| 80 | NS_T_MD = 3; // Mail destination. |
| 81 | NS_T_MF = 4; // Mail forwarder. |
| 82 | NS_T_CNAME = 5; // Canonical name. |
| 83 | NS_T_SOA = 6; // Start of authority zone. |
| 84 | NS_T_MB = 7; // Mailbox domain name. |
| 85 | NS_T_MG = 8; // Mail group member. |
| 86 | NS_T_MR = 9; // Mail rename name. |
| 87 | NS_T_NULL = 10; // Null resource record. |
| 88 | NS_T_WKS = 11; // Well known service. |
| 89 | NS_T_PTR = 12; // Domain name pointer. |
| 90 | NS_T_HINFO = 13; // Host information. |
| 91 | NS_T_MINFO = 14; // Mailbox information. |
| 92 | NS_T_MX = 15; // Mail routing information. |
| 93 | NS_T_TXT = 16; // Text strings. |
| 94 | NS_T_RP = 17; // Responsible person. |
| 95 | NS_T_AFSDB = 18; // AFS cell database. |
| 96 | NS_T_X25 = 19; // X_25 calling address. |
| 97 | NS_T_ISDN = 20; // ISDN calling address. |
| 98 | NS_T_RT = 21; // Router. |
| 99 | NS_T_NSAP = 22; // NSAP address. |
| 100 | NS_T_NSAP_PTR = 23; // Reverse NSAP lookup (deprecated). |
| 101 | NS_T_SIG = 24; // Security signature. |
| 102 | NS_T_KEY = 25; // Security key. |
| 103 | NS_T_PX = 26; // X.400 mail mapping. |
| 104 | NS_T_GPOS = 27; // Geographical position (withdrawn). |
| 105 | NS_T_AAAA = 28; // IPv6 Address. |
| 106 | NS_T_LOC = 29; // Location Information. |
| 107 | NS_T_NXT = 30; // Next domain (security). |
| 108 | NS_T_EID = 31; // Endpoint identifier. |
| 109 | NS_T_NIMLOC = 32; // Nimrod Locator. |
| 110 | NS_T_SRV = 33; // Server Selection. |
| 111 | NS_T_ATMA = 34; // ATM Address |
| 112 | NS_T_NAPTR = 35; // Naming Authority PoinTeR |
| 113 | NS_T_KX = 36; // Key Exchange |
| 114 | NS_T_CERT = 37; // Certification record |
| 115 | NS_T_A6 = 38; // IPv6 address (experimental) |
| 116 | NS_T_DNAME = 39; // Non-terminal DNAME |
| 117 | NS_T_SINK = 40; // Kitchen sink (experimentatl) |
| 118 | NS_T_OPT = 41; // EDNS0 option (meta-RR) |
| 119 | NS_T_APL = 42; // Address prefix list (RFC 3123) |
| 120 | NS_T_DS = 43; // Delegation Signer |
| 121 | NS_T_SSHFP = 44; // SSH Fingerprint |
| 122 | NS_T_IPSECKEY = 45; // IPSEC Key |
| 123 | NS_T_RRSIG = 46; // RRset Signature |
| 124 | NS_T_NSEC = 47; // Negative security |
| 125 | NS_T_DNSKEY = 48; // DNS Key |
| 126 | NS_T_DHCID = 49; // Dynamic host configuratin identifier |
| 127 | NS_T_NSEC3 = 50; // Negative security type 3 |
| 128 | NS_T_NSEC3PARAM = 51; // Negative security type 3 parameters |
| 129 | NS_T_HIP = 55; // Host Identity Protocol |
| 130 | NS_T_SPF = 99; // Sender Policy Framework |
| 131 | NS_T_TKEY = 249; // Transaction key |
| 132 | NS_T_TSIG = 250; // Transaction signature. |
| 133 | NS_T_IXFR = 251; // Incremental zone transfer. |
| 134 | NS_T_AXFR = 252; // Transfer zone of authority. |
| 135 | NS_T_MAILB = 253; // Transfer mailbox records. |
| 136 | NS_T_MAILA = 254; // Transfer mail agent records. |
| 137 | NS_T_ANY = 255; // Wildcard match. |
| 138 | NS_T_ZXFR = 256; // BIND-specific, nonstandard. |
| 139 | NS_T_DLV = 32769; // DNSSEC look-aside validatation. |
| 140 | NS_T_MAX = 65536; |
| 141 | } |
| 142 | |
| 143 | enum IpVersion { |
| 144 | IV_UNKNOWN = 0; |
| 145 | IV_IPV4 = 1; |
| 146 | IV_IPV6 = 2; |
| 147 | } |
| 148 | |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 149 | enum Protocol { |
| 150 | PROTO_UNKNOWN = 0; |
| 151 | PROTO_UDP = 1; |
| 152 | PROTO_TCP = 2; |
| 153 | PROTO_DOT = 3; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | enum PrivateDnsModes { |
| 157 | PDM_UNKNOWN = 0; |
| 158 | PDM_OFF = 1; |
| 159 | PDM_OPPORTUNISTIC = 2; |
| 160 | PDM_STRICT = 3; |
| 161 | } |
| 162 | |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 163 | enum NetworkType { |
| 164 | NT_UNKNOWN = 0; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 165 | // Indicates this network uses a Cellular transport. |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 166 | NT_CELLULAR = 1; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 167 | // Indicates this network uses a Wi-Fi transport. |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 168 | NT_WIFI = 2; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 169 | // Indicates this network uses a Bluetooth transport. |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 170 | NT_BLUETOOTH = 3; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 171 | // Indicates this network uses an Ethernet transport. |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 172 | NT_ETHERNET = 4; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 173 | // Indicates this network uses a VPN transport. |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 174 | NT_VPN = 5; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 175 | // Indicates this network uses a Wi-Fi Aware transport. |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 176 | NT_WIFI_AWARE = 6; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 177 | // Indicates this network uses a LoWPAN transport. |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 178 | NT_LOWPAN = 7; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | enum CacheStatus{ |
| 182 | // the cache can't handle that kind of queries. |
| 183 | // or the answer buffer is too small. |
| 184 | CS_UNSUPPORTED = 0; |
| 185 | // the cache doesn't know about this query. |
| 186 | CS_NOTFOUND = 1; |
| 187 | // the cache found the answer. |
| 188 | CS_FOUND = 2; |
| 189 | // Don't do anything on cache. |
| 190 | CS_SKIP = 3; |
| 191 | } |
| 192 | |
| 193 | message DnsQueryEvent { |
| 194 | optional NsRcode rcode = 1; |
| 195 | |
| 196 | optional NsType type = 2; |
| 197 | |
| 198 | optional CacheStatus cache_hit = 3; |
| 199 | |
| 200 | optional IpVersion ip_version = 4; |
| 201 | |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 202 | optional Protocol protocol = 5; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 203 | |
| 204 | // Number of DNS query retry times |
| 205 | optional int32 retry_times = 6; |
| 206 | |
| 207 | // Ordinal number of name server. |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 208 | optional int32 dns_server_index = 7; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 209 | |
| 210 | // Used only by TCP and DOT. True for new connections. |
| 211 | optional bool connected = 8; |
| 212 | |
| 213 | optional int32 latency_micros = 9; |
| 214 | } |
| 215 | |
| 216 | message DnsQueryEvents { |
| 217 | repeated DnsQueryEvent dns_query_event = 1; |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Logs a DNS lookup operation initiated by the system resolver on behalf of an application |
| 222 | * invoking native APIs such as getaddrinfo() or Java APIs such as Network#getAllByName(). |
| 223 | * |
| 224 | * The NetworkDnsEventReported message represents the entire lookup operation, which may |
| 225 | * result one or more queries to the recursive DNS resolvers. Those are individually logged |
| 226 | * in DnsQueryEvents to enable computing error rates and network latency and timeouts |
| 227 | * broken up by query type, transport, network interface, etc. |
| 228 | */ |
| 229 | message NetworkDnsEventReported { |
| 230 | optional EventType event_type = 1; |
| 231 | |
| 232 | optional ReturnCode return_code = 2; |
| 233 | |
| 234 | // The latency in microseconds of the entire DNS lookup operation. |
| 235 | optional int32 latency_micros = 3; |
| 236 | |
| 237 | // Only valid for event_type = EVENT_GETADDRINFO. |
| 238 | optional int32 hints_ai_flags = 4; |
| 239 | |
| 240 | // Flags passed to android_res_nsend() defined in multinetwork.h |
| 241 | // Only valid for event_type = EVENT_RESNSEND. |
| 242 | optional int32 res_nsend_flags = 5; |
| 243 | |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 244 | optional NetworkType network_type = 6; |
lifr | 9b87e36 | 2019-05-08 13:00:14 +0800 | [diff] [blame] | 245 | |
| 246 | // The DNS over TLS mode on a specific netId. |
| 247 | optional PrivateDnsModes private_dns_modes = 7; |
| 248 | |
| 249 | // Additional pass-through fields opaque to statsd. |
| 250 | // The DNS resolver Mainline module can add new fields here without requiring an OS update. |
| 251 | optional DnsQueryEvents dns_query_events = 8; |
lifr | 66ec4ce | 2019-07-20 15:51:22 +0800 | [diff] [blame] | 252 | |
| 253 | // The sample rate of DNS stats (to statsd) is 1/sampling_rate_denom. |
| 254 | optional int32 sampling_rate_denom = 9; |
lifr | 9cd5d67 | 2019-06-20 11:30:28 +0800 | [diff] [blame] | 255 | } |