From 645edfe3201a4b1513f91a81862e240f9ea73242 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 24 Feb 2010 18:13:28 +0000 Subject: [PATCH] add force_local_ip_v4 and force_local_ip_v6 global vars to override the core funcs to always discover the same ip git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16801 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_utils.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/switch_utils.c b/src/switch_utils.c index 0623e8a45f..c0aabcdcac 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -980,6 +980,8 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int *ma { switch_status_t status = SWITCH_STATUS_FALSE; char *base; + const char *force_local_ip_v4 = switch_core_get_variable("force_local_ip_v4"); + const char *force_local_ip_v6 = switch_core_get_variable("force_local_ip_v6"); #ifdef WIN32 SOCKET tmp_socket; @@ -996,6 +998,22 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int *ma char abuf[25] = ""; #endif + switch (family) { + case AF_INET: + if (force_local_ip_v4) { + switch_copy_string(buf, force_local_ip_v4, len); + } + return SWITCH_STATUS_SUCCESS; + case AF_INET6: + if (force_local_ip_v6) { + switch_copy_string(buf, force_local_ip_v6, len); + } + return SWITCH_STATUS_SUCCESS; + default: + break; + } + + if (len < 16) { return status; }