From 2a72b02f6bb96e9c098a5f07386bbccf859d9eac Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Mon, 11 Feb 2013 13:39:55 -0600
Subject: [PATCH] add switch_print_host

---
 src/include/switch_utils.h |  3 +++
 src/switch_utils.c         | 11 +++++++++++
 2 files changed, 14 insertions(+)

diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h
index 11a4cdc38e..6c9b52505d 100644
--- a/src/include/switch_utils.h
+++ b/src/include/switch_utils.h
@@ -228,6 +228,9 @@ typedef union{
 
 SWITCH_DECLARE(switch_bool_t) switch_testv6_subnet(ip_t _ip, ip_t _net, ip_t _mask);
 
+
+SWITCH_DECLARE(char *) switch_print_host(switch_sockaddr_t *addr, char *buf, switch_size_t len);
+
 #define switch_goto_status(_status, _label) status = _status; goto _label
 #define switch_goto_int(_n, _i, _label) _n = _i; goto _label
 #define switch_samples_per_packet(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval)))
diff --git a/src/switch_utils.c b/src/switch_utils.c
index efbc335486..d54fabaa06 100644
--- a/src/switch_utils.c
+++ b/src/switch_utils.c
@@ -64,6 +64,17 @@ SWITCH_DECLARE(int) switch_inet_pton(int af, const char *src, void *dst)
 }
 #endif
 
+SWITCH_DECLARE(char *) switch_print_host(switch_sockaddr_t *addr, char *buf, switch_size_t len)
+{
+	switch_port_t port;
+
+	switch_get_addr(buf, len, addr);
+	port = switch_sockaddr_get_port(addr);
+
+	snprintf(buf + strlen(buf), len - strlen(buf), ":%d", port);
+	return buf;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_frame_alloc(switch_frame_t **frame, switch_size_t size)
 {
 	switch_frame_t *new_frame;