From 4c8bf297fb9c78fc59dc607c5c4fb221a873f731 Mon Sep 17 00:00:00 2001 From: Luis Azedo Date: Thu, 30 Jul 2015 16:09:56 +0100 Subject: [PATCH] FS-7917 add check for ipv6 in sofia_glue_create_via --- src/mod/endpoints/mod_sofia/sofia_glue.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 0a46691a0e..ec25e3645d 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -455,17 +455,18 @@ char *sofia_glue_create_external_via(switch_core_session_t *session, sofia_profi char *sofia_glue_create_via(switch_core_session_t *session, const char *ip, switch_port_t port, sofia_transport_t transport) { + char *ipv6 = strchr(ip, ':'); if (port && port != 5060) { if (session) { - return switch_core_session_sprintf(session, "SIP/2.0/%s %s:%d;rport", sofia_glue_transport2str(transport), ip, port); + return switch_core_session_sprintf(session, "SIP/2.0/%s %s%s%s:%d;rport", sofia_glue_transport2str(transport), ipv6 ? "[" : "", ip, ipv6 ? "]" : "", port); } else { - return switch_mprintf("SIP/2.0/%s %s:%d;rport", sofia_glue_transport2str(transport), ip, port); + return switch_mprintf("SIP/2.0/%s %s%s%s:%d;rport", sofia_glue_transport2str(transport), ipv6 ? "[" : "", ip, ipv6 ? "]" : "", port); } } else { if (session) { - return switch_core_session_sprintf(session, "SIP/2.0/%s %s;rport", sofia_glue_transport2str(transport), ip); + return switch_core_session_sprintf(session, "SIP/2.0/%s %s%s%s;rport", sofia_glue_transport2str(transport), ipv6 ? "[" : "", ip, ipv6 ? "]" : ""); } else { - return switch_mprintf("SIP/2.0/%s %s;rport", sofia_glue_transport2str(transport), ip); + return switch_mprintf("SIP/2.0/%s %s%s%s;rport", sofia_glue_transport2str(transport), ipv6 ? "[" : "", ip, ipv6 ? "]" : ""); } } }