From 8c794acbccda4d475170c1def6d3e0cd859b4699 Mon Sep 17 00:00:00 2001 From: Steven Ayre Date: Wed, 14 Mar 2012 15:05:03 +0000 Subject: [PATCH] FS-3999 --resolve mod_event_socket: add IPv6 support Signed-off-by: Travis Cross --- .../event_handlers/mod_event_socket/mod_event_socket.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index edfd291501..e90d174966 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -428,7 +428,7 @@ SWITCH_STANDARD_APP(socket_function) return; } - if ((port_name = strchr(host, ':'))) { + if ((port_name = strrchr(host, ':'))) { *port_name++ = '\0'; port = (switch_port_t) atoi(port_name); } @@ -440,12 +440,12 @@ SWITCH_STANDARD_APP(socket_function) switch_channel_set_variable(channel, "socket_host", host); - if (switch_sockaddr_info_get(&sa, host, AF_INET, port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { + if (switch_sockaddr_info_get(&sa, host, SWITCH_UNSPEC, port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket Error!\n"); return; } - if (switch_socket_create(&new_sock, AF_INET, SOCK_STREAM, SWITCH_PROTO_TCP, switch_core_session_get_pool(session)) + if (switch_socket_create(&new_sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Socket Error!\n"); return; @@ -2766,7 +2766,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime) config(); while (!prefs.done) { - rv = switch_sockaddr_info_get(&sa, prefs.ip, SWITCH_INET, prefs.port, 0, pool); + rv = switch_sockaddr_info_get(&sa, prefs.ip, SWITCH_UNSPEC, prefs.port, 0, pool); if (rv) goto fail; rv = switch_socket_create(&listen_list.sock, switch_sockaddr_get_family(sa), SOCK_STREAM, SWITCH_PROTO_TCP, pool);