blob: d2f058b291ba6bc8756f4402b4a802e37a76fe99 [file] [log] [blame]
Bernie Innocenti55864192018-08-30 04:05:20 +09001/*
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 */
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090023#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 */
Bernie Innocenti55864192018-08-30 04:05:20 +090027
28/* Defaults used for initializing __res_params */
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090029#define SUCCESS_THRESHOLD \
30 75 /* if successes * 100 / total_samples is less than \
31 * this value, the server is considered failing \
32 */
33#define NSSAMPLE_VALIDITY \
34 1800 /* Sample validity in seconds. \
35 * Set to -1 to disable skipping failing \
36 * servers. \
37 */
Bernie Innocenti55864192018-08-30 04:05:20 +090038
39/* If EDNS0_PADDING is defined, queries will be padded to a multiple of this length
40when EDNS0 is active. */
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090041#define EDNS0_PADDING 128
Bernie Innocenti55864192018-08-30 04:05:20 +090042
43/* per-netid configuration parameters passed from netd to the resolver */
44struct __res_params {
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090045 uint16_t sample_validity; // sample lifetime in s
Bernie Innocenti55864192018-08-30 04:05:20 +090046 // threshold of success / total samples below which a server is considered broken
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090047 uint8_t success_threshold; // 0: disable, value / 100 otherwise
48 uint8_t min_samples; // min # samples needed for statistics to be considered meaningful
49 uint8_t max_samples; // max # samples taken into account for statistics
50 int base_timeout_msec; // base query retry timeout (if 0, use RES_TIMEOUT)
Bernie Innocenti55864192018-08-30 04:05:20 +090051};
52
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090053typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } res_sendhookact;
Bernie Innocenti55864192018-08-30 04:05:20 +090054
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090055typedef res_sendhookact (*res_send_qhook)(struct sockaddr* const*, const u_char**, int*, u_char*,
56 int, int*);
Bernie Innocenti55864192018-08-30 04:05:20 +090057
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090058typedef res_sendhookact (*res_send_rhook)(const struct sockaddr*, const u_char*, int, u_char*, int,
59 int*);
Bernie Innocenti55864192018-08-30 04:05:20 +090060
Bernie Innocentiee1b85b2018-09-25 14:23:19 +090061#define LIBNETD_RESOLV_PUBLIC extern "C" [[gnu::visibility("default")]]
62
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090063#endif // _RESOLV_PARAMS_H