-static int udp_beforepoll(void *state, struct pollfd *fds, int *nfds_io,
- int *timeout_io, const struct timeval *tv,
- uint64_t *now)
+/*
+ * Re comm_addr.ix: This field allows us to note in the comm_addr
+ * which socket an incoming packet was received on. This is required
+ * for conveniently logging the actual source of a packet. But the ix
+ * does not formally form part of the address: it is not used when
+ * sending, nor when comparing two comm_addrs.
+ *
+ * The special value -1 means that the comm_addr was constructed by
+ * another module in secnet (eg the resolver), rather than being a
+ * description of the source of an incoming packet.
+ */
+
+static const char *udp_addr_to_string(void *commst, const struct comm_addr *ca)
+{
+ struct udp *st=commst;
+ struct udpsocks *socks=&st->socks;
+ static char sbuf[100];
+ int ix=ca->ix>=0 ? ca->ix : 0;
+
+ assert(ix>=0 && ix<socks->n_socks);
+ snprintf(sbuf, sizeof(sbuf), "udp:%s%s-%s",
+ iaddr_to_string(&socks->socks[ix].addr),
+ ca->ix<0 ? "&" : "",
+ iaddr_to_string(&ca->ia));
+ return sbuf;
+}
+
+static int udp_socks_beforepoll(void *state, struct pollfd *fds, int *nfds_io,
+ int *timeout_io)