summaryrefslogtreecommitdiffstats
path: root/src/printf.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-02-23 20:00:03 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-02-23 20:00:03 +0100
commit9a0cba318b42ea3c375f6232d7d0b8e74e60ae2b (patch)
tree0579382b5cee4c0bd2b2874444208a8094c5b269 /src/printf.c
parenteeb1d34f36f622eee48c609ccc95faee4e451ae6 (diff)
downloadfastd-9a0cba318b42ea3c375f6232d7d0b8e74e60ae2b.tar
fastd-9a0cba318b42ea3c375f6232d7d0b8e74e60ae2b.zip
Print port for "any" address in bind log messages
Diffstat (limited to 'src/printf.c')
-rw-r--r--src/printf.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/printf.c b/src/printf.c
index 57d6973..e55ae20 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -39,12 +39,15 @@ static inline int snprintf_safe(char *buffer, size_t size, const char *format, .
return ret < 0 ? 0 : ret > size ? size : ret;
}
-static int snprint_peer_address(const fastd_context_t *ctx, char *buffer, size_t size, const fastd_peer_address_t *address) {
+static int snprint_peer_address(const fastd_context_t *ctx, char *buffer, size_t size, const fastd_peer_address_t *address, bool bind_address) {
char addr_buf[INET6_ADDRSTRLEN] = "";
switch (address->sa.sa_family) {
case AF_UNSPEC:
- return snprintf(buffer, size, "any");
+ if (bind_address)
+ return snprintf_safe(buffer, size, "any:%u", ntohs(address->in.sin_port));
+ else
+ return snprintf(buffer, size, "any");
case AF_INET:
if (inet_ntop(AF_INET, &address->in.sin_addr, addr_buf, sizeof(addr_buf)))
@@ -131,10 +134,11 @@ int fastd_vsnprintf(const fastd_context_t *ctx, char *buffer, size_t size, const
break;
case 'I':
+ case 'B':
p = va_arg(ap, const fastd_peer_address_t*);
if (p)
- buffer += snprint_peer_address(ctx, buffer, buffer_end-buffer, (const fastd_peer_address_t*)p);
+ buffer += snprint_peer_address(ctx, buffer, buffer_end-buffer, (const fastd_peer_address_t*)p, *format == 'B');
else
buffer += snprintf_safe(buffer, buffer_end-buffer, "(null)");
break;