aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2009-10-21 13:34:49 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2009-10-21 13:34:49 +0000
commit5371fe2fc8e61b6072d3a440257fa9f9b9f3f703 (patch)
treef69ce8b4078309d49bb4e929a9af677158b267a9
parent039146041a2843457640affbda0fa063a8f6e8b1 (diff)
Add support for specifying the IP address to use for media streams in sip.conf
(closes issue #14729) Reported by: _brent_ Patches: media_address.patch uploaded by brent (license 388) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@225003 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--CHANGES2
-rw-r--r--channels/chan_sip.c9
-rw-r--r--configs/sip.conf.sample6
3 files changed, 15 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 4b3b2c616..4f073d339 100644
--- a/CHANGES
+++ b/CHANGES
@@ -48,6 +48,8 @@ SIP Changes
configuration for the externip and externhost options when tcp or tls is used.
* Added support for message body (stored in content variable) to SIP NOTIFY message
accessible via AMI and CLI.
+ * Added 'media_address' configuration option which can be used to explicitly specify
+ the IP address to use in the SDP for media (audio and video) streams.
IAX2 Changes
-----------
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 27d658a81..529562cc0 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2329,6 +2329,7 @@ static struct sockaddr_in internip;
* to support the above functions.
*/
static struct sockaddr_in externip; /*!< External IP address if we are behind NAT */
+static struct sockaddr_in media_address; /*!< External RTP IP address if we are behind NAT */
static char externhost[MAXHOSTNAMELEN]; /*!< External host name */
static time_t externexpire; /*!< Expiration counter for re-resolving external host name in dynamic DNS */
@@ -10154,7 +10155,7 @@ static void get_our_media_address(struct sip_pvt *p, int needvideo,
dest->sin_port = p->redirip.sin_port;
dest->sin_addr = p->redirip.sin_addr;
} else {
- dest->sin_addr = p->ourip.sin_addr;
+ dest->sin_addr = media_address.sin_addr.s_addr ? media_address.sin_addr : p->ourip.sin_addr;
dest->sin_port = sin->sin_port;
}
if (needvideo) {
@@ -10163,7 +10164,7 @@ static void get_our_media_address(struct sip_pvt *p, int needvideo,
vdest->sin_addr = p->vredirip.sin_addr;
vdest->sin_port = p->vredirip.sin_port;
} else {
- vdest->sin_addr = p->ourip.sin_addr;
+ vdest->sin_addr = media_address.sin_addr.s_addr ? media_address.sin_addr : p->ourip.sin_addr;
vdest->sin_port = vsin->sin_port;
}
}
@@ -24951,6 +24952,7 @@ static int reload_config(enum channelreloadreason reason)
ast_free_ha(localaddr);
memset(&localaddr, 0, sizeof(localaddr));
memset(&externip, 0, sizeof(externip));
+ memset(&media_address, 0, sizeof(media_address));
memset(&default_prefs, 0 , sizeof(default_prefs));
memset(&sip_cfg.outboundproxy, 0, sizeof(struct sip_proxy));
sip_cfg.outboundproxy.ip.sin_port = htons(STANDARD_SIP_PORT);
@@ -25320,6 +25322,9 @@ static int reload_config(enum channelreloadreason reason)
localaddr = na;
if (ha_error)
ast_log(LOG_ERROR, "Bad localnet configuration value line %d : %s\n", v->lineno, v->value);
+ } else if (!strcasecmp(v->name, "media_address")) {
+ if (ast_parse_arg(v->value, PARSE_INADDR, &media_address))
+ ast_log(LOG_WARNING, "Invalid address for media_address keyword: %s\n", v->value);
} else if (!strcasecmp(v->name, "externip")) {
if (ast_parse_arg(v->value, PARSE_INADDR, &externip))
ast_log(LOG_WARNING, "Invalid address for externip keyword: %s\n", v->value);
diff --git a/configs/sip.conf.sample b/configs/sip.conf.sample
index a6baf180a..74a739161 100644
--- a/configs/sip.conf.sample
+++ b/configs/sip.conf.sample
@@ -695,6 +695,12 @@ srvlookup=yes ; Enable DNS SRV lookups on outbound calls
; nat = force_rport ; Force rport to always be on.
; nat = yes ; Force rport to always be on and perform symmetric RTP.
; nat = comedia ; Use rport if the remote side says to use it and perform symmetric RTP.
+;
+; The IP address used for media (audio and video) in the SDP can also be overridden by using
+; the media_address configuration option. This is only applicable to the general section and
+; can not be set per-user or per-peer.
+;
+; media_address = 172.16.42.1
;----------------------------------- MEDIA HANDLING --------------------------------
; By default, Asterisk tries to re-invite media streams to an optimal path. If there's