summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Traud <pabstraud@compuserve.com>2016-09-23 16:54:28 +0200
committerAlexander Traud <pabstraud@compuserve.com>2016-09-23 09:59:14 -0500
commit0502675e5c7ab77b7359776b77166d28760978af (patch)
tree3f4a0e0c2a8fb97e0a597db4acc4b8d70d15789b
parent7cce1a781754820ce889426287765df39c60d083 (diff)
chan_sip: Resolve externhost not to IPv6; instead go for IPv4.
For the channel driver chan_sip, you specify externhost=example.com in sip.conf when your Asterisk is behind a NAT and your IP address is assigned dynamically. Or stated differently: You do not have a static IP address to use "externaddr" directly. This NAT support is quite handy but just about IPv4. Previously, Asterisk resolved "externhost" to any IP version. When the first DNS answer resolved to an IPv6, Asterisk sent an IPv6 in SIP/SDP for origin (o=) and connection (c=). This happened in outgoing SIP-REGISTER and while answering SIP-INVITE. If the remote peer is IPv4-only, it might not handle o=/c= with an IPv6. This change makes sure, no IPv6 is resolved anymore for "externhost". ASTERISK-18232 #close Reported by: Jacek Kowalski Tested by: Alexander Traud patches: changes.patch submitted by Alessandro Crespi Change-Id: If68eedbeff65bd1c1d8a9ed921c02ba464b32dac
-rw-r--r--channels/chan_sip.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 51a08690e..5ef197b45 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -3838,7 +3838,7 @@ static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_socka
(!sip_cfg.matchexternaddrlocally || !ast_apply_ha(localaddr, us)) ) {
/* if we used externhost, see if it is time to refresh the info */
if (externexpire && time(NULL) >= externexpire) {
- if (ast_sockaddr_resolve_first(&externaddr, externhost, 0)) {
+ if (ast_sockaddr_resolve_first_af(&externaddr, externhost, 0, AST_AF_INET)) {
ast_log(LOG_NOTICE, "Warning: Re-lookup of '%s' failed!\n", externhost);
}
externexpire = time(NULL) + externrefresh;
@@ -32455,7 +32455,7 @@ static int reload_config(enum channelreloadreason reason)
externexpire = 0;
} else if (!strcasecmp(v->name, "externhost")) {
ast_copy_string(externhost, v->value, sizeof(externhost));
- if (ast_sockaddr_resolve_first(&externaddr, externhost, 0)) {
+ if (ast_sockaddr_resolve_first_af(&externaddr, externhost, 0, AST_AF_INET)) {
ast_log(LOG_WARNING, "Invalid address for externhost keyword: %s\n", externhost);
}
externexpire = time(NULL);