[asterisk-commits] jpdionne: branch group/v6-new r261613 - in /team/group/v6-new: channels/ incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 6 12:14:44 CDT 2010


Author: jpdionne
Date: Thu May  6 12:14:40 2010
New Revision: 261613

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=261613
Log:
Converted RTP engine to IPv6.


Modified:
    team/group/v6-new/channels/chan_multicast_rtp.c
    team/group/v6-new/include/asterisk/rtp_engine.h
    team/group/v6-new/main/rtp_engine.c
    team/group/v6-new/res/res_rtp_asterisk.c
    team/group/v6-new/res/res_rtp_multicast.c

Modified: team/group/v6-new/channels/chan_multicast_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/channels/chan_multicast_rtp.c?view=diff&rev=261613&r1=261612&r2=261613
==============================================================================
--- team/group/v6-new/channels/chan_multicast_rtp.c (original)
+++ team/group/v6-new/channels/chan_multicast_rtp.c Thu May  6 12:14:40 2010
@@ -111,7 +111,8 @@
 {
 	char *tmp = ast_strdupa(data), *multicast_type = tmp, *destination, *control;
 	struct ast_rtp_instance *instance;
-	struct sockaddr_in control_address = { .sin_family = AF_INET, }, destination_address = { .sin_family = AF_INET, };
+	struct ast_sockaddr control_address;
+	struct ast_sockaddr destination_address;
 	struct ast_channel *chan;
 	format_t fmt = ast_best_codec(format);
 
@@ -125,13 +126,15 @@
 	}
 	*destination++ = '\0';
 
-	if (ast_parse_arg(destination, PARSE_INADDR | PARSE_PORT_REQUIRE, &destination_address)) {
+	if (!ast_sockaddr_parse(&destination_address, destination,
+				PARSE_PORT_REQUIRE)) {
 		goto failure;
 	}
 
 	if ((control = strchr(destination, '/'))) {
 		*control++ = '\0';
-		if (ast_parse_arg(control, PARSE_INADDR | PARSE_PORT_REQUIRE, &control_address)) {
+		if (!ast_sockaddr_parse(&control_address, control,
+					PARSE_PORT_REQUIRE)) {
 			goto failure;
 		}
 	}

Modified: team/group/v6-new/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/include/asterisk/rtp_engine.h?view=diff&rev=261613&r1=261612&r2=261613
==============================================================================
--- team/group/v6-new/include/asterisk/rtp_engine.h (original)
+++ team/group/v6-new/include/asterisk/rtp_engine.h Thu May  6 12:14:40 2010
@@ -71,6 +71,7 @@
 
 #include "asterisk/astobj2.h"
 #include "asterisk/frame.h"
+#include "asterisk/netsock2.h"
 
 /* Maximum number of payloads supported */
 #define AST_RTP_MAX_PT 256
@@ -310,7 +311,7 @@
 	/*! Module this RTP engine came from, used for reference counting */
 	struct ast_module *mod;
 	/*! Callback for setting up a new RTP instance */
-	int (*new)(struct ast_rtp_instance *instance, struct sched_context *sched, struct sockaddr_in *sin, void *data);
+	int (*new)(struct ast_rtp_instance *instance, struct sched_context *sched, struct ast_sockaddr *sa, void *data);
 	/*! Callback for destroying an RTP instance */
 	int (*destroy)(struct ast_rtp_instance *instance);
 	/*! Callback for writing out a frame */
@@ -336,9 +337,9 @@
 	/*! Callback for setting packetization preferences */
 	void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref);
 	/*! Callback for setting the remote address that RTP is to be sent to */
-	void (*remote_address_set)(struct ast_rtp_instance *instance, struct sockaddr_in *sin);
+	void (*remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa);
 	/*! Callback for setting an alternate remote address */
-	void (*alt_remote_address_set)(struct ast_rtp_instance *instance, struct sockaddr_in *sin);
+	void (*alt_remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa);
 	/*! Callback for changing DTMF mode */
 	int (*dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
 	/*! Callback for retrieving statistics */
@@ -366,7 +367,7 @@
 	/*! Callback to indicate that packets will now flow */
 	int (*activate)(struct ast_rtp_instance *instance);
 	/*! Callback to request that the RTP engine send a STUN BIND request */
-	void (*stun_request)(struct ast_rtp_instance *instance, struct sockaddr_in *suggestion, const char *username);
+	void (*stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
 	/*! Callback to get the transcodeable formats supported */
 	int (*available_formats)(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk);
 	/*! Linked list information */
@@ -511,7 +512,7 @@
  *
  * \param engine_name Name of the engine to use for the RTP instance
  * \param sched Scheduler context that the RTP engine may want to use
- * \param sin Address we want to bind to
+ * \param Address we want to bind to
  * \param data Unique data for the engine
  *
  * \retval non-NULL success
@@ -525,14 +526,16 @@
  * \endcode
  *
  * This creates a new RTP instance using the default engine and asks the RTP engine to bind to the address given
- * in the sin structure.
+ * in the address structure.
  *
  * \note The RTP engine does not have to use the address provided when creating an RTP instance. It may choose to use
  *       another depending on it's own configuration.
  *
  * \since 1.8
  */
-struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name, struct sched_context *sched, struct sockaddr_in *sin, void *data);
+struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name,
+                struct sched_context *sched, const struct ast_sockaddr *sa,
+                void *data);
 
 /*!
  * \brief Destroy an RTP instance
@@ -654,7 +657,8 @@
  *
  * \since 1.8
  */
-int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address);
+int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address);
+
 
 /*!
  * \brief Set the address of an an alternate RTP address to receive from
@@ -668,7 +672,7 @@
  * Example usage:
  *
  * \code
- * ast_rtp_instance_set_alt_remote_address(instance, &sin);
+ * ast_rtp_instance_set_alt_remote_address(instance, &address);
  * \endcode
  *
  * This changes the alternate remote address that RTP will be sent to on instance to the address given in the sin
@@ -676,7 +680,7 @@
  *
  * \since 1.8
  */
-int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address);
+int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address);
 
 /*!
  * \brief Set the address that we are expecting to receive RTP on
@@ -698,7 +702,8 @@
  *
  * \since 1.8
  */
-int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance, struct sockaddr_in *address);
+int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance,
+                const struct ast_sockaddr *address);
 
 /*!
  * \brief Get the local address that we are expecting RTP on
@@ -712,15 +717,15 @@
  * Example usage:
  *
  * \code
- * struct sockaddr_in sin;
- * ast_rtp_instance_get_local_address(instance, &sin);
- * \endcode
- *
- * This gets the local address that we are expecting RTP on and stores it in the 'sin' structure.
- *
- * \since 1.8
- */
-int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct sockaddr_in *address);
+ * struct ast_sockaddr address;
+ * ast_rtp_instance_get_local_address(instance, &address);
+ * \endcode
+ *
+ * This gets the local address that we are expecting RTP on and stores it in the 'address' structure.
+ *
+ * \since 1.8
+ */
+int ast_rtp_instance_get_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
@@ -734,16 +739,16 @@
  * Example usage:
  *
  * \code
- * struct sockaddr_in sin;
- * ast_rtp_instance_get_remote_address(instance, &sin);
+ * struct ast_sockaddr address;
+ * ast_rtp_instance_get_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 sin structure.
- *
- * \since 1.8
- */
-int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address);
+ * into the address structure.
+ *
+ * \since 1.8
+ */
+int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
 
 /*!
  * \brief Set the value of an RTP instance extended property
@@ -1589,7 +1594,7 @@
  *
  * \since 1.8
  */
-void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct sockaddr_in *suggestion, const char *username);
+void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
 
 /*!
  * \brief Set the RTP timeout value

Modified: team/group/v6-new/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/main/rtp_engine.c?view=diff&rev=261613&r1=261612&r2=261613
==============================================================================
--- team/group/v6-new/main/rtp_engine.c (original)
+++ team/group/v6-new/main/rtp_engine.c Thu May  6 12:14:40 2010
@@ -38,6 +38,7 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/pbx.h"
 #include "asterisk/translate.h"
+#include "asterisk/netsock2.h"
 
 /*! Structure that represents an RTP session (instance) */
 struct ast_rtp_instance {
@@ -48,11 +49,11 @@
 	/*! RTP properties that have been set and their value */
 	int properties[AST_RTP_PROPERTY_MAX];
 	/*! Address that we are expecting RTP to come in to */
-	struct sockaddr_in local_address;
+	struct ast_sockaddr local_address;
 	/*! Address that we are sending RTP to */
-	struct sockaddr_in remote_address;
+	struct ast_sockaddr remote_address;
 	/*! Alternate address that we are receiving RTP from */
-	struct sockaddr_in alt_remote_address;
+	struct ast_sockaddr alt_remote_address;
 	/*! Instance that we are bridged to if doing remote or local bridging */
 	struct ast_rtp_instance *bridged;
 	/*! Payload and packetization information */
@@ -283,9 +284,11 @@
 	return 0;
 }
 
-struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name, struct sched_context *sched, struct sockaddr_in *sin, void *data)
-{
-	struct sockaddr_in address = { 0, };
+struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name,
+		struct sched_context *sched, const struct ast_sockaddr *sa,
+		void *data)
+{
+	struct ast_sockaddr address = {{0,}};
 	struct ast_rtp_instance *instance = NULL;
 	struct ast_rtp_engine *engine = NULL;
 
@@ -320,11 +323,8 @@
 		return NULL;
 	}
 	instance->engine = engine;
-	instance->local_address.sin_family = AF_INET;
-	instance->local_address.sin_addr = sin->sin_addr;
-	instance->remote_address.sin_family = AF_INET;
-	address.sin_family = AF_INET;
-	address.sin_addr = sin->sin_addr;
+	ast_sockaddr_copy(&instance->local_address, sa);
+	ast_sockaddr_copy(&address, sa);
 
 	ast_debug(1, "Using engine '%s' for RTP instance '%p'\n", engine->name, instance);
 
@@ -360,17 +360,17 @@
 	return instance->engine->read(instance, rtcp);
 }
 
-int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance, struct sockaddr_in *address)
-{
-	instance->local_address.sin_addr = address->sin_addr;
-	instance->local_address.sin_port = address->sin_port;
+int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance,
+		const struct ast_sockaddr *address)
+{
+	ast_sockaddr_copy(&instance->local_address, address);
 	return 0;
 }
 
-int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address)
-{
-	instance->remote_address.sin_addr = address->sin_addr;
-	instance->remote_address.sin_port = address->sin_port;
+int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance,
+		const struct ast_sockaddr *address)
+{
+	ast_sockaddr_copy(&instance->remote_address, address);
 
 	/* moo */
 
@@ -381,10 +381,10 @@
 	return 0;
 }
 
-int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address)
-{
-	instance->alt_remote_address.sin_addr = address->sin_addr;
-	instance->alt_remote_address.sin_port = address->sin_port;
+int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance,
+		const struct ast_sockaddr *address)
+{
+	ast_sockaddr_copy(&instance->alt_remote_address, address);
 
 	/* oink */
 
@@ -395,24 +395,22 @@
 	return 0;
 }
 
-int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct sockaddr_in *address)
-{
-	if ((address->sin_family != AF_INET) ||
-	    (address->sin_port != instance->local_address.sin_port) ||
-	    (address->sin_addr.s_addr != instance->local_address.sin_addr.s_addr)) {
-		memcpy(address, &instance->local_address, sizeof(*address));
+int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance,
+		struct ast_sockaddr *address)
+{
+	if (ast_sockaddr_cmp(address, &instance->local_address) != 0) {
+		ast_sockaddr_copy(address, &instance->local_address);
 		return 1;
 	}
 
 	return 0;
 }
 
-int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address)
-{
-	if ((address->sin_family != AF_INET) ||
-	    (address->sin_port != instance->remote_address.sin_port) ||
-	    (address->sin_addr.s_addr != instance->remote_address.sin_addr.s_addr)) {
-		memcpy(address, &instance->remote_address, sizeof(*address));
+int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance,
+		struct ast_sockaddr *address)
+{
+	if (ast_sockaddr_cmp(address, &instance->remote_address) != 0) {
+		ast_sockaddr_copy(address, &instance->remote_address);
 		return 1;
 	}
 
@@ -938,8 +936,8 @@
 	enum ast_bridge_result res = AST_BRIDGE_FAILED;
 	struct ast_channel *who = NULL, *other = NULL, *cs[3] = { NULL, };
 	format_t oldcodec0 = codec0, oldcodec1 = codec1;
-	struct sockaddr_in ac1 = {0,}, vac1 = {0,}, tac1 = {0,}, ac0 = {0,}, vac0 = {0,}, tac0 = {0,};
-	struct sockaddr_in t1 = {0,}, vt1 = {0,}, tt1 = {0,}, t0 = {0,}, vt0 = {0,}, tt0 = {0,};
+	struct ast_sockaddr ac1 = {{0,}}, vac1 = {{0,}}, tac1 = {{0,}}, ac0 = {{0,}}, vac0 = {{0,}}, tac0 = {{0,}};
+	struct ast_sockaddr t1 = {{0,}}, vt1 = {{0,}}, tt1 = {{0,}}, t0 = {{0,}}, vt0 = {{0,}}, tt0 = {{0,}};
 	struct ast_frame *fr = NULL;
 
 	/* Test the first channel */
@@ -1014,44 +1012,58 @@
 			codec0 = glue0->get_codec(c0);
 		}
 
-		if ((inaddrcmp(&t1, &ac1)) ||
-		    (vinstance1 && inaddrcmp(&vt1, &vac1)) ||
-		    (tinstance1 && inaddrcmp(&tt1, &tac1)) ||
+		if ((ast_sockaddr_cmp(&t1, &ac1)) ||
+		    (vinstance1 && ast_sockaddr_cmp(&vt1, &vac1)) ||
+		    (tinstance1 && ast_sockaddr_cmp(&tt1, &tac1)) ||
 		    (codec1 != oldcodec1)) {
-			ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %s)\n",
-				  c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), ast_getformatname(codec1));
-			ast_debug(1, "Oooh, '%s' changed end vaddress to %s:%d (format %s)\n",
-				  c1->name, ast_inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), ast_getformatname(codec1));
-			ast_debug(1, "Oooh, '%s' changed end taddress to %s:%d (format %s)\n",
-				  c1->name, ast_inet_ntoa(tt1.sin_addr), ntohs(tt1.sin_port), ast_getformatname(codec1));
-			ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
-				  c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), ast_getformatname(oldcodec1));
-			ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
-				  c1->name, ast_inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), ast_getformatname(oldcodec1));
-			ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
-				  c1->name, ast_inet_ntoa(tac1.sin_addr), ntohs(tac1.sin_port), ast_getformatname(oldcodec1));
-			if (glue0->update_peer(c0, t1.sin_addr.s_addr ? instance1 : NULL, vt1.sin_addr.s_addr ? vinstance1 : NULL, tt1.sin_addr.s_addr ? tinstance1 : NULL, codec1, 0)) {
+			ast_debug(1, "Oooh, '%s' changed end address to %s (format %s)\n",
+				  c1->name, ast_sockaddr_stringify(&t1),
+				  ast_getformatname(codec1));
+			ast_debug(1, "Oooh, '%s' changed end vaddress to %s (format %s)\n",
+				  c1->name, ast_sockaddr_stringify(&vt1),
+				  ast_getformatname(codec1));
+			ast_debug(1, "Oooh, '%s' changed end taddress to %s (format %s)\n",
+				  c1->name, ast_sockaddr_stringify(&tt1),
+				  ast_getformatname(codec1));
+			ast_debug(1, "Oooh, '%s' was %s/(format %s)\n",
+				  c1->name, ast_sockaddr_stringify(&ac1),
+				  ast_getformatname(oldcodec1));
+			ast_debug(1, "Oooh, '%s' was %s/(format %s)\n",
+				  c1->name, ast_sockaddr_stringify(&vac1),
+				  ast_getformatname(oldcodec1));
+			ast_debug(1, "Oooh, '%s' was %s/(format %s)\n",
+				  c1->name, ast_sockaddr_stringify(&tac1),
+				  ast_getformatname(oldcodec1));
+			if (glue0->update_peer(c0, t1.len ? instance1 : NULL,
+						vt1.len ? vinstance1 : NULL,
+						tt1.len ? tinstance1 : NULL,
+						codec1, 0)) {
 				ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name);
 			}
-			memcpy(&ac1, &t1, sizeof(ac1));
-			memcpy(&vac1, &vt1, sizeof(vac1));
-			memcpy(&tac1, &tt1, sizeof(tac1));
+			ast_sockaddr_copy(&ac1, &t1);
+			ast_sockaddr_copy(&vac1, &vt1);
+			ast_sockaddr_copy(&tac1, &tt1);
 			oldcodec1 = codec1;
 		}
-		if ((inaddrcmp(&t0, &ac0)) ||
-		    (vinstance0 && inaddrcmp(&vt0, &vac0)) ||
-		    (tinstance0 && inaddrcmp(&tt0, &tac0)) ||
+		if ((ast_sockaddr_cmp(&t0, &ac0)) ||
+		    (vinstance0 && ast_sockaddr_cmp(&vt0, &vac0)) ||
+		    (tinstance0 && ast_sockaddr_cmp(&tt0, &tac0)) ||
 		    (codec0 != oldcodec0)) {
-			ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %s)\n",
-				  c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), ast_getformatname(codec0));
-			ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n",
-				  c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), ast_getformatname(oldcodec0));
-			if (glue1->update_peer(c1, t0.sin_addr.s_addr ? instance0 : NULL, vt0.sin_addr.s_addr ? vinstance0 : NULL, tt0.sin_addr.s_addr ? tinstance0 : NULL, codec0, 0)) {
+			ast_debug(1, "Oooh, '%s' changed end address to %s (format %s)\n",
+				  c0->name, ast_sockaddr_stringify(&t0),
+				  ast_getformatname(codec0));
+			ast_debug(1, "Oooh, '%s' was %s/(format %s)\n",
+				  c0->name, ast_sockaddr_stringify(&ac0),
+				  ast_getformatname(oldcodec0));
+			if (glue1->update_peer(c1, t0.len ? instance0 : NULL,
+						vt0.len ? vinstance0 : NULL,
+						tt0.len ? tinstance0 : NULL,
+						codec0, 0)) {
 				ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name);
 			}
-			memcpy(&ac0, &t0, sizeof(ac0));
-			memcpy(&vac0, &vt0, sizeof(vac0));
-			memcpy(&tac0, &tt0, sizeof(tac0));
+			ast_sockaddr_copy(&ac0, &t0);
+			ast_sockaddr_copy(&vac0, &vt0);
+			ast_sockaddr_copy(&tac0, &tt0);
 			oldcodec0 = codec0;
 		}
 
@@ -1101,9 +1113,9 @@
 				}
 				/* Update local address information */
 				ast_rtp_instance_get_remote_address(instance0, &t0);
-				memcpy(&ac0, &t0, sizeof(ac0));
+				ast_sockaddr_copy(&ac0, &t0);
 				ast_rtp_instance_get_remote_address(instance1, &t1);
-				memcpy(&ac1, &t1, sizeof(ac1));
+				ast_sockaddr_copy(&ac1, &t1);
 				/* Update codec information */
 				if (glue0->get_codec && c0->tech_pvt) {
 					oldcodec0 = codec0 = glue0->get_codec(c0);
@@ -1609,7 +1621,9 @@
 	return instance->engine->activate ? instance->engine->activate(instance) : 0;
 }
 
-void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct sockaddr_in *suggestion, const char *username)
+void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance,
+				   struct ast_sockaddr *suggestion,
+				   const char *username)
 {
 	if (instance->engine->stun_request) {
 		instance->engine->stun_request(instance, suggestion, username);

Modified: team/group/v6-new/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/res/res_rtp_asterisk.c?view=diff&rev=261613&r1=261612&r2=261613
==============================================================================
--- team/group/v6-new/res/res_rtp_asterisk.c (original)
+++ team/group/v6-new/res/res_rtp_asterisk.c Thu May  6 12:14:40 2010
@@ -35,7 +35,6 @@
 #include <sys/time.h>
 #include <signal.h>
 #include <fcntl.h>
-#include <math.h>
 
 #include "asterisk/stun.h"
 #include "asterisk/pbx.h"
@@ -45,7 +44,6 @@
 #include "asterisk/config.h"
 #include "asterisk/lock.h"
 #include "asterisk/utils.h"
-#include "asterisk/netsock.h"
 #include "asterisk/cli.h"
 #include "asterisk/manager.h"
 #include "asterisk/unaligned.h"
@@ -86,8 +84,8 @@
 static int rtcpdebug;			/*!< Are we debugging RTCP? */
 static int rtcpstats;			/*!< Are we debugging RTCP? */
 static int rtcpinterval = RTCP_DEFAULT_INTERVALMS; /*!< Time between rtcp reports in millisecs */
-static struct sockaddr_in rtpdebugaddr;	/*!< Debug packets to/from this host */
-static struct sockaddr_in rtcpdebugaddr;	/*!< Debug RTCP packets to/from this host */
+static struct ast_sockaddr rtpdebugaddr;	/*!< Debug packets to/from this host */
+static struct ast_sockaddr rtcpdebugaddr;	/*!< Debug RTCP packets to/from this host */
 #ifdef SO_NO_CHECK
 static int nochecksums;
 #endif
@@ -167,8 +165,8 @@
 	struct ast_rtp *bridged;        /*!< Who we are Packet bridged to */
 
 	enum strict_rtp_state strict_rtp_state; /*!< Current state that strict RTP protection is in */
-	struct sockaddr_in strict_rtp_address;  /*!< Remote address information for strict RTP purposes */
-	struct sockaddr_in alt_rtp_address; /*!<Alternate remote address information */
+	struct ast_sockaddr strict_rtp_address;  /*!< Remote address information for strict RTP purposes */
+	struct ast_sockaddr alt_rtp_address; /*!<Alternate remote address information */
 
 	struct rtp_red *red;
 };
@@ -186,8 +184,8 @@
 struct ast_rtcp {
 	int rtcp_info;
 	int s;				/*!< Socket */
-	struct sockaddr_in us;		/*!< Socket representation of the local endpoint. */
-	struct sockaddr_in them;	/*!< Socket representation of the remote endpoint. */
+	struct ast_sockaddr us;		/*!< Socket representation of the local endpoint. */
+	struct ast_sockaddr them;	/*!< Socket representation of the remote endpoint. */
 	unsigned int soc;		/*!< What they told us */
 	unsigned int spc;		/*!< What they told us */
 	unsigned int themrxlsr;		/*!< The middle 32 bits of the NTP timestamp in the last received SR*/
@@ -252,7 +250,7 @@
 AST_LIST_HEAD_NOLOCK(frame_list, ast_frame);
 
 /* Forward Declarations */
-static int ast_rtp_new(struct ast_rtp_instance *instance, struct sched_context *sched, struct sockaddr_in *sin, void *data);
+static int ast_rtp_new(struct ast_rtp_instance *instance, struct sched_context *sched, struct ast_sockaddr *addr, void *data);
 static int ast_rtp_destroy(struct ast_rtp_instance *instance);
 static int ast_rtp_dtmf_begin(struct ast_rtp_instance *instance, char digit);
 static int ast_rtp_dtmf_end(struct ast_rtp_instance *instance, char digit);
@@ -262,14 +260,14 @@
 static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtcp);
 static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
 static int ast_rtp_fd(struct ast_rtp_instance *instance, int rtcp);
-static void ast_rtp_remote_address_set(struct ast_rtp_instance *instance, struct sockaddr_in *sin);
-static void ast_rtp_alt_remote_address_set(struct ast_rtp_instance *instance, struct sockaddr_in *sin);
+static void ast_rtp_remote_address_set(struct ast_rtp_instance *instance, struct ast_sockaddr *addr);
+static void ast_rtp_alt_remote_address_set(struct ast_rtp_instance *instance, struct ast_sockaddr *addr);
 static int rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations);
 static int rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame);
 static int ast_rtp_local_bridge(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1);
 static int ast_rtp_get_stat(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
 static int ast_rtp_dtmf_compatible(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
-static void ast_rtp_stun_request(struct ast_rtp_instance *instance, struct sockaddr_in *suggestion, const char *username);
+static void ast_rtp_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
 static void ast_rtp_stop(struct ast_rtp_instance *instance);
 
 /* RTP Engine Declaration */
@@ -296,36 +294,22 @@
 	.stop = ast_rtp_stop,
 };
 
-static inline int rtp_debug_test_addr(struct sockaddr_in *addr)
+static inline int rtp_debug_test_addr(struct ast_sockaddr *addr)
 {
 	if (!rtpdebug) {
 		return 0;
 	}
 
-	if (rtpdebugaddr.sin_addr.s_addr) {
-		if (((ntohs(rtpdebugaddr.sin_port) != 0)
-		     && (rtpdebugaddr.sin_port != addr->sin_port))
-		    || (rtpdebugaddr.sin_addr.s_addr != addr->sin_addr.s_addr))
-			return 0;
-	}
-
-	return 1;
-}
-
-static inline int rtcp_debug_test_addr(struct sockaddr_in *addr)
+	return ast_sockaddr_cmp(&rtpdebugaddr, addr) == 0;
+}
+
+static inline int rtcp_debug_test_addr(struct ast_sockaddr *addr)
 {
 	if (!rtcpdebug) {
 		return 0;
 	}
 
-	if (rtcpdebugaddr.sin_addr.s_addr) {
-		if (((ntohs(rtcpdebugaddr.sin_port) != 0)
-		     && (rtcpdebugaddr.sin_port != addr->sin_port))
-		    || (rtcpdebugaddr.sin_addr.s_addr != addr->sin_addr.s_addr))
-			return 0;
-	}
-
-	return 1;
+	return ast_sockaddr_cmp(&rtcpdebugaddr, addr) == 0;
 }
 
 static int rtp_get_rate(format_t subclass)
@@ -393,7 +377,9 @@
 	return sock;
 }
 
-static int ast_rtp_new(struct ast_rtp_instance *instance, struct sched_context *sched, struct sockaddr_in *sin, void *data)
+static int ast_rtp_new(struct ast_rtp_instance *instance,
+		       struct sched_context *sched, struct ast_sockaddr *addr,
+		       void *data)
 {
 	struct ast_rtp *rtp = NULL;
 	int x, startplace;
@@ -421,11 +407,11 @@
 	startplace = x;
 
 	for (;;) {
-		sin->sin_port = htons(x);
+		ast_sockaddr_set_port(addr, x);
 		/* Try to bind, this will tell us whether the port is available or not */
-		if (!bind(rtp->s, (struct sockaddr *)sin, sizeof(*sin))) {
+		if (!ast_bind(rtp->s, addr)) {
 			ast_debug(1, "Allocated port %d for RTP instance '%p'\n", x, instance);
-			ast_rtp_instance_set_local_address(instance, sin);
+			ast_rtp_instance_set_local_address(instance, addr);
 			break;
 		}
 
@@ -486,7 +472,7 @@
 static int ast_rtp_dtmf_begin(struct ast_rtp_instance *instance, char digit)
 {
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
-	struct sockaddr_in remote_address = { 0, };
+	struct ast_sockaddr remote_address = { {0,} };
 	int hdrlen = 12, res = 0, i = 0, payload = 101;
 	char data[256];
 	unsigned int *rtpheader = (unsigned int*)data;
@@ -494,7 +480,7 @@
 	ast_rtp_instance_get_remote_address(instance, &remote_address);
 
 	/* If we have no remote address information bail out now */
-	if (!remote_address.sin_addr.s_addr || !remote_address.sin_port) {
+	if (ast_sockaddr_isnull(&remote_address)) {
 		return -1;
 	}
 
@@ -529,15 +515,16 @@
 	/* Actually send the packet */
 	for (i = 0; i < 2; i++) {
 		rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (rtp->send_duration));
-		res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &remote_address, sizeof(remote_address));
+		res = ast_sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, &remote_address);
 		if (res < 0) {
-			ast_log(LOG_ERROR, "RTP Transmission error to %s:%u: %s\n",
-				ast_inet_ntoa(remote_address.sin_addr), ntohs(remote_address.sin_port), strerror(errno));
+			ast_log(LOG_ERROR, "RTP Transmission error to %s: %s\n",
+				ast_sockaddr_stringify(&remote_address),
+				strerror(errno));
 		}
 		if (rtp_debug_test_addr(&remote_address)) {
-			ast_verbose("Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
-				    ast_inet_ntoa(remote_address.sin_addr),
-				    ntohs(remote_address.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
+			ast_verbose("Sent RTP DTMF packet to %s (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+				    ast_sockaddr_stringify(&remote_address),
+				    payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 		}
 		rtp->seqno++;
 		rtp->send_duration += 160;
@@ -555,7 +542,7 @@
 static int ast_rtp_dtmf_continuation(struct ast_rtp_instance *instance)
 {
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
-	struct sockaddr_in remote_address = { 0, };
+	struct ast_sockaddr remote_address = { {0,} };
 	int hdrlen = 12, res = 0;
 	char data[256];
 	unsigned int *rtpheader = (unsigned int*)data;
@@ -563,7 +550,7 @@
 	ast_rtp_instance_get_remote_address(instance, &remote_address);
 
 	/* Make sure we know where the other side is so we can send them the packet */
-	if (!remote_address.sin_addr.s_addr || !remote_address.sin_port) {
+	if (ast_sockaddr_isnull(&remote_address)) {
 		return -1;
 	}
 
@@ -575,17 +562,17 @@
 	rtpheader[0] = htonl((2 << 30) | (rtp->send_payload << 16) | (rtp->seqno));
 
 	/* Boom, send it on out */
-	res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &remote_address, sizeof(remote_address));
+	res = ast_sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, &remote_address);
 	if (res < 0) {
-		ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
-			ast_inet_ntoa(remote_address.sin_addr),
-			ntohs(remote_address.sin_port), strerror(errno));
+		ast_log(LOG_ERROR, "RTP Transmission error to %s: %s\n",
+			ast_sockaddr_stringify(&remote_address),
+			strerror(errno));
 	}
 
 	if (rtp_debug_test_addr(&remote_address)) {
-		ast_verbose("Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
-			    ast_inet_ntoa(remote_address.sin_addr),
-			    ntohs(remote_address.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
+		ast_verbose("Sent RTP DTMF packet to %s (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+			    ast_sockaddr_stringify(&remote_address),
+			    rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 	}
 
 	/* And now we increment some values for the next time we swing by */
@@ -598,7 +585,7 @@
 static int ast_rtp_dtmf_end(struct ast_rtp_instance *instance, char digit)
 {
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
-	struct sockaddr_in remote_address = { 0, };
+	struct ast_sockaddr remote_address = { {0,} };
 	int hdrlen = 12, res = 0, i = 0;
 	char data[256];
 	unsigned int *rtpheader = (unsigned int*)data;
@@ -606,7 +593,7 @@
 	ast_rtp_instance_get_remote_address(instance, &remote_address);
 
 	/* Make sure we know where the remote side is so we can send them the packet we construct */
-	if (!remote_address.sin_addr.s_addr || !remote_address.sin_port) {
+	if (ast_sockaddr_isnull(&remote_address)) {
 		return -1;
 	}
 
@@ -638,16 +625,16 @@
 
 	/* Send it 3 times, that's the magical number */
 	for (i = 0; i < 3; i++) {
-		res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &remote_address, sizeof(remote_address));
+		res = ast_sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, &remote_address);
 		if (res < 0) {
-			ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
-				ast_inet_ntoa(remote_address.sin_addr),
-				ntohs(remote_address.sin_port), strerror(errno));
+			ast_log(LOG_ERROR, "RTP Transmission error to %s: %s\n",
+				ast_sockaddr_stringify(&remote_address),
+				strerror(errno));
 		}
 		if (rtp_debug_test_addr(&remote_address)) {
-			ast_verbose("Sent RTP DTMF packet to %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
-				    ast_inet_ntoa(remote_address.sin_addr),
-				    ntohs(remote_address.sin_port), rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
+			ast_verbose("Sent RTP DTMF packet to %s (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+				    ast_sockaddr_stringify(&remote_address),
+				    rtp->send_payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
 		}
 	}
 
@@ -733,10 +720,10 @@
 
 	double rxlost_current;
 
-	if (!rtp || !rtp->rtcp || (&rtp->rtcp->them.sin_addr == 0))
+	if (!rtp || !rtp->rtcp)
 		return 0;
 
-	if (!rtp->rtcp->them.sin_addr.s_addr) {
+	if (ast_sockaddr_isnull(&rtp->rtcp->them)) {
 		ast_log(LOG_ERROR, "RTCP RR transmission error, rtcp halted\n");
 		AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid);
 		return 0;
@@ -789,7 +776,7 @@
 	rtcpheader[(len/4)+2] = htonl(0x01 << 24);              /* Empty for the moment */
 	len += 12;
 
-	res = sendto(rtp->rtcp->s, (unsigned int *)rtcpheader, len, 0, (struct sockaddr *)&rtp->rtcp->them, sizeof(rtp->rtcp->them));
+	res = ast_sendto(rtp->rtcp->s, (unsigned int *)rtcpheader, len, 0, &rtp->rtcp->them);
 
 	if (res < 0) {
 		ast_log(LOG_ERROR, "RTCP RR transmission error, rtcp halted: %s\n",strerror(errno));
@@ -800,13 +787,12 @@
 
 	rtp->rtcp->rr_count++;
 	if (rtcp_debug_test_addr(&rtp->rtcp->them)) {
-		ast_verbose("\n* Sending RTCP RR to %s:%d\n"
+		ast_verbose("\n* Sending RTCP RR to %s\n"
 			"  Our SSRC: %u\nTheir SSRC: %u\niFraction lost: %d\nCumulative loss: %u\n"
 			"  IA jitter: %.4f\n"
 			"  Their last SR: %u\n"
 			    "  DLSR: %4.4f (sec)\n\n",
-			    ast_inet_ntoa(rtp->rtcp->them.sin_addr),
-			    ntohs(rtp->rtcp->them.sin_port),
+			    ast_sockaddr_stringify(&rtp->rtcp->them),
 			    rtp->ssrc, rtp->themssrc, fraction, lost,
 			    rtp->rxjitter,
 			    rtp->rtcp->themrxlsr,
@@ -836,11 +822,10 @@
 	struct timeval dlsr;
 	char bdata[512];
 
-	/* Commented condition is always not NULL if rtp->rtcp is not NULL */
-	if (!rtp || !rtp->rtcp/* || (&rtp->rtcp->them.sin_addr == 0)*/)
+	if (!rtp || !rtp->rtcp)
 		return 0;
 
-	if (!rtp->rtcp->them.sin_addr.s_addr) {  /* This'll stop rtcp for this rtp session */
+	if (ast_sockaddr_isnull(&rtp->rtcp->them)) {  /* This'll stop rtcp for this rtp session */
 		ast_verbose("RTCP SR transmission error, rtcp halted\n");
 		AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid);
 		return 0;
@@ -889,9 +874,11 @@
 	rtcpheader[(len/4)+2] = htonl(0x01 << 24);                    /* Empty for the moment */
 	len += 12;
 
-	res = sendto(rtp->rtcp->s, (unsigned int *)rtcpheader, len, 0, (struct sockaddr *)&rtp->rtcp->them, sizeof(rtp->rtcp->them));
+	res = ast_sendto(rtp->rtcp->s, (unsigned int *)rtcpheader, len, 0, &rtp->rtcp->them);
 	if (res < 0) {
-		ast_log(LOG_ERROR, "RTCP SR transmission error to %s:%d, rtcp halted %s\n",ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port), strerror(errno));
+		ast_log(LOG_ERROR, "RTCP SR transmission error to %s, rtcp halted %s\n",
+			ast_sockaddr_stringify(&rtp->rtcp->them),
+			strerror(errno));
 		AST_SCHED_DEL(rtp->sched, rtp->rtcp->schedid);
 		return 0;
 	}
@@ -903,7 +890,7 @@
 	rtp->rtcp->lastsrtxcount = rtp->txcount;
 
 	if (rtcp_debug_test_addr(&rtp->rtcp->them)) {
-		ast_verbose("* Sent RTCP SR to %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
+		ast_verbose("* Sent RTCP SR to %s\n", ast_sockaddr_stringify(&rtp->rtcp->them));
 		ast_verbose("  Our SSRC: %u\n", rtp->ssrc);
 		ast_verbose("  Sent(NTP): %u.%010u\n", (unsigned int)now.tv_sec, (unsigned int)now.tv_usec*4096);
 		ast_verbose("  Sent(RTP): %u\n", rtp->lastts);
@@ -916,7 +903,7 @@
 		ast_verbose("  Their last SR: %u\n", rtp->rtcp->themrxlsr);
 		ast_verbose("  DLSR: %4.4f (sec)\n\n", (double)(ntohl(rtcpheader[12])/65536.0));
 	}
-	manager_event(EVENT_FLAG_REPORTING, "RTCPSent", "To %s:%d\r\n"
+	manager_event(EVENT_FLAG_REPORTING, "RTCPSent", "To %s\r\n"
 					    "OurSSRC: %u\r\n"
 					    "SentNTP: %u.%010u\r\n"
 					    "SentRTP: %u\r\n"
@@ -928,7 +915,7 @@
 					    "IAJitter: %.4f\r\n"
 					    "TheirLastSR: %u\r\n"
 		      "DLSR: %4.4f (sec)\r\n",
-		      ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port),
+		      ast_sockaddr_stringify(&rtp->rtcp->them),
 		      rtp->ssrc,
 		      (unsigned int)now.tv_sec, (unsigned int)now.tv_usec*4096,
 		      rtp->lastts,
@@ -966,7 +953,7 @@
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
 	int pred, mark = 0;
 	unsigned int ms = calc_txstamp(rtp, &frame->delivery);
-	struct sockaddr_in remote_address = { 0, };
+	struct ast_sockaddr remote_address = { {0,} };
 	int rate = rtp_get_rate(frame->subclass.codec) / 1000;
 
 	if (frame->subclass.codec == AST_FORMAT_G722) {
@@ -1041,7 +1028,7 @@
 	ast_rtp_instance_get_remote_address(instance, &remote_address);
 
 	/* If we know the remote address construct a packet and send it out */
-	if (remote_address.sin_port && remote_address.sin_addr.s_addr) {
+	if (!ast_sockaddr_isnull(&remote_address)) {
 		int hdrlen = 12, res;
 		unsigned char *rtpheader = (unsigned char *)(frame->data.ptr - hdrlen);
 
@@ -1049,13 +1036,17 @@
 		put_unaligned_uint32(rtpheader + 4, htonl(rtp->lastts));
 		put_unaligned_uint32(rtpheader + 8, htonl(rtp->ssrc));
 
-		if ((res = sendto(rtp->s, (void *)rtpheader, frame->datalen + hdrlen, 0, (struct sockaddr *)&remote_address, sizeof(remote_address))) < 0) {
+		if ((res = ast_sendto(rtp->s, (void *)rtpheader, frame->datalen + hdrlen, 0, &remote_address)) < 0) {
 			if (!ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_NAT) || (ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_NAT) && (ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) {
-				ast_debug(1, "RTP Transmission error of packet %d to %s:%d: %s\n", rtp->seqno, ast_inet_ntoa(remote_address.sin_addr), ntohs(remote_address.sin_port), strerror(errno));
+				ast_debug(1, "RTP Transmission error of packet %d to %s: %s\n",
+					  rtp->seqno,
+					  ast_sockaddr_stringify(&remote_address),
+					  strerror(errno));
 			} else if (((ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) && !ast_test_flag(rtp, FLAG_NAT_INACTIVE_NOWARN)) {
 				/* Only give this error message once if we are not RTP debugging */
 				if (option_debug || rtpdebug)
-					ast_debug(0, "RTP NAT: Can't write RTP to private address %s:%d, waiting for other end to send audio...\n", ast_inet_ntoa(remote_address.sin_addr), ntohs(remote_address.sin_port));
+					ast_debug(0, "RTP NAT: Can't write RTP to private address %s, waiting for other end to send audio...\n",
+						  ast_sockaddr_stringify(&remote_address));
 				ast_set_flag(rtp, FLAG_NAT_INACTIVE_NOWARN);
 			}
 		} else {
@@ -1069,8 +1060,9 @@
 		}
 
 		if (rtp_debug_test_addr(&remote_address)) {
-			ast_verbose("Sent RTP packet to      %s:%u (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
-				    ast_inet_ntoa(remote_address.sin_addr), ntohs(remote_address.sin_port), codec, rtp->seqno, rtp->lastts, res - hdrlen);
+			ast_verbose("Sent RTP packet to      %s (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
+				    ast_sockaddr_stringify(&remote_address),
+				    codec, rtp->seqno, rtp->lastts, res - hdrlen);
 		}
 	}
 
@@ -1119,13 +1111,13 @@
 static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
 {
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
-	struct sockaddr_in remote_address = { 0, };
+	struct ast_sockaddr remote_address = { {0,} };
 	format_t codec, subclass;
 
 	ast_rtp_instance_get_remote_address(instance, &remote_address);
 
 	/* If we don't actually know the remote address don't even bother doing anything */
-	if (!remote_address.sin_addr.s_addr) {
+	if (ast_sockaddr_isnull(&remote_address)) {
 		ast_debug(1, "No remote address on RTP instance '%p' so dropping frame\n", instance);
 		return 0;
 	}
@@ -1286,17 +1278,19 @@
 static struct ast_frame *create_dtmf_frame(struct ast_rtp_instance *instance, enum ast_frame_type type, int compensate)
 {
 	struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
-	struct sockaddr_in remote_address = { 0, };
+	struct ast_sockaddr remote_address = { {0,} };
 
 	ast_rtp_instance_get_remote_address(instance, &remote_address);
 
 	if (((compensate && type == AST_FRAME_DTMF_END) || (type == AST_FRAME_DTMF_BEGIN)) && ast_tvcmp(ast_tvnow(), rtp->dtmfmute) < 0) {

[... 631 lines stripped ...]



More information about the asterisk-commits mailing list