blob: b2508921df12ee5864d19146a8e7cb6f2adf24f3 [file] [log] [blame]
Bernie Innocenti189eb502018-10-01 23:10:18 +09001#ifndef NETD_RESOLV_STATIC_H
2#define NETD_RESOLV_STATIC_H
Bernie Innocenti55864192018-08-30 04:05:20 +09003
4#include <netdb.h>
Bernie Innocenti1f4a9fd2018-09-07 21:10:25 +09005#include <stdio.h>
Bernie Innocenti55864192018-08-30 04:05:20 +09006
7/* this structure contains all the variables that were declared
8 * 'static' in the original NetBSD resolver code.
9 *
10 * this caused vast amounts of crashes and memory corruptions
11 * when the resolver was being used by multiple threads.
12 *
13 * (note: the OpenBSD/FreeBSD resolver has similar 'issues')
14 */
15
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090016#define MAXALIASES 35
17#define MAXADDRS 35
Bernie Innocenti55864192018-08-30 04:05:20 +090018
Bernie Innocenti1f4a9fd2018-09-07 21:10:25 +090019struct res_static {
Bernie Innocentif12d5bb2018-08-31 14:09:46 +090020 char* h_addr_ptrs[MAXADDRS + 1];
21 char* host_aliases[MAXALIASES];
22 char hostbuf[8 * 1024];
23 u_int32_t host_addr[16 / sizeof(u_int32_t)]; /* IPv4 or IPv6 */
24 FILE* hostf;
25 int stayopen;
26 const char* servent_ptr;
27 struct servent servent;
28 struct hostent host;
Bernie Innocenti1f4a9fd2018-09-07 21:10:25 +090029};
Bernie Innocenti55864192018-08-30 04:05:20 +090030
Bernie Innocenti189eb502018-10-01 23:10:18 +090031res_static* res_get_static();
Bernie Innocenti55864192018-08-30 04:05:20 +090032
Bernie Innocenti189eb502018-10-01 23:10:18 +090033#endif // NETD_RESOLV_STATIC_H