Pierre Imai | 6b3f0d6 | 2016-02-22 17:50:41 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
| 17 | #ifndef _RESOLV_PARAMS_H |
| 18 | #define _RESOLV_PARAMS_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | /* Hard-coded defines */ |
Pierre Imai | 97c9d73 | 2016-04-18 12:00:12 +0900 | [diff] [blame] | 23 | #define MAXNS 4 /* max # name servers we'll track */ |
| 24 | #define MAXDNSRCH 6 /* max # domains in search path */ |
| 25 | #define MAXDNSRCHPATH 256 /* max length of domain search paths */ |
| 26 | #define MAXNSSAMPLES 64 /* max # samples to store per server */ |
Pierre Imai | 6b3f0d6 | 2016-02-22 17:50:41 +0900 | [diff] [blame] | 27 | |
| 28 | /* Defaults used for initializing __res_params */ |
Pierre Imai | fff3567 | 2016-04-18 11:42:14 +0900 | [diff] [blame] | 29 | #define SUCCESS_THRESHOLD 75 /* if successes * 100 / total_samples is less than |
Pierre Imai | 6b3f0d6 | 2016-02-22 17:50:41 +0900 | [diff] [blame] | 30 | * this value, the server is considered failing |
| 31 | */ |
| 32 | #define NSSAMPLE_VALIDITY 1800 /* Sample validity in seconds. |
| 33 | * Set to -1 to disable skipping failing |
| 34 | * servers. |
| 35 | */ |
| 36 | |
Ben Schwartz | 27dd915 | 2018-02-05 17:54:06 -0500 | [diff] [blame] | 37 | /* If EDNS0_PADDING is defined, queries will be padded to a multiple of this length |
| 38 | when EDNS0 is active. */ |
| 39 | #define EDNS0_PADDING 128 |
| 40 | |
Pierre Imai | 6b3f0d6 | 2016-02-22 17:50:41 +0900 | [diff] [blame] | 41 | /* per-netid configuration parameters passed from netd to the resolver */ |
| 42 | struct __res_params { |
| 43 | uint16_t sample_validity; // sample lifetime in s |
| 44 | // threshold of success / total samples below which a server is considered broken |
| 45 | uint8_t success_threshold; // 0: disable, value / 100 otherwise |
| 46 | uint8_t min_samples; // min # samples needed for statistics to be considered meaningful |
| 47 | uint8_t max_samples; // max # samples taken into account for statistics |
Bernie Innocenti | 58d1362 | 2018-07-29 18:21:23 +0900 | [diff] [blame] | 48 | int base_timeout_msec; // base query retry timeout (if 0, use RES_TIMEOUT) |
Stephen Hines | 9935e0f | 2017-01-25 00:39:47 -0800 | [diff] [blame] | 49 | }; |
Pierre Imai | 6b3f0d6 | 2016-02-22 17:50:41 +0900 | [diff] [blame] | 50 | |
Ben Schwartz | f0305dc | 2017-04-24 17:57:11 -0400 | [diff] [blame] | 51 | typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } |
| 52 | res_sendhookact; |
| 53 | |
| 54 | typedef res_sendhookact (*res_send_qhook)(struct sockaddr * const *, |
| 55 | const u_char **, int *, |
| 56 | u_char *, int, int *); |
| 57 | |
| 58 | typedef res_sendhookact (*res_send_rhook)(const struct sockaddr *, |
| 59 | const u_char *, int, u_char *, |
| 60 | int, int *); |
| 61 | |
Pierre Imai | 6b3f0d6 | 2016-02-22 17:50:41 +0900 | [diff] [blame] | 62 | #endif // _RESOLV_PARAMS_H |