]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add switch_print_host
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 11 Feb 2013 19:39:55 +0000 (13:39 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 1 Apr 2013 02:27:25 +0000 (21:27 -0500)
src/include/switch_utils.h
src/switch_utils.c

index 11a4cdc38e5a54671dce364b2950186633882b7b..6c9b52505dea50c8b7e4f4d891058b5183a8a238 100644 (file)
@@ -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)))
index efbc3354867749e2652627a05419e4e8c85490ae..d54fabaa06c8255a32a6f48ff5e8dbf7d66444d2 100644 (file)
@@ -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;