[Asterisk-code-review] SDP: Change media address to specify our address to use. (asterisk[master])

Richard Mudgett asteriskteam at digium.com
Fri May 5 18:51:54 CDT 2017


Richard Mudgett has uploaded a new change for review. ( https://gerrit.asterisk.org/5594 )

Change subject: SDP: Change media_address to specify our address to use.
......................................................................

SDP: Change media_address to specify our address to use.

When we optionally set the media_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 interface address.

Change-Id: I160d9fac322a075bd2557b430632544178196189
---
M include/asterisk/sdp_options.h
M main/sdp_options.c
M main/sdp_private.h
M main/sdp_state.c
4 files changed, 16 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/94/5594/1

diff --git a/include/asterisk/sdp_options.h b/include/asterisk/sdp_options.h
index 9c699a2..5b65679 100644
--- a/include/asterisk/sdp_options.h
+++ b/include/asterisk/sdp_options.h
@@ -186,26 +186,6 @@
 
 /*!
  * \since 15.0.0
- * \brief Set SDP Options bind_rtp_to_media_address
- *
- * \param options SDP Options
- * \param bind_rtp_to_media_address
- */
-void ast_sdp_options_set_bind_rtp_to_media_address(struct ast_sdp_options *options,
-	unsigned int bind_rtp_to_media_address);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options bind_rtp_to_media_address
- *
- * \param options SDP Options
- *
- * \returns bind_rtp_to_media_address
- */
-unsigned int ast_sdp_options_get_bind_rtp_to_media_address(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
  * \brief Set SDP Options rtp_symmetric
  *
  * \param options SDP Options
@@ -502,26 +482,6 @@
  * \returns udptl_far_max_datagram
  */
 unsigned int ast_sdp_options_get_udptl_far_max_datagram(const struct ast_sdp_options *options);
-
-/*!
- * \since 15.0.0
- * \brief Set SDP Options bind_udptl_to_media_address
- *
- * \param options SDP Options
- * \param bind_udptl_to_media_address
- */
-void ast_sdp_options_set_bind_udptl_to_media_address(struct ast_sdp_options *options,
-	unsigned int bind_udptl_to_media_address);
-
-/*!
- * \since 15.0.0
- * \brief Get SDP Options bind_udptl_to_media_address
- *
- * \param options SDP Options
- *
- * \returns bind_udptl_to_media_address
- */
-unsigned int ast_sdp_options_get_bind_udptl_to_media_address(const struct ast_sdp_options *options);
 
 /*!
  * \since 15.0.0
diff --git a/main/sdp_options.c b/main/sdp_options.c
index 9b57e18..542bafb 100644
--- a/main/sdp_options.c
+++ b/main/sdp_options.c
@@ -59,8 +59,6 @@
 DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(sdpsession, 0);
 DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(rtp_engine, 0);
 
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, bind_rtp_to_media_address);
-DEFINE_GETTERS_SETTERS_FOR(unsigned int, bind_udptl_to_media_address);
 DEFINE_GETTERS_SETTERS_FOR(unsigned int, rtp_symmetric);
 DEFINE_GETTERS_SETTERS_FOR(unsigned int, udptl_symmetric);
 DEFINE_GETTERS_SETTERS_FOR(enum ast_t38_ec_modes, udptl_error_correction);
diff --git a/main/sdp_private.h b/main/sdp_private.h
index c90a574..5b62e5d 100644
--- a/main/sdp_private.h
+++ b/main/sdp_private.h
@@ -34,8 +34,6 @@
 		AST_STRING_FIELD(rtp_engine);
 	);
 	struct {
-		unsigned int bind_rtp_to_media_address:1;
-		unsigned int bind_udptl_to_media_address:1;
 		unsigned int rtp_symmetric:1;
 		unsigned int udptl_symmetric:1;
 		unsigned int rtp_ipv6:1;
diff --git a/main/sdp_state.c b/main/sdp_state.c
index 3a87a81..7052769 100644
--- a/main/sdp_state.c
+++ b/main/sdp_state.c
@@ -150,13 +150,15 @@
 {
 	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->media_address)) {
+		if (!ast_sockaddr_parse(&address_rtp, options->media_address, 0)) {
+			ast_log(LOG_ERROR, "Attempted to bind RTP to invalid media address: %s\n",
+				options->media_address);
+			return NULL;
+		}
 	} else {
 		if (ast_check_ipv6()) {
 			ast_sockaddr_parse(&address_rtp, "::", 0);
@@ -165,7 +167,8 @@
 		}
 	}
 
-	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 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->media_address)) {
+		if (!ast_sockaddr_parse(&address_udptl, options->media_address, 0)) {
+			ast_log(LOG_ERROR, "Attempted to bind UDPTL to invalid media address: %s\n",
+				options->media_address);
+			return NULL;
+		}
 	} else {
 		if (ast_check_ipv6()) {
 			ast_sockaddr_parse(&address_udptl, "::", 0);

-- 
To view, visit https://gerrit.asterisk.org/5594
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I160d9fac322a075bd2557b430632544178196189
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list