chiark / gitweb /
comm: Introduce comm_addr_to_string
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 11 May 2014 18:12:03 +0000 (19:12 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 15 May 2014 01:02:14 +0000 (02:02 +0100)
Convenience function for calling addr_to_string.  Use it where
appropriate.

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
secnet.h
site.c
util.c

index 44b180f..647c940 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -344,6 +344,11 @@ struct comm_if {
     comm_addr_to_string_fn *addr_to_string;
 };
 
+static inline const char *comm_addr_to_string(const struct comm_addr *ca)
+{
+    return ca->comm->addr_to_string(ca->comm->st, ca);
+}
+
 /* LOG interface */
 
 #define LOG_MESSAGE_BUFLEN 1023
diff --git a/site.c b/site.c
index 1af21ea..1d8c777 100644 (file)
--- a/site.c
+++ b/site.c
@@ -1933,14 +1933,14 @@ static void transport_peers_debug(struct site *st, transport_peers *dst,
         i++, (argp+=stride?stride:sizeof(*args))) {
        const struct comm_addr *ca=(void*)argp;
        slog(st, LOG_PEER_ADDRS, " args: addrs[%d]=%s",
-            i, ca->comm->addr_to_string(ca->comm->st,ca));
+            i, comm_addr_to_string(ca));
     }
     for (i=0; i<dst->npeers; i++) {
        struct timeval diff;
        timersub(tv_now,&dst->peers[i].last,&diff);
        const struct comm_addr *ca=&dst->peers[i].addr;
        slog(st, LOG_PEER_ADDRS, " peers: addrs[%d]=%s T-%ld.%06ld",
-            i, ca->comm->addr_to_string(ca->comm->st,ca),
+            i, comm_addr_to_string(ca),
             (unsigned long)diff.tv_sec, (unsigned long)diff.tv_usec);
     }
 }
diff --git a/util.c b/util.c
index 9a20420..3bfa6bb 100644 (file)
--- a/util.c
+++ b/util.c
@@ -394,7 +394,7 @@ void send_nak(const struct comm_addr *dest, uint32_t our_index,
     if (logwhy)
        Message(M_INFO,"%s: %08"PRIx32"<-%08"PRIx32": %08"PRIx32":"
                " %s; sending NAK\n",
-               dest->comm->addr_to_string(dest->comm->st,dest),
+               comm_addr_to_string(dest),
                our_index, their_index, msgtype, logwhy);
     dest->comm->sendmsg(dest->comm->st, buf, dest);
 }