summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES4
-rw-r--r--UPGRADE-1.8.txt5
-rw-r--r--channels/chan_sip.c48
-rw-r--r--configs/sip.conf.sample21
4 files changed, 15 insertions, 63 deletions
diff --git a/CHANGES b/CHANGES
index f3d134f6c..9667147e0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1109,10 +1109,6 @@ SIP changes
option is enabled, Asterisk will watch for a CNG tone in the incoming audio
for a received call. If it is detected, the channel will jump to the
'fax' extension in the dialplan.
- * Improved NAT and STUN support.
- chan_sip now can use port numbers in bindaddr, externip and externhost
- options, as well as contact a STUN server to detect its external address
- for the SIP socket. See sip.conf.sample, 'NAT' section.
* The default SIP useragent= identifier now includes the Asterisk version
* A new option, match_auth_username in sip.conf changes the matching of incoming requests.
If set, and the incoming request carries authentication info,
diff --git a/UPGRADE-1.8.txt b/UPGRADE-1.8.txt
index 905681fe2..9202cfb10 100644
--- a/UPGRADE-1.8.txt
+++ b/UPGRADE-1.8.txt
@@ -109,6 +109,11 @@ From 1.6.2 to 1.8:
482 Loop Detected response. The dialplan will just continue from where it
left off.
+* The 'stunaddr' option has been removed from chan_sip. This feature did not
+ behave as expected, had no correct use case, and was not RFC compliant. The
+ removal of this feature will hopefully be followed by a correct RFC compliant
+ STUN implementation in chan_sip in the future.
+
From 1.6.1 to 1.6.2:
* SIP no longer sends the 183 progress message for early media by
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 21c7f08f1..e6773b895 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -259,7 +259,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/translate.h"
#include "asterisk/ast_version.h"
#include "asterisk/event.h"
-#include "asterisk/stun.h"
#include "asterisk/cel.h"
#include "asterisk/data.h"
#include "asterisk/aoc.h"
@@ -1145,9 +1144,6 @@ static struct ast_sockaddr internip;
* hostname is stored in externhost, and the hostname->IP mapping
* is refreshed every 'externrefresh' seconds;
*
- * + with "stunaddr = host[:port]" we run queries every externrefresh seconds
- * to the specified server, and store the result in externaddr.
- *
* Other variables (externhost, externexpire, externrefresh) are used
* to support the above functions.
*/
@@ -1157,7 +1153,6 @@ static struct ast_sockaddr media_address; /*!< External RTP IP address if we are
static char externhost[MAXHOSTNAMELEN]; /*!< External host name */
static time_t externexpire; /*!< Expiration counter for re-resolving external host name in dynamic DNS */
static int externrefresh = 10; /*!< Refresh timer for DNS-based external address (dyndns) */
-static struct sockaddr_in stunaddr; /*!< stun server address */
static uint16_t externtcpport; /*!< external tcp port */
static uint16_t externtlsport; /*!< external tls port */
@@ -3116,14 +3111,13 @@ static void build_via(struct sip_pvt *p)
static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us, struct sip_pvt *p)
{
struct ast_sockaddr theirs;
- struct sockaddr_in externaddr_sin;
/* Set want_remap to non-zero if we want to remap 'us' to an externally
* reachable IP address and port. This is done if:
* 1. we have a localaddr list (containing 'internal' addresses marked
* as 'deny', so ast_apply_ha() will return AST_SENSE_DENY on them,
* and AST_SENSE_ALLOW on 'external' ones);
- * 2. either stunaddr or externaddr is set, so we know what to use as the
+ * 2. externaddr is set, so we know what to use as the
* externally visible address;
* 3. the remote address, 'them', is external;
* 4. the address returned by ast_ouraddrfor() is 'internal' (AST_SENSE_DENY
@@ -3145,22 +3139,16 @@ static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_socka
}
} else {
want_remap = localaddr &&
- !(ast_sockaddr_isnull(&externaddr) && stunaddr.sin_addr.s_addr) &&
+ !ast_sockaddr_isnull(&externaddr) &&
ast_apply_ha(localaddr, &theirs) == AST_SENSE_ALLOW ;
}
if (want_remap &&
(!sip_cfg.matchexternaddrlocally || !ast_apply_ha(localaddr, us)) ) {
- /* if we used externhost or stun, see if it is time to refresh the info */
+ /* if we used externhost, see if it is time to refresh the info */
if (externexpire && time(NULL) >= externexpire) {
- if (stunaddr.sin_addr.s_addr) {
- ast_sockaddr_to_sin(&externaddr, &externaddr_sin);
- ast_stun_request(sipsock, &stunaddr, NULL, &externaddr_sin);
- } else {
- if (ast_sockaddr_resolve_first(&externaddr, externhost, 0)) {
- ast_log(LOG_NOTICE, "Warning: Re-lookup of '%s' failed!\n", externhost);
- }
- externexpire = time(NULL);
+ if (ast_sockaddr_resolve_first(&externaddr, externhost, 0)) {
+ ast_log(LOG_NOTICE, "Warning: Re-lookup of '%s' failed!\n", externhost);
}
externexpire = time(NULL) + externrefresh;
}
@@ -3186,9 +3174,6 @@ static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_socka
break;
}
}
- else {
- ast_log(LOG_WARNING, "stun failed\n");
- }
ast_debug(1, "Target address %s is not local, substituting externaddr\n",
ast_sockaddr_stringify(them));
} else if (p) {
@@ -14684,7 +14669,7 @@ static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
* address and port in the SIP headers without the need for STUN.
* The address part is also reused for the media sessions.
* Note that ast_sip_ouraddrfor() still rewrites p->ourip
- * if you specify externaddr/seternaddr/stunaddr.
+ * if you specify externaddr/seternaddr/.
*/
static attribute_unused void check_via_response(struct sip_pvt *p, struct sip_request *req)
{
@@ -16875,8 +16860,6 @@ static char *sip_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_
msg = "Disabled, no localnet list";
else if (ast_sockaddr_isnull(&externaddr))
msg = "Disabled";
- else if (stunaddr.sin_addr.s_addr != 0)
- msg = "Enabled using STUN";
else if (!ast_strlen_zero(externhost))
msg = "Enabled using externhost";
else
@@ -16896,8 +16879,6 @@ static char *sip_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_
ast_strdupa(ast_sockaddr_stringify_addr(&d->netmask)));
}
}
- ast_cli(a->fd, " STUN server: %s:%d\n", ast_inet_ntoa(stunaddr.sin_addr), ntohs(stunaddr.sin_port));
-
ast_cli(a->fd, "\nGlobal Signalling Settings:\n");
ast_cli(a->fd, "---------------------------\n");
ast_cli(a->fd, " Codecs: ");
@@ -26179,7 +26160,6 @@ static int reload_config(enum channelreloadreason reason)
int registry_count = 0, peer_count = 0, timerb_set = 0, timert1_set = 0;
int subscribe_network_change = 1;
time_t run_start, run_end;
- struct sockaddr_in externaddr_sin;
int bindport = 0;
run_start = time(0);
@@ -26282,7 +26262,6 @@ static int reload_config(enum channelreloadreason reason)
/* Reset IP addresses */
ast_sockaddr_parse(&bindaddr, "0.0.0.0:0", 0);
- memset(&stunaddr, 0, sizeof(stunaddr));
memset(&internip, 0, sizeof(internip));
/* Free memory for local network address mask */
@@ -26668,12 +26647,6 @@ static int reload_config(enum channelreloadreason reason)
}
} else if (!strcasecmp(v->name, "registerattempts")) {
global_regattempts_max = atoi(v->value);
- } else if (!strcasecmp(v->name, "stunaddr")) {
- stunaddr.sin_port = htons(3478);
- if (ast_parse_arg(v->value, PARSE_INADDR, &stunaddr)) {
- ast_log(LOG_WARNING, "Invalid STUN server address: %s\n", v->value);
- }
- externexpire = time(NULL);
} else if (!strcasecmp(v->name, "bindaddr") || !strcasecmp(v->name, "udpbindaddr")) {
if (ast_parse_arg(v->value, PARSE_ADDR, &bindaddr)) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
@@ -26988,15 +26961,6 @@ static int reload_config(enum channelreloadreason reason)
}
}
}
- if (stunaddr.sin_addr.s_addr != 0) {
- ast_debug(1, "stun to %s:%d\n",
- ast_inet_ntoa(stunaddr.sin_addr) , ntohs(stunaddr.sin_port));
- ast_sockaddr_to_sin(&externaddr, &externaddr_sin);
- ast_stun_request(sipsock, &stunaddr,
- NULL, &externaddr_sin);
- ast_debug(1, "STUN sees us at %s\n",
- ast_sockaddr_stringify(&externaddr));
- }
ast_mutex_unlock(&netlock);
/* Start TCP server */
diff --git a/configs/sip.conf.sample b/configs/sip.conf.sample
index 244e22b6c..62af0e213 100644
--- a/configs/sip.conf.sample
+++ b/configs/sip.conf.sample
@@ -727,31 +727,18 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; externhost=foo.dyndns.net ; refreshed periodically
; externrefresh=180 ; change the refresh interval
;
-; c. "stunaddr = stun.server[:port]" queries the STUN server specified
-; as an argument to obtain the external address/port.
-; Queries are also sent periodically every "externrefresh" seconds
-; (as a side effect, sending the query also acts as a keepalive for
-; the state entry on the nat box):
-;
-; stunaddr = foo.stun.com:3478
-; externrefresh = 15
-;
-; NOTE: STUN is only implemented for IPv4.
-;
; Note that at the moment all these mechanism work only for the SIP socket.
-; The IP address discovered with externaddr/externhost/STUN is reused for
+; The IP address discovered with externaddr/externhost is reused for
; media sessions as well, but the port numbers are not remapped so you
; may still experience problems.
;
; NOTE 1: in some cases, NAT boxes will use different port numbers in
; the internal<->external mapping. In these cases, the "externaddr" and
-; "externhost" might not help you configure addresses properly, and you
-; really need to use STUN.
+; "externhost" might not help you configure addresses properly.
;
; NOTE 2: when using "externaddr" or "externhost", the address part is
-; also used as the external address for media sessions. Even if you
-; use "stunaddr", STUN queries will be sent only from the SIP port,
-; not from media sockets. Thus, the port information in the SDP may be wrong!
+; also used as the external address for media sessions. Thus, the port
+; information in the SDP may be wrong!
;
; In addition to the above, Asterisk has an additional "nat" parameter to
; address NAT-related issues in incoming SIP or media sessions.