Skip to content
Snippets Groups Projects
Commit 5dd99465 authored by Alexander Traud's avatar Alexander Traud
Browse files

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
parent 8d5219e6
No related branches found
No related tags found
No related merge requests found
......@@ -3843,7 +3843,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;
......@@ -32573,7 +32573,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);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment