summaryrefslogtreecommitdiff
path: root/main/sdp_state.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2017-05-05 14:30:40 -0500
committerRichard Mudgett <rmudgett@digium.com>2017-05-09 12:57:57 -0500
commit16785c0908791b0bd583599ea9ce0ad5cb479f81 (patch)
tree6e581b79b8219ed53888e3f20cf677ec1a898778 /main/sdp_state.c
parent3dae4279be4f61f16473d3e5ea9d45d1f8462eda (diff)
SDP: Add interface_address to specify our address to use.
When we optionally set the interface_address we are forcing the media to go out a specific interface address. This allows us to optionally have the media go out the interface that SIP signalling came in on or if we are configured to have the media always go out a specific address. Change-Id: I160d9fac322a075bd2557b430632544178196189
Diffstat (limited to 'main/sdp_state.c')
-rw-r--r--main/sdp_state.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/main/sdp_state.c b/main/sdp_state.c
index 3a87a81e2..0da93e4ac 100644
--- a/main/sdp_state.c
+++ b/main/sdp_state.c
@@ -150,13 +150,15 @@ static struct ast_rtp_instance *create_rtp(const struct ast_sdp_options *options
{
struct ast_rtp_instance *rtp;
struct ast_rtp_engine_ice *ice;
- struct ast_sockaddr temp_media_address;
static struct ast_sockaddr address_rtp;
- struct ast_sockaddr *media_address = &address_rtp;
+ struct ast_sockaddr *media_address = &address_rtp;
- if (options->bind_rtp_to_media_address && !ast_strlen_zero(options->media_address)) {
- ast_sockaddr_parse(&temp_media_address, options->media_address, 0);
- media_address = &temp_media_address;
+ if (!ast_strlen_zero(options->interface_address)) {
+ if (!ast_sockaddr_parse(&address_rtp, options->interface_address, 0)) {
+ ast_log(LOG_ERROR, "Attempted to bind RTP to invalid media address: %s\n",
+ options->interface_address);
+ return NULL;
+ }
} else {
if (ast_check_ipv6()) {
ast_sockaddr_parse(&address_rtp, "::", 0);
@@ -165,7 +167,8 @@ static struct ast_rtp_instance *create_rtp(const struct ast_sdp_options *options
}
}
- if (!(rtp = ast_rtp_instance_new(options->rtp_engine, sched, media_address, NULL))) {
+ rtp = ast_rtp_instance_new(options->rtp_engine, sched, media_address, NULL);
+ if (!rtp) {
ast_log(LOG_ERROR, "Unable to create RTP instance using RTP engine '%s'\n",
options->rtp_engine);
return NULL;
@@ -204,13 +207,15 @@ static struct ast_rtp_instance *create_rtp(const struct ast_sdp_options *options
static struct sdp_state_udptl *create_udptl(const struct ast_sdp_options *options)
{
struct sdp_state_udptl *udptl;
- struct ast_sockaddr temp_media_address;
static struct ast_sockaddr address_udptl;
- struct ast_sockaddr *media_address = &address_udptl;
+ struct ast_sockaddr *media_address = &address_udptl;
- if (options->bind_udptl_to_media_address && !ast_strlen_zero(options->media_address)) {
- ast_sockaddr_parse(&temp_media_address, options->media_address, 0);
- media_address = &temp_media_address;
+ if (!ast_strlen_zero(options->interface_address)) {
+ if (!ast_sockaddr_parse(&address_udptl, options->interface_address, 0)) {
+ ast_log(LOG_ERROR, "Attempted to bind UDPTL to invalid media address: %s\n",
+ options->interface_address);
+ return NULL;
+ }
} else {
if (ast_check_ipv6()) {
ast_sockaddr_parse(&address_udptl, "::", 0);