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";
17package android.stats.dnsresolver;
18
19enum EventType {
20    EVENT_UNKNOWN = 0;
21    EVENT_GETADDRINFO = 1;
22    EVENT_GETHOSTBYNAME = 2;
23    EVENT_GETHOSTBYADDR = 3;
24    EVENT_RES_NSEND = 4;
25}
26
27// The return value of the DNS resolver for each DNS lookups.
28// bionic/libc/include/netdb.h
29// system/netd/resolv/include/netd_resolv/resolv.h
30enum ReturnCode {
31    RC_EAI_NO_ERROR = 0;
32    RC_EAI_ADDRFAMILY = 1;
33    RC_EAI_AGAIN = 2;
34    RC_EAI_BADFLAGS = 3;
35    RC_EAI_FAIL = 4;
36    RC_EAI_FAMILY = 5;
37    RC_EAI_MEMORY = 6;
38    RC_EAI_NODATA = 7;
39    RC_EAI_NONAME = 8;
40    RC_EAI_SERVICE = 9;
41    RC_EAI_SOCKTYPE = 10;
42    RC_EAI_SYSTEM = 11;
43    RC_EAI_BADHINTS = 12;
44    RC_EAI_PROTOCOL = 13;
45    RC_EAI_OVERFLOW = 14;
46    RC_RESOLV_TIMEOUT = 255;
47    RC_EAI_MAX = 256;
48}
49
50enum NsRcode {
51    NS_R_NO_ERROR = 0;  // No error occurred.
52    NS_R_FORMERR = 1;   // Format error.
53    NS_R_SERVFAIL = 2;  // Server failure.
54    NS_R_NXDOMAIN = 3;  // Name error.
55    NS_R_NOTIMPL = 4;   // Unimplemented.
56    NS_R_REFUSED = 5;   // Operation refused.
57    // these are for BIND_UPDATE
58    NS_R_YXDOMAIN = 6;  // Name exists
59    NS_R_YXRRSET = 7;   // RRset exists
60    NS_R_NXRRSET = 8;   // RRset does not exist
61    NS_R_NOTAUTH = 9;   // Not authoritative for zone
62    NS_R_NOTZONE = 10;  // Zone of record different from zone section
63    NS_R_MAX = 11;
64    // The following are EDNS extended rcodes
65    NS_R_BADVERS = 16;
66    // The following are TSIG errors
67    // NS_R_BADSIG  = 16,
68    NS_R_BADKEY = 17;
69    NS_R_BADTIME = 18;
70}
71
72// Currently defined type values for resources and queries.
73enum NsType {
74    NS_T_INVALID = 0;      // Cookie.
75    NS_T_A = 1;            // Host address.
76    NS_T_NS = 2;           // Authoritative server.
77    NS_T_MD = 3;           // Mail destination.
78    NS_T_MF = 4;           // Mail forwarder.
79    NS_T_CNAME = 5;        // Canonical name.
80    NS_T_SOA = 6;          // Start of authority zone.
81    NS_T_MB = 7;           // Mailbox domain name.
82    NS_T_MG = 8;           // Mail group member.
83    NS_T_MR = 9;           // Mail rename name.
84    NS_T_NULL = 10;        // Null resource record.
85    NS_T_WKS = 11;         // Well known service.
86    NS_T_PTR = 12;         // Domain name pointer.
87    NS_T_HINFO = 13;       // Host information.
88    NS_T_MINFO = 14;       // Mailbox information.
89    NS_T_MX = 15;          // Mail routing information.
90    NS_T_TXT = 16;         // Text strings.
91    NS_T_RP = 17;          // Responsible person.
92    NS_T_AFSDB = 18;       // AFS cell database.
93    NS_T_X25 = 19;         // X_25 calling address.
94    NS_T_ISDN = 20;        // ISDN calling address.
95    NS_T_RT = 21;          // Router.
96    NS_T_NSAP = 22;        // NSAP address.
97    NS_T_NSAP_PTR = 23;    // Reverse NSAP lookup (deprecated).
98    NS_T_SIG = 24;         // Security signature.
99    NS_T_KEY = 25;         // Security key.
100    NS_T_PX = 26;          // X.400 mail mapping.
101    NS_T_GPOS = 27;        // Geographical position (withdrawn).
102    NS_T_AAAA = 28;        // IPv6 Address.
103    NS_T_LOC = 29;         // Location Information.
104    NS_T_NXT = 30;         // Next domain (security).
105    NS_T_EID = 31;         // Endpoint identifier.
106    NS_T_NIMLOC = 32;      // Nimrod Locator.
107    NS_T_SRV = 33;         // Server Selection.
108    NS_T_ATMA = 34;        // ATM Address
109    NS_T_NAPTR = 35;       // Naming Authority PoinTeR
110    NS_T_KX = 36;          // Key Exchange
111    NS_T_CERT = 37;        // Certification record
112    NS_T_A6 = 38;          // IPv6 address (experimental)
113    NS_T_DNAME = 39;       // Non-terminal DNAME
114    NS_T_SINK = 40;        // Kitchen sink (experimentatl)
115    NS_T_OPT = 41;         // EDNS0 option (meta-RR)
116    NS_T_APL = 42;         // Address prefix list (RFC 3123)
117    NS_T_DS = 43;          // Delegation Signer
118    NS_T_SSHFP = 44;       // SSH Fingerprint
119    NS_T_IPSECKEY = 45;    // IPSEC Key
120    NS_T_RRSIG = 46;       // RRset Signature
121    NS_T_NSEC = 47;        // Negative security
122    NS_T_DNSKEY = 48;      // DNS Key
123    NS_T_DHCID = 49;       // Dynamic host configuratin identifier
124    NS_T_NSEC3 = 50;       // Negative security type 3
125    NS_T_NSEC3PARAM = 51;  // Negative security type 3 parameters
126    NS_T_HIP = 55;         // Host Identity Protocol
127    NS_T_SPF = 99;         // Sender Policy Framework
128    NS_T_TKEY = 249;       // Transaction key
129    NS_T_TSIG = 250;       // Transaction signature.
130    NS_T_IXFR = 251;       // Incremental zone transfer.
131    NS_T_AXFR = 252;       // Transfer zone of authority.
132    NS_T_MAILB = 253;      // Transfer mailbox records.
133    NS_T_MAILA = 254;      // Transfer mail agent records.
134    NS_T_ANY = 255;        // Wildcard match.
135    NS_T_ZXFR = 256;       // BIND-specific, nonstandard.
136    NS_T_DLV = 32769;      // DNSSEC look-aside validatation.
137    NS_T_MAX = 65536;
138}
139
140enum IpVersion {
141    IV_UNKNOWN = 0;
142    IV_IPV4 = 1;
143    IV_IPV6 = 2;
144}
145
146enum TransportType {
147    TT_UNKNOWN = 0;
148    TT_UDP = 1;
149    TT_TCP = 2;
150    TT_DOT = 3;
151}
152
153enum PrivateDnsModes {
154    PDM_UNKNOWN = 0;
155    PDM_OFF = 1;
156    PDM_OPPORTUNISTIC = 2;
157    PDM_STRICT = 3;
158}
159
160enum Transport {
161    // Indicates this network uses a Cellular transport.
162    TRANSPORT_DEFAULT = 0;  // TRANSPORT_CELLULAR
163    // Indicates this network uses a Wi-Fi transport.
164    TRANSPORT_WIFI = 1;
165    // Indicates this network uses a Bluetooth transport.
166    TRANSPORT_BLUETOOTH = 2;
167    // Indicates this network uses an Ethernet transport.
168    TRANSPORT_ETHERNET = 3;
169    // Indicates this network uses a VPN transport.
170    TRANSPORT_VPN = 4;
171    // Indicates this network uses a Wi-Fi Aware transport.
172    TRANSPORT_WIFI_AWARE = 5;
173    // Indicates this network uses a LoWPAN transport.
174    TRANSPORT_LOWPAN = 6;
175}
176
177enum CacheStatus{
178    // the cache can't handle that kind of queries.
179    // or the answer buffer is too small.
180    CS_UNSUPPORTED = 0;
181    // the cache doesn't know about this query.
182    CS_NOTFOUND = 1;
183    // the cache found the answer.
184    CS_FOUND = 2;
185    // Don't do anything on cache.
186    CS_SKIP = 3;
187}
188
189message DnsQueryEvent {
190    optional android.stats.dnsresolver.NsRcode rcode = 1;
191
192    optional android.stats.dnsresolver.NsType type = 2;
193
194    optional android.stats.dnsresolver.CacheStatus cache_hit = 3;
195
196    optional android.stats.dnsresolver.IpVersion ip_version = 4;
197
198    optional android.stats.dnsresolver.TransportType transport = 5;
199
200    // Number of DNS query retry times
201    optional int32 retry_times = 6;
202
203    // Ordinal number of name server.
204    optional int32 dns_server_count = 7;
205
206    // Used only by TCP and DOT. True for new connections.
207    optional bool connected = 8;
208
209    optional int32 latency_micros = 9;
210}
211
212message DnsQueryEvents {
213    repeated DnsQueryEvent dns_query_event = 1;
214}
215