[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
Thu Mar 1 14:15:32 CST 2012


Author: seanbright
Date: Thu Mar  1 14:15:28 2012
New Revision: 357715

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=357715
Log:
Resolve bindaddr before calling ast_netsock_bindaddr().

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=357715&r1=357714&r2=357715
==============================================================================
--- 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 Thu Mar  1 14:15:28 2012
@@ -13201,16 +13201,28 @@
 			if (reload) {
 				ast_log(LOG_NOTICE, "Ignoring bindaddr on reload\n");
 			} else {
-				if (!(ns = ast_netsock_bind(netsock, io, v->value, portno, qos.tos, qos.cos, socket_read, NULL))) {
-					ast_log(LOG_WARNING, "Unable apply binding to '%s' at line %d\n", v->value, v->lineno);
+				struct ast_sockaddr *addrs;
+				int num_addrs = 0;
+
+				if ((num_addrs = ast_sockaddr_resolve(&addrs, v->value, 0, AST_AF_UNSPEC))) {
+					int i;
+
+					for (i = 0; i < num_addrs; i++) {
+						if (!ast_sockaddr_port(&addrs[i])) {
+							ast_sockaddr_set_port(&addrs[i], portno);
+						}
+						if ((ns = ast_netsock_bindaddr(netsock, io, &addrs[i], qos.tos, qos.cos, socket_read, NULL))) {
+							ast_verb(2, "Binding IAX2 to '%s'\n", ast_sockaddr_stringify(&addrs[i]));
+							if (defaultsockfd < 0) {
+								defaultsockfd = ast_netsock_sockfd(ns);
+							}
+							ast_netsock_unref(ns);
+						}
+					}
+
+					ast_free(addrs);
 				} else {
-						if (strchr(v->value, ':'))
-						ast_verb(2, "Binding IAX2 to '%s'\n", v->value);
-						else
-						ast_verb(2, "Binding IAX2 to '%s:%d'\n", v->value, portno);
-					if (defaultsockfd < 0) 
-						defaultsockfd = ast_netsock_sockfd(ns);
-					ast_netsock_unref(ns);
+					ast_log(LOG_WARNING, "Unable to bind to '%s' at line %d\n", v->value, v->lineno);
 				}
 			}
 		} else if (!strcasecmp(v->name, "authdebug")) {




More information about the asterisk-commits mailing list