summaryrefslogtreecommitdiff
path: root/src/network/lookup.h
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2016-01-28 18:24:34 -0500
committerRich Felker <dalias@aerifal.cx>2016-01-28 18:39:22 -0500
commitd6cb08bcaca4ff1f921375510ca72bccea969c75 (patch)
tree35a357b3c880d2a71aac9056ddb30c1646418d77 /src/network/lookup.h
parent19df86cbb39f2429f7c7e20c99c606c38a5fd4e9 (diff)
downloadmusl-d6cb08bcaca4ff1f921375510ca72bccea969c75.tar.gz
factor resolv.conf parsing out of res_msend to its own file
this change is made in preparation for adding search domains, for which higher-level code will need to parse resolv.conf. simply parsing it twice for each lookup would be one reasonable option, but the existing parser code was buggy anyway, which suggested to me that it's a bad idea to have two variants of this code in two different places. the old code in res_msend potentially misinterpreted overly long lines in resolv.conf, and stopped parsing after it found 3 nameservers, even if there were relevant options left to be parsed later in the file.
Diffstat (limited to 'src/network/lookup.h')
-rw-r--r--src/network/lookup.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/network/lookup.h b/src/network/lookup.h
index 69419115..0468edbc 100644
--- a/src/network/lookup.h
+++ b/src/network/lookup.h
@@ -2,6 +2,7 @@
#define LOOKUP_H
#include <stdint.h>
+#include <stddef.h>
struct address {
int family;
@@ -15,6 +16,14 @@ struct service {
unsigned char proto, socktype;
};
+#define MAXNS 3
+
+struct resolvconf {
+ struct address ns[MAXNS];
+ unsigned nns, attempts, ndots;
+ unsigned timeout;
+};
+
/* The limit of 48 results is a non-sharp bound on the number of addresses
* that can fit in one 512-byte DNS packet full of v4 results and a second
* packet full of v6 results. Due to headers, the actual limit is lower. */
@@ -25,4 +34,6 @@ int __lookup_serv(struct service buf[static MAXSERVS], const char *name, int pro
int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags);
int __lookup_ipliteral(struct address buf[static 1], const char *name, int family);
+int __get_resolv_conf(struct resolvconf *, char *, size_t);
+
#endif