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_INTERNAL_ERROR = 254;
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    // Define rcode=12~15(UNASSIGNED) in rcode enum type.
66    // Some DNS Servers might return undefined code to devices.
67    // Without the enum definition, that would be noise for our dashboard.
68    NS_R_UNASSIGNED12 = 12; // Unassigned
69    NS_R_UNASSIGNED13 = 13; // Unassigned
70    NS_R_UNASSIGNED14 = 14; // Unassigned
71    NS_R_UNASSIGNED15 = 15; // Unassigned
72    // The following are EDNS extended rcodes
73    NS_R_BADVERS = 16;
74    // The following are TSIG errors
75    // NS_R_BADSIG  = 16,
76    NS_R_BADKEY = 17;
77    NS_R_BADTIME = 18;
78    NS_R_INTERNAL_ERROR = 254;
79    NS_R_TIMEOUT = 255;
80}
81
82// Currently defined type values for resources and queries.
83enum NsType {
84    NS_T_INVALID = 0;      // Cookie.
85    NS_T_A = 1;            // Host address.
86    NS_T_NS = 2;           // Authoritative server.
87    NS_T_MD = 3;           // Mail destination.
88    NS_T_MF = 4;           // Mail forwarder.
89    NS_T_CNAME = 5;        // Canonical name.
90    NS_T_SOA = 6;          // Start of authority zone.
91    NS_T_MB = 7;           // Mailbox domain name.
92    NS_T_MG = 8;           // Mail group member.
93    NS_T_MR = 9;           // Mail rename name.
94    NS_T_NULL = 10;        // Null resource record.
95    NS_T_WKS = 11;         // Well known service.
96    NS_T_PTR = 12;         // Domain name pointer.
97    NS_T_HINFO = 13;       // Host information.
98    NS_T_MINFO = 14;       // Mailbox information.
99    NS_T_MX = 15;          // Mail routing information.
100    NS_T_TXT = 16;         // Text strings.
101    NS_T_RP = 17;          // Responsible person.
102    NS_T_AFSDB = 18;       // AFS cell database.
103    NS_T_X25 = 19;         // X_25 calling address.
104    NS_T_ISDN = 20;        // ISDN calling address.
105    NS_T_RT = 21;          // Router.
106    NS_T_NSAP = 22;        // NSAP address.
107    NS_T_NSAP_PTR = 23;    // Reverse NSAP lookup (deprecated).
108    NS_T_SIG = 24;         // Security signature.
109    NS_T_KEY = 25;         // Security key.
110    NS_T_PX = 26;          // X.400 mail mapping.
111    NS_T_GPOS = 27;        // Geographical position (withdrawn).
112    NS_T_AAAA = 28;        // IPv6 Address.
113    NS_T_LOC = 29;         // Location Information.
114    NS_T_NXT = 30;         // Next domain (security).
115    NS_T_EID = 31;         // Endpoint identifier.
116    NS_T_NIMLOC = 32;      // Nimrod Locator.
117    NS_T_SRV = 33;         // Server Selection.
118    NS_T_ATMA = 34;        // ATM Address
119    NS_T_NAPTR = 35;       // Naming Authority PoinTeR
120    NS_T_KX = 36;          // Key Exchange
121    NS_T_CERT = 37;        // Certification record
122    NS_T_A6 = 38;          // IPv6 address (experimental)
123    NS_T_DNAME = 39;       // Non-terminal DNAME
124    NS_T_SINK = 40;        // Kitchen sink (experimentatl)
125    NS_T_OPT = 41;         // EDNS0 option (meta-RR)
126    NS_T_APL = 42;         // Address prefix list (RFC 3123)
127    NS_T_DS = 43;          // Delegation Signer
128    NS_T_SSHFP = 44;       // SSH Fingerprint
129    NS_T_IPSECKEY = 45;    // IPSEC Key
130    NS_T_RRSIG = 46;       // RRset Signature
131    NS_T_NSEC = 47;        // Negative security
132    NS_T_DNSKEY = 48;      // DNS Key
133    NS_T_DHCID = 49;       // Dynamic host configuratin identifier
134    NS_T_NSEC3 = 50;       // Negative security type 3
135    NS_T_NSEC3PARAM = 51;  // Negative security type 3 parameters
136    NS_T_HIP = 55;         // Host Identity Protocol
137    NS_T_SPF = 99;         // Sender Policy Framework
138    NS_T_TKEY = 249;       // Transaction key
139    NS_T_TSIG = 250;       // Transaction signature.
140    NS_T_IXFR = 251;       // Incremental zone transfer.
141    NS_T_AXFR = 252;       // Transfer zone of authority.
142    NS_T_MAILB = 253;      // Transfer mailbox records.
143    NS_T_MAILA = 254;      // Transfer mail agent records.
144    NS_T_ANY = 255;        // Wildcard match.
145    NS_T_ZXFR = 256;       // BIND-specific, nonstandard.
146    NS_T_DLV = 32769;      // DNSSEC look-aside validatation.
147    NS_T_MAX = 65536;
148}
149
150enum IpVersion {
151    IV_UNKNOWN = 0;
152    IV_IPV4 = 1;
153    IV_IPV6 = 2;
154}
155
156enum Protocol {
157    PROTO_UNKNOWN = 0;
158    PROTO_UDP = 1;
159    PROTO_TCP = 2;
160    PROTO_DOT = 3;
161}
162
163enum PrivateDnsModes {
164    PDM_UNKNOWN = 0;
165    PDM_OFF = 1;
166    PDM_OPPORTUNISTIC = 2;
167    PDM_STRICT = 3;
168}
169
170enum NetworkType {
171    NT_UNKNOWN = 0;
172    // Indicates this network uses a Cellular transport.
173    NT_CELLULAR = 1;
174    // Indicates this network uses a Wi-Fi transport.
175    NT_WIFI = 2;
176    // Indicates this network uses a Bluetooth transport.
177    NT_BLUETOOTH = 3;
178    // Indicates this network uses an Ethernet transport.
179    NT_ETHERNET = 4;
180    // Indicates this network uses a VPN transport, now deprecated.
181    NT_VPN = 5 [deprecated=true];
182    // Indicates this network uses a Wi-Fi Aware transport.
183    NT_WIFI_AWARE = 6;
184    // Indicates this network uses a LoWPAN transport.
185    NT_LOWPAN = 7;
186    // Indicates this network uses a Cellular+VPN transport.
187    NT_CELLULAR_VPN = 8;
188    // Indicates this network uses a Wi-Fi+VPN transport.
189    NT_WIFI_VPN = 9;
190    // Indicates this network uses a Bluetooth+VPN transport.
191    NT_BLUETOOTH_VPN = 10;
192    // Indicates this network uses an Ethernet+VPN transport.
193    NT_ETHERNET_VPN = 11;
194    // Indicates this network uses a Wi-Fi+Cellular+VPN transport.
195    NT_WIFI_CELLULAR_VPN = 12;
196}
197
198enum CacheStatus{
199    // the cache can't handle that kind of queries.
200    // or the answer buffer is too small.
201    CS_UNSUPPORTED = 0;
202    // the cache doesn't know about this query.
203    CS_NOTFOUND = 1;
204    // the cache found the answer.
205    CS_FOUND = 2;
206    // Don't do anything on cache.
207    CS_SKIP = 3;
208}
209
210// The enum LinuxErrno is defined in the following 2 files.
211// 1. bionic/libc/kernel/uapi/asm-generic/errno-base.h
212// 2. bionic/libc/kernel/uapi/asm-generic/errno.h
213enum LinuxErrno {
214    SYS_NO_ERROR = 0;
215    SYS_EPERM = 1;              // Not super-user
216    SYS_ENOENT = 2;             // No such file or directory
217    SYS_ESRCH = 3;              // No such process
218    SYS_EINTR = 4;              // Interrupted system call
219    SYS_EIO = 5;                // I/O error
220    SYS_ENXIO = 6;              // No such device or address
221    SYS_E2BIG = 7;              // Arg list too long
222    SYS_ENOEXEC = 8;            // Exec format error
223    SYS_EBADF = 9;              // Bad file number
224    SYS_ECHILD = 10;            // No children
225    SYS_EAGAIN = 11;            // No more processes
226    SYS_ENOMEM = 12;            // Not enough core
227    SYS_EACCES = 13;            // Permission denied
228    SYS_EFAULT = 14;            // Bad address
229    SYS_ENOTBLK = 15;           // Block device required
230    SYS_EBUSY = 16;             // Mount device busy
231    SYS_EEXIST = 17;            // File exists
232    SYS_EXDEV = 18;             // Cross-device link
233    SYS_ENODEV = 19;            // No such device
234    SYS_ENOTDIR = 20;           // Not a directory
235    SYS_EISDIR = 21;            // Is a directory
236    SYS_EINVAL = 22;            // Invalid argument
237    SYS_ENFILE = 23;            // Too many open files in system
238    SYS_EMFILE = 24;            // Too many open files
239    SYS_ENOTTY = 25;            // Not a typewriter
240    SYS_ETXTBSY = 26;           // Text file busy
241    SYS_EFBIG = 27;             // File too large
242    SYS_ENOSPC = 28;            // No space left on device
243    SYS_ESPIPE = 29;            // Illegal seek
244    SYS_EROFS = 30;             // Read only file system
245    SYS_EMLINK = 31;            // Too many links
246    SYS_EPIPE = 32;             // Broken pipe
247    SYS_EDOM = 33;              // Math arg out of domain of func
248    SYS_ERANGE = 34;            // Math result not representable
249    SYS_EDEADLOCK = 35;         // File locking deadlock error
250    SYS_ENAMETOOLONG = 36;      // File or path name too long
251    SYS_ENOLCK = 37;            // No record locks available
252    SYS_ENOSYS = 38;            // Function not implemented
253    SYS_ENOTEMPTY = 39;         // Directory not empty
254    SYS_ELOOP = 40;             // Too many symbolic links
255    SYS_ENOMSG = 42;            // No message of desired type
256    SYS_EIDRM = 43;             // Identifier removed
257    SYS_ECHRNG = 44;            // Channel number out of range
258    SYS_EL2NSYNC = 45;          // Level 2 not synchronized
259    SYS_EL3HLT = 46;            // Level 3 halted
260    SYS_EL3RST = 47;            // Level 3 reset
261    SYS_ELNRNG = 48;            // Link number out of range
262    SYS_EUNATCH = 49;           // rotocol driver not attached
263    SYS_ENOCSI = 50;            // No CSI structure available
264    SYS_EL2HLT = 51;            // Level 2 halted
265    SYS_EBADE = 52;             // Invalid exchange
266    SYS_EBADR = 53;             // Invalid request descriptor
267    SYS_EXFULL = 54;            // Exchange full
268    SYS_ENOANO = 55;            // No anode
269    SYS_EBADRQC = 56;           // Invalid request code
270    SYS_EBADSLT = 57;           // Invalid slot
271    SYS_EBFONT = 59;            // Bad font file fmt
272    SYS_ENOSTR = 60;            // Device not a stream
273    SYS_ENODATA = 61;           // No data (for no delay io)
274    SYS_ETIME = 62;             // Timer expired
275    SYS_ENOSR = 63;             // Out of streams resources
276    SYS_ENONET = 64;            // Machine is not on the network
277    SYS_ENOPKG = 65;            // Package not installed
278    SYS_EREMOTE = 66;           // The object is remote
279    SYS_ENOLINK = 67;           // The link has been severed
280    SYS_EADV = 68;              // Advertise error
281    SYS_ESRMNT = 69;            // Srmount error
282    SYS_ECOMM = 70;             // Communication error on send
283    SYS_EPROTO = 71;            // Protocol error
284    SYS_EMULTIHOP = 72;         // Multihop attempted
285    SYS_EDOTDOT = 73;           // Cross mount point (not really error)
286    SYS_EBADMSG = 74;           // Trying to read unreadable message
287    SYS_EOVERFLOW = 75;         // Value too large for defined data type
288    SYS_ENOTUNIQ = 76;          // Given log. name not unique
289    SYS_EBADFD = 77;            // f.d. invalid for this operation
290    SYS_EREMCHG = 78;           // Remote address changed
291    SYS_ELIBACC = 79;           // Can't access a needed shared lib
292    SYS_ELIBBAD = 80;           // Accessing a corrupted shared lib
293    SYS_ELIBSCN = 81;           // .lib section in a.out corrupted
294    SYS_ELIBMAX = 82;           // Attempting to link in too many libs
295    SYS_ELIBEXEC = 83;          // Attempting to exec a shared library
296    SYS_EILSEQ = 84;
297    SYS_ERESTART = 85;
298    SYS_ESTRPIPE = 86;
299    SYS_EUSERS = 87;
300    SYS_ENOTSOCK = 88;          // Socket operation on non-socket
301    SYS_EDESTADDRREQ = 89;      // Destination address required
302    SYS_EMSGSIZE = 90;          // Message too long
303    SYS_EPROTOTYPE = 91;        // Protocol wrong type for socket
304    SYS_ENOPROTOOPT = 92;       // Protocol not available
305    SYS_EPROTONOSUPPORT = 93;   // Unknown protocol
306    SYS_ESOCKTNOSUPPORT = 94;   // Socket type not supported
307    SYS_EOPNOTSUPP = 95;        // Operation not supported on transport endpoint
308    SYS_EPFNOSUPPORT = 96;      // Protocol family not supported
309    SYS_EAFNOSUPPORT = 97;      // Address family not supported by protocol family
310    SYS_EADDRINUSE = 98;        // Address already in use
311    SYS_EADDRNOTAVAIL = 99;     // Address not available
312    SYS_ENETDOWN = 100;         // Network interface is not configured
313    SYS_ENETUNREACH = 101;      // Network is unreachable
314    SYS_ENETRESET = 102;
315    SYS_ECONNABORTED = 103;     // Connection aborted
316    SYS_ECONNRESET = 104;       // Connection reset by peer
317    SYS_ENOBUFS = 105;          // No buffer space available
318    SYS_EISCONN = 106;          // Socket is already connected
319    SYS_ENOTCONN = 107;         // Socket is not connected
320    SYS_ESHUTDOWN = 108;        // Can't send after socket shutdown
321    SYS_ETOOMANYREFS = 109;
322    SYS_ETIMEDOUT = 110;        // Connection timed out
323    SYS_ECONNREFUSED = 111;     // Connection refused
324    SYS_EHOSTDOWN = 112;        // Host is down
325    SYS_EHOSTUNREACH = 113;     // Host is unreachable
326    SYS_EALREADY = 114;         // Socket already connected
327    SYS_EINPROGRESS = 115;      // Connection already in progress
328    SYS_ESTALE = 116;
329    SYS_EUCLEAN = 117;
330    SYS_ENOTNAM = 118;
331    SYS_ENAVAIL = 119;
332    SYS_EISNAM = 120;
333    SYS_EREMOTEIO = 121;
334    SYS_EDQUOT = 122;
335    SYS_ENOMEDIUM = 123;        // No medium (in tape drive)
336    SYS_EMEDIUMTYPE = 124;
337    SYS_ECANCELED = 125;
338    SYS_ENOKEY = 126;
339    SYS_EKEYEXPIRED = 127;
340    SYS_EKEYREVOKED = 128;
341    SYS_EKEYREJECTED = 129;
342    SYS_EOWNERDEAD = 130;
343    SYS_ENOTRECOVERABLE = 131;
344    SYS_ERFKILL = 132;
345    SYS_EHWPOISON = 133;
346}
347
348message DnsQueryEvent {
349    optional android.stats.dnsresolver.NsRcode rcode = 1;
350
351    optional android.stats.dnsresolver.NsType type = 2;
352
353    optional android.stats.dnsresolver.CacheStatus cache_hit = 3;
354
355    optional android.stats.dnsresolver.IpVersion ip_version = 4;
356
357    optional android.stats.dnsresolver.Protocol protocol = 5;
358
359    // Number of DNS query retry times
360    optional int32 retry_times = 6;
361
362    // Ordinal number of name server.
363    optional int32 dns_server_index = 7;
364
365    // Used only by TCP and DOT. True for new connections.
366    optional bool connected = 8;
367
368    optional int32 latency_micros = 9;
369
370    optional android.stats.dnsresolver.LinuxErrno linux_errno = 10;
371}
372
373message DnsQueryEvents {
374    repeated DnsQueryEvent dns_query_event = 1;
375}
376