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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Feb 27 16:36:16 CST 2012


Author: seanbright
Date: Mon Feb 27 16:36:12 2012
New Revision: 357092

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=357092
Log:
On second thought, this is full of fail.  ast_sockaddr_set_port is a noop unless
the family is known, so give this some more thought.

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=357092&r1=357091&r2=357092
==============================================================================
--- 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:36:12 2012
@@ -517,7 +517,7 @@
 	uint64_t flags;
 
 	/* Dynamic Registration fields */
-	struct ast_sockaddr defaddr;			/*!< Default address if there is one */
+	struct sockaddr_in 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 %s\n", ast_sockaddr_stringify_addr(&peer->defaddr), ast_sockaddr_stringify_port(&peer->defaddr));
+		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, "  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 || !ast_sockaddr_isnull(&peer->defaddr))) {
+	if (!(peer_addr.sin_addr.s_addr || peer->defaddr.sin_addr.s_addr)) {
 		goto return_unref;
 	}
 
@@ -4648,7 +4648,8 @@
 		sin->sin_addr = peer_addr.sin_addr;
 		sin->sin_port = peer_addr.sin_port;
 	} else {
-		ast_sockaddr_to_sin(&peer->defaddr, sin);
+		sin->sin_addr = peer->defaddr.sin_addr;
+		sin->sin_port = peer->defaddr.sin_port;
 	}
 
 	res = 0;
@@ -12523,7 +12524,7 @@
 						/* Initialize stuff iff we're not found, otherwise
 						   we keep going with what we had */
 						if (ast_sockaddr_port(&peer->addr)) {
-							ast_sockaddr_set_port(&peer->defaddr, ast_sockaddr_port(&peer->addr));
+							peer->defaddr.sin_port = htons(ast_sockaddr_port(&peer->addr));
 						}
 						ast_sockaddr_setnull(&peer->addr);
 					}
@@ -12540,11 +12541,14 @@
 				if (!maskfound)
 					inet_aton("255.255.255.255", &peer->mask);
 			} else if (!strcasecmp(v->name, "defaultip")) {
-				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)) {
+				struct ast_sockaddr peer_defaddr_tmp;
+
+				peer_defaddr_tmp.ss.ss_family = AF_INET;
+				if (ast_get_ip(&peer_defaddr_tmp, 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") ||
@@ -12561,7 +12565,7 @@
 				ast_string_field_set(peer, peercontext, v->value);
 			} else if (!strcasecmp(v->name, "port")) {
 				if (ast_test_flag64(peer, IAX_DYNAMIC)) {
-					ast_sockaddr_set_port(&peer->defaddr, atoi(v->value));
+					peer->defaddr.sin_port = htons(atoi(v->value));
 				} else {
 					ast_sockaddr_set_port(&peer->addr, atoi(v->value));
 				}
@@ -14030,10 +14034,10 @@
 		return res;
 
 	res = AST_DEVICE_UNAVAILABLE;
-	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)) &&
+	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) &&
 	    (!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 svn-commits mailing list