diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-07-12 16:53:59 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-07-12 16:53:59 +0000 |
commit | 207845f50a8fb54fe8e584928078dc3687399caf (patch) | |
tree | f58eac67edc2dbaba13a48442a2093f76e869991 | |
parent | 8cf671e973a4ea2ef7c9ca1321531a7ceeaa5073 (diff) | |
download | s6-dns-207845f50a8fb54fe8e584928078dc3687399caf.tar.xz |
Pass on all clients, add hosts support wherever applicable
Signed-off-by: Laurent Bercot <ska@appnovation.com>
28 files changed, 504 insertions, 216 deletions
diff --git a/doc/libs6dns/hosts.html b/doc/libs6dns/hosts.html index 93bfc10..b9a03bf 100644 --- a/doc/libs6dns/hosts.html +++ b/doc/libs6dns/hosts.html @@ -71,7 +71,7 @@ use the macros without a <tt>_r</tt> suffix. <h2> Functions </h2> -<h3> Preparation </h3> +<h3> Compilation </h3> <p> <code> int s6dns_hosts_compile (int fdr, int fdw) </code> <br /> @@ -84,45 +84,158 @@ on failure. </p> <p> - You normally don't need to use this function yourself, because -it's implicitly used by the following one. + You normally don't need to use this function yourself. To +compile the hosts database prior to use, you can call the +<a href="../s6-dns-hosts-compile.html">s6-dns-hosts-compile</a> +program (which uses this function). Alternatively, +at initialization time, the hosts database will be compiled +automatically if there isn't a more recent compiled version. </p> +<h3> Initialization </h3> + <p> -<code> int s6dns_hosts_init (void) </code> <br /> -Initializes the database from the <tt>/etc/hosts</tt> file. -If there's a pre-compiled <tt>/etc/hosts.cdb</tt> file that +<code> int s6dns_hosts_init (cdb *c, char const *txtfile, char const *cdbfile, char const *prefix) </code> <br /> +Initializes the compiled hosts database in <em>*c</em>. +If there's a pre-compiled <em>cdbfile</em> file that is more recent than <tt>/etc/hosts</tt>, then it is used; -else, the <tt>/etc/hosts</tt> file is compiled into a -temporary file under <tt>/tmp</tt>, which is used and -immediately unlinked. The function returns 1 on success and -0 (and sets errno) on failure. +else, the <em>txtfile</em> file is compiled into a +temporary file starting with <em>prefix</em>, which is used and +immediately unlinked. The function returns -1 (and sets errno) +on failure, 1 on success, and 0 if it can find neither a +suitable <em>cdbfile</em> nor a suitable <em>txtfile</em>. </p> <p> -<code> int s6dns_hosts_init_r (cdb *c, char const *txtfile, char const *cdbfile, char const *prefix) </code> <br /> -The generic version of the above function. Initializes the database -in <em>*c</em> from the compiled file <em>cdbfile</em> if it exists and is -more recent than <em>txtfile</em>, else compiles <em>txtfile</em> into -a temporary file with a path starting with <em>prefix</em>, makes it -accessible in <em>*c</em> and immediately unlinks it. +<code> void s6dns_hosts_free (cdb *c) </code> <br /> +Frees the compiled hosts database in <em>c</em>. </p> <p> -<code> void s6dns_hosts_free (void) </code> <br /> -Frees the compiled hosts database. Only use this if -you're certain you'll have no more use for it. + You probably don't need to use these functions yourself: +instead, the higher-level <tt>s6dns_init()</tt> and +<tt>s6dns_finish()</tt> functions perform all the necessary +initialization and cleanup, including the hosts database one. </p> + +<h3> IP to name resolution </h3> + <p> -<code> void s6dns_hosts_free_r (cdb *c) </code> <br /> -The generic version of the above function. +<code> int s6dns_hosts_name (char const *ip, stralloc *storage, genalloc *indices, int is6) </code> <br /> +Gets the list of names for IP address <em>ip</em> from the hosts database. +The names are stored in the stralloc <em>*storage</em>; for each name, +its index in <em>storage→s</em> is appended, as a <tt>size_t</tt>, +to the genalloc <em>*indices</em>. If <em>is6</em> is nonzero, <em>ip</em> +is interpreted as an IPv6 address, i.e. a network byte order sequence of +16 bytes; otherwise it is interpreted as an IPv4 address, i.e. a network +byte order sequence of 4 bytes. The function returns -1 (and sets errno) +in case of failure, 0 if no match could be found (which includes no +existing hosts database), or the number of names it found. Names listed +as the first name on a line in <tt>/etc/hosts</tt> are always given as +fully qualified, i.e. with a terminating dot; other names are given as +they were input in <tt>/etc/hosts</tt>. </p> -<h3> IP to name resolution </h3> +<p> +<code> int s6dns_hosts_name4 (char const *ip, stralloc *storage, genalloc *indices) </code> <br /> +Same, but <em>ip</em> is assumed to be an IPv4. +</p> + +<p> +<code> int s6dns_hosts_name6 (char const *ip, stralloc *storage, genalloc *indices) </code> <br /> +Same, but <em>ip</em> is assumed to be an IPv6. +</p> + +<h3> Name to IP resolution </h3> + +<h4> Fully qualified names </h4> + +<p> +<code> extern int s6dns_hosts_a_noq (char const *name, stralloc *ip4s) </code> <br /> +Gets the list of IPv4 addresses for name <em>name</em> from the hosts database. +The addresses are stored in the stralloc <em>*ip4s</em>, in network byte order, +4 bytes per item. <em>name</em> is assumed to be fully qualified: <tt>skarnet.org</tt> +will yield the same results as <tt>skarnet.org.</tt>, and <tt>blah</tt> will yield +the same results as <tt>blah.</tt> with the ending dot. The function returns -1 +(and sets errno) in case of failure, 0 if no match (including no valid hosts +database), or the number of IP addresses appended to <em>*ip4s</em> (i.e. the +length increase divided by 4). +</p> + +<p> +<code> extern int s6dns_hosts_aaaa_noq (char const *name, stralloc *ip6s) </code> <br /> +Same as above, but gets the list of IPv6 addresses for <em>name</em>; there are +16 bytes per address instead of 4. +</p> + +<p> +<code> extern int s6dns_hosts_aaaaa_noq (char const *name, genalloc *ips) </code> <br /> +Same as above, but gets the list of all IP addresses for <em>name</em>, v4 or v6 +indiscriminately. Every address is stored in the genalloc <em>*ips</em> as an +<a href="https://git.skarnet.org/cgi-bin/cgit.cgi/skalibs/tree/src/headers/ip46-header#n21"><tt>ip46full</tt> structure</a>. +</p> + +<h4> Aliases </h4> + +<p> +<code> extern int s6dns_hosts_a_unq (char const *name, stralloc *ip4s) </code> <br /> +Gets the list of IPv4 addresses for name <em>name</em> from the hosts database. +The addresses are stored in the stralloc <em>*ip4s</em>, in network byte order, +4 bytes per item. <em>name</em> is assumed to be unqualified: <tt>blah</tt> +is interpreted as a local alias that will only match a <tt>blah</tt> +entry in <tt>/etc/hosts</tt> that does <strong>not</strong> appear as a first +entry. The function returns -1 +(and sets errno) in case of failure, 0 if no match (including no valid hosts +database), or the number of IP addresses appended to <em>*ip4s</em> (i.e. the +length increase divided by 4). +</p> + +<p> +<code> extern int s6dns_hosts_aaaa_unq (char const *name, stralloc *ip6s) </code> <br /> +Same as above, but gets the list of IPv6 addresses for <em>name</em>; there are +16 bytes per address instead of 4. +</p> + +<p> +<code> extern int s6dns_hosts_aaaaa_unq (char const *name, genalloc *ips) </code> <br /> +Same as above, but gets the list of all IP addresses for <em>name</em>, v4 or v6 +indiscriminately. Every address is stored in the genalloc <em>*ips</em> as an +<a href="https://git.skarnet.org/cgi-bin/cgit.cgi/skalibs/tree/src/headers/ip46-header#n21"><tt>ip46full</tt> structure</a>. +</p> + +<h4> With qualification </h4> + +<p> +<code> extern int s6dns_hosts_a_q (char const *name, stralloc *ip4s) </code> <br /> +Gets the list of IPv4 addresses, from the hosts database, for all possible +qualifications for name <em>name</em>. +The addresses are stored in the stralloc <em>*ip4s</em>, in network byte order, +4 bytes per item. The function returns -1 +(and sets errno) in case of failure, 0 if no match (including no valid hosts +database), or the number of IP addresses appended to <em>*ip4s</em> (i.e. the +length increase divided by 4). +</p> + +<p> + First, <em>name</em> is looked up in the hosts database as a simple +unqualified names. Then, <em>name</em> is qualified with all the suffixes +read from <tt>/etc/resolv.conf</tt>, and all of the resulting FQDNs are +looked up in the hosts database. All the results are concatenated and +appended to the <em>*ip4s</em> stralloc. +</p> + +<p> +<code> extern int s6dns_hosts_aaaa_q (char const *name, stralloc *ip6s) </code> <br /> +Same as above, but gets the list of IPv6 addresses for <em>name</em>; there are +16 bytes per address instead of 4. +</p> <p> -<code> int s6dns_hosts_name_r (cdb const *c, char const *ip, stralloc *storage, genalloc *indices, int is6) </code> <br /> +<code> extern int s6dns_hosts_aaaaa_q (char const *name, genalloc *ips) </code> <br /> +Same as above, but gets the list of all IP addresses for <em>name</em>, v4 or v6 +indiscriminately. Every address is stored in the genalloc <em>*ips</em> as an +<a href="https://git.skarnet.org/cgi-bin/cgit.cgi/skalibs/tree/src/headers/ip46-header#n21"><tt>ip46full</tt> structure</a>. </p> </body> diff --git a/package/deps.mak b/package/deps.mak index 6991226..400420e 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -28,11 +28,11 @@ src/caches/shibari_whitelist_add6.o src/caches/shibari_whitelist_add6.lo: src/ca src/caches/shibari_whitelist_ip4_match.o src/caches/shibari_whitelist_ip4_match.lo: src/caches/shibari_whitelist_ip4_match.c src/caches/shibari-internal.h src/caches/shibari_whitelist_ip6_match.o src/caches/shibari_whitelist_ip6_match.lo: src/caches/shibari_whitelist_ip6_match.c src/caches/shibari-internal.h src/caches/shibari_whitelist_read.o src/caches/shibari_whitelist_read.lo: src/caches/shibari_whitelist_read.c src/caches/shibari-internal.h -src/clients/s6-dnsip.o src/clients/s6-dnsip.lo: src/clients/s6-dnsip.c src/include/s6-dns/s6dns.h +src/clients/s6-dnsip.o src/clients/s6-dnsip.lo: src/clients/s6-dnsip.c src/include/s6-dns/hosts.h src/include/s6-dns/s6dns-rci.h src/include/s6-dns/s6dns-resolve.h src/clients/s6-dnsip4-filter.o src/clients/s6-dnsip4-filter.lo: src/clients/s6-dnsip4-filter.c src/include/s6-dns/s6dns-constants.h src/include/s6-dns/s6dns-message.h src/clients/s6dns-generic-filter.h -src/clients/s6-dnsip4.o src/clients/s6-dnsip4.lo: src/clients/s6-dnsip4.c src/include/s6-dns/s6dns.h +src/clients/s6-dnsip4.o src/clients/s6-dnsip4.lo: src/clients/s6-dnsip4.c src/include/s6-dns/hosts.h src/include/s6-dns/s6dns-rci.h src/include/s6-dns/s6dns-resolve.h src/clients/s6-dnsip6-filter.o src/clients/s6-dnsip6-filter.lo: src/clients/s6-dnsip6-filter.c src/include/s6-dns/s6dns-constants.h src/include/s6-dns/s6dns-message.h src/clients/s6dns-generic-filter.h -src/clients/s6-dnsip6.o src/clients/s6-dnsip6.lo: src/clients/s6-dnsip6.c src/include/s6-dns/s6dns.h +src/clients/s6-dnsip6.o src/clients/s6-dnsip6.lo: src/clients/s6-dnsip6.c src/include/s6-dns/hosts.h src/include/s6-dns/s6dns-rci.h src/include/s6-dns/s6dns-resolve.h src/clients/s6-dnsmx.o src/clients/s6-dnsmx.lo: src/clients/s6-dnsmx.c src/include/s6-dns/s6dns.h src/clients/s6-dnsname-filter.o src/clients/s6-dnsname-filter.lo: src/clients/s6-dnsname-filter.c src/include/s6-dns/s6dns-constants.h src/include/s6-dns/s6dns-domain.h src/include/s6-dns/s6dns-message.h src/clients/s6dns-generic-filter.h src/clients/s6-dnsname.o src/clients/s6-dnsname.lo: src/clients/s6-dnsname.c src/include/s6-dns/s6dns.h @@ -100,7 +100,7 @@ src/libs6dns/s6dns_hosts_init.o src/libs6dns/s6dns_hosts_init.lo: src/libs6dns/s src/libs6dns/s6dns_hosts_ip_q.o src/libs6dns/s6dns_hosts_ip_q.lo: src/libs6dns/s6dns_hosts_ip_q.c src/include/s6-dns/hosts.h src/include/s6-dns/s6dns-domain.h src/libs6dns/s6dns_hosts_ip_string.o src/libs6dns/s6dns_hosts_ip_string.lo: src/libs6dns/s6dns_hosts_ip_string.c src/include/s6-dns/hosts.h src/include/s6-dns/s6dns-domain.h src/libs6dns/s6dns_hosts_name.o src/libs6dns/s6dns_hosts_name.lo: src/libs6dns/s6dns_hosts_name.c src/include/s6-dns/hosts.h -src/libs6dns/s6dns_init.o src/libs6dns/s6dns_init.lo: src/libs6dns/s6dns_init.c src/include/s6-dns/s6dns-rci.h src/include/s6-dns/s6dns.h +src/libs6dns/s6dns_init.o src/libs6dns/s6dns_init.lo: src/libs6dns/s6dns_init.c src/include/s6-dns/hosts.h src/include/s6-dns/s6dns-rci.h src/include/s6-dns/s6dns.h src/libs6dns/s6dns_message_counts_next.o src/libs6dns/s6dns_message_counts_next.lo: src/libs6dns/s6dns_message_counts_next.c src/include/s6-dns/s6dns-message.h src/libs6dns/s6dns_message_counts_pack.o src/libs6dns/s6dns_message_counts_pack.lo: src/libs6dns/s6dns_message_counts_pack.c src/include/s6-dns/s6dns-message.h src/libs6dns/s6dns_message_counts_unpack.o src/libs6dns/s6dns_message_counts_unpack.lo: src/libs6dns/s6dns_message_counts_unpack.c src/include/s6-dns/s6dns-message.h @@ -211,12 +211,12 @@ s6-dnstxt: src/clients/s6-dnstxt.o ${LIBS6DNS} s6-randomip: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} s6-randomip: src/clients/s6-randomip.o ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) -libs6dns.a.xyzzy: src/libs6dns/s6dns_constants_error.o src/libs6dns/s6dns_constants_error_str.o src/libs6dns/s6dns_debughook_zero.o src/libs6dns/s6dns_domain_arpafromip4.o src/libs6dns/s6dns_domain_arpafromip6.o src/libs6dns/s6dns_domain_decode.o src/libs6dns/s6dns_domain_encode.o src/libs6dns/s6dns_domain_encodelist.o src/libs6dns/s6dns_domain_fromstring.o src/libs6dns/s6dns_domain_fromstring_noqualify_encode.o src/libs6dns/s6dns_domain_fromstring_qualify_encode.o src/libs6dns/s6dns_domain_noqualify.o src/libs6dns/s6dns_domain_qualify.o src/libs6dns/s6dns_domain_tostring.o src/libs6dns/s6dns_engine.o src/libs6dns/s6dns_engine_free.o src/libs6dns/s6dns_engine_freen.o src/libs6dns/s6dns_engine_here.o src/libs6dns/s6dns_engine_nextdeadline.o src/libs6dns/s6dns_engine_zero.o src/libs6dns/s6dns_fmt_domainlist.o src/libs6dns/s6dns_fmt_hinfo.o src/libs6dns/s6dns_fmt_mx.o src/libs6dns/s6dns_fmt_soa.o src/libs6dns/s6dns_fmt_srv.o src/libs6dns/s6dns_fmt_caa.o src/libs6dns/s6dns_hosts_compile.o src/libs6dns/s6dns_hosts_aaaaa_q.o src/libs6dns/s6dns_hosts_aaaaa_string.o src/libs6dns/s6dns_hosts_ip_q.o src/libs6dns/s6dns_hosts_ip_string.o src/libs6dns/s6dns_hosts_name.o src/libs6dns/s6dns_hosts_here.o src/libs6dns/s6dns_message_counts_next.o src/libs6dns/s6dns_message_counts_pack.o src/libs6dns/s6dns_message_counts_unpack.o src/libs6dns/s6dns_message_counts_zero.o src/libs6dns/s6dns_message_get_domain.o src/libs6dns/s6dns_message_get_domain_nodecode.o src/libs6dns/s6dns_message_get_hinfo.o src/libs6dns/s6dns_message_get_string.o src/libs6dns/s6dns_message_get_string_internal.o src/libs6dns/s6dns_message_get_strings.o src/libs6dns/s6dns_message_get_mx.o src/libs6dns/s6dns_message_get_soa.o src/libs6dns/s6dns_message_get_srv.o src/libs6dns/s6dns_message_get_caa.o src/libs6dns/s6dns_message_header_pack.o src/libs6dns/s6dns_message_header_unpack.o src/libs6dns/s6dns_message_header_zero.o src/libs6dns/s6dns_message_parse_answer_aaaa.o src/libs6dns/s6dns_message_parse_answer_a.o src/libs6dns/s6dns_message_parse_answer_domain.o src/libs6dns/s6dns_message_parse_answer_hinfo.o src/libs6dns/s6dns_message_parse_answer_mx.o src/libs6dns/s6dns_message_parse_answer_soa.o src/libs6dns/s6dns_message_parse_answer_srv.o src/libs6dns/s6dns_message_parse_answer_caa.o src/libs6dns/s6dns_message_parse_answer_strings.o src/libs6dns/s6dns_message_parse.o src/libs6dns/s6dns_message_parse_getrr.o src/libs6dns/s6dns_message_parse_init.o src/libs6dns/s6dns_message_parse_next.o src/libs6dns/s6dns_message_parse_question.o src/libs6dns/s6dns_message_parse_skipqd.o src/libs6dns/s6dns_rci_free.o src/libs6dns/s6dns_rci_here.o src/libs6dns/s6dns_rci_init.o src/libs6dns/s6dns_rci_zero.o src/libs6dns/s6dns_resolve_core.o src/libs6dns/s6dns_resolve_parse.o src/libs6dns/s6dns_resolven_loop.o src/libs6dns/s6dns_resolven_parse.o src/libs6dns/s6dns_resolve_dpag.o src/libs6dns/s6dns_resolve_mpag.o src/libs6dns/s6dns_resolve_name4.o src/libs6dns/s6dns_resolve_name6.o src/libs6dns/s6dns_resolvenoq.o src/libs6dns/s6dns_resolveq.o src/libs6dns/s6dns_resolvenoq_aaaaa.o src/libs6dns/s6dns_resolveq_aaaaa.o src/libs6dns/s6dns_analyze_packet.o src/libs6dns/s6dns_analyze_qtype_parse.o src/libs6dns/s6dns_analyze_record.o src/libs6dns/s6dns_analyze_record_a.o src/libs6dns/s6dns_analyze_record_aaaa.o src/libs6dns/s6dns_analyze_record_hinfo.o src/libs6dns/s6dns_analyze_record_mx.o src/libs6dns/s6dns_analyze_record_soa.o src/libs6dns/s6dns_analyze_record_srv.o src/libs6dns/s6dns_analyze_record_caa.o src/libs6dns/s6dns_analyze_record_domain.o src/libs6dns/s6dns_analyze_record_strings.o src/libs6dns/s6dns_analyze_record_unknown.o src/libs6dns/s6dns_analyze_rtypetable.o src/libs6dns/s6dns_debug_dumpdt_stdout.o src/libs6dns/s6dns_debug_dumpdt_stderr.o src/libs6dns/s6dns_debug_dumpdt_post_recv.o src/libs6dns/s6dns_debug_dumpdt_pre_send.o src/libs6dns/s6dns_debug_dumpdt_post_send.o src/libs6dns/s6dns_init.o src/libs6dns/s6dns_finish.o +libs6dns.a.xyzzy: src/libs6dns/s6dns_analyze_packet.o src/libs6dns/s6dns_analyze_qtype_parse.o src/libs6dns/s6dns_analyze_record.o src/libs6dns/s6dns_analyze_record_a.o src/libs6dns/s6dns_analyze_record_aaaa.o src/libs6dns/s6dns_analyze_record_caa.o src/libs6dns/s6dns_analyze_record_domain.o src/libs6dns/s6dns_analyze_record_hinfo.o src/libs6dns/s6dns_analyze_record_mx.o src/libs6dns/s6dns_analyze_record_soa.o src/libs6dns/s6dns_analyze_record_srv.o src/libs6dns/s6dns_analyze_record_strings.o src/libs6dns/s6dns_analyze_record_unknown.o src/libs6dns/s6dns_analyze_rtypetable.o src/libs6dns/s6dns_constants_error.o src/libs6dns/s6dns_constants_error_str.o src/libs6dns/s6dns_debug_dumpdt_post_recv.o src/libs6dns/s6dns_debug_dumpdt_post_send.o src/libs6dns/s6dns_debug_dumpdt_pre_send.o src/libs6dns/s6dns_debug_dumpdt_stderr.o src/libs6dns/s6dns_debug_dumpdt_stdout.o src/libs6dns/s6dns_debughook_zero.o src/libs6dns/s6dns_domain_arpafromip4.o src/libs6dns/s6dns_domain_arpafromip6.o src/libs6dns/s6dns_domain_decode.o src/libs6dns/s6dns_domain_encode.o src/libs6dns/s6dns_domain_encodelist.o src/libs6dns/s6dns_domain_fromstring.o src/libs6dns/s6dns_domain_fromstring_noqualify_encode.o src/libs6dns/s6dns_domain_fromstring_qualify_encode.o src/libs6dns/s6dns_domain_noqualify.o src/libs6dns/s6dns_domain_qualify.o src/libs6dns/s6dns_domain_tostring.o src/libs6dns/s6dns_engine.o src/libs6dns/s6dns_engine_free.o src/libs6dns/s6dns_engine_freen.o src/libs6dns/s6dns_engine_here.o src/libs6dns/s6dns_engine_nextdeadline.o src/libs6dns/s6dns_engine_zero.o src/libs6dns/s6dns_finish.o src/libs6dns/s6dns_fmt_caa.o src/libs6dns/s6dns_fmt_domainlist.o src/libs6dns/s6dns_fmt_hinfo.o src/libs6dns/s6dns_fmt_mx.o src/libs6dns/s6dns_fmt_soa.o src/libs6dns/s6dns_fmt_srv.o src/libs6dns/s6dns_hosts_aaaaa_q.o src/libs6dns/s6dns_hosts_aaaaa_string.o src/libs6dns/s6dns_hosts_compile.o src/libs6dns/s6dns_hosts_here.o src/libs6dns/s6dns_hosts_init.o src/libs6dns/s6dns_hosts_ip_q.o src/libs6dns/s6dns_hosts_ip_string.o src/libs6dns/s6dns_hosts_name.o src/libs6dns/s6dns_init.o src/libs6dns/s6dns_message_counts_next.o src/libs6dns/s6dns_message_counts_pack.o src/libs6dns/s6dns_message_counts_unpack.o src/libs6dns/s6dns_message_counts_zero.o src/libs6dns/s6dns_message_get_caa.o src/libs6dns/s6dns_message_get_domain.o src/libs6dns/s6dns_message_get_domain_nodecode.o src/libs6dns/s6dns_message_get_hinfo.o src/libs6dns/s6dns_message_get_mx.o src/libs6dns/s6dns_message_get_soa.o src/libs6dns/s6dns_message_get_srv.o src/libs6dns/s6dns_message_get_string.o src/libs6dns/s6dns_message_get_string_internal.o src/libs6dns/s6dns_message_get_strings.o src/libs6dns/s6dns_message_header_pack.o src/libs6dns/s6dns_message_header_unpack.o src/libs6dns/s6dns_message_header_zero.o src/libs6dns/s6dns_message_parse.o src/libs6dns/s6dns_message_parse_answer_a.o src/libs6dns/s6dns_message_parse_answer_aaaa.o src/libs6dns/s6dns_message_parse_answer_caa.o src/libs6dns/s6dns_message_parse_answer_domain.o src/libs6dns/s6dns_message_parse_answer_hinfo.o src/libs6dns/s6dns_message_parse_answer_mx.o src/libs6dns/s6dns_message_parse_answer_soa.o src/libs6dns/s6dns_message_parse_answer_srv.o src/libs6dns/s6dns_message_parse_answer_strings.o src/libs6dns/s6dns_message_parse_getrr.o src/libs6dns/s6dns_message_parse_init.o src/libs6dns/s6dns_message_parse_next.o src/libs6dns/s6dns_message_parse_question.o src/libs6dns/s6dns_message_parse_skipqd.o src/libs6dns/s6dns_rci_free.o src/libs6dns/s6dns_rci_here.o src/libs6dns/s6dns_rci_init.o src/libs6dns/s6dns_rci_zero.o src/libs6dns/s6dns_resolve_core.o src/libs6dns/s6dns_resolve_dpag.o src/libs6dns/s6dns_resolve_mpag.o src/libs6dns/s6dns_resolve_name4.o src/libs6dns/s6dns_resolve_name6.o src/libs6dns/s6dns_resolve_parse.o src/libs6dns/s6dns_resolven_loop.o src/libs6dns/s6dns_resolven_parse.o src/libs6dns/s6dns_resolvenoq.o src/libs6dns/s6dns_resolvenoq_aaaaa.o src/libs6dns/s6dns_resolveq.o src/libs6dns/s6dns_resolveq_aaaaa.o else -libs6dns.a.xyzzy: src/libs6dns/s6dns_constants_error.lo src/libs6dns/s6dns_constants_error_str.lo src/libs6dns/s6dns_debughook_zero.lo src/libs6dns/s6dns_domain_arpafromip4.lo src/libs6dns/s6dns_domain_arpafromip6.lo src/libs6dns/s6dns_domain_decode.lo src/libs6dns/s6dns_domain_encode.lo src/libs6dns/s6dns_domain_encodelist.lo src/libs6dns/s6dns_domain_fromstring.lo src/libs6dns/s6dns_domain_fromstring_noqualify_encode.lo src/libs6dns/s6dns_domain_fromstring_qualify_encode.lo src/libs6dns/s6dns_domain_noqualify.lo src/libs6dns/s6dns_domain_qualify.lo src/libs6dns/s6dns_domain_tostring.lo src/libs6dns/s6dns_engine.lo src/libs6dns/s6dns_engine_free.lo src/libs6dns/s6dns_engine_freen.lo src/libs6dns/s6dns_engine_here.lo src/libs6dns/s6dns_engine_nextdeadline.lo src/libs6dns/s6dns_engine_zero.lo src/libs6dns/s6dns_fmt_domainlist.lo src/libs6dns/s6dns_fmt_hinfo.lo src/libs6dns/s6dns_fmt_mx.lo src/libs6dns/s6dns_fmt_soa.lo src/libs6dns/s6dns_fmt_srv.lo src/libs6dns/s6dns_fmt_caa.lo src/libs6dns/s6dns_hosts_compile.lo src/libs6dns/s6dns_hosts_aaaaa_q.lo src/libs6dns/s6dns_hosts_aaaaa_string.lo src/libs6dns/s6dns_hosts_ip_q.lo src/libs6dns/s6dns_hosts_ip_string.lo src/libs6dns/s6dns_hosts_name.lo src/libs6dns/s6dns_hosts_here.lo src/libs6dns/s6dns_message_counts_next.lo src/libs6dns/s6dns_message_counts_pack.lo src/libs6dns/s6dns_message_counts_unpack.lo src/libs6dns/s6dns_message_counts_zero.lo src/libs6dns/s6dns_message_get_domain.lo src/libs6dns/s6dns_message_get_domain_nodecode.lo src/libs6dns/s6dns_message_get_hinfo.lo src/libs6dns/s6dns_message_get_string.lo src/libs6dns/s6dns_message_get_string_internal.lo src/libs6dns/s6dns_message_get_strings.lo src/libs6dns/s6dns_message_get_mx.lo src/libs6dns/s6dns_message_get_soa.lo src/libs6dns/s6dns_message_get_srv.lo src/libs6dns/s6dns_message_get_caa.lo src/libs6dns/s6dns_message_header_pack.lo src/libs6dns/s6dns_message_header_unpack.lo src/libs6dns/s6dns_message_header_zero.lo src/libs6dns/s6dns_message_parse_answer_aaaa.lo src/libs6dns/s6dns_message_parse_answer_a.lo src/libs6dns/s6dns_message_parse_answer_domain.lo src/libs6dns/s6dns_message_parse_answer_hinfo.lo src/libs6dns/s6dns_message_parse_answer_mx.lo src/libs6dns/s6dns_message_parse_answer_soa.lo src/libs6dns/s6dns_message_parse_answer_srv.lo src/libs6dns/s6dns_message_parse_answer_caa.lo src/libs6dns/s6dns_message_parse_answer_strings.lo src/libs6dns/s6dns_message_parse.lo src/libs6dns/s6dns_message_parse_getrr.lo src/libs6dns/s6dns_message_parse_init.lo src/libs6dns/s6dns_message_parse_next.lo src/libs6dns/s6dns_message_parse_question.lo src/libs6dns/s6dns_message_parse_skipqd.lo src/libs6dns/s6dns_rci_free.lo src/libs6dns/s6dns_rci_here.lo src/libs6dns/s6dns_rci_init.lo src/libs6dns/s6dns_rci_zero.lo src/libs6dns/s6dns_resolve_core.lo src/libs6dns/s6dns_resolve_parse.lo src/libs6dns/s6dns_resolven_loop.lo src/libs6dns/s6dns_resolven_parse.lo src/libs6dns/s6dns_resolve_dpag.lo src/libs6dns/s6dns_resolve_mpag.lo src/libs6dns/s6dns_resolve_name4.lo src/libs6dns/s6dns_resolve_name6.lo src/libs6dns/s6dns_resolvenoq.lo src/libs6dns/s6dns_resolveq.lo src/libs6dns/s6dns_resolvenoq_aaaaa.lo src/libs6dns/s6dns_resolveq_aaaaa.lo src/libs6dns/s6dns_analyze_packet.lo src/libs6dns/s6dns_analyze_qtype_parse.lo src/libs6dns/s6dns_analyze_record.lo src/libs6dns/s6dns_analyze_record_a.lo src/libs6dns/s6dns_analyze_record_aaaa.lo src/libs6dns/s6dns_analyze_record_hinfo.lo src/libs6dns/s6dns_analyze_record_mx.lo src/libs6dns/s6dns_analyze_record_soa.lo src/libs6dns/s6dns_analyze_record_srv.lo src/libs6dns/s6dns_analyze_record_caa.lo src/libs6dns/s6dns_analyze_record_domain.lo src/libs6dns/s6dns_analyze_record_strings.lo src/libs6dns/s6dns_analyze_record_unknown.lo src/libs6dns/s6dns_analyze_rtypetable.lo src/libs6dns/s6dns_debug_dumpdt_stdout.lo src/libs6dns/s6dns_debug_dumpdt_stderr.lo src/libs6dns/s6dns_debug_dumpdt_post_recv.lo src/libs6dns/s6dns_debug_dumpdt_pre_send.lo src/libs6dns/s6dns_debug_dumpdt_post_send.lo src/libs6dns/s6dns_init.lo src/libs6dns/s6dns_finish.lo +libs6dns.a.xyzzy: src/libs6dns/s6dns_analyze_packet.lo src/libs6dns/s6dns_analyze_qtype_parse.lo src/libs6dns/s6dns_analyze_record.lo src/libs6dns/s6dns_analyze_record_a.lo src/libs6dns/s6dns_analyze_record_aaaa.lo src/libs6dns/s6dns_analyze_record_caa.lo src/libs6dns/s6dns_analyze_record_domain.lo src/libs6dns/s6dns_analyze_record_hinfo.lo src/libs6dns/s6dns_analyze_record_mx.lo src/libs6dns/s6dns_analyze_record_soa.lo src/libs6dns/s6dns_analyze_record_srv.lo src/libs6dns/s6dns_analyze_record_strings.lo src/libs6dns/s6dns_analyze_record_unknown.lo src/libs6dns/s6dns_analyze_rtypetable.lo src/libs6dns/s6dns_constants_error.lo src/libs6dns/s6dns_constants_error_str.lo src/libs6dns/s6dns_debug_dumpdt_post_recv.lo src/libs6dns/s6dns_debug_dumpdt_post_send.lo src/libs6dns/s6dns_debug_dumpdt_pre_send.lo src/libs6dns/s6dns_debug_dumpdt_stderr.lo src/libs6dns/s6dns_debug_dumpdt_stdout.lo src/libs6dns/s6dns_debughook_zero.lo src/libs6dns/s6dns_domain_arpafromip4.lo src/libs6dns/s6dns_domain_arpafromip6.lo src/libs6dns/s6dns_domain_decode.lo src/libs6dns/s6dns_domain_encode.lo src/libs6dns/s6dns_domain_encodelist.lo src/libs6dns/s6dns_domain_fromstring.lo src/libs6dns/s6dns_domain_fromstring_noqualify_encode.lo src/libs6dns/s6dns_domain_fromstring_qualify_encode.lo src/libs6dns/s6dns_domain_noqualify.lo src/libs6dns/s6dns_domain_qualify.lo src/libs6dns/s6dns_domain_tostring.lo src/libs6dns/s6dns_engine.lo src/libs6dns/s6dns_engine_free.lo src/libs6dns/s6dns_engine_freen.lo src/libs6dns/s6dns_engine_here.lo src/libs6dns/s6dns_engine_nextdeadline.lo src/libs6dns/s6dns_engine_zero.lo src/libs6dns/s6dns_finish.lo src/libs6dns/s6dns_fmt_caa.lo src/libs6dns/s6dns_fmt_domainlist.lo src/libs6dns/s6dns_fmt_hinfo.lo src/libs6dns/s6dns_fmt_mx.lo src/libs6dns/s6dns_fmt_soa.lo src/libs6dns/s6dns_fmt_srv.lo src/libs6dns/s6dns_hosts_aaaaa_q.lo src/libs6dns/s6dns_hosts_aaaaa_string.lo src/libs6dns/s6dns_hosts_compile.lo src/libs6dns/s6dns_hosts_here.lo src/libs6dns/s6dns_hosts_init.lo src/libs6dns/s6dns_hosts_ip_q.lo src/libs6dns/s6dns_hosts_ip_string.lo src/libs6dns/s6dns_hosts_name.lo src/libs6dns/s6dns_init.lo src/libs6dns/s6dns_message_counts_next.lo src/libs6dns/s6dns_message_counts_pack.lo src/libs6dns/s6dns_message_counts_unpack.lo src/libs6dns/s6dns_message_counts_zero.lo src/libs6dns/s6dns_message_get_caa.lo src/libs6dns/s6dns_message_get_domain.lo src/libs6dns/s6dns_message_get_domain_nodecode.lo src/libs6dns/s6dns_message_get_hinfo.lo src/libs6dns/s6dns_message_get_mx.lo src/libs6dns/s6dns_message_get_soa.lo src/libs6dns/s6dns_message_get_srv.lo src/libs6dns/s6dns_message_get_string.lo src/libs6dns/s6dns_message_get_string_internal.lo src/libs6dns/s6dns_message_get_strings.lo src/libs6dns/s6dns_message_header_pack.lo src/libs6dns/s6dns_message_header_unpack.lo src/libs6dns/s6dns_message_header_zero.lo src/libs6dns/s6dns_message_parse.lo src/libs6dns/s6dns_message_parse_answer_a.lo src/libs6dns/s6dns_message_parse_answer_aaaa.lo src/libs6dns/s6dns_message_parse_answer_caa.lo src/libs6dns/s6dns_message_parse_answer_domain.lo src/libs6dns/s6dns_message_parse_answer_hinfo.lo src/libs6dns/s6dns_message_parse_answer_mx.lo src/libs6dns/s6dns_message_parse_answer_soa.lo src/libs6dns/s6dns_message_parse_answer_srv.lo src/libs6dns/s6dns_message_parse_answer_strings.lo src/libs6dns/s6dns_message_parse_getrr.lo src/libs6dns/s6dns_message_parse_init.lo src/libs6dns/s6dns_message_parse_next.lo src/libs6dns/s6dns_message_parse_question.lo src/libs6dns/s6dns_message_parse_skipqd.lo src/libs6dns/s6dns_rci_free.lo src/libs6dns/s6dns_rci_here.lo src/libs6dns/s6dns_rci_init.lo src/libs6dns/s6dns_rci_zero.lo src/libs6dns/s6dns_resolve_core.lo src/libs6dns/s6dns_resolve_dpag.lo src/libs6dns/s6dns_resolve_mpag.lo src/libs6dns/s6dns_resolve_name4.lo src/libs6dns/s6dns_resolve_name6.lo src/libs6dns/s6dns_resolve_parse.lo src/libs6dns/s6dns_resolven_loop.lo src/libs6dns/s6dns_resolven_parse.lo src/libs6dns/s6dns_resolvenoq.lo src/libs6dns/s6dns_resolvenoq_aaaaa.lo src/libs6dns/s6dns_resolveq.lo src/libs6dns/s6dns_resolveq_aaaaa.lo endif libs6dns.so.xyzzy: EXTRA_LIBS := -lskarnet -libs6dns.so.xyzzy: src/libs6dns/s6dns_constants_error.lo src/libs6dns/s6dns_constants_error_str.lo src/libs6dns/s6dns_debughook_zero.lo src/libs6dns/s6dns_domain_arpafromip4.lo src/libs6dns/s6dns_domain_arpafromip6.lo src/libs6dns/s6dns_domain_decode.lo src/libs6dns/s6dns_domain_encode.lo src/libs6dns/s6dns_domain_encodelist.lo src/libs6dns/s6dns_domain_fromstring.lo src/libs6dns/s6dns_domain_fromstring_noqualify_encode.lo src/libs6dns/s6dns_domain_fromstring_qualify_encode.lo src/libs6dns/s6dns_domain_noqualify.lo src/libs6dns/s6dns_domain_qualify.lo src/libs6dns/s6dns_domain_tostring.lo src/libs6dns/s6dns_engine.lo src/libs6dns/s6dns_engine_free.lo src/libs6dns/s6dns_engine_freen.lo src/libs6dns/s6dns_engine_here.lo src/libs6dns/s6dns_engine_nextdeadline.lo src/libs6dns/s6dns_engine_zero.lo src/libs6dns/s6dns_fmt_domainlist.lo src/libs6dns/s6dns_fmt_hinfo.lo src/libs6dns/s6dns_fmt_mx.lo src/libs6dns/s6dns_fmt_soa.lo src/libs6dns/s6dns_fmt_srv.lo src/libs6dns/s6dns_fmt_caa.lo src/libs6dns/s6dns_hosts_compile.lo src/libs6dns/s6dns_hosts_aaaaa_q.lo src/libs6dns/s6dns_hosts_aaaaa_string.lo src/libs6dns/s6dns_hosts_ip_q.lo src/libs6dns/s6dns_hosts_ip_string.lo src/libs6dns/s6dns_hosts_name.lo src/libs6dns/s6dns_hosts_here.lo src/libs6dns/s6dns_message_counts_next.lo src/libs6dns/s6dns_message_counts_pack.lo src/libs6dns/s6dns_message_counts_unpack.lo src/libs6dns/s6dns_message_counts_zero.lo src/libs6dns/s6dns_message_get_domain.lo src/libs6dns/s6dns_message_get_domain_nodecode.lo src/libs6dns/s6dns_message_get_hinfo.lo src/libs6dns/s6dns_message_get_string.lo src/libs6dns/s6dns_message_get_string_internal.lo src/libs6dns/s6dns_message_get_strings.lo src/libs6dns/s6dns_message_get_mx.lo src/libs6dns/s6dns_message_get_soa.lo src/libs6dns/s6dns_message_get_srv.lo src/libs6dns/s6dns_message_get_caa.lo src/libs6dns/s6dns_message_header_pack.lo src/libs6dns/s6dns_message_header_unpack.lo src/libs6dns/s6dns_message_header_zero.lo src/libs6dns/s6dns_message_parse_answer_aaaa.lo src/libs6dns/s6dns_message_parse_answer_a.lo src/libs6dns/s6dns_message_parse_answer_domain.lo src/libs6dns/s6dns_message_parse_answer_hinfo.lo src/libs6dns/s6dns_message_parse_answer_mx.lo src/libs6dns/s6dns_message_parse_answer_soa.lo src/libs6dns/s6dns_message_parse_answer_srv.lo src/libs6dns/s6dns_message_parse_answer_caa.lo src/libs6dns/s6dns_message_parse_answer_strings.lo src/libs6dns/s6dns_message_parse.lo src/libs6dns/s6dns_message_parse_getrr.lo src/libs6dns/s6dns_message_parse_init.lo src/libs6dns/s6dns_message_parse_next.lo src/libs6dns/s6dns_message_parse_question.lo src/libs6dns/s6dns_message_parse_skipqd.lo src/libs6dns/s6dns_rci_free.lo src/libs6dns/s6dns_rci_here.lo src/libs6dns/s6dns_rci_init.lo src/libs6dns/s6dns_rci_zero.lo src/libs6dns/s6dns_resolve_core.lo src/libs6dns/s6dns_resolve_parse.lo src/libs6dns/s6dns_resolven_loop.lo src/libs6dns/s6dns_resolven_parse.lo src/libs6dns/s6dns_resolve_dpag.lo src/libs6dns/s6dns_resolve_mpag.lo src/libs6dns/s6dns_resolve_name4.lo src/libs6dns/s6dns_resolve_name6.lo src/libs6dns/s6dns_resolvenoq.lo src/libs6dns/s6dns_resolveq.lo src/libs6dns/s6dns_resolvenoq_aaaaa.lo src/libs6dns/s6dns_resolveq_aaaaa.lo src/libs6dns/s6dns_analyze_packet.lo src/libs6dns/s6dns_analyze_qtype_parse.lo src/libs6dns/s6dns_analyze_record.lo src/libs6dns/s6dns_analyze_record_a.lo src/libs6dns/s6dns_analyze_record_aaaa.lo src/libs6dns/s6dns_analyze_record_hinfo.lo src/libs6dns/s6dns_analyze_record_mx.lo src/libs6dns/s6dns_analyze_record_soa.lo src/libs6dns/s6dns_analyze_record_srv.lo src/libs6dns/s6dns_analyze_record_caa.lo src/libs6dns/s6dns_analyze_record_domain.lo src/libs6dns/s6dns_analyze_record_strings.lo src/libs6dns/s6dns_analyze_record_unknown.lo src/libs6dns/s6dns_analyze_rtypetable.lo src/libs6dns/s6dns_debug_dumpdt_stdout.lo src/libs6dns/s6dns_debug_dumpdt_stderr.lo src/libs6dns/s6dns_debug_dumpdt_post_recv.lo src/libs6dns/s6dns_debug_dumpdt_pre_send.lo src/libs6dns/s6dns_debug_dumpdt_post_send.lo src/libs6dns/s6dns_init.lo src/libs6dns/s6dns_finish.lo +libs6dns.so.xyzzy: src/libs6dns/s6dns_analyze_packet.lo src/libs6dns/s6dns_analyze_qtype_parse.lo src/libs6dns/s6dns_analyze_record.lo src/libs6dns/s6dns_analyze_record_a.lo src/libs6dns/s6dns_analyze_record_aaaa.lo src/libs6dns/s6dns_analyze_record_caa.lo src/libs6dns/s6dns_analyze_record_domain.lo src/libs6dns/s6dns_analyze_record_hinfo.lo src/libs6dns/s6dns_analyze_record_mx.lo src/libs6dns/s6dns_analyze_record_soa.lo src/libs6dns/s6dns_analyze_record_srv.lo src/libs6dns/s6dns_analyze_record_strings.lo src/libs6dns/s6dns_analyze_record_unknown.lo src/libs6dns/s6dns_analyze_rtypetable.lo src/libs6dns/s6dns_constants_error.lo src/libs6dns/s6dns_constants_error_str.lo src/libs6dns/s6dns_debug_dumpdt_post_recv.lo src/libs6dns/s6dns_debug_dumpdt_post_send.lo src/libs6dns/s6dns_debug_dumpdt_pre_send.lo src/libs6dns/s6dns_debug_dumpdt_stderr.lo src/libs6dns/s6dns_debug_dumpdt_stdout.lo src/libs6dns/s6dns_debughook_zero.lo src/libs6dns/s6dns_domain_arpafromip4.lo src/libs6dns/s6dns_domain_arpafromip6.lo src/libs6dns/s6dns_domain_decode.lo src/libs6dns/s6dns_domain_encode.lo src/libs6dns/s6dns_domain_encodelist.lo src/libs6dns/s6dns_domain_fromstring.lo src/libs6dns/s6dns_domain_fromstring_noqualify_encode.lo src/libs6dns/s6dns_domain_fromstring_qualify_encode.lo src/libs6dns/s6dns_domain_noqualify.lo src/libs6dns/s6dns_domain_qualify.lo src/libs6dns/s6dns_domain_tostring.lo src/libs6dns/s6dns_engine.lo src/libs6dns/s6dns_engine_free.lo src/libs6dns/s6dns_engine_freen.lo src/libs6dns/s6dns_engine_here.lo src/libs6dns/s6dns_engine_nextdeadline.lo src/libs6dns/s6dns_engine_zero.lo src/libs6dns/s6dns_finish.lo src/libs6dns/s6dns_fmt_caa.lo src/libs6dns/s6dns_fmt_domainlist.lo src/libs6dns/s6dns_fmt_hinfo.lo src/libs6dns/s6dns_fmt_mx.lo src/libs6dns/s6dns_fmt_soa.lo src/libs6dns/s6dns_fmt_srv.lo src/libs6dns/s6dns_hosts_aaaaa_q.lo src/libs6dns/s6dns_hosts_aaaaa_string.lo src/libs6dns/s6dns_hosts_compile.lo src/libs6dns/s6dns_hosts_here.lo src/libs6dns/s6dns_hosts_init.lo src/libs6dns/s6dns_hosts_ip_q.lo src/libs6dns/s6dns_hosts_ip_string.lo src/libs6dns/s6dns_hosts_name.lo src/libs6dns/s6dns_init.lo src/libs6dns/s6dns_message_counts_next.lo src/libs6dns/s6dns_message_counts_pack.lo src/libs6dns/s6dns_message_counts_unpack.lo src/libs6dns/s6dns_message_counts_zero.lo src/libs6dns/s6dns_message_get_caa.lo src/libs6dns/s6dns_message_get_domain.lo src/libs6dns/s6dns_message_get_domain_nodecode.lo src/libs6dns/s6dns_message_get_hinfo.lo src/libs6dns/s6dns_message_get_mx.lo src/libs6dns/s6dns_message_get_soa.lo src/libs6dns/s6dns_message_get_srv.lo src/libs6dns/s6dns_message_get_string.lo src/libs6dns/s6dns_message_get_string_internal.lo src/libs6dns/s6dns_message_get_strings.lo src/libs6dns/s6dns_message_header_pack.lo src/libs6dns/s6dns_message_header_unpack.lo src/libs6dns/s6dns_message_header_zero.lo src/libs6dns/s6dns_message_parse.lo src/libs6dns/s6dns_message_parse_answer_a.lo src/libs6dns/s6dns_message_parse_answer_aaaa.lo src/libs6dns/s6dns_message_parse_answer_caa.lo src/libs6dns/s6dns_message_parse_answer_domain.lo src/libs6dns/s6dns_message_parse_answer_hinfo.lo src/libs6dns/s6dns_message_parse_answer_mx.lo src/libs6dns/s6dns_message_parse_answer_soa.lo src/libs6dns/s6dns_message_parse_answer_srv.lo src/libs6dns/s6dns_message_parse_answer_strings.lo src/libs6dns/s6dns_message_parse_getrr.lo src/libs6dns/s6dns_message_parse_init.lo src/libs6dns/s6dns_message_parse_next.lo src/libs6dns/s6dns_message_parse_question.lo src/libs6dns/s6dns_message_parse_skipqd.lo src/libs6dns/s6dns_rci_free.lo src/libs6dns/s6dns_rci_here.lo src/libs6dns/s6dns_rci_init.lo src/libs6dns/s6dns_rci_zero.lo src/libs6dns/s6dns_resolve_core.lo src/libs6dns/s6dns_resolve_dpag.lo src/libs6dns/s6dns_resolve_mpag.lo src/libs6dns/s6dns_resolve_name4.lo src/libs6dns/s6dns_resolve_name6.lo src/libs6dns/s6dns_resolve_parse.lo src/libs6dns/s6dns_resolven_loop.lo src/libs6dns/s6dns_resolven_parse.lo src/libs6dns/s6dns_resolvenoq.lo src/libs6dns/s6dns_resolvenoq_aaaaa.lo src/libs6dns/s6dns_resolveq.lo src/libs6dns/s6dns_resolveq_aaaaa.lo ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) libskadns.a.xyzzy: src/skadns/skadns_cancel.o src/skadns/skadns_end.o src/skadns/skadns_packet.o src/skadns/skadns_packetlen.o src/skadns/skadns_release.o src/skadns/skadns_send.o src/skadns/skadns_start.o src/skadns/skadns_startf.o src/skadns/skadns_update.o src/skadns/skadns_zero.o else diff --git a/src/clients/s6-dnsip.c b/src/clients/s6-dnsip.c index 9828443..6a5747d 100644 --- a/src/clients/s6-dnsip.c +++ b/src/clients/s6-dnsip.c @@ -11,49 +11,73 @@ #include <skalibs/buffer.h> #include <skalibs/tai.h> #include <skalibs/random.h> -#include <s6-dns/s6dns.h> -#define USAGE "s6-dnsip [ -q ] [ -r ] [ -t timeout ] domain" +#include <s6-dns/s6dns-rci.h> +#include <s6-dns/hosts.h> +#include <s6-dns/s6dns-resolve.h> + +#define USAGE "s6-dnsip [ -q ] [ -H | -h ] [ -r ] [ -t timeout ] domain" #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv) { genalloc ips = GENALLOC_ZERO ; /* ip46full */ tain deadline ; - size_t i = 0 ; unsigned int t = 0 ; int flagqualify = 0 ; + int flaghosts = 0 ; int flagunsort = 0 ; + int r = 0 ; PROG = "s6-dnsip" ; - for (;;) { - int opt = lgetopt(argc, argv, "qrt:") ; - if (opt == -1) break ; - switch (opt) + subgetopt l = SUBGETOPT_ZERO ; + for (;;) { - case 'q' : flagqualify = 1 ; break ; - case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; - default : dieusage() ; + int opt = subgetopt_r(argc, argv, "qHhrt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'q' : flagqualify = 1 ; break ; + case 'H' : flaghosts = 0 ; break ; + case 'h' : flaghosts = 1 ; break ; + case 'r' : flagunsort = 1 ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } } + argc -= l.ind ; argv += l.ind ; } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (argc < 1) dieusage() ; tain_now_set_stopwatch_g() ; if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; + + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) + strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; + if (flaghosts) + { + flaghosts = s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") ; + if (flaghosts == -1) strerr_diefu1sys(111, "initialize hosts database from /etc/hosts or /etc/hosts.cdb") ; + } + + if (flaghosts) { - int r = s6dns_resolve_aaaaa_g(&ips, argv[0], strlen(argv[0]), flagqualify, &deadline) ; + r = flagqualify ? s6dns_hosts_aaaaa_q(argv[0], &ips) : s6dns_hosts_aaaaa_noq(argv[0], &ips) ; + if (r == -1) strerr_diefu3sys(111, "look up ", argv[0], " in hosts database") ; + } + + if (!r) + { + r = s6dns_resolve_aaaaa_g(&ips, argv[0], strlen(argv[0]), flagqualify, &deadline) ; if (r < 0) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; - if (!r && errno) strerr_diefu4x(2, "resolve ", argv[0], ": ", s6dns_constants_error_str(errno)) ; + if (!r) strerr_diefu4x(2, "resolve ", argv[0], ": ", s6dns_constants_error_str(errno)) ; } - if (!genalloc_len(ip46full, &ips)) return 1 ; + if (!genalloc_len(ip46full, &ips)) return 1 ; if (flagunsort) random_unsort(ips.s, genalloc_len(ip46full, &ips), sizeof(ip46full)) ; - for (i = 0 ; i < genalloc_len(ip46full, &ips) ; i++) + for (size_t i = 0 ; i < genalloc_len(ip46full, &ips) ; i++) { char fmt[IP6_FMT] ; size_t n = ip46full_fmt(fmt, genalloc_s(ip46full, &ips) + i) ; diff --git a/src/clients/s6-dnsip4-filter.c b/src/clients/s6-dnsip4-filter.c index 4842734..dbfc82b 100644 --- a/src/clients/s6-dnsip4-filter.c +++ b/src/clients/s6-dnsip4-filter.c @@ -1,9 +1,11 @@ /* ISC license. */ #include <string.h> + #include <skalibs/fmtscan.h> #include <skalibs/strerr.h> #include <skalibs/stralloc.h> + #include <s6-dns/s6dns-constants.h> #include <s6-dns/s6dns-message.h> #include "s6dns-generic-filter.h" diff --git a/src/clients/s6-dnsip4.c b/src/clients/s6-dnsip4.c index db32804..370c006 100644 --- a/src/clients/s6-dnsip4.c +++ b/src/clients/s6-dnsip4.c @@ -2,6 +2,7 @@ #include <string.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> @@ -9,53 +10,78 @@ #include <skalibs/buffer.h> #include <skalibs/tai.h> #include <skalibs/random.h> -#include <s6-dns/s6dns.h> -#define USAGE "s6-dnsip4 [ -q ] [ -r ] [ -t timeout ] domain" +#include <s6-dns/s6dns-rci.h> +#include <s6-dns/hosts.h> +#include <s6-dns/s6dns-resolve.h> + +#define USAGE "s6-dnsip4 [ -q ] [ -H | -h ] [ -r ] [ -t timeout ] domain" #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv) { stralloc ips = STRALLOC_ZERO ; tain deadline ; - size_t i = 0 ; unsigned int t = 0 ; int flagqualify = 0 ; + int flaghosts = 0 ; int flagunsort = 0 ; + int r = 0 ; PROG = "s6-dnsip4" ; - for (;;) { - int opt = lgetopt(argc, argv, "qrt:") ; - if (opt == -1) break ; - switch (opt) + subgetopt l = SUBGETOPT_ZERO ; + for (;;) { - case 'q' : flagqualify = 1 ; break ; - case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; - default : dieusage() ; + int opt = subgetopt_r(argc, argv, "qHhrt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'q' : flagqualify = 1 ; break ; + case 'H' : flaghosts = 0 ; break ; + case 'h' : flaghosts = 1 ; break ; + case 'r' : flagunsort = 1 ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } } + argc -= l.ind ; argv += l.ind ; } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (argc < 1) dieusage() ; tain_now_set_stopwatch_g() ; if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; + + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) + strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; + if (flaghosts) + { + flaghosts = s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") ; + if (flaghosts == -1) strerr_diefu1sys(111, "initialize hosts database from /etc/hosts or /etc/hosts.cdb") ; + } + + if (flaghosts) { - int r = s6dns_resolve_a_g(&ips, argv[0], strlen(argv[0]), flagqualify, &deadline) ; - if (r < 0) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; + r = flagqualify ? s6dns_hosts_a_q(argv[0], &ips) : s6dns_hosts_a_noq(argv[0], &ips) ; + if (r == -1) strerr_diefu3sys(111, "look up ", argv[0], " in hosts database") ; + } + + if (!r) + { + r = s6dns_resolve_a_g(&ips, argv[0], strlen(argv[0]), flagqualify, &deadline) ; + if (r == -1) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; if (!r) strerr_diefu4x(2, "resolve ", argv[0], ": ", s6dns_constants_error_str(errno)) ; } + if (!ips.len) return 1 ; if (flagunsort) random_unsort(ips.s, ips.len / 4, 4) ; - for (i = 0 ; i < ips.len / 4 ; i++) + for (size_t i = 0 ; i < ips.len / 4 ; i++) { char fmt[IP4_FMT] ; size_t n = ip4_fmt(fmt, ips.s + 4 * i) ; fmt[n++] = '\n' ; - if (buffer_put(buffer_1small, fmt, n) < (ssize_t)n) + if (buffer_put(buffer_1small, fmt, n) == -1) strerr_diefu1sys(111, "write to stdout") ; } if (!buffer_flush(buffer_1small)) diff --git a/src/clients/s6-dnsip6-filter.c b/src/clients/s6-dnsip6-filter.c index d2855bc..a7840f7 100644 --- a/src/clients/s6-dnsip6-filter.c +++ b/src/clients/s6-dnsip6-filter.c @@ -1,9 +1,11 @@ /* ISC license. */ #include <string.h> + #include <skalibs/fmtscan.h> #include <skalibs/strerr.h> #include <skalibs/stralloc.h> + #include <s6-dns/s6dns-constants.h> #include <s6-dns/s6dns-message.h> #include "s6dns-generic-filter.h" diff --git a/src/clients/s6-dnsip6.c b/src/clients/s6-dnsip6.c index eb37a53..2fb2f6f 100644 --- a/src/clients/s6-dnsip6.c +++ b/src/clients/s6-dnsip6.c @@ -2,6 +2,7 @@ #include <string.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> @@ -9,48 +10,73 @@ #include <skalibs/buffer.h> #include <skalibs/tai.h> #include <skalibs/random.h> -#include <s6-dns/s6dns.h> -#define USAGE "s6-dnsip6 [ -q ] [ -r ] [ -t timeout ] domain" +#include <s6-dns/s6dns-rci.h> +#include <s6-dns/hosts.h> +#include <s6-dns/s6dns-resolve.h> + +#define USAGE "s6-dnsip6 [ -q ] [ -H | -h ] [ -r ] [ -t timeout ] domain" #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv) { stralloc ips = STRALLOC_ZERO ; tain deadline ; - size_t i = 0 ; unsigned int t = 0 ; int flagqualify = 0 ; + int flaghosts = 0 ; int flagunsort = 0 ; + int r = 0 ; PROG = "s6-dnsip6" ; - for (;;) { - int opt = lgetopt(argc, argv, "qrt:") ; - if (opt == -1) break ; - switch (opt) + subgetopt l = SUBGETOPT_ZERO ; + for (;;) { - case 'q' : flagqualify = 1 ; break ; - case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; - default : dieusage() ; + int opt = subgetopt_r(argc, argv, "qHhrt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'q' : flagqualify = 1 ; break ; + case 'H' : flaghosts = 0 ; break ; + case 'h' : flaghosts = 1 ; break ; + case 'r' : flagunsort = 1 ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } } + argc -= l.ind ; argv += l.ind ; } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (argc < 1) dieusage() ; tain_now_set_stopwatch_g() ; if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; + + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) + strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; + if (flaghosts) + { + flaghosts = s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") ; + if (flaghosts == -1) strerr_diefu1sys(111, "initialize hosts database from /etc/hosts or /etc/hosts.cdb") ; + } + + if (flaghosts) { - int r = s6dns_resolve_aaaa_g(&ips, argv[0], strlen(argv[0]), flagqualify, &deadline) ; - if (r < 0) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; + r = flagqualify ? s6dns_hosts_aaaa_q(argv[0], &ips) : s6dns_hosts_aaaa_noq(argv[0], &ips) ; + if (r == -1) strerr_diefu3sys(111, "look up ", argv[0], " in hosts database") ; + } + + if (!r) + { + r = s6dns_resolve_aaaa_g(&ips, argv[0], strlen(argv[0]), flagqualify, &deadline) ; + if (r == -1) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; if (!r) strerr_diefu4x(2, "resolve ", argv[0], ": ", s6dns_constants_error_str(errno)) ; } + if (!ips.len) return 1 ; if (flagunsort) random_unsort(ips.s, ips.len / 16, 16) ; - for (i = 0 ; i < ips.len / 16 ; i++) + for (size_t i = 0 ; i < ips.len / 16 ; i++) { char fmt[IP6_FMT] ; size_t n = ip6_fmt(fmt, ips.s + 16 * i) ; diff --git a/src/clients/s6-dnsmx.c b/src/clients/s6-dnsmx.c index 159a5c6..356eb4b 100644 --- a/src/clients/s6-dnsmx.c +++ b/src/clients/s6-dnsmx.c @@ -2,6 +2,7 @@ #include <string.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> @@ -9,6 +10,7 @@ #include <skalibs/tai.h> #include <skalibs/genalloc.h> #include <skalibs/random.h> + #include <s6-dns/s6dns.h> #define USAGE "s6-dnsmx [ -q ] [ -r ] [ -t timeout ] name" @@ -18,38 +20,43 @@ int main (int argc, char const *const *argv) { genalloc mxs = GENALLOC_ZERO ; /* array of s6dns_message_rr_mx_t */ tain deadline ; - size_t i = 0 ; unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; + int r ; PROG = "s6-dnsmx" ; - for (;;) + { - int opt = lgetopt(argc, argv, "qrt:") ; - if (opt == -1) break ; - switch (opt) + subgetopt l = SUBGETOPT_ZERO ; + for (;;) { - case 'q' : flagqualify = 1 ; break ; - case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; - default : dieusage() ; + int opt = subgetopt_r(argc, argv, "qrt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'q' : flagqualify = 1 ; break ; + case 'r' : flagunsort = 1 ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } } + argc -= l.ind ; argv += l.ind ; } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (argc < 1) dieusage() ; tain_now_set_stopwatch_g() ; if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; - { - int r = s6dns_resolve_mx_g(&mxs, argv[0], strlen(argv[0]), flagqualify, &deadline) ; - if (r < 0) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; - if (!r) strerr_diefu4x(2, "resolve ", argv[0], ": ", s6dns_constants_error_str(errno)) ; - } + + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) + strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; + + r = s6dns_resolve_mx_g(&mxs, argv[0], strlen(argv[0]), flagqualify, &deadline) ; + if (r < 0) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; + if (!r) strerr_diefu4x(2, "resolve ", argv[0], ": ", s6dns_constants_error_str(errno)) ; if (!genalloc_len(s6dns_message_rr_mx_t, &mxs)) return 1 ; if (flagunsort) random_unsort(mxs.s, genalloc_len(s6dns_message_rr_mx_t, &mxs), sizeof(s6dns_message_rr_mx_t)) ; - for (i = 0 ; i < genalloc_len(s6dns_message_rr_mx_t, &mxs) ; i++) + for (size_t i = 0 ; i < genalloc_len(s6dns_message_rr_mx_t, &mxs) ; i++) { char buf[S6DNS_FMT_MX] ; size_t len = s6dns_fmt_mx(buf, S6DNS_FMT_MX, genalloc_s(s6dns_message_rr_mx_t, &mxs) + i) ; diff --git a/src/clients/s6-dnsname.c b/src/clients/s6-dnsname.c index c35751b..7c35f06 100644 --- a/src/clients/s6-dnsname.c +++ b/src/clients/s6-dnsname.c @@ -2,6 +2,7 @@ #include <sys/types.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> @@ -11,9 +12,10 @@ #include <skalibs/genalloc.h> #include <skalibs/ip46.h> #include <skalibs/random.h> + #include <s6-dns/s6dns.h> -#define USAGE "s6-dnsname [ -4 | -6 ] [ -r ] [ -t timeout ] ip" +#define USAGE "s6-dnsname [ -4 | -6 ] [ -H | -h ] [ -r ] [ -t timeout ] ip" #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv) @@ -22,25 +24,33 @@ int main (int argc, char const *const *argv) tain deadline ; ip46full ip = IP46FULL_ZERO ; unsigned int t = 0 ; + int flaghosts = 0 ; int flagunsort = 0 ; int do4 = 0 ; int do6 = 0 ; PROG = "s6-dnsname" ; - for (;;) + { - int opt = lgetopt(argc, argv, "46rt:") ; - if (opt == -1) break ; - switch (opt) + subgetopt l = SUBGETOPT_ZERO ; + for (;;) { - case '4' : do4 = 1 ; break ; - case '6' : do6 = 1 ; break ; - case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; - default : dieusage() ; + int opt = subgetopt_r(argc, argv, "46Hhrt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case '4' : do4 = 1 ; break ; + case '6' : do6 = 1 ; break ; + case 'H' : flaghosts = 0 ; break ; + case 'h' : flaghosts = 1 ; break ; + case 'r' : flagunsort = 1 ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } } + argc -= l.ind ; argv += l.ind ; } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (argc < 1) dieusage() ; + if (!do4 && !do6) do4 = do6 = 1 ; if (do4 && do6) { @@ -56,12 +66,38 @@ int main (int argc, char const *const *argv) tain_now_set_stopwatch_g() ; if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; + + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) + strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; + if (flaghosts) + { + flaghosts = s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") ; + if (flaghosts == -1) strerr_diefu1sys(111, "initialize hosts database from /etc/hosts or /etc/hosts.cdb") ; + } + + if (flaghosts) + { + stralloc sa = STRALLOC_ZERO ; + int r = s6dns_hosts_name(ip.ip, &sa, &ds, ip.is6) ; + if (r == -1) strerr_diefu3sys(111, "look up ", argv[0], " in hosts database") ; + if (r) + { + for (size_t i = 0 ; i < genalloc_len(size_t, &ds) ; i++) + { + if (buffer_puts(buffer_1, sa.s + genalloc_s(size_t, &ds)[i]) < 0 + || buffer_put(buffer_1, "\n", 1) < 0) goto err ; + } + if (!buffer_flush(buffer_1)) goto err ; + return 0 ; + } + } + { int r = ip.is6 ? s6dns_resolve_name6_g(&ds, ip.ip, &deadline) : s6dns_resolve_name4_g(&ds, ip.ip, &deadline) ; if (r < 0) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; if (!r) strerr_diefu4x(2, "resolve ", argv[0], ": ", s6dns_constants_error_str(errno)) ; } + if (!genalloc_len(s6dns_domain_t, &ds)) return 1 ; if (flagunsort) random_unsort(ds.s, genalloc_len(s6dns_domain_t, &ds), sizeof(s6dns_domain_t)) ; { @@ -72,6 +108,7 @@ int main (int argc, char const *const *argv) } if (buffer_putflush(buffer_1, "\n", 1) < 1) goto err ; return 0 ; + err: strerr_diefu1sys(111, "write to stdout") ; } diff --git a/src/clients/s6-dnsns.c b/src/clients/s6-dnsns.c index 88f5197..7e19caf 100644 --- a/src/clients/s6-dnsns.c +++ b/src/clients/s6-dnsns.c @@ -3,6 +3,7 @@ #include <sys/types.h> #include <string.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> @@ -10,6 +11,7 @@ #include <skalibs/tai.h> #include <skalibs/genalloc.h> #include <skalibs/random.h> + #include <s6-dns/s6dns.h> #define USAGE "s6-dnsns [ -q ] [ -r ] [ -t timeout ] name" @@ -22,31 +24,37 @@ int main (int argc, char const *const *argv) unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; + int r ; PROG = "s6-dnsns" ; - for (;;) + { - int opt = lgetopt(argc, argv, "qrt:") ; - if (opt == -1) break ; - switch (opt) + subgetopt l = SUBGETOPT_ZERO ; + for (;;) { - case 'q' : flagqualify = 1 ; break ; - case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; - default : dieusage() ; + int opt = subgetopt_r(argc, argv, "qrt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'q' : flagqualify = 1 ; break ; + case 'r' : flagunsort = 1 ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } } + argc -= l.ind ; argv += l.ind ; } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (argc < 1) dieusage() ; tain_now_set_stopwatch_g() ; if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; - { - int r = s6dns_resolve_ns_g(&ds, argv[0], strlen(argv[0]), flagqualify, &deadline) ; - if (r < 0) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; - if (!r) strerr_diefu4x(2, "resolve ", argv[0], ": ", s6dns_constants_error_str(errno)) ; - } + + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) + strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; + + r = s6dns_resolve_ns_g(&ds, argv[0], strlen(argv[0]), flagqualify, &deadline) ; + if (r == -1) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; + if (!r) strerr_diefu4x(2, "resolve ", argv[0], ": ", s6dns_constants_error_str(errno)) ; if (!genalloc_len(s6dns_domain_t, &ds)) return 1 ; if (flagunsort) random_unsort(ds.s, genalloc_len(s6dns_domain_t, &ds), sizeof(s6dns_domain_t)) ; { diff --git a/src/clients/s6-dnsq.c b/src/clients/s6-dnsq.c index c6d50cf..6f85c42 100644 --- a/src/clients/s6-dnsq.c +++ b/src/clients/s6-dnsq.c @@ -3,6 +3,7 @@ #include <string.h> #include <stdint.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/bitarray.h> #include <skalibs/strerr.h> @@ -11,6 +12,7 @@ #include <skalibs/genwrite.h> #include <skalibs/tai.h> #include <skalibs/ip46.h> + #include <s6-dns/s6dns.h> #include <s6-dns/s6dns-analyze.h> #include <s6-dns/s6dns-debug.h> @@ -60,11 +62,10 @@ int main (int argc, char const *const *argv) { ip46 z[S6DNS_MAX_SERVERS] ; size_t n ; - unsigned int k = 0 ; if (!*argv[2+i]) continue ; if (!ip46_scanlist(z, S6DNS_MAX_SERVERS - j, argv[2 + i], &n)) strerr_diefu2sys(100, "make an IP address list out of ", argv[2+i]) ; - for (; k < n ; k++) + for (size_t k = 0 ; k < n ; k++) { memcpy(s6dns_ip46list_ip(&servers, j + k), z[k].ip, SKALIBS_IP_SIZE) ; #ifdef SKALIBS_IPV6_ENABLED diff --git a/src/clients/s6-dnsqr.c b/src/clients/s6-dnsqr.c index 290b06a..d8424e5 100644 --- a/src/clients/s6-dnsqr.c +++ b/src/clients/s6-dnsqr.c @@ -3,12 +3,14 @@ #include <string.h> #include <stdint.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/strerr.h> #include <skalibs/sgetopt.h> #include <skalibs/buffer.h> #include <skalibs/genwrite.h> #include <skalibs/tai.h> + #include <s6-dns/s6dns.h> #include <s6-dns/s6dns-analyze.h> #include <s6-dns/s6dns-debug.h> @@ -54,7 +56,9 @@ int main (int argc, char const *const *argv) if (debuglevel & 2) { dbh.pre_send = &s6dns_debug_dumpdt_pre_send ; dbh.post_send = &s6dns_debug_dumpdt_post_send ; } tain_now_set_stopwatch_g() ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) + strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; + if (!s6dns_resolve_core_r_g(&d, qtype, &s6dns_engine_here, &s6dns_rci_here.servers, &dbh, &deadline)) { char fmt[UINT16_FMT] ; diff --git a/src/clients/s6-dnsqualify.c b/src/clients/s6-dnsqualify.c index 38bf3ea..1752389 100644 --- a/src/clients/s6-dnsqualify.c +++ b/src/clients/s6-dnsqualify.c @@ -2,8 +2,10 @@ #include <sys/types.h> #include <string.h> + #include <skalibs/strerr.h> #include <skalibs/buffer.h> + #include <s6-dns/s6dns.h> #define USAGE "s6-dnsqualify name" @@ -16,7 +18,10 @@ int main (int argc, char const *const *argv) if (argc < 2) dieusage() ; if (!s6dns_domain_fromstring(&d, argv[1], strlen(argv[1]))) strerr_diefu2sys(100, "make a domain name from ", argv[1]) ; - if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; + + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) + strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; + { s6dns_domain_t list[s6dns_rci_here.rulesnum] ; unsigned int n = s6dns_qualify(list, &d) ; diff --git a/src/clients/s6-dnssoa.c b/src/clients/s6-dnssoa.c index 4df42b4..0ed2ff3 100644 --- a/src/clients/s6-dnssoa.c +++ b/src/clients/s6-dnssoa.c @@ -3,6 +3,7 @@ #include <sys/types.h> #include <string.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> @@ -10,6 +11,7 @@ #include <skalibs/tai.h> #include <skalibs/genalloc.h> #include <skalibs/random.h> + #include <s6-dns/s6dns.h> #define USAGE "s6-dnssoa [ -q ] [ -r ] [ -t timeout ] name" diff --git a/src/clients/s6-dnssrv.c b/src/clients/s6-dnssrv.c index b60e3be..c0b9fe3 100644 --- a/src/clients/s6-dnssrv.c +++ b/src/clients/s6-dnssrv.c @@ -3,6 +3,7 @@ #include <sys/types.h> #include <string.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> @@ -10,6 +11,7 @@ #include <skalibs/tai.h> #include <skalibs/genalloc.h> #include <skalibs/random.h> + #include <s6-dns/s6dns.h> #define USAGE "s6-dnssrv [ -q ] [ -r ] [ -t timeout ] service protocol name" @@ -19,30 +21,36 @@ int main (int argc, char const *const *argv) { genalloc srvs = GENALLOC_ZERO ; /* array of s6dns_message_rr_srv_t */ tain deadline ; - size_t i = 0 ; unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; PROG = "s6-dnssrv" ; - for (;;) + { - int opt = lgetopt(argc, argv, "qt:") ; - if (opt == -1) break ; - switch (opt) + subgetopt l = SUBGETOPT_ZERO ; + for (;;) { - case 'q' : flagqualify = 1 ; break ; - case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; - default : dieusage() ; + int opt = subgetopt_r(argc, argv, "qrt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'q' : flagqualify = 1 ; break ; + case 'r' : flagunsort = 1 ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } } + argc -= l.ind ; argv += l.ind ; } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (argc < 3) dieusage() ; tain_now_set_stopwatch_g() ; if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; - if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; + + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) + strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; + { size_t n0 = strlen(argv[0]) ; size_t n1 = strlen(argv[1]) ; @@ -63,7 +71,7 @@ int main (int argc, char const *const *argv) } if (!genalloc_len(s6dns_message_rr_srv_t, &srvs)) return 1 ; if (flagunsort) random_unsort(srvs.s, genalloc_len(s6dns_message_rr_srv_t, &srvs), sizeof(s6dns_message_rr_srv_t)) ; - for (i = 0 ; i < genalloc_len(s6dns_message_rr_srv_t, &srvs) ; i++) + for (size_t i = 0 ; i < genalloc_len(s6dns_message_rr_srv_t, &srvs) ; i++) { char buf[S6DNS_FMT_SRV] ; size_t len = s6dns_fmt_srv(buf, S6DNS_FMT_SRV, genalloc_s(s6dns_message_rr_srv_t, &srvs) + i) ; diff --git a/src/clients/s6-dnstxt.c b/src/clients/s6-dnstxt.c index 2564917..5818ac8 100644 --- a/src/clients/s6-dnstxt.c +++ b/src/clients/s6-dnstxt.c @@ -2,6 +2,7 @@ #include <string.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> @@ -11,6 +12,7 @@ #include <skalibs/genalloc.h> #include <skalibs/skamisc.h> #include <skalibs/random.h> + #include <s6-dns/s6dns.h> #define USAGE "s6-dnstxt [ -q ] [ -r ] [ -t timeout ] name" @@ -23,24 +25,27 @@ int main (int argc, char const *const *argv) genalloc offsets = GENALLOC_ZERO ; /* array of size_t */ tain deadline ; size_t n ; - size_t i = 0 ; unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; PROG = "s6-dnstxt" ; - for (;;) + { - int opt = lgetopt(argc, argv, "qrt:") ; - if (opt == -1) break ; - switch (opt) + subgetopt l = SUBGETOPT_ZERO ; + for (;;) { - case 'q' : flagqualify = 1 ; break ; - case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; - default : dieusage() ; + int opt = subgetopt_r(argc, argv, "qrt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'q' : flagqualify = 1 ; break ; + case 'r' : flagunsort = 1 ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } } + argc -= l.ind ; argv += l.ind ; } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (argc < 1) dieusage() ; if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; @@ -56,7 +61,7 @@ int main (int argc, char const *const *argv) if (!n) return 1 ; { size_t printable_offsets[n] ; - for (i = 0 ; i < n ; i++) + for (size_t i = 0 ; i < n ; i++) { size_t beg = genalloc_s(size_t, &offsets)[i] ; size_t end = (i < n-1 ? genalloc_s(size_t, &offsets)[i+1] : sa.len) - 1 ; @@ -67,7 +72,7 @@ int main (int argc, char const *const *argv) genalloc_free(size_t, &offsets) ; stralloc_free(&sa) ; if (flagunsort) random_unsort((char *)printable_offsets, n, sizeof(size_t)) ; - for (i = 0 ; i < n ; i++) + for (size_t i = 0 ; i < n ; i++) if ((buffer_puts(buffer_1small, quoted.s + printable_offsets[i]) < 0) || (buffer_put(buffer_1small, "\n", 1) < 1)) strerr_diefu1sys(111, "write to stdout") ; diff --git a/src/clients/s6-randomip.c b/src/clients/s6-randomip.c index 6a43794..158440a 100644 --- a/src/clients/s6-randomip.c +++ b/src/clients/s6-randomip.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <sys/types.h> +#include <stddef.h> #include <errno.h> #include <skalibs/types.h> @@ -22,22 +22,23 @@ int main (int argc, char const *const *argv) size_t what = 0 ; int finite = 0 ; PROG = "s6-randomip" ; - for (;;) { - int opt = lgetopt(argc, argv, "46n:") ; - if (opt == -1) break ; - switch (opt) + subgetopt l = SUBGETOPT_ZERO ; + for (;;) { - case '4' : what |= 1 ; break ; - case '6' : what |= 2 ; break ; - case 'n' : - if (!uint0_scan(subgetopt_here.arg, &n)) dieusage() ; - finite = 1 ; - break ; - default : dieusage() ; + int opt = subgetopt_r(argc, argv, "46n:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case '4' : what |= 1 ; break ; + case '6' : what |= 2 ; break ; + case 'n' : if (!uint0_scan(l.arg, &n)) dieusage() ; finite = 1 ; + break ; + default : dieusage() ; + } } + argc -= l.ind ; argv += l.ind ; } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (!what) what = 1 ; what = 1 << (1 << what) ; for (i = 0 ; !finite || (i < n) ; i++) @@ -52,7 +53,7 @@ int main (int argc, char const *const *argv) random_buf(ip, len) ; len = (len == 16) ? ip6_fmt(fmt, ip) : ip4_fmt(fmt, ip) ; fmt[len++] = '\n' ; - if (buffer_put(buffer_1, fmt, len) < (ssize_t)len) + if (buffer_put(buffer_1, fmt, len) < len) strerr_diefu1sys(111, "write to stdout") ; } if (!buffer_flush(buffer_1)) diff --git a/src/clients/s6dns-generic-filter.h b/src/clients/s6dns-generic-filter.h index 29f758e..9f92dea 100644 --- a/src/clients/s6dns-generic-filter.h +++ b/src/clients/s6dns-generic-filter.h @@ -5,7 +5,9 @@ #include <sys/types.h> #include <stdint.h> + #include <skalibs/stralloc.h> + #include <s6-dns/s6dns-domain.h> typedef size_t scan_func (s6dns_domain_t *, char const *) ; diff --git a/src/clients/s6dns_generic_filter_main.c b/src/clients/s6dns_generic_filter_main.c index 3e1894d..4c58aae 100644 --- a/src/clients/s6dns_generic_filter_main.c +++ b/src/clients/s6dns_generic_filter_main.c @@ -3,6 +3,7 @@ #include <sys/types.h> #include <stdint.h> #include <errno.h> + #include <skalibs/error.h> #include <skalibs/types.h> #include <skalibs/sgetopt.h> @@ -15,6 +16,7 @@ #include <skalibs/buffer.h> #include <skalibs/bufalloc.h> #include <skalibs/skamisc.h> + #include <s6-dns/s6dns-constants.h> #include <s6-dns/s6dns-domain.h> #include <s6-dns/skadns.h> diff --git a/src/clients/s6dns_namescanner.c b/src/clients/s6dns_namescanner.c index 2df6aae..57d3836 100644 --- a/src/clients/s6dns_namescanner.c +++ b/src/clients/s6dns_namescanner.c @@ -3,6 +3,7 @@ #include <sys/types.h> #include <limits.h> #include <errno.h> + #include <s6-dns/s6dns-domain.h> #include "s6dns-generic-filter.h" diff --git a/src/include/s6-dns/hosts.h b/src/include/s6-dns/hosts.h index 0f85d0b..e76bfcb 100644 --- a/src/include/s6-dns/hosts.h +++ b/src/include/s6-dns/hosts.h @@ -13,11 +13,8 @@ extern cdb s6dns_hosts_here ; extern int s6dns_hosts_compile (int, int) ; -extern int s6dns_hosts_init_r (cdb *, char const *, char const *, char const *) ; -#define s6dns_hosts_init() s6dns_hosts_init_r(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") -#define s6dns_hosts_free_r(c) cdb_free(c) -#define s6dns_hosts_free() s6dns_hosts_free_r(&s6dns_hosts_here) - +extern int s6dns_hosts_init (cdb *, char const *, char const *, char const *) ; +#define s6dns_hosts_free(c) cdb_free(c) /* IP to name */ @@ -41,8 +38,8 @@ extern int s6dns_hosts_ip_string_r (cdb const *, char const *, stralloc *, unsig #define s6dns_hosts_ip_noq(name, sa, is6) s6dns_hosts_ip_noq_r(&s6dns_hosts_here, (name), sa, is6) #define s6dns_hosts_ip_unq(name, sa, is6) s6dns_hosts_ip_unq_r(&s6dns_hosts_here, (name), sa, is6) -#define s6dns_hosts_a_string_r(c, name, sa, isalias) s6dns_hosts_ip_string_r(c, name, sa, !!(isunq) << 1) -#define s6dns_hosts_aaaa_string_r(c, name, sa, isalias) s6dns_hosts_ip_string_r(c, name, sa, (!!(isunq) << 1) | 1) +#define s6dns_hosts_a_string_r(c, name, sa, isunq) s6dns_hosts_ip_string_r(c, name, sa, !!(isunq) << 1) +#define s6dns_hosts_aaaa_string_r(c, name, sa, isunq) s6dns_hosts_ip_string_r(c, name, sa, (!!(isunq) << 1) | 1) extern int s6dns_hosts_aaaaa_string_r (cdb const *, char const *, genalloc *, int) ; #define s6dns_hosts_a_string(name, sa, isunq) s6dns_hosts_a_string_r(&s6dns_hosts_here, (name), sa, isunq) @@ -68,14 +65,14 @@ extern int s6dns_hosts_aaaaa_string_r (cdb const *, char const *, genalloc *, in /* name to IP, with qualification */ -extern int s6dns_hosts_ip_q_r (cdb const *, char const *, stralloc *sa, char const *, unsigned int, int) ; -#define s6dns_hosts_a_q_r(c, name, sa, rules, rulesnum) s6dns_hosts_ip_q_r(c, name, sa, rules, rulesnum, 0) -#define s6dns_hosts_aaaa_q_r(c, name, rules, rulesnum, sa) s6dns_hosts_ip_q_r(c, name, sa, rules, rulesnum, 1) +extern int s6dns_hosts_ip_q_r (cdb const *, char const *, stralloc *, char const *, unsigned int, int) ; +#define s6dns_hosts_a_q_r(c, name, sa, rules, rulesnum) s6dns_hosts_ip_q_r(c, name, sa, rules, (rulesnum), 0) +#define s6dns_hosts_aaaa_q_r(c, name, sa, rules, rulesnum) s6dns_hosts_ip_q_r(c, name, sa, rules, (rulesnum), 1) extern int s6dns_hosts_aaaaa_q_r (cdb const *, char const *, genalloc *, char const *, unsigned int) ; #define s6dns_hosts_ip_q(name, sa, is6) s6dns_hosts_ip_q_r(&s6dns_hosts_here, (name), sa, s6dns_rci_here.rules.s, s6dns_rci_here.rulesnum, is6) #define s6dns_hosts_a_q(name, sa) s6dns_hosts_a_q_r(&s6dns_hosts_here, (name), sa, s6dns_rci_here.rules.s, s6dns_rci_here.rulesnum) -#define s6dns_hosts_aaaa_q(name, sa) s6dns_hosts_ip_q_r(&s6dns_hosts_here, (name), sa, s6dns_rci_here.rules.s, s6dns_rci_here.rulesnum) -#define s6dns_hosts_aaaaa_q(name, ga) s6dns_hosts_aaaaa_q_r(&s6dns_hosts_here, (name), ga) +#define s6dns_hosts_aaaa_q(name, sa) s6dns_hosts_aaaa_q_r(&s6dns_hosts_here, (name), sa, s6dns_rci_here.rules.s, s6dns_rci_here.rulesnum) +#define s6dns_hosts_aaaaa_q(name, ga) s6dns_hosts_aaaaa_q_r(&s6dns_hosts_here, (name), ga, s6dns_rci_here.rules.s, s6dns_rci_here.rulesnum) #endif diff --git a/src/include/s6-dns/skadns.h b/src/include/s6-dns/skadns.h index 8f27d2e..32e3648 100644 --- a/src/include/s6-dns/skadns.h +++ b/src/include/s6-dns/skadns.h @@ -5,10 +5,12 @@ #include <stdint.h> #include <errno.h> + #include <skalibs/tai.h> #include <skalibs/genalloc.h> #include <skalibs/gensetdyn.h> #include <skalibs/textclient.h> + #include <s6-dns/config.h> #include <s6-dns/s6dns-domain.h> diff --git a/src/libs6dns/deps-lib/s6dns b/src/libs6dns/deps-lib/s6dns index 6eaf610..266b574 100644 --- a/src/libs6dns/deps-lib/s6dns +++ b/src/libs6dns/deps-lib/s6dns @@ -1,5 +1,24 @@ +s6dns_analyze_packet.o +s6dns_analyze_qtype_parse.o +s6dns_analyze_record.o +s6dns_analyze_record_a.o +s6dns_analyze_record_aaaa.o +s6dns_analyze_record_caa.o +s6dns_analyze_record_domain.o +s6dns_analyze_record_hinfo.o +s6dns_analyze_record_mx.o +s6dns_analyze_record_soa.o +s6dns_analyze_record_srv.o +s6dns_analyze_record_strings.o +s6dns_analyze_record_unknown.o +s6dns_analyze_rtypetable.o s6dns_constants_error.o s6dns_constants_error_str.o +s6dns_debug_dumpdt_post_recv.o +s6dns_debug_dumpdt_post_send.o +s6dns_debug_dumpdt_pre_send.o +s6dns_debug_dumpdt_stderr.o +s6dns_debug_dumpdt_stdout.o s6dns_debughook_zero.o s6dns_domain_arpafromip4.o s6dns_domain_arpafromip6.o @@ -18,46 +37,49 @@ s6dns_engine_freen.o s6dns_engine_here.o s6dns_engine_nextdeadline.o s6dns_engine_zero.o +s6dns_finish.o +s6dns_fmt_caa.o s6dns_fmt_domainlist.o s6dns_fmt_hinfo.o s6dns_fmt_mx.o s6dns_fmt_soa.o s6dns_fmt_srv.o -s6dns_fmt_caa.o -s6dns_hosts_compile.o s6dns_hosts_aaaaa_q.o s6dns_hosts_aaaaa_string.o +s6dns_hosts_compile.o +s6dns_hosts_here.o +s6dns_hosts_init.o s6dns_hosts_ip_q.o s6dns_hosts_ip_string.o s6dns_hosts_name.o -s6dns_hosts_here.o +s6dns_init.o s6dns_message_counts_next.o s6dns_message_counts_pack.o s6dns_message_counts_unpack.o s6dns_message_counts_zero.o +s6dns_message_get_caa.o s6dns_message_get_domain.o s6dns_message_get_domain_nodecode.o s6dns_message_get_hinfo.o -s6dns_message_get_string.o -s6dns_message_get_string_internal.o -s6dns_message_get_strings.o s6dns_message_get_mx.o s6dns_message_get_soa.o s6dns_message_get_srv.o -s6dns_message_get_caa.o +s6dns_message_get_string.o +s6dns_message_get_string_internal.o +s6dns_message_get_strings.o s6dns_message_header_pack.o s6dns_message_header_unpack.o s6dns_message_header_zero.o -s6dns_message_parse_answer_aaaa.o +s6dns_message_parse.o s6dns_message_parse_answer_a.o +s6dns_message_parse_answer_aaaa.o +s6dns_message_parse_answer_caa.o s6dns_message_parse_answer_domain.o s6dns_message_parse_answer_hinfo.o s6dns_message_parse_answer_mx.o s6dns_message_parse_answer_soa.o s6dns_message_parse_answer_srv.o -s6dns_message_parse_answer_caa.o s6dns_message_parse_answer_strings.o -s6dns_message_parse.o s6dns_message_parse_getrr.o s6dns_message_parse_init.o s6dns_message_parse_next.o @@ -68,36 +90,15 @@ s6dns_rci_here.o s6dns_rci_init.o s6dns_rci_zero.o s6dns_resolve_core.o -s6dns_resolve_parse.o -s6dns_resolven_loop.o -s6dns_resolven_parse.o s6dns_resolve_dpag.o s6dns_resolve_mpag.o s6dns_resolve_name4.o s6dns_resolve_name6.o +s6dns_resolve_parse.o +s6dns_resolven_loop.o +s6dns_resolven_parse.o s6dns_resolvenoq.o -s6dns_resolveq.o s6dns_resolvenoq_aaaaa.o +s6dns_resolveq.o s6dns_resolveq_aaaaa.o -s6dns_analyze_packet.o -s6dns_analyze_qtype_parse.o -s6dns_analyze_record.o -s6dns_analyze_record_a.o -s6dns_analyze_record_aaaa.o -s6dns_analyze_record_hinfo.o -s6dns_analyze_record_mx.o -s6dns_analyze_record_soa.o -s6dns_analyze_record_srv.o -s6dns_analyze_record_caa.o -s6dns_analyze_record_domain.o -s6dns_analyze_record_strings.o -s6dns_analyze_record_unknown.o -s6dns_analyze_rtypetable.o -s6dns_debug_dumpdt_stdout.o -s6dns_debug_dumpdt_stderr.o -s6dns_debug_dumpdt_post_recv.o -s6dns_debug_dumpdt_pre_send.o -s6dns_debug_dumpdt_post_send.o -s6dns_init.o -s6dns_finish.o -lskarnet diff --git a/src/libs6dns/s6dns_finish.c b/src/libs6dns/s6dns_finish.c index f786329..a8a479a 100644 --- a/src/libs6dns/s6dns_finish.c +++ b/src/libs6dns/s6dns_finish.c @@ -7,5 +7,6 @@ void s6dns_finish () { s6dns_engine_free(&s6dns_engine_here) ; + s6dns_hosts_free(&s6dns_hosts_here) ; s6dns_rci_free(&s6dns_rci_here) ; } diff --git a/src/libs6dns/s6dns_hosts_init.c b/src/libs6dns/s6dns_hosts_init.c index 762d738..8f78ab1 100644 --- a/src/libs6dns/s6dns_hosts_init.c +++ b/src/libs6dns/s6dns_hosts_init.c @@ -5,6 +5,7 @@ #include <errno.h> #include <stdlib.h> #include <sys/stat.h> +#include <time.h> #include <skalibs/posixplz.h> #include <skalibs/cdb.h> @@ -12,7 +13,7 @@ #include <s6-dns/hosts.h> -int s6dns_hosts_init_r (cdb *c, char const *txtfile, char const *cdbfile, char const *tmpprefix) +int s6dns_hosts_init (cdb *c, char const *txtfile, char const *cdbfile, char const *tmpprefix) { int fdr ; int fdc = openc_read(cdbfile) ; @@ -25,7 +26,8 @@ int s6dns_hosts_init_r (cdb *c, char const *txtfile, char const *cdbfile, char c if (errno == ENOENT) goto useit ; else goto errc ; } - if (stc.st_mtim > str.st_mtim) goto useit ; + if (stc.st_mtim.tv_sec > str.st_mtim.tv_sec + || (stc.st_mtim.tv_sec == str.st_mtim.tv_sec && stc.st_mtim.tv_nsec > str.st_mtim.tv_nsec)) goto useit ; fd_close(fdc) ; } diff --git a/src/libs6dns/s6dns_init.c b/src/libs6dns/s6dns_init.c index 7f98d13..10dcbf5 100644 --- a/src/libs6dns/s6dns_init.c +++ b/src/libs6dns/s6dns_init.c @@ -1,10 +1,16 @@ /* ISC license. */ #include <s6-dns/s6dns-rci.h> +#include <s6-dns/hosts.h> #include <s6-dns/s6dns.h> int s6dns_init (void) { if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) return 0 ; + if (s6dns_hosts_init(&s6dns_hosts_here, "/etc/hosts", "/etc/hosts.cdb", "/tmp/hosts.cdb") == -1) goto err ; return 1 ; + + err: + s6dns_rci_free(&s6dns_rci_here) ; + return 0 ; } diff --git a/src/skadns/skadns_startf.c b/src/skadns/skadns_startf.c index bf20edd..e9fadd3 100644 --- a/src/skadns/skadns_startf.c +++ b/src/skadns/skadns_startf.c @@ -2,6 +2,7 @@ #include <skalibs/posixplz.h> #include <skalibs/textclient.h> + #include <s6-dns/skadns.h> int skadns_startf (skadns_t *a, tain const *deadline, tain *stamp) diff --git a/src/skadns/skadnsd.c b/src/skadns/skadnsd.c index 8714d2b..0909dfa 100644 --- a/src/skadns/skadnsd.c +++ b/src/skadns/skadnsd.c @@ -115,7 +115,9 @@ int main (void) if (ndelay_on(1) < 0) strerr_diefu2sys(111, "ndelay_on ", "1") ; if (!sig_ignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; tain_now_set_stopwatch_g() ; - if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; + + if (!s6dns_rci_init(&s6dns_rci_here, "/etc/resolv.conf")) + strerr_diefu1sys(111, "initialize structures from /etc/resolv.conf") ; { tain deadline ; |