From 352f4ff9a268b81ef5d4b2413f582565806e4790 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 30 Jun 2017 21:10:23 +0200 Subject: resolv: Introduce struct resolv_context [BZ #21668] struct resolv_context objects provide a temporary resolver context which does not change during a name lookup operation. Only when the outmost context is created, the stub resolver configuration is verified to be current (at present, only against previous res_init calls). Subsequent attempts to obtain the context will reuse the result of the initial verification operation. struct resolv_context can also be extended in the future to store data which needs to be deallocated during thread cancellation. --- resolv/resolv-internal.h | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'resolv/resolv-internal.h') diff --git a/resolv/resolv-internal.h b/resolv/resolv-internal.h index 5a9faf8de9..9246497196 100644 --- a/resolv/resolv-internal.h +++ b/resolv/resolv-internal.h @@ -52,9 +52,41 @@ enum RESOLV_EDNS_BUFFER_SIZE = 1200, }; +struct resolv_context; + +/* Internal function for implementing res_nmkquery and res_mkquery. + Also used by __res_context_query. */ +int __res_context_mkquery (struct resolv_context *, int op, const char *dname, + int class, int type, const unsigned char *data, + unsigned char *buf, int buflen) attribute_hidden; + +/* Main resolver query function for use within glibc. */ +int __res_context_search (struct resolv_context *, const char *, int, int, + unsigned char *, int, unsigned char **, + unsigned char **, int *, int *, int *); +libresolv_hidden_proto (__res_context_search) + +/* Main resolver query function for use within glibc. */ +int __res_context_query (struct resolv_context *, const char *, int, int, + unsigned char *, int, unsigned char **, + unsigned char **, int *, int *, int *); +libresolv_hidden_proto (__res_context_query) + +/* Internal function used to implement the query and search + functions. */ +int __res_context_send (struct resolv_context *, const unsigned char *, int, + const unsigned char *, int, unsigned char *, + int, unsigned char **, unsigned char **, + int *, int *, int *) attribute_hidden; + +/* Internal function similar to res_hostalias. */ +const char *__res_context_hostalias (struct resolv_context *, + const char *, char *, size_t); +libresolv_hidden_proto (__res_context_hostalias); + /* Add an OPT record to a DNS query. */ -int __res_nopt (res_state, int n0, unsigned char *buf, int buflen, - int anslen) attribute_hidden; +int __res_nopt (struct resolv_context *, int n0, + unsigned char *buf, int buflen, int anslen) attribute_hidden; /* Convert from presentation format (which usually means ASCII printable) to network format (which is usually some kind of binary -- cgit v1.2.3-70-g09d2