dh: move write_mpbin in to dh.c This function has a hazardous API. In fact, the one call site misuses it, as we shall see in a moment. If we wanted a thing like this with a less hazardous API we probably wouldn't base it on mpz_get_str nowadays. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
util: pathprefix_template: New facility We will use this for constructing public and private key filenames to load. No callers yet. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
util: priomsg: Provide and use priomsg_update_fixed We are going to want to reuse this. No functional change. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
util: Reorder information in NAK log messages In particular, put the supplied reason string last so that it will be unambiguous. And putting the message type first seems more natural. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
util: priomsg: Allow passing priomsg_update_p a null pm This makes it more convenient for callers who may not have anything to update. No functional change with any existing caller, of why there aren't any anyway. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
util: priomsg: New facility No callers yet. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
util: truncmsg: New way of manipulating buffers No callers yet. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
buffer: Abolish unused `flags' This variable is never examined. This has the comment `How paranoid should we be?' but in fact the paranoia level (such as it is) is set by which entrypoint we call. It would not be appropriate to make this a buffer property anyway. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
iaddr_to_string: Do not falsely claim bad addrs are scoped IPv6 In particular, if the AF is neither INET nor INET6, adns_addr2text quite rightly fails with EAFNOSUPPORT. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
hash: Provide and use hash_hash connvenience function No functional change. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
style: util.[ch]: Introduce hex_encode_alloc name Prompted by review of 7be31e47b2a8 "util.[ch]: Factor out hex encoding and decoding utilities." which says The interface is a bit odd, but it will fit with the uses I have in mind. Not sure if it's the encode or decode interface which is referred to. Certainly there should be a non-allocating variant. I decided to rename the allocating one. The two separate buffer arguments to hex_decode are indeed a bit odd but IMO tolerable. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
style: util.[ch]: Move doc comments into header file I think doc comments belong (only) in the header. Spotted this anomaly during review of 7be31e47b2a8 "util.[ch]: Factor out hex encoding and decoding utilities." (although it wasn't introduced there). Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
util.[ch]: Factor out hex encoding and decoding utilities. Also improve the decoder's error handling. The interface is a bit odd, but it will fit with the uses I have in mind. Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
util.c: Don't byte-swap IPv4 addresses, even if we don't have IPv6. The `string_item_to_ipaddr' function returns addresses as a single integer in host byte order. But this isn't what's wanted for setting up `struct sockaddr_in', for example. The function `adns_text2addr' does the right thing. I think this has always been wrong for setting up UDP sockets: before the introduction of `string_item_to_iaddr', `udp_apply' would call `string_item_to_ipaddr' directly, and neglected to swap the bytes. Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Administrivia: Fix erroneous GPL3+ licence notices "version d or later" (!) Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
comm clientinfo: Provide clientinfo interface This will allow a comm client to provide information from its configuration dicts to the comm, so that a comm can be shared by multiple clients but still have client-specific configuration. Currently, this new interface has no callers, and no consumers. No comm clients call comm_if->_clientinfo(); they all just pass NULL. No comms take any notice of the clientinfo information; they always return NULL for the clientinfo*. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Copyright updates - update to GPLv3, etc. Update to GPLv3. secnet as actually installed is GPLv3+ anyway because it depends on python-ipaddr (Apache 2.0, which is GPLv2-incompatible), adns (now GPLv3+), and libgmp (now LGPLv3+). Also: * Add missing copyright notices and credits. * Get rid of old FSF street address; use URL instead. * Remove obsolete LICENCE.txt (which was for snprintf reimplementation). * Remove obsolete references to Cendio (for old ipaddr.py, now gone). Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Portability fix: Build where sizeof is not compatible with int On Debian amd64, for example: util.c: In function 'iaddr_to_string': util.c:575:3: error: field precision specifier '.*' expects argument of type 'int', but argument 3 has type 'long unsigned int' Thanks to Jonathan Amery for the report. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Static buffers: Provide new rotating static buffer macros Provide new macros SBUF_DEFINE and SBUF which replace the open coded rotating static buffers in ipaddr_getbuf (ipaddr_to_string and subnet_to_string) and iaddr_to_string. No functional change. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Static buffers: Replace references to bufs[b] Introduce a new macro SBUF which currently refers to bufs[b]. We are going to change its definition in a moment. Splitting the patches up this way makes it easier to see that they're right. No functional change in this patch. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>