From 1a629f8a54982fc50c01125690fe04b4aa2fa924 Mon Sep 17 00:00:00 2001 From: pabelanger Date: Thu, 14 Oct 2010 15:15:12 +0000 Subject: Add the ability for ast_find_ourip to return IPv4, IPv6 or both. While testing chan_gtalk I noticed jabber was using my IPv6 address and not IPv4. When using bindaddr=0.0.0.0 it is possible for ast_find_ourip() to return both IPv6 and IPv4 results. Adding a family parameter gives you the ablility to choose. Since jabber/gtalk/h323 do not support IPv6, we should only return IPv4 results. Review: https://reviewboard.asterisk.org/r/973/ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.8@291758 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_gtalk.c | 4 ++-- channels/chan_h323.c | 2 +- channels/chan_jingle.c | 10 ++++++---- channels/chan_sip.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'channels') diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c index 326ea7035..36ef90307 100644 --- a/channels/chan_gtalk.c +++ b/channels/chan_gtalk.c @@ -859,7 +859,7 @@ static int gtalk_create_candidates(struct gtalk *client, struct gtalk_pvt *p, ch ast_rtp_instance_get_local_address(p->rtp, &sin_tmp); ast_sockaddr_to_sin(&sin_tmp, &sin); ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr); - ast_find_ourip(&us, &bindaddr_tmp); + ast_find_ourip(&us, &bindaddr_tmp, AF_INET); if (!strcmp(ast_sockaddr_stringify_addr(&us), "127.0.0.1")) { ast_log(LOG_WARNING, "Found a loopback IP on the system, check your network configuration or set the bindaddr attribute."); } @@ -2217,7 +2217,7 @@ static int load_module(void) } ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr); - if (ast_find_ourip(&ourip_tmp, &bindaddr_tmp)) { + if (ast_find_ourip(&ourip_tmp, &bindaddr_tmp, AF_INET)) { ast_log(LOG_WARNING, "Unable to get own IP address, Gtalk disabled\n"); return 0; } diff --git a/channels/chan_h323.c b/channels/chan_h323.c index 2362d9a49..89b452dbc 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -965,7 +965,7 @@ static int __oh323_rtp_create(struct oh323_pvt *pvt) struct ast_sockaddr tmp; ast_sockaddr_from_sin(&tmp, &bindaddr); - if (ast_find_ourip(&our_addr, &tmp)) { + if (ast_find_ourip(&our_addr, &tmp, AF_INET)) { ast_mutex_unlock(&pvt->lock); ast_log(LOG_ERROR, "Unable to locate local IP address for RTP stream\n"); return -1; diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c index 25b4d7e45..c12704835 100644 --- a/channels/chan_jingle.c +++ b/channels/chan_jingle.c @@ -623,7 +623,7 @@ static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p, ast_rtp_instance_get_local_address(p->rtp, &sin_tmp); ast_sockaddr_to_sin(&sin_tmp, &sin); ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr); - ast_find_ourip(&us_tmp, &bindaddr_tmp); + ast_find_ourip(&us_tmp, &bindaddr_tmp, AF_INET); us.s_addr = htonl(ast_sockaddr_ipv4(&us_tmp)); /* Setup our first jingle candidate */ @@ -1904,15 +1904,17 @@ static int load_module(void) } sched = sched_context_create(); - if (!sched) + if (!sched) { ast_log(LOG_WARNING, "Unable to create schedule context\n"); + } io = io_context_create(); - if (!io) + if (!io) { ast_log(LOG_WARNING, "Unable to create I/O context\n"); + } ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr); - if (ast_find_ourip(&ourip_tmp, &bindaddr_tmp)) { + if (ast_find_ourip(&ourip_tmp, &bindaddr_tmp, AF_INET)) { ast_log(LOG_WARNING, "Unable to get own IP address, Jingle disabled\n"); return 0; } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 58e3f5c4f..302ca35a1 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -27086,7 +27086,7 @@ static int reload_config(enum channelreloadreason reason) /* Set UDP address and open socket */ ast_sockaddr_copy(&internip, &bindaddr); - if (ast_find_ourip(&internip, &bindaddr)) { + if (ast_find_ourip(&internip, &bindaddr, 0)) { ast_log(LOG_WARNING, "Unable to get own IP address, SIP disabled\n"); ast_config_destroy(cfg); return 0; -- cgit v1.2.3