diff options
author | Joshua Colp <jcolp@digium.com> | 2015-08-25 09:17:34 -0300 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2015-08-25 13:55:33 -0300 |
commit | d013ecf7486ad4a04d8ccb52340c5e62bb44b6f6 (patch) | |
tree | 2269da22459b95fc71e10faf182430ae47187478 /res/res_pjsip_session.c | |
parent | 6b8734fe6890dfa4754b07eceaab52a4712297a9 (diff) |
res_pjsip: Add common ast_sip_get_host_ip API.
Modules commonly used the pj_gethostip function for retrieving the
IP address of the host. This function does not cache the result and may
result in a DNS lookup occurring, or additional work. If the DNS
server is unreachable or network issues arise this can cause the
pj_gethostip function to block for a period of time.
This change adds an ast_sip_get_host_ip and ast_sip_get_host_ip_string
function which does the same thing but caches the host IP address at
module load time. This results in no additional work being done each
time the local host IP address is needed.
ASTERISK-25342 #close
Change-Id: I3205deb679b01fa5ac05a94b623bfd620a2abe1e
Diffstat (limited to 'res/res_pjsip_session.c')
-rw-r--r-- | res/res_pjsip_session.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index 625ab8be3..a3c0dfc7e 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -2675,12 +2675,7 @@ static struct pjmedia_sdp_session *create_local_sdp(pjsip_inv_session *inv, stru if (!ast_strlen_zero(session->endpoint->media.address)) { pj_strdup2(inv->pool_prov, &local->origin.addr, session->endpoint->media.address); } else { - pj_sockaddr localaddr; - char our_ip[PJ_INET6_ADDRSTRLEN]; - - pj_gethostip(session->endpoint->media.rtp.ipv6 ? pj_AF_INET6() : pj_AF_INET(), &localaddr); - pj_sockaddr_print(&localaddr, our_ip, sizeof(our_ip), 0); - pj_strdup2(inv->pool_prov, &local->origin.addr, our_ip); + pj_strdup2(inv->pool_prov, &local->origin.addr, ast_sip_get_host_ip_string(session->endpoint->media.rtp.ipv6 ? pj_AF_INET6() : pj_AF_INET())); } } |