pkstream/pkstream.c: Be more careful about handling address families. * Introduce a concept of `known' address families. Currently, only `AF_INET' is known. * Filter `struct addrinfo' chains for known address families. If we come up short, complain. * Tweak `aihints' to arrange that addresses which are supposed to match up actually will do: so server peer and bind addresses should match; client bind and connect addresses should match; and UDP local and remote addresses should match. * Initialize address structures using the `ai_family' slot from the appropriate `struct addrinfo' structure.
pkstream/pkstream.c: Use `getaddrinfo' to resolve addresses and services. This will give us multiple addresses for simple queries, which we must do something sensible with: * for server bind and peer addresses, we accumulate them in our address vectors as before; * for client bind addresses, and local UDP addresses, we just take the first match, and hope that's good enough; and * for client connect addresses, and remote UDP addresses, we try to connect to each address in turn and take the first one that works. Some utility functions have been added or enhanced: * `pushaddr' has become `pushaddrs', and its job is now to push the addresses from a `struct addrinfo' chain onto an address vector; and * `copyaddr' has been introduced to do possible partial copies of addresses. Note that everything is still strictly IPv4 throughout. But almost all of the pieces are now in place...
pkstream/pkstream.c: Allow multiple listening and peer addresses. When being a TCP server. * Accept multiple `-b' and `-p' options, and accumulate their values into string vectors; * expand the `connwait' addresses into vectors; * when resolving addresses, accumulate the addresses into the appropriate result vectors; * maintain multiple `sel_file' objects waiting for their respective listening sockets; * and search the vector of peers when accepting incoming connections (an empty vector means that all remote addresses are permitted, so we no longer need to dig into the address structure here).
pkstream/pkstream.c: Introduce helper functions to fiddle with addresses. The remaining places where pieces of addresses are fiddled with directly, outside of these new functions, are: * in `doaccept', where we continue inspect the peer address to see if it's a wildcard, because we'll handle this in a very different way later; and * in `parseaddr', which needs to fill in addresses and port numbers.
pkstream/pkstream.c: Rearrange socket setup, particularly `parseaddr'. * Have `parseaddr' fill in a socket address structure directly. * Change the interface to pass in either separate host and service (does this remind you of anything?) names, or a single combined string to be parsed apart, as indicated by a new flag `paf_parse'. * Have `main' keep track of the various host and service name strings and then sort everything out at the end, rather than exercising the resolver during option parsing. Take advantage of this by diagnosing incompatible option combinations. * To make this work, upgrade `cw.peer' to be full socket address. * Factor out socket-address initialization, and initialize the structures on demand rather than in advance.
Various C files: Ignore write errors of UDP and IP datagrams. These packets are expected to go missing periodically and everyone will cope. Unfortunately, GCC wants us to do something with the return code from write(2), so we explicitly assign it to a write-only variable and hope that its data-flow analysis is done after it checks for return-code ignoring.
Build: Fix construction of manual pages. Firstly, there was a bug in vars.am: the suffix rule used to construct manpages was broken because suffix rules aren't allowed to have dependencies of their own. So purge defs.man.in (we now just have defs.man) and confsubst the entire manpage each time. Secondly, in preparation for new manpages for services, consolidate the summary-building machinery into vars.am. The server makefile no longer needs a special case for tripe-admin.8. To keep things tidy, defs.man and make-summary have been stashed in common. This seems as good a place as any.