stats.proto 8.6 KB

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