[svn-commits] elguero: branch 12 r401488 - in /branches/12: channels/ configs/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Oct 22 21:31:53 CDT 2013


Author: elguero
Date: Tue Oct 22 21:31:48 2013
New Revision: 401488

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=401488
Log:
chan_iax2: Fix Binding To Multiple Addresses Again

When reworking chan_iax2 for IPv6, the ability to bind to multiple addresses
was removed by mistake.  This patch restores this functionality and adds notes
about IPv6 addresses in the sample config.

(closes issue ASTERISK-22741)
Reported by: Joshua Colp
Tested by: Michael L. Young
Patches:
    asterisk-22741-fix-binding-multiple-addr.diff
                                     uploaded by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/2945/

Modified:
    branches/12/channels/chan_iax2.c
    branches/12/configs/iax.conf.sample

Modified: branches/12/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/channels/chan_iax2.c?view=diff&rev=401488&r1=401487&r2=401488
==============================================================================
--- branches/12/channels/chan_iax2.c (original)
+++ branches/12/channels/chan_iax2.c Tue Oct 22 21:31:48 2013
@@ -13256,7 +13256,6 @@
 			else if (ast_parse_arg(v->value, PARSE_UINT32 | PARSE_IN_RANGE, &portno, 1024, 65535)) {
 				portno = IAX_DEFAULT_PORTNO;
 			}
-			ast_sockaddr_set_port(&bindaddr, portno);
 		} else if (!strcasecmp(v->name, "pingtime")){
 			ping_time = atoi(v->value);
 		}
@@ -13318,18 +13317,28 @@
 			if (reload) {
 				ast_log(LOG_NOTICE, "Ignoring bindaddr on reload\n");
 			} else {
-				/* remember port if it has already been set */
-				int setport = ast_sockaddr_port(&bindaddr);
-
-				if (ast_parse_arg(v->value, PARSE_ADDR | PARSE_PORT_IGNORE, NULL)) {
-					ast_log(LOG_WARNING, "Invalid address '%s' specified, default '%s' will be used\n", v->value,
-						ast_sockaddr_stringify(&bindaddr));
+
+				if (!ast_parse_arg(v->value, PARSE_ADDR, NULL)) {
+
+					ast_sockaddr_parse(&bindaddr, v->value, 0);
+
+					if (!ast_sockaddr_port(&bindaddr)) {
+						ast_sockaddr_set_port(&bindaddr, portno);
+					}
+
+					if (!(ns = ast_netsock_bindaddr(netsock, io, &bindaddr, qos.tos, qos.cos, socket_read, NULL))) {
+						ast_log(LOG_WARNING, "Unable to apply binding to '%s' at line %d\n", v->value, v->lineno);
+					} else {
+						ast_verb(2, "Binding IAX2 to address %s\n", ast_sockaddr_stringify(&bindaddr));
+
+						if (defaultsockfd < 0) {
+							defaultsockfd = ast_netsock_sockfd(ns);
+						}
+						ast_netsock_unref(ns);
+					}
+
 				} else {
-					ast_sockaddr_parse(&bindaddr, v->value, PARSE_PORT_IGNORE);
-				}
-
-				if (setport) {
-					ast_sockaddr_set_port(&bindaddr, setport);
+					ast_log(LOG_WARNING, "Invalid address '%s' specified, at line %d\n", v->value, v->lineno);
 				}
 			}
 		} else if (!strcasecmp(v->name, "authdebug")) {
@@ -13528,15 +13537,14 @@
 		network_change_stasis_unsubscribe();
 	}
 
-	if (!ast_sockaddr_port(&bindaddr)) {
-		ast_sockaddr_set_port(&bindaddr, IAX_DEFAULT_PORTNO);
-	}
-
 	if (defaultsockfd < 0) {
+
+		ast_sockaddr_set_port(&bindaddr, portno);
+
 		if (!(ns = ast_netsock_bindaddr(netsock, io, &bindaddr, qos.tos, qos.cos, socket_read, NULL))) {
 			ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
 		} else {
-			ast_verb(2, "Binding IAX2 to address %s\n", ast_sockaddr_stringify(&bindaddr));
+			ast_verb(2, "Binding IAX2 to default address %s\n", ast_sockaddr_stringify(&bindaddr));
 			defaultsockfd = ast_netsock_sockfd(ns);
 			ast_netsock_unref(ns);
 		}

Modified: branches/12/configs/iax.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/12/configs/iax.conf.sample?view=diff&rev=401488&r1=401487&r2=401488
==============================================================================
--- branches/12/configs/iax.conf.sample (original)
+++ branches/12/configs/iax.conf.sample Tue Oct 22 21:31:48 2013
@@ -22,11 +22,13 @@
 ;bindport=4569           ; The default port to listen on
                          ; NOTE: bindport must be specified BEFORE bindaddr or
                          ; may be specified on a specific bindaddr if followed by
-                         ; colon and port (e.g. bindaddr=192.168.0.1:4569)
+                         ; colon and port (e.g. bindaddr=192.168.0.1:4569) or for
+                         ; IPv6 the address needs to be in brackets then colon
+                         ; and port (e.g. bindaddr=[2001:db8::1]:4569).
 
 ;bindaddr=192.168.0.1    ; You can specify 'bindaddr' more than once to bind to
                          ; multiple addresses, but the first will be the
-                         ; default.
+                         ; default. IPv6 addresses are accepted.
 
 ;
 ; Set 'iaxcompat' to yes if you plan to use layered switches or some other




More information about the svn-commits mailing list