adns_str* etc.: Permit calling on adns_s_* values (not _max_) This is useful because otherwise an application may not use these values for its own errors, if that might result in them being passed to the adns_strerror etc. No code change: the table already has all the values. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
adns_str* etc.: Return NULL rather than crashing, and docs Previously, calling these functions with arbitrary values would cause them to do a struct member lookup on a null pointer. Now they return the pointer instead. Also, some users have been confused by the docs, and have passsed, for example, adns_s_max_misconfig. This is also not permitted. Clarify that only values actually returned by adns are allowed. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
time handling: Support use of CLOCK_MONOTONIC This involves a new initflag. And introducing a wrapper for gettimeofday(). Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk> squash! time handling: Support use of CLOCK_MONOTONIC squash! time handling: Support use of CLOCK_MONOTONIC
Update copyright dates everywhere Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Config parsing: Provide a way to ignore unknown resolv.conf contents You can now set the option `adns_ignoreunkcfg'. This is relevant to Debian #411263. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
API: Reject unknown flags Check for unknown flags in adns_initflags, adns_queryflags, and adns_rrtype. This will allow us to extend the API in the future but still retain backward-ABI-safety: new applications which pass a new flag but are run against old adns will get an error (typically, ENOSYS). In each case we reserve a few of the spare bits for `harmless' extensions: flags which we decide, at the time of introduction, that it is harmless for old implementations to ignore. We simply provide explicit hex values for the flags. This is easier than listing all of the actually-defined flags, and probably no less reliable. Failing to add a new flag to the check as well as to the enum will produce an obvious error (unless the `harmless' flag is used - and those are at the top of the space to reduce that probability). In the case of adns_rrtype, all of the external functions quickly pass the type to adns__findtype, so we can do the check there. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Remove RCSids. We are using git now and it doesn't do this kind of thing. They are a pain, anyway. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
API: Provide adns_qf_cname_strict In the medium term we want to make adns tolerate cname chains better. One thing we want to do is to change the default to be adns_qf_cname_loose. So introduce a flag now that allows applications to explicitly request strict. For now this new flag has no effect. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
enums: Add `sizeforce' member value The C standard helpfully permits enums with a small range of values to be short. This effect is not desirable in an API because it means that adding new values (new flags, say) may cause ABI incompatibility. Add some `sizeforce' members to relevant enums in the API. In none of the three cases do we expect this to actually cause an ABI break on actual practical platforms, because the values we choose are within the same power-of-two bitwidth. Specifically: max value in adns 1.4 new max value adns_initflags 0x0300 0x7fff adns_queryflags 0x0ff00000 0x7fffffff adns_rrtype 0x20000 0x7fffffff adns_status 499 unchanged The small max value of adns_initflags is unfortunate. But we can't change it without actually breaking the ABI on actual existing platforms. We can put off biting that bullet until we run out of initflags - there are still three flags remaining. This patch is not expected to have any practical effect with existing platforms and compilers but it makes the code more correct and less likely to be misoptimised by a future aggressive compiler. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
adns.h: Generalise some mentions of A RRs. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Licensing: Update copyright dates for Ian Jackson Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Licensing: Delete FSF street address Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Licensing: Update version in file header comments Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
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>
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>
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>
src/, client/: Support for AAAA lookups. I've added a couple of simple test cases. Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
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>
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>
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>