[asterisk-commits] seanbright: branch seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_se...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 27 16:18:12 CST 2012


Author: seanbright
Date: Mon Feb 27 16:18:08 2012
New Revision: 357091

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=357091
Log:
Update iax2_peer.defaddr to ast_sockaddr with notes to revisit.

Modified:
    team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/channels/chan_iax2.c

Modified: team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/channels/chan_iax2.c?view=diff&rev=357091&r1=357090&r2=357091
==============================================================================
--- team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/channels/chan_iax2.c (original)
+++ team/seanbright/the_ipv6ification_of_chan_iax2_by_the_coward_sean_bright/channels/chan_iax2.c Mon Feb 27 16:18:08 2012
@@ -517,7 +517,7 @@
 	uint64_t flags;
 
 	/* Dynamic Registration fields */
-	struct sockaddr_in defaddr;			/*!< Default address if there is one */
+	struct ast_sockaddr defaddr;			/*!< Default address if there is one */
 	int authmethods;				/*!< Authentication methods (IAX_AUTH_*) */
 	int encmethods;					/*!< Encryption methods (IAX_ENCRYPT_*) */
 
@@ -3784,7 +3784,7 @@
 		ast_cli(a->fd, "  Expire       : %d\n", peer->expire);
 		ast_cli(a->fd, "  ACL          : %s\n", (peer->ha ? "Yes" : "No"));
 		ast_cli(a->fd, "  Addr->IP     : %s Port %d\n",  peer_addr.sin_addr.s_addr ? ast_inet_ntoa(peer_addr.sin_addr) : "(Unspecified)", ntohs(peer_addr.sin_port));
-		ast_cli(a->fd, "  Defaddr->IP  : %s Port %d\n", ast_inet_ntoa(peer->defaddr.sin_addr), ntohs(peer->defaddr.sin_port));
+		ast_cli(a->fd, "  Defaddr->IP  : %s Port %s\n", ast_sockaddr_stringify_addr(&peer->defaddr), ast_sockaddr_stringify_port(&peer->defaddr));
 		ast_cli(a->fd, "  Username     : %s\n", peer->username);
 		ast_cli(a->fd, "  Codecs       : ");
 		iax2_getformatname_multiple(codec_buf, sizeof(codec_buf) -1, peer->capability);
@@ -4593,7 +4593,7 @@
 	ast_sockaddr_to_sin(&peer->addr, &peer_addr);
 
 	/* if the peer has no address (current or default), return failure */
-	if (!(peer_addr.sin_addr.s_addr || peer->defaddr.sin_addr.s_addr)) {
+	if (!(peer_addr.sin_addr.s_addr || !ast_sockaddr_isnull(&peer->defaddr))) {
 		goto return_unref;
 	}
 
@@ -4648,8 +4648,7 @@
 		sin->sin_addr = peer_addr.sin_addr;
 		sin->sin_port = peer_addr.sin_port;
 	} else {
-		sin->sin_addr = peer->defaddr.sin_addr;
-		sin->sin_port = peer->defaddr.sin_port;
+		ast_sockaddr_to_sin(&peer->defaddr, sin);
 	}
 
 	res = 0;
@@ -12524,7 +12523,7 @@
 						/* Initialize stuff iff we're not found, otherwise
 						   we keep going with what we had */
 						if (ast_sockaddr_port(&peer->addr)) {
-							peer->defaddr.sin_port = htons(ast_sockaddr_port(&peer->addr));
+							ast_sockaddr_set_port(&peer->defaddr, ast_sockaddr_port(&peer->addr));
 						}
 						ast_sockaddr_setnull(&peer->addr);
 					}
@@ -12541,14 +12540,11 @@
 				if (!maskfound)
 					inet_aton("255.255.255.255", &peer->mask);
 			} else if (!strcasecmp(v->name, "defaultip")) {
-				struct ast_sockaddr peer_defaddr_tmp;
-
-				peer_defaddr_tmp.ss.ss_family = AF_INET;
-				if (ast_get_ip(&peer_defaddr_tmp, v->value)) {
+				ast_sockaddr_setnull(&peer->defaddr);
+				/* SRB: How do we want to handle this?  Could be v4 or v6 */
+				if (ast_get_ip(&peer->defaddr, v->value)) {
 					return peer_unref(peer);
 				}
-				ast_sockaddr_to_sin(&peer_defaddr_tmp,
-						    &peer->defaddr);
 			} else if (!strcasecmp(v->name, "sourceaddress")) {
 				peer_set_srcaddr(peer, v->value);
 			} else if (!strcasecmp(v->name, "permit") ||
@@ -12565,7 +12561,7 @@
 				ast_string_field_set(peer, peercontext, v->value);
 			} else if (!strcasecmp(v->name, "port")) {
 				if (ast_test_flag64(peer, IAX_DYNAMIC)) {
-					peer->defaddr.sin_port = htons(atoi(v->value));
+					ast_sockaddr_set_port(&peer->defaddr, atoi(v->value));
 				} else {
 					ast_sockaddr_set_port(&peer->addr, atoi(v->value));
 				}
@@ -14034,10 +14030,10 @@
 		return res;
 
 	res = AST_DEVICE_UNAVAILABLE;
-	ast_debug(3, "iax2_devicestate: Found peer. What's device state of %s? addr=%d, defaddr=%d maxms=%d, lastms=%d\n",
-		pds.peer, ast_sockaddr_ipv4(&p->addr), p->defaddr.sin_addr.s_addr, p->maxms, p->lastms);
-
-	if ((ast_sockaddr_ipv4(&p->addr) || p->defaddr.sin_addr.s_addr) &&
+	ast_debug(3, "iax2_devicestate: Found peer. What's device state of %s? addr=%d, defaddr=%s maxms=%d, lastms=%d\n",
+		pds.peer, ast_sockaddr_ipv4(&p->addr), ast_sockaddr_stringify_addr(&p->defaddr), p->maxms, p->lastms);
+
+	if ((ast_sockaddr_ipv4(&p->addr) || !ast_sockaddr_isnull(&p->defaddr)) &&
 	    (!p->maxms || ((p->lastms > -1) && (p->historicms <= p->maxms)))) {
 		/* Peer is registered, or have default IP address
 		   and a valid registration */




More information about the asterisk-commits mailing list