aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--channels/chan_sip.c6
-rw-r--r--include/asterisk/rtp_engine.h57
-rw-r--r--main/rtp_engine.c16
3 files changed, 66 insertions, 13 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 0fa510e1e..ff9a8617f 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -27564,19 +27564,19 @@ static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *i
}
if (instance) {
- changed |= ast_rtp_instance_get_remote_address(instance, &p->redirip);
+ changed |= ast_rtp_instance_get_and_cmp_remote_address(instance, &p->redirip);
} else if (!ast_sockaddr_isnull(&p->redirip)) {
memset(&p->redirip, 0, sizeof(p->redirip));
changed = 1;
}
if (vinstance) {
- changed |= ast_rtp_instance_get_remote_address(vinstance, &p->vredirip);
+ changed |= ast_rtp_instance_get_and_cmp_remote_address(vinstance, &p->vredirip);
} else if (!ast_sockaddr_isnull(&p->vredirip)) {
memset(&p->vredirip, 0, sizeof(p->vredirip));
changed = 1;
}
if (tinstance) {
- changed |= ast_rtp_instance_get_remote_address(tinstance, &p->tredirip);
+ changed |= ast_rtp_instance_get_and_cmp_remote_address(tinstance, &p->tredirip);
} else if (!ast_sockaddr_isnull(&p->tredirip)) {
memset(&p->tredirip, 0, sizeof(p->tredirip));
changed = 1;
diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h
index 74ea34668..39633c84c 100644
--- a/include/asterisk/rtp_engine.h
+++ b/include/asterisk/rtp_engine.h
@@ -720,9 +720,6 @@ int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance,
* \param instance The RTP instance to get the address from
* \param address The variable to store the address in
*
- * \retval 0 success
- * \retval -1 failure
- *
* Example usage:
*
* \code
@@ -734,7 +731,30 @@ int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance,
*
* \since 1.8
*/
-int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
+void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
+
+/*!
+ * \brief Get the address of the local endpoint that we are sending RTP to, comparing its address to another
+ *
+ * \param instance The instance that we want to get the local address for
+ * \param address An initialized address that may be overwritten if the local address is different
+ *
+ * \retval 0 address was not changed
+ * \retval 1 address was changed
+ * Example usage:
+ *
+ * \code
+ * struct ast_sockaddr address;
+ * int ret;
+ * ret = ast_rtp_instance_get_and_cmp_local_address(instance, &address);
+ * \endcode
+ *
+ * This retrieves the current local address set on the instance pointed to by instance and puts the value
+ * into the address structure.
+ *
+ * \since 1.8
+ */
+int ast_rtp_instance_get_and_cmp_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
/*!
* \brief Get the address of the remote endpoint that we are sending RTP to
@@ -742,9 +762,6 @@ int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct
* \param instance The instance that we want to get the remote address for
* \param address A structure to put the address into
*
- * \retval 0 success
- * \retval -1 failure
- *
* Example usage:
*
* \code
@@ -757,7 +774,31 @@ int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct
*
* \since 1.8
*/
-int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
+void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
+
+/*!
+ * \brief Get the address of the remote endpoint that we are sending RTP to, comparing its address to another
+ *
+ * \param instance The instance that we want to get the remote address for
+ * \param address An initialized address that may be overwritten if the remote address is different
+ *
+ * \retval 0 address was not changed
+ * \retval 1 address was changed
+ * Example usage:
+ *
+ * \code
+ * struct ast_sockaddr address;
+ * int ret;
+ * ret = ast_rtp_instance_get_and_cmp_remote_address(instance, &address);
+ * \endcode
+ *
+ * This retrieves the current remote address set on the instance pointed to by instance and puts the value
+ * into the address structure.
+ *
+ * \since 1.8
+ */
+
+int ast_rtp_instance_get_and_cmp_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
/*!
* \brief Set the value of an RTP instance extended property
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index ff8ebd481..0fecff8cf 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -410,7 +410,7 @@ int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance,
return 0;
}
-int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance,
+int ast_rtp_instance_get_and_cmp_local_address(struct ast_rtp_instance *instance,
struct ast_sockaddr *address)
{
if (ast_sockaddr_cmp(address, &instance->local_address) != 0) {
@@ -421,7 +421,13 @@ int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance,
return 0;
}
-int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance,
+void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance,
+ struct ast_sockaddr *address)
+{
+ ast_sockaddr_copy(address, &instance->local_address);
+}
+
+int ast_rtp_instance_get_and_cmp_remote_address(struct ast_rtp_instance *instance,
struct ast_sockaddr *address)
{
if (ast_sockaddr_cmp(address, &instance->remote_address) != 0) {
@@ -432,6 +438,12 @@ int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance,
return 0;
}
+void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance,
+ struct ast_sockaddr *address)
+{
+ ast_sockaddr_copy(address, &instance->remote_address);
+}
+
void ast_rtp_instance_set_extended_prop(struct ast_rtp_instance *instance, int property, void *value)
{
if (instance->engine->extended_prop_set) {