rwrap: Add support for res_ninit().

Signed-off-by: Andreas Schneider <asn@samba.org>
rwrap: Add support for res_nclose().

Signed-off-by: Andreas Schneider <asn@samba.org>
rwrap: Add support for res_nquery().

Signed-off-by: Andreas Schneider <asn@samba.org>
rwrap: Add support for res_nsearch().

Signed-off-by: Andreas Schneider <asn@samba.org>
rwrap: Add support to read a resolv.conf.

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Pair-Programmed-With: Andreas Schneider <asn@samba.org>
rwrap: Fix loading libresolv on BSD.

Signed-off-by: Andreas Schneider <asn@samba.org>
rwrap: Disalbe IPv6 support on BSD.

The _ext structure is opaque on BSD, so we can't access its elements.

Signed-off-by: Andreas Schneider <asn@samba.org>
rwrap: Skip extra name servers

glibc only supports 3 name servers. When libc encounters any extra
entries, it just skips them. We should do the same.

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
tests: Add a test for parsing resolv.conf

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
doc: Update the manpage.

Signed-off-by: Andreas Schneider <asn@samba.org>
Add TODO file.

Signed-off-by: Andreas Schneider <asn@samba.org>
tests: Use standard function name

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
tests: Fix test_res_init on platforms with no v6 nsaddrs

On platforms that dont support IPv6, the v6 address is skipped and we
end up reading three v4 addresses.

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
tests: Zero the state before using it

Leaving random garbage in the dnsstate might lead to crashes.

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
tests: Add a simple DNS server

This DNS server will be usable for testing. Currently only supports A
records.

The server responds to any A query with the value of RWRAP_TEST_A_REC
environment variable. If undefined, the server always replies with
127.0.10.10.

Please note the server does *not* perform many security checks and is
completely unsuitable outside a test suite! Check out servers like
dnsmasq for anything more complex.

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
tests: Add torture library from socket_wrapper

Pretty much a blatant copy of the torture library from socket_wrapper,
just s/echo_srv/dns_srv/

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
tests: Add generating resolv.conf to torture

Adds a setup/teardown functions that allow a unit test to easily
generate a resolv.conf pointing to our test DNS server.

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
tests: Add a unit test for res_nquery and res_nsearch

Adds a test that connects to a test DNS server and searches it using
res_query and res_search.

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
cmake: Rely on the cmake config cmocka provides.