+static const char *saddr_to_string(const struct sockaddr_in *sin) {
+ static char bufs[2][100];
+ static int b;
+
+ b ^= 1;
+ snprintf(bufs[b], sizeof(bufs[b]), "[%s]:%d",
+ inet_ntoa(sin->sin_addr),
+ ntohs(sin->sin_port));
+ return bufs[b];
+}
+
+static const char *addr_to_string(void *commst, const struct comm_addr *ca) {
+ struct udp *st=commst;
+ static char sbuf[100];
+
+ struct sockaddr_in la;
+ la.sin_addr.s_addr=htonl(st->addr);
+ la.sin_port=htons(st->port);
+
+ snprintf(sbuf, sizeof(sbuf), "udp:%s-%s",
+ saddr_to_string(&la), saddr_to_string(&ca->sin));
+ return sbuf;
+}
+