[asterisk-commits] pabelanger: branch pabelanger/OverrideIAX2 r334431 - /team/pabelanger/Overrid...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Sep 3 20:15:47 CDT 2011


Author: pabelanger
Date: Sat Sep  3 20:15:37 2011
New Revision: 334431

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=334431
Log:
Bind after configuration file is parsed


Modified:
    team/pabelanger/OverrideIAX2/channels/chan_iax2.c

Modified: team/pabelanger/OverrideIAX2/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/pabelanger/OverrideIAX2/channels/chan_iax2.c?view=diff&rev=334431&r1=334430&r2=334431
==============================================================================
--- team/pabelanger/OverrideIAX2/channels/chan_iax2.c (original)
+++ team/pabelanger/OverrideIAX2/channels/chan_iax2.c Sat Sep  3 20:15:37 2011
@@ -255,7 +255,6 @@
 
 static const char tdesc[] = "Inter Asterisk eXchange Driver (Ver 2)";
 
-
 /*! \brief Maximum transmission unit for the UDP packet in the trunk not to be
     fragmented. This is based on 1516 - ethernet - ip - udp - iax minus one g711 frame = 1240 */
 #define MAX_TRUNK_MTU 1240
@@ -277,9 +276,9 @@
 static int max_retries = 4;
 static int ping_time = 21;
 static int lagrq_time = 10;
-static int maxjitterbuffer=1000;
-static int resyncthreshold=1000;
-static int maxjitterinterps=10;
+static int maxjitterbuffer = 1000;
+static int resyncthreshold = 1000;
+static int maxjitterinterps = 10;
 static int jittertargetextra = 40; /* number of milliseconds the new jitter buffer adds on to its size */
 
 #define MAX_TRUNKDATA           640 * 200       /*!< 40ms, uncompressed linear * 200 channels */
@@ -307,6 +306,8 @@
 static int srvlookup = 0;
 
 static struct ast_timer *timer;				/* Timer for trunking */
+
+static char *bindaddr = "0.0.0.0";
 
 static struct ast_netsock_list *netsock;
 static struct ast_netsock_list *outsock;		/*!< used if sourceaddress specified and bindaddr == INADDR_ANY */
@@ -13179,23 +13180,7 @@
 		} else if (!strcasecmp(v->name, "minregexpire")) {
 			min_reg_expire = atoi(v->value);
 		} else if (!strcasecmp(v->name, "bindaddr")) {
-			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);
-				} 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_copy_string(bindaddr, v->value, sizeof(bindaddr));
 		} else if (!strcasecmp(v->name, "authdebug")) {
 			authdebug = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "encryption")) {
@@ -13393,14 +13378,16 @@
 		network_change_event_unsubscribe();
 	}
 
-	if (defaultsockfd < 0) {
-		if (!(ns = ast_netsock_bind(netsock, io, "0.0.0.0", portno, qos.tos, qos.cos, socket_read, NULL))) {
-			ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
+	if (!(ns = ast_netsock_bind(netsock, io, bindaddr, portno, qos.tos, qos.cos, socket_read, NULL))) {
+		ast_log(LOG_ERROR, "Unable to create network socket: %s\n", strerror(errno));
+	} else {
+		if (strchr(v->value, ':')) {
+			ast_verb(2, "Binding IAX2 to '%s'\n", v->value);
 		} else {
-			ast_verb(2, "Binding IAX2 to default address 0.0.0.0:%d\n", portno);
-			defaultsockfd = ast_netsock_sockfd(ns);
-			ast_netsock_unref(ns);
-		}
+			ast_verb(2, "Binding IAX2 to '%s:%d'\n", v->value, portno);
+		}
+		defaultsockfd = ast_netsock_sockfd(ns);
+		ast_netsock_unref(ns);
 	}
 	if (reload) {
 		ast_netsock_release(outsock);




More information about the asterisk-commits mailing list