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)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 13 Jun 2014 08:57:41 +0000 (09:57 +0100)
commitb3209391cb7207697e4eb1097223dc224b9e260e
treed30c7318fe6aa1d95b92b3377dd83fd630418dc2
parentddf8d57f24522e830f4e8817790f92786022d988
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