resolv_params.h revision 6b3f0d65f2c706625e5efb495df0f2c6178b965a
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 */ 23#define MAXNS 3 /* max # name servers we'll track */ 24#define MAXNSSAMPLES 64 /* max # samples to store per server */ 25 26/* Defaults used for initializing __res_params */ 27#define SUCCESS_THRESHOLD 75 /* if successes * 100 / total_samples is less than 28 * this value, the server is considered failing 29 */ 30#define NSSAMPLE_VALIDITY 1800 /* Sample validity in seconds. 31 * Set to -1 to disable skipping failing 32 * servers. 33 */ 34 35/* per-netid configuration parameters passed from netd to the resolver */ 36struct __res_params { 37 uint16_t sample_validity; // sample lifetime in s 38 // threshold of success / total samples below which a server is considered broken 39 uint8_t success_threshold; // 0: disable, value / 100 otherwise 40 uint8_t min_samples; // min # samples needed for statistics to be considered meaningful 41 uint8_t max_samples; // max # samples taken into account for statistics 42} __attribute__((__packed__)); 43 44#endif // _RESOLV_PARAMS_H 45