diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/net/address.c | 11 | ||||
-rw-r--r-- | src/lib/net/address.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/net/address.c b/src/lib/net/address.c index 7f63593875..76c7aadd22 100644 --- a/src/lib/net/address.c +++ b/src/lib/net/address.c @@ -1206,6 +1206,17 @@ fmt_addr32(uint32_t addr) return buf; } +/** Like fmt_addrport(), but takes <b>addr</b> as a host-order IPv4 + * addresses. Also not thread-safe, also clobbers its return buffer on + * repeated calls. */ +const char * +fmt_addr32_port(uint32_t addr, uint16_t port) +{ + static char buf[INET_NTOA_BUF_LEN + 6]; + snprintf(buf, sizeof(buf), "%s:%u", fmt_addr32(addr), port); + return buf; +} + /** Return a string representing <b>family</b>. * * This string is a string constant, and must not be freed. diff --git a/src/lib/net/address.h b/src/lib/net/address.h index eca5ddab75..5ab654ef1d 100644 --- a/src/lib/net/address.h +++ b/src/lib/net/address.h @@ -236,6 +236,7 @@ const char *fmt_addr_impl(const tor_addr_t *addr, int decorate); const char *fmt_addrport(const tor_addr_t *addr, uint16_t port); #define fmt_addrport_ap(ap) fmt_addrport(&(ap)->addr, (ap)->port) const char *fmt_addr32(uint32_t addr); +const char *fmt_addr32_port(uint32_t addr, uint16_t port); const char *fmt_af_family(sa_family_t family); const char *fmt_addr_family(const tor_addr_t *addr); |