[Asterisk-code-review] SDP: Add interface address to specify our address to use. (asterisk[master])
Jenkins2
asteriskteam at digium.com
Fri May 12 11:50:00 CDT 2017
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5594 )
Change subject: SDP: Add interface_address to specify our address to use.
......................................................................
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
---
M include/asterisk/sdp_options.h
M main/sdp_options.c
M main/sdp_private.h
M main/sdp_state.c
4 files changed, 40 insertions(+), 56 deletions(-)
Approvals:
Mark Michelson: Looks good to me, approved
Jenkins2: Approved for Submit
Joshua Colp: Looks good to me, but someone else must approve
diff --git a/include/asterisk/sdp_options.h b/include/asterisk/sdp_options.h
index 9c699a2..f49b794 100644
--- a/include/asterisk/sdp_options.h
+++ b/include/asterisk/sdp_options.h
@@ -126,6 +126,26 @@
/*!
* \since 15.0.0
+ * \brief Set SDP Options interface_address
+ *
+ * \param options SDP Options
+ * \param interface_address
+ */
+void ast_sdp_options_set_interface_address(struct ast_sdp_options *options,
+ const char *interface_address);
+
+/*!
+ * \since 15.0.0
+ * \brief Get SDP Options interface_address
+ *
+ * \param options SDP Options
+ *
+ * \returns interface_address
+ */
+const char *ast_sdp_options_get_interface_address(const struct ast_sdp_options *options);
+
+/*!
+ * \since 15.0.0
* \brief Set SDP Options sdpowner
*
* \param options SDP Options
@@ -183,26 +203,6 @@
* \returns rtp_engine
*/
const char *ast_sdp_options_get_rtp_engine(const struct ast_sdp_options *options);
-
-/*!
- * \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
@@ -502,26 +502,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..ab8fb29 100644
--- a/main/sdp_options.c
+++ b/main/sdp_options.c
@@ -55,12 +55,11 @@
} \
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(media_address, 0);
+DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(interface_address, 0);
DEFINE_STRINGFIELD_GETTERS_SETTERS_FOR(sdpowner, 0);
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..a0b63df 100644
--- a/main/sdp_private.h
+++ b/main/sdp_private.h
@@ -24,8 +24,10 @@
struct ast_sdp_options {
AST_DECLARE_STRING_FIELDS(
- /*! Optional media address to use in SDP */
+ /*! Media address to use in SDP */
AST_STRING_FIELD(media_address);
+ /*! Optional address of the interface media should use. */
+ AST_STRING_FIELD(interface_address);
/*! SDP origin username */
AST_STRING_FIELD(sdpowner);
/*! SDP session name */
@@ -34,8 +36,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..0da93e4 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->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 @@
}
}
- 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->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);
--
To view, visit https://gerrit.asterisk.org/5594
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I160d9fac322a075bd2557b430632544178196189
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-code-review
mailing list