diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-02-23 20:00:03 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-02-23 20:00:03 +0100 |
commit | 9a0cba318b42ea3c375f6232d7d0b8e74e60ae2b (patch) | |
tree | 0579382b5cee4c0bd2b2874444208a8094c5b269 | |
parent | eeb1d34f36f622eee48c609ccc95faee4e451ae6 (diff) | |
download | fastd-9a0cba318b42ea3c375f6232d7d0b8e74e60ae2b.tar fastd-9a0cba318b42ea3c375f6232d7d0b8e74e60ae2b.zip |
Print port for "any" address in bind log messages
-rw-r--r-- | src/fastd.c | 8 | ||||
-rw-r--r-- | src/printf.c | 10 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/fastd.c b/src/fastd.c index 9b3fd82..cf72dfc 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -260,9 +260,9 @@ static int bind_socket(fastd_context_t *ctx, const fastd_bind_address_t *addr, b if (warn) { if (addr->bindtodev) - pr_warn(ctx, "unable to bind to %I on `%s'", &addr->addr, addr->bindtodev); + pr_warn(ctx, "unable to bind to %B on `%s'", &addr->addr, addr->bindtodev); else - pr_warn(ctx, "unable to bind to %I", &addr->addr); + pr_warn(ctx, "unable to bind to %B", &addr->addr); } return -1; @@ -279,9 +279,9 @@ static void bind_sockets(fastd_context_t *ctx) { if (ctx->socks[i].fd >= 0) { if (ctx->socks[i].addr->bindtodev) - pr_info(ctx, "successfully bound to %I on `%s'", &ctx->socks[i].addr->addr, ctx->socks[i].addr->bindtodev); + pr_info(ctx, "successfully bound to %B on `%s'", &ctx->socks[i].addr->addr, ctx->socks[i].addr->bindtodev); else - pr_info(ctx, "successfully bound to %I", &ctx->socks[i].addr->addr); + pr_info(ctx, "successfully bound to %B", &ctx->socks[i].addr->addr); } } } 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; |