chiark / gitweb /
New public-facing functions for address/text conversions.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 3 Jun 2014 19:42:01 +0000 (20:42 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 12 Oct 2014 19:39:47 +0000 (20:39 +0100)
commit6c5ce29f1b7e82b0c5b9a832d1d23f560fd979f4
treee9f5e5b1dd74a2995f4807f7e469851541a057cb
parent07554ccd8286775b4f88a608ba3b94ff7b9efaf9
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.

[Code by iwj; commit message and merging by mdw.]
client/Makefile.in
client/addrtext.c [new file with mode: 0644]
src/addrfam.c
src/adns.h