chiark / gitweb /
adns.git
4 years agoUpdate version numbers to be between releases
Ian Jackson [Mon, 20 Oct 2014 01:31:46 +0000 (02:31 +0100)]
Update version numbers to be between releases

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoRELEASE-CHECKLIST: Say to update versions after doing release
Ian Jackson [Mon, 20 Oct 2014 01:32:44 +0000 (02:32 +0100)]
RELEASE-CHECKLIST: Say to update versions after doing release

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoRELEASE-CHECKLIST: wip, as used for 1.5.0~rc0
Ian Jackson [Mon, 20 Oct 2014 01:30:36 +0000 (02:30 +0100)]
RELEASE-CHECKLIST: wip, as used for 1.5.0~rc0

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME.html: Web page management changes adns-1.5.0-rc0
Ian Jackson [Mon, 20 Oct 2014 01:10:31 +0000 (02:10 +0100)]
README.html: Web page management changes

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoVersions: update to 1.5.0 RC0
Ian Jackson [Mon, 20 Oct 2014 00:37:40 +0000 (01:37 +0100)]
Versions: update to 1.5.0 RC0

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoNEWS: More updates
Ian Jackson [Mon, 20 Oct 2014 00:28:07 +0000 (01:28 +0100)]
NEWS: More updates

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoNEWS: Remove "pleased to announce" - should be in mail
Ian Jackson [Mon, 20 Oct 2014 00:26:31 +0000 (01:26 +0100)]
NEWS: Remove "pleased to announce" - should be in mail

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME.html: Abolish dead link to BIND
Ian Jackson [Mon, 20 Oct 2014 00:25:44 +0000 (01:25 +0100)]
README.html: Abolish dead link to BIND

4 years agoREADME.html: mention signatures as possibly being on the web page
Ian Jackson [Mon, 20 Oct 2014 00:25:27 +0000 (01:25 +0100)]
README.html: mention signatures as possibly being on the web page

4 years agoBuild system: Provide `web-install' target
Ian Jackson [Mon, 20 Oct 2014 00:24:22 +0000 (01:24 +0100)]
Build system: Provide `web-install' target

This copies the various website files to WEBDIR.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoadns.h: Generalise some mentions of A RRs.
Ian Jackson [Mon, 20 Oct 2014 00:22:36 +0000 (01:22 +0100)]
adns.h: Generalise some mentions of A RRs.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoBuild system: Break out common.make[.in]
Ian Jackson [Mon, 20 Oct 2014 00:22:07 +0000 (01:22 +0100)]
Build system: Break out common.make[.in]

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoBuild system: Know how to build adnshost.txt
Ian Jackson [Mon, 20 Oct 2014 00:09:29 +0000 (01:09 +0100)]
Build system: Know how to build adnshost.txt

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agochangelog: Reorder slightly
Ian Jackson [Sun, 19 Oct 2014 23:57:17 +0000 (00:57 +0100)]
changelog: Reorder slightly

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoBuild system: Do not include Makefile and src/config.h in distribution tarball
Ian Jackson [Sun, 19 Oct 2014 23:38:40 +0000 (00:38 +0100)]
Build system: Do not include Makefile and src/config.h in distribution tarball

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agochangelog: More updates
Ian Jackson [Sun, 19 Oct 2014 23:29:32 +0000 (00:29 +0100)]
changelog: More updates

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoNEWS: Draft release notes for 1.5.0~rc0
Ian Jackson [Sun, 19 Oct 2014 23:29:24 +0000 (00:29 +0100)]
NEWS: Draft release notes for 1.5.0~rc0

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years ago.gitignore: Add autom4te.cache
Ian Jackson [Sun, 19 Oct 2014 23:15:15 +0000 (00:15 +0100)]
.gitignore: Add autom4te.cache

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoBuild system: update configure to autoconf 2.69
Ian Jackson [Sun, 19 Oct 2014 23:14:18 +0000 (00:14 +0100)]
Build system: update configure to autoconf 2.69

Ran `configure' on Debian wheezy i386.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoLicensing: Abolish `proprietary' part in GPL-vs-LGPL
Ian Jackson [Sun, 19 Oct 2014 23:11:10 +0000 (00:11 +0100)]
Licensing: Abolish `proprietary' part in GPL-vs-LGPL

Having accepted substantial contributions I am no longer in a position
to offer this.  And anyway the offer was mostly there to put people
off asking for something for nothing - no-one actually ever offered me
money.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoLicensing: Abolish LICENCE.WAIVERS
Ian Jackson [Sun, 19 Oct 2014 23:10:25 +0000 (00:10 +0100)]
Licensing: Abolish LICENCE.WAIVERS

The only existing waiver was for the AGPL, and the GPLv3 which we are
now using has an AGPL-compatibility clause already in it.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoLicensing: Add copyright for Mark Wooding
Ian Jackson [Sun, 19 Oct 2014 23:07:19 +0000 (00:07 +0100)]
Licensing: Add copyright for Mark Wooding

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoLicensing: Update copyright dates for Ian Jackson
Ian Jackson [Sun, 19 Oct 2014 23:06:42 +0000 (00:06 +0100)]
Licensing: Update copyright dates for Ian Jackson

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoLicensing: Delete FSF address from INSTALL
Ian Jackson [Sun, 19 Oct 2014 23:02:48 +0000 (00:02 +0100)]
Licensing: Delete FSF address from INSTALL

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoLicensing: Copy GPL-3 into COPYING
Ian Jackson [Sun, 19 Oct 2014 23:01:59 +0000 (00:01 +0100)]
Licensing: Copy GPL-3 into COPYING

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoLicensing: Delete FSF street address
Ian Jackson [Sun, 19 Oct 2014 23:00:55 +0000 (00:00 +0100)]
Licensing: Delete FSF street address

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoLicensing: Update version in file header comments
Ian Jackson [Sun, 19 Oct 2014 22:58:22 +0000 (23:58 +0100)]
Licensing: Update version in file header comments

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agochangelog: Update with changes so far
Ian Jackson [Sun, 19 Oct 2014 22:53:03 +0000 (23:53 +0100)]
changelog: Update with changes so far

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoRemove cvs-to-git conversion script
Ian Jackson [Sun, 19 Oct 2014 22:50:34 +0000 (23:50 +0100)]
Remove cvs-to-git conversion script

This has now done its work and is no longer needed.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoMakefile.in: Fix "make dist" for git
Ian Jackson [Sun, 19 Oct 2014 22:39:44 +0000 (23:39 +0100)]
Makefile.in: Fix "make dist" for git

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoDocumentation and webpage updates
Ian Jackson [Sun, 19 Oct 2014 22:36:57 +0000 (23:36 +0100)]
Documentation and webpage updates

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoMakefile.in: update DISTVERSION
Ian Jackson [Sun, 19 Oct 2014 22:35:32 +0000 (23:35 +0100)]
Makefile.in: update DISTVERSION

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/types.c: Clarify comment for addr_submit (style) wip.ipv6
Ian Jackson [Mon, 13 Oct 2014 12:54:35 +0000 (13:54 +0100)]
src/types.c: Clarify comment for addr_submit (style)

We don't just fiddle with tinfo; this function actually sets it.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/types.c: Rewrite pap_addr (style)
Ian Jackson [Mon, 13 Oct 2014 12:50:47 +0000 (13:50 +0100)]
src/types.c: Rewrite pap_addr (style)

Completely rework this function to make it much clearer.  Also rename
many of the surviving variables.

No functional change.

The following rune was helpful to me when preparing this patch:

  diff -bu <(git-show HEAD:src/types.c | perl -pe 's/\bstoreto\b/out/g; s/\bmax\b/cbyte_max/g; s/\boaddr\b/use_addr/; s/\bsalen\b/out_salen/g; s/\bstep\b/in_addrlen/g; s/\baf\b/out_af/g; s/\brrsz\b/out_rrsz/g; s/\brrty\b/in_rrty/g') src/types.c |less +/pap_addr

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/types.c: Clarify gettimeofday error handling (style)
Ian Jackson [Mon, 13 Oct 2014 12:09:03 +0000 (13:09 +0100)]
src/types.c: Clarify gettimeofday error handling (style)

Use `r=...; if (r)...' rather than `if (syscall) ...'.  And add a
comment explaining why we're not using adns__must_gettimeofday.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/types.c: Clarify addr_rrtypeflag loop (style)
Ian Jackson [Sun, 12 Oct 2014 19:34:42 +0000 (20:34 +0100)]
src/types.c: Clarify addr_rrtypeflag loop (style)

This structure avoids repeating the loop termination condition.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/types.c: Rename `hunoz' (style)
Ian Jackson [Sun, 12 Oct 2014 19:20:39 +0000 (20:20 +0100)]
src/types.c: Rename `hunoz' (style)

Call this `addr__rrty_eat_final_comma', not `addr_rrty_hunoz' (which
AFAICT from web searches is meaningful to Lisp programmers).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/query.c: adns__free_interim: Add assertion
Ian Jackson [Sun, 12 Oct 2014 19:11:23 +0000 (20:11 +0100)]
src/query.c: adns__free_interim: Add assertion

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/query.c: Rename alloc_info (style)
Ian Jackson [Sun, 12 Oct 2014 19:10:02 +0000 (20:10 +0100)]
src/query.c: Rename alloc_info (style)

Rename it to alloc__info to emphasize its privateness.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/event.c: Use `continue' in adns_processreadable (style)
Ian Jackson [Sun, 12 Oct 2014 19:02:27 +0000 (20:02 +0100)]
src/event.c: Use `continue' in adns_processreadable (style)

This is IMO clearer than another nested indent of the bulk of the loop
body.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/setup.c: Reuse variable i (style)
Ian Jackson [Sun, 12 Oct 2014 18:41:52 +0000 (19:41 +0100)]
src/setup.c: Reuse variable i (style)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/: Rename `udpsocket' and `nudp' (style)
Ian Jackson [Sun, 12 Oct 2014 17:00:35 +0000 (18:00 +0100)]
src/: Rename `udpsocket' and `nudp' (style)

I prefer plurals for arrays and the count should have a near-identical
name.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoMakefiles: Remove pipes on clean
Ian Jackson [Sun, 12 Oct 2014 16:17:23 +0000 (17:17 +0100)]
Makefiles: Remove pipes on clean

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoregress/: Replace PF_ with AF_
Ian Jackson [Sun, 12 Oct 2014 16:16:32 +0000 (17:16 +0100)]
regress/: Replace PF_ with AF_

I don't much like PF_.  None of the modern specs or docs talk about PF
any more.

Entirely formulaic patch:
  perl -i~ -pe 's/\bPF_INET\b/AF_INET/g' regress/*
  perl -i~ -pe 's/\bPF_INET6\b/AF_INET6/g' regress/*

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/: Fix commentary mood (style)
Ian Jackson [Sun, 12 Oct 2014 14:36:11 +0000 (15:36 +0100)]
src/: Fix commentary mood (style)

I prefer `/* does X */', to `/* do X */', for the comment next to a
function which does X.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/: Rename a variable `n' to `salen' (style)
Ian Jackson [Sun, 12 Oct 2014 14:29:13 +0000 (15:29 +0100)]
src/: Rename a variable `n' to `salen' (style)

I don't think a length can be called `n'.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/: Add a missing space (style)
Ian Jackson [Sun, 12 Oct 2014 14:25:25 +0000 (15:25 +0100)]
src/: Add a missing space (style)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/: Clarify logic in clk_srv (style)
Ian Jackson [Sun, 12 Oct 2014 14:08:14 +0000 (15:08 +0100)]
src/: Clarify logic in clk_srv (style)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/: Rename some variables `stat' to `st' (style)
Ian Jackson [Sun, 12 Oct 2014 14:00:51 +0000 (15:00 +0100)]
src/: Rename some variables `stat' to `st' (style)

These inconsistencies have been there since the dawn of time.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/: Rename a variable `err' to `st' (style)
Ian Jackson [Sun, 12 Oct 2014 13:57:28 +0000 (14:57 +0100)]
src/: Rename a variable `err' to `st' (style)

(This was introduced in `src/: Change how query domain names are
checked.' and I prefer this name.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoregress/Makefile.in: Declare <client>_c.o as .SECONDARY
Ian Jackson [Sat, 26 Jul 2014 13:56:17 +0000 (14:56 +0100)]
regress/Makefile.in: Declare <client>_c.o as .SECONDARY

Otherwise you can get this:

 regress$ make adnstest_record -j2
 gcc -g -O2 -Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith -Wno-pointer-sign  -I../src -I. -I./../src  -DADNS_REGRESS_TEST -I. -c -g -o addrfam_d.o ../src/addrfam.c
 gcc    adnstest_c.o hrecord.o hcommon.o types_d.o event_d.o query_d.o reply_d.o general_d.o setup_d.o transmit_d.o parse_d.o poll_d.o check_d.o addrfam_d.o  -o adnstest_record
 gcc: error: adnstest_c.o: No such file or directory
 make: *** [adnstest_record] Error 1
 regress$

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoreverse parsing: New test cases
Ian Jackson [Thu, 24 Jul 2014 00:22:54 +0000 (01:22 +0100)]
reverse parsing: New test cases

Check that the reverse parser rejects labels with leading zeroes, with
digits out of range, or with out-of-range label values.  And check
uppercase IPv6 PTRs.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoreverse parsing: Clearer algorithm
Ian Jackson [Thu, 24 Jul 2014 00:02:54 +0000 (01:02 +0100)]
reverse parsing: Clearer algorithm

We used to have a kind of open-coded coroutine arrangement for parsing
reverse domains.  This is complicated and confusing.

Instead, when "parsing" the labels, simply stash their locations and
lengths.  Then, at the end, we have all of the information needed to
check, parse and process the whole domain.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoreverse parsing: Make adns__revparse_* return bool
Ian Jackson [Wed, 23 Jul 2014 22:18:56 +0000 (23:18 +0100)]
reverse parsing: Make adns__revparse_* return bool

This seems nicer and is going to be more convenient.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoreverse parsing: Pass dgram and labstart instead of label
Ian Jackson [Wed, 23 Jul 2014 21:58:03 +0000 (22:58 +0100)]
reverse parsing: Pass dgram and labstart instead of label

We are going to want to deal with labstart and dgram separately.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoIntroduce adns__labels_equal and ctype_toupper
Ian Jackson [Thu, 24 Jul 2014 00:46:09 +0000 (01:46 +0100)]
Introduce adns__labels_equal and ctype_toupper

This not only makes adns__findrr_anychk less confusing, but it also
makes it possible to reuse this functionality.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoregress/gdbwrap: Provide a convenience script
Ian Jackson [Wed, 23 Jul 2014 23:52:51 +0000 (00:52 +0100)]
regress/gdbwrap: Provide a convenience script

This lets you run gdb from within r1test with appropriate fd plumbing.
(It's a shame gdb doesn't have a way to simply tell it to take its
commands from /dev/tty.)

Add the suggested example gdb script file, x.gdb, to .gitignore.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoregress: New test bogus-sortlist
Ian Jackson [Sat, 19 Jul 2014 18:55:39 +0000 (19:55 +0100)]
regress: New test bogus-sortlist

Exercise the code which checks the sortlist for invalid address/mask
pairs.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoaddrfam: Make SIN, SIN6 more regular
Ian Jackson [Sat, 19 Jul 2014 16:39:46 +0000 (17:39 +0100)]
addrfam: Make SIN, SIN6 more regular

Abolish CSIN and CSIN6.  Instead, provide a first argument which may
be `const' or empty.  (Empty macro arguments are permitted since C99.)

This makes them useable in SOCKADDR_IN_IN6*, so use them there.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoaddrfam: Introduce SOCKADDR_IN_IN6, etc.
Ian Jackson [Sat, 19 Jul 2014 16:37:37 +0000 (17:37 +0100)]
addrfam: Introduce SOCKADDR_IN_IN6, etc.

These macros make writing IPv4/IPv6 handling functions convenient.
Use them everywhere applicable.

This replaces AF_CASES, which was longwinded (and also error-prone,
since it is possible to pass a different af to switch() and
unknown_af()).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoaddrfam: New arrangements for protocol address types
Ian Jackson [Sat, 12 Jul 2014 11:56:46 +0000 (12:56 +0100)]
addrfam: New arrangements for protocol address types

Abolish union gen_addr and struct af_addr.  It is not legitimate to
up-cast to a union (since the alignment might be wrong), and the
profusion of additonal address types is confusing.

The new arrangements are:

* Use adns_sockaddr wherever we can.  That includes situations
  where the port (or v6 scope, etc.) is not relevant.

* Where that's not possible, use a struct sockaddr if we can.

* Where we need to deal with an IP address of unspecified family (we
  use the phrase `protocol address') we must use a void*.

Other changes we make here:

* Reorganise the set of functions provided by addrfam.c.  Previously
  there was a comprehensive set of manipulators.  Now, we have
  precisely the set of functions we need.

  The new functions are called adns__addr_* when they deal with
  adns_sockaddrs, and adns_sockaddr_* when dealing with struct
  sockaddrs.

  The new functions normally no longer need to take an explicit af
  parameter, since they can use the af field in the sockaddr.

* adns__sockaddrs_equal (previously, adns__sockaddr_equal_p) now uses
  the generic protocol address comparison function; consequently
  remove the IN6_ADDR_EQUALP macro since it now has only one use site.

* Remove the Lispy "-p" suffix from predicate function names.

And of course the very formulaic changes to code which accesses
addresses of various kinds.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoaddrfam: mark unknown_af as not returning
Ian Jackson [Sat, 19 Jul 2014 15:10:46 +0000 (16:10 +0100)]
addrfam: mark unknown_af as not returning

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years ago.gitignore: add addrtext_s, remove non-built dynamic local tests
Ian Jackson [Sat, 19 Jul 2014 14:55:30 +0000 (15:55 +0100)]
.gitignore: add addrtext_s, remove non-built dynamic local tests

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoSupport IPv6 in addr queries.
Mark Wooding [Wed, 11 Jun 2014 00:02:49 +0000 (01:02 +0100)]
Support IPv6 in addr queries.

This is the end-game.  Add flags and options to allow clients and
administrators to choose which address families they want returned.  For
logical compatibility with old clients, don't return foreign address
families unless explicitly requested.

Lots of tests are modified to select only IPv4 addresses.  There's
nothing else up my sleeve.  A new test is added for the additional
functionality; more are expected later.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/types.c: Handle inconsistent CNAME records between addr answers.
Mark Wooding [Tue, 10 Jun 2014 23:40:42 +0000 (00:40 +0100)]
src/types.c: Handle inconsistent CNAME records between addr answers.

It can happen, if we have multiple address queries outstanding, that
they disagree about whether the original name has a CNAME record, or
what the CNAME target is.  This needn't be a configuration error or a
server bug: the zone might have been caught during a changeover.  So we
should try to handle this situation gracefully.

We resolve this as follows.  At least one answer must have reported a
CNAME record, else there is no ambiguity.  We choose the first such
record to arrive, and commit to it, discarding other addresses already
received, if any.  We then resubmit address queries for the address
types still outstanding, but asking specifically for the CNAME target
rather than the original name.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agoSupport v6-mapping IPv4 addresses found doing addr lookups.
Mark Wooding [Tue, 10 Jun 2014 23:33:00 +0000 (00:33 +0100)]
Support v6-mapping IPv4 addresses found doing addr lookups.

Not available if the client doesn't have the larger adns_rr_addr
structure.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/types.c: Cope with multiple address families when dereferencing.
Mark Wooding [Tue, 10 Jun 2014 23:14:10 +0000 (00:14 +0100)]
src/types.c: Cope with multiple address families when dereferencing.

The pap_findaddrs/pap_hostaddr machinery is improved to cope with
multiple address families.  First of all, we must find out which
families are wanted, using addr_rrtypes.  Then we keep track of which
address types are satisfied from the additional section, during
pap_findaddrs, and submit addr subqueries to look them up.

We no longer issue the top-level addr query: we handle the individual
subqueries ourselves, because we have to merge the results onto the
existing vector of addresses.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/types.c: Better record parsing for addr queries.
Mark Wooding [Tue, 10 Jun 2014 23:03:17 +0000 (00:03 +0100)]
src/types.c: Better record parsing for addr queries.

The parser now needs to know which kind of record it's meant to be
dealing with, so that it can convert it into the right kind of socket
address.  As a result, pap_findaddrs needs to pass in the right record
type when parsing addresses from the additional section, so we separate
out the main work into a separate function.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/types.c: Start on IPv6 support in adns_r_addr queries.
Mark Wooding [Tue, 10 Jun 2014 22:44:13 +0000 (23:44 +0100)]
src/types.c: Start on IPv6 support in adns_r_addr queries.

The way addr queries work internally is now very different.  The
toplevel query is now `virtual', and exists to spawn subqueries for each
applicable address type (currently hardcoded to A only, but this will
change later).

The toplevel query has a callback function which assembles its answer
from the various child queries, and there's a collection of support
machinery too.  (Some of the bookkeeping done during this may seem
unnecessary, but it will come in handy later.)

Because more of the work is now done in internal query callbacks, some
of the answers in the tests are reported in different order.  See
`Reentrancy: Avoid reentrant callbacks' for more detailed explanation
of a similar change.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoReentrancy: Avoid reentrant callbacks
Ian Jackson [Sun, 12 Oct 2014 21:03:43 +0000 (22:03 +0100)]
Reentrancy: Avoid reentrant callbacks

Avoid making reentrant callbacks for internal queries during other
processing.

Currently there is a theoretical reentrancy bug in
adns__submit_internal, if the internal query can itself be persuaded
to fail immediately.  The result would be a reentrant call to
callback() for the child query inside functions like typei->parse.

The possibility of such reentrancy is a bug waiting to happen - and
indeed we are going to introduce more complicated query submissions
which are more likely to fail immediately, turning this from a
theoretical to a real bug.

Solve this as follows: when an internal query completes, just put it
on a list.  Whenever we are on our way out of adns, we look through
this list and make the callbacks (until the list is empty).

This means that a fair amount of code needs to be taught that it might
encounter queries in this callback pending state.

We have to update some of the tests' expected output:

Because adns now processes the callback later, a number of the
parallel subqueries made by some of the tests end up finishing before
being cancelled - and therefore the replies to those subqueries don't
show up in the debug output as unrecognised.

Also, in case-norecurse, the deferral of the callback causes the order
of result reporting to be changed: the main query due to subqueries
finishing (`PTR(checked)') ends up later on the results queue than the
other queries dealt with in the same event loop iteration.  (The
actual answer packet to final query, `CNAME(-)', arrives later.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoReentrancy: Introduce adns__cancel
Ian Jackson [Sun, 12 Oct 2014 21:10:14 +0000 (22:10 +0100)]
Reentrancy: Introduce adns__cancel

We need a version of adns_cancel which does not call adns_returning,
for internal call sites who want to avoid reentrancy hazards.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoReentrancy: Introduce adns__returning
Ian Jackson [Sun, 12 Oct 2014 20:35:25 +0000 (21:35 +0100)]
Reentrancy: Introduce adns__returning

Replace all the adns__consistency calls on the return paths from adns
with adns__returning (except in setup.c, whose functions never set up
any queries).

I have separately gone through the public entrypoints in adns.h and
checked that they have the expected adns__consistency calls.  So with
this patch, the new imprecation about adns__returning is satisfied.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoReentrancy: Add warning comment to adns__must_gettimeofday
Ian Jackson [Sun, 12 Oct 2014 20:18:29 +0000 (21:18 +0100)]
Reentrancy: Add warning comment to adns__must_gettimeofday

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoReentrancy: adns__internal_submit does list handling
Ian Jackson [Sun, 12 Oct 2014 20:10:23 +0000 (21:10 +0100)]
Reentrancy: adns__internal_submit does list handling

Move the formulaic queue management from the call sites to
adns__internal_submit.  The requirement to do this wasn't mentioned in
adns__internal_submit's comment, and now that it's not there it
probably isn't worth remarking on.

No ultimate functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/types.c: When sorting, IPv4 prefixes match v6-mapped IPv4 addresses.
Mark Wooding [Tue, 10 Jun 2014 20:57:52 +0000 (21:57 +0100)]
src/types.c: When sorting, IPv4 prefixes match v6-mapped IPv4 addresses.

It's not very pretty, but the whole business of v6-mapped addresses is a
bodge, IMHO.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/: New type hook `query_send'.
Mark Wooding [Sat, 7 Jun 2014 21:26:34 +0000 (22:26 +0100)]
src/: New type hook `query_send'.

Puts the type code in control of how to actually send the query off.  In
particular, this allows `virtual queries' which only actually spawn
child queries for interesting records, and then collate the results.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/query.c: Export adns__cancel_children.
Mark Wooding [Sat, 7 Jun 2014 21:21:29 +0000 (22:21 +0100)]
src/query.c: Export adns__cancel_children.

We'll want this later.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/query.c: New function `adns__free_interim' for releasing memory.
Mark Wooding [Sat, 7 Jun 2014 21:29:28 +0000 (22:29 +0100)]
src/query.c: New function `adns__free_interim' for releasing memory.

Useful, for example, if you're growing a dynamically allocated array.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/: Track sizes of interim-allocated blocks.
Mark Wooding [Sat, 7 Jun 2014 18:47:28 +0000 (19:47 +0100)]
src/: Track sizes of interim-allocated blocks.

Now callers don't need to keep track of them by hand, which is annoying
and fiddly.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/: Support for transport over IPv6 (and other protocol families).
Mark Wooding [Thu, 5 Jun 2014 09:24:23 +0000 (10:24 +0100)]
src/: Support for transport over IPv6 (and other protocol families).

We create a UDP socket for each distinct protocol family during
initialization, and then use the appropriate one for each server.  The
changes are somewhat invasive, but not really very complicated.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/event.c: introduce ADD_POLLFD
Ian Jackson [Sun, 12 Oct 2014 18:50:25 +0000 (19:50 +0100)]
src/event.c: introduce ADD_POLLFD

Abstract away the fiddly fd array handling so that it is harder to
make mistakes.  We are going to want to add more fds.

No functional change in this patch.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoregress/: Include the protocol family in socket(2) lines.
Mark Wooding [Fri, 6 Jun 2014 09:40:28 +0000 (10:40 +0100)]
regress/: Include the protocol family in socket(2) lines.

I updated the test files with this rune:

grep -lZ "^ socket type=" *.sys | xargs -0r sed -i \
  's/^ socket type=/ socket domain=PF_INET type=/'

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agoregress/: Use adns_addr2text/text2addr instead of inet_aton/ntoa.
Mark Wooding [Wed, 28 May 2014 22:52:34 +0000 (23:52 +0100)]
regress/: Use adns_addr2text/text2addr instead of inet_aton/ntoa.

Makes the test harness agnostic regarding address families.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/: Support IPv6 reverse queries.
Mark Wooding [Sat, 24 May 2014 13:00:03 +0000 (14:00 +0100)]
src/: Support IPv6 reverse queries.

This involves moving most of the label parser in ckl_ptr, and the
reverse-domain constructor, into addrfam and teaching them about IPv6.

The label parser is a little tricky because it involves keeping track of
a parse state for each possible address family until we run out of
possibilities or the parse is complete.

Moving the reverse-domain constructor introduces a slightly unpleasant
hack: because knowledge of the right reverse-lookup zone belongs in
addrfam, we get adns_submit_reverse to pass a sentinel through
_reverse_any to addrfam.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/, client/: Support for AAAA lookups.
Mark Wooding [Sat, 24 May 2014 13:00:03 +0000 (14:00 +0100)]
src/, client/: Support for AAAA lookups.

I've added a couple of simple test cases.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/, client/: Use the new adns_text2addr/addr2text functions.
Mark Wooding [Sat, 24 May 2014 13:00:03 +0000 (14:00 +0100)]
src/, client/: Use the new adns_text2addr/addr2text functions.

The sortlist is now IPv6 aware.  The nameserver configuration could cope
with IPv6 addresses, but the transport machinery can't, so we pick them
out by hand.  PTR reverse-query handling still doesn't do anything
special, because we don't have AAAA query support yet.

I've also hacked adnshost's `-i' and `--reverse' options to use the new
functions, and they'll accept IPv6 addresses, but the underlying
adns_submit_reverse machinery will reject them still.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/addrfam.c (adns_addr2text): Don't print junk in debugging output.
Mark Wooding [Sat, 24 May 2014 13:00:03 +0000 (14:00 +0100)]
src/addrfam.c (adns_addr2text): Don't print junk in debugging output.

At the point we print `adns_addr2text: will print scoped addr ...' the
buffer isn't null-terminated.  Fortunately, we have the length of the
valid portion of the buffer, so use that to print only the good piece.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agoNew public-facing functions for address/text conversions.
Ian Jackson [Tue, 3 Jun 2014 19:42:01 +0000 (20:42 +0100)]
New public-facing functions for address/text conversions.

The usual functions for doing these conversions are getaddrinfo(3) and
getnameinfo(3).  Unfortunately, these seem generally to be rather buggy
(with different bugs on different platforms).  For example, the Linux
glibc implementation tries to do complicated things with AF_NETLINK
sockets even though it's only going to do a simple syntactic
transformation.

So we provide our own versions, which only handle conversions between
addresses and their text numerical representations (and don't try to do
anything complicated with DNS).

For compatibility, the functions handle various crazy things which are
generally undesirable:

  * traditional IPv4 text conversions allow degenerate forms A, A.B and
    A.B.C, where the host part is given as a simple number rather than
    being split into octets;

  * traditional IPv4 text conversions allow the individual components to
    be given in bases other than 10, using the usual C prefixes;

  * IPv6 socket addresses (but, annoyingly, not `struct in6_addr') have
    a `scope-id' field (which actually identifies what RFC4007 calls a
    `zone', i.e., the namespace in which the address should be
    interpreted), and these are described by a `%...' suffix; and

  * the `scope-id' may be a name, though the syntax and meaning of such
    names isn't defined anywhere except for the link-local scope, where
    the names and numbers are interface names and indices, which need to
    be looked up.

All of this means that there are a number of options and unfortunate
error conditions, which make the interface more complicated than is
really ideal.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/addrfam.c, src/...: Abstract out address-family-specific details.
Mark Wooding [Sat, 24 May 2014 13:00:03 +0000 (14:00 +0100)]
src/addrfam.c, src/...: Abstract out address-family-specific details.

Functions which know about the internals of particular address types and
socket-address structures live in a new file `addrfam.c'.

Some details aren't handled yet: notably, we don't have conversions
between internal address structures and external formats such as text
strings or reverse-lookup domain names.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/: Fix internals to carry around address families.
Mark Wooding [Tue, 3 Jun 2014 09:27:38 +0000 (10:27 +0100)]
src/: Fix internals to carry around address families.

This is preparatory work for IPv6 support, but there isn't any yet.
The code still acts directly on address structures (having asserted that
the family is AF_INET); switching on the address family is for later.

[ No functional change intended in this commit. -iwj ]

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/adns.h, src/types.c: Now adns_rr_addr can hold a sockaddr_in6.
Mark Wooding [Sun, 1 Jun 2014 00:20:47 +0000 (01:20 +0100)]
src/adns.h, src/types.c: Now adns_rr_addr can hold a sockaddr_in6.

This uses the recently introduced variable-size record structure
machinery so that only clients compiled against the new header file see
the larger record structure.

Note that we don't even try to actually do lookups for IPv6 addresses.
That will come later on.  This is just about sorting out the binary
interface.

Arrange that regress/case-brokenmail.sys asks for the correct record
size, because otherwise the answers get printed out wrongly.

[ I have done git-grep sizeof on a version of the head of this series
and found no un-corrected uses of sizeof(adns_rr_addr) -iwj. ]

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agoBodge adns_r_addr query-id selection and fix regression tests to match.
Mark Wooding [Fri, 30 May 2014 20:04:19 +0000 (21:04 +0100)]
Bodge adns_r_addr query-id selection and fix regression tests to match.

A future change is going to change how query-ids are allocated for
adns_r_addr queries.  So here we apply a simple bodge which will produce
the same allocation pattern, but without the complexity of the rest of
the change, and fix the test suite to match.

I used the script regress/hack-query-ids to help me modify the
case-*.sys files, though this was primarily a rather tedious manual
process.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosrc/: Lay the groundwork for variably-sized record structures.
Mark Wooding [Sat, 31 May 2014 23:13:20 +0000 (00:13 +0100)]
src/: Lay the groundwork for variably-sized record structures.

All records in a particular answer are going to be the same size: that's
not going to change.  The case we're dealing with here is that we're
going to want to include new information (e.g., new kinds of address
families) which will make the structures larger -- and would break old
binary clients.

The plan is for new clients to encode a flag saying that they understand
the extended structure in the type field (implicitly, through a header-
file change).  But all of this means that just dredging `typei->rrsz'
out of the typeinfo structure isn't going to cut it any more, so we add
a type hook to compute the right size, and make sure that we use it by
renaming the slot containing the fixed value.  Most places in the code
can avoid having to call the hook by grabbing the record size from the
answer structure.

This involves adding an extra parameter to the postsort hook, which
otherwise might not be able to determine the right size for itself.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/: Pass the wanted query's type code to adns__internal_submit.
Mark Wooding [Sat, 7 Jun 2014 18:38:01 +0000 (19:38 +0100)]
src/: Pass the wanted query's type code to adns__internal_submit.

This has two effects.  Firstly, we can propagate non-representation bits
(e.g., compatibility flags) from parent to child query.  Secondly, we
can have a single typeinfo handle several different low-level record
types.  The former is going to pay off very soon; the latter will take a
bit longer, but it'll be worth it.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/: Carve out a `representation' subfield of adns_rrtype.
Mark Wooding [Sat, 31 May 2014 23:48:59 +0000 (00:48 +0100)]
src/: Carve out a `representation' subfield of adns_rrtype.

Only the bits covered by adns_rrt_reprmask are used in translating a
query type into a typeinfo structure.

Arrange for adnstest to only print out the representation bits of the
type; otherwise lots of the regression test files need to change for no
especially good reason.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/: PTR queries now submit A subqueries, not `addr'.
Mark Wooding [Sun, 1 Jun 2014 10:07:07 +0000 (11:07 +0100)]
src/: PTR queries now submit A subqueries, not `addr'.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/types.c, regress/: Use checklabel hook to parse PTR query domains.
Mark Wooding [Sun, 1 Jun 2014 20:50:59 +0000 (21:50 +0100)]
src/types.c, regress/: Use checklabel hook to parse PTR query domains.

A PTR with forward-lookup checking needs to parse the original question
into an address, so as to have something to compare the results of the
forward queries against.  Previously this was done in pa_ptr, when the
first PTR answer came in.  But parsing can fail, and is a simple
syntactic computation on the input domain name, so it seems rather
unfortunate to delay checking the name until an answer has come in.  Now
that we have the checklabel hook, then, we might as well use it here.
(Indeed, this is in fact the reason for introducing it.)

Unfortunately, this check now rejects a number of queries early, which
previously would have resulted in a query and maybe a NODATA or NXDOMAIN
answer, but in exactly the way we just rigged all of the test cases.  So
we remove the temporary hack to adns_submit and everything stays good.
Right?

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agosrc/, regress/: Prepare for early failures in PTR queries.
Mark Wooding [Sat, 7 Jun 2014 11:26:46 +0000 (12:26 +0100)]
src/, regress/: Prepare for early failures in PTR queries.

Soon we're going to change the way adns_r_ptr queries work: in
particular, queries with names which can't be parsed back into addresses
will be rejected during submission rather than waiting for the answer to
the initial PTR question to come back.

So here we apply a really simple temporary hack to adns_submit which
approximately captures the behaviour we're after, and adjust the various
test cases to match.  We'll take this hack out when we make the proper
change to the PTR handling.

Hopefully this will persuade reviewers that there's nothing up my
sleeves while I mess with the regression tests.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
4 years agoregress/r1test: Support an `ADNS_TEST_DEBUG' env var.
Mark Wooding [Sat, 31 May 2014 22:05:19 +0000 (23:05 +0100)]
regress/r1test: Support an `ADNS_TEST_DEBUG' env var.

Amazingly, sometimes the tests don't pass.  When that happens, it's
handy to be able to debug the library and find out why.

It's a little tricky to attach GDB to the running process directly.  I
used the following:

$ ADNS_TEST_DEBUG"noip gdbserver localhost:666" ./r1test CASE

and then, in another terminal, something like

$ noip gdb adnstest_s
(gdb) target remote localhost:666

to debug the program.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
5 years agosrc/: Change how query domain names are checked.
Mark Wooding [Sat, 31 May 2014 16:26:34 +0000 (17:26 +0100)]
src/: Change how query domain names are checked.

The `qdparselabel' hook is no more.  Unescaping of the query domain is
now done in one place, and always in the same way.  Checking of the
domain name is done through a new `checklabel' hook, with a more
convenient interface.

The checklabel hook does not have the original possibly-escaped version
of the query domain available to it; it can only check the name being
submitted on the wire, not the form in which it was provided to the
library.  This eliminates the inconsistency in SRV record handling,
where

\095http._tcp.distorted.org.uk

is acceptable, but

_\104ttp._tcp.distorted.org.uk

is not.  It also now prohibits SRV queries on `_wrong', which I think
was always intended but didn't actually work.

All queries are checked, including internally generated ones, so this
can be used to store information about the query domain for later use,
so we let the hook store information in the qcontext structure.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>