[svn-commits] jpdionne: branch group/v6-new r271125 - in /team/group/v6-new/channels: ./ si...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 17 10:16:04 CDT 2010


Author: jpdionne
Date: Thu Jun 17 10:16:00 2010
New Revision: 271125

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=271125
Log:
Fix various inconsistencies in configuration with *bindaddr and {tcp,tls}enable.

Modified:
    team/group/v6-new/channels/chan_sip.c
    team/group/v6-new/channels/sip/include/sip.h

Modified: team/group/v6-new/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/channels/chan_sip.c?view=diff&rev=271125&r1=271124&r2=271125
==============================================================================
--- team/group/v6-new/channels/chan_sip.c (original)
+++ team/group/v6-new/channels/chan_sip.c Thu Jun 17 10:16:00 2010
@@ -2190,6 +2190,9 @@
 
 /*! \brief The TCP server definition */
 static struct ast_tcptls_session_args sip_tcp_desc = {
+	.local_address = { { 0, } },
+	.remote_address = { { 0, } },
+	.old_address = { { 0, } },
 	.accept_fd = -1,
 	.master = AST_PTHREADT_NULL,
 	.tls_cfg = NULL,
@@ -2201,6 +2204,9 @@
 
 /*! \brief The TCP/TLS server definition */
 static struct ast_tcptls_session_args sip_tls_desc = {
+	.local_address = { { 0, } },
+	.remote_address = { { 0, } },
+	.old_address = { { 0, } },
 	.accept_fd = -1,
 	.master = AST_PTHREADT_NULL,
 	.tls_cfg = &sip_tls_cfg,
@@ -16271,11 +16277,11 @@
 	ast_cli(a->fd, "\n\nGlobal Settings:\n");
 	ast_cli(a->fd, "----------------\n");
 	ast_cli(a->fd, "  UDP Bindaddress:        %s\n", ast_sockaddr_stringify(&bindaddr));
-	ast_cli(a->fd, "  TCP SIP Bindaddres:     %s\n",
-		ast_sockaddr_isnull(&sip_tcp_desc.local_address) ?
-				"Disabled" :
-				ast_sockaddr_stringify(&sip_tcp_desc.local_address));
-	ast_cli(a->fd, "  TLS SIP Bindaddres:     %s\n",
+	ast_cli(a->fd, "  TCP SIP Bindaddress:    %s\n",
+		sip_cfg.tcp_enabled != FALSE ?
+				ast_sockaddr_stringify(&sip_tcp_desc.local_address) :
+				"Disabled");
+	ast_cli(a->fd, "  TLS SIP Bindaddress:    %s\n",
 		default_tls_cfg.enabled != FALSE ?
 				ast_sockaddr_stringify(&sip_tls_desc.local_address) :
 				"Disabled");
@@ -25935,6 +25941,7 @@
 	ast_set_flag(&global_flags[1], SIP_PAGE2_ALLOWOVERLAP);		/* Default for all devices: TRUE */
 	sip_cfg.peer_rtupdate = TRUE;
 	global_dynamic_exclude_static = 0;	/* Exclude static peers */
+	sip_cfg.tcp_enabled = FALSE;
 
 	/* Session-Timers */
 	global_st_mode = SESSION_TIMER_MODE_ACCEPT;
@@ -26073,7 +26080,7 @@
 		} else if (!strcasecmp(v->name, "tcpenable")) {
 			if(!ast_false(v->value)) {
 				ast_debug(2, "Enabling TCP socket for listening\n");
-				ast_sockaddr_parse(&sip_tcp_desc.local_address, "0.0.0.0:5060", 0);
+				sip_cfg.tcp_enabled = TRUE;
 			}
 		} else if (!strcasecmp(v->name, "tcpbindaddr")) {
 			if (ast_parse_arg(v->value, PARSE_ADDR, &sip_tcp_desc.local_address))
@@ -26245,6 +26252,8 @@
 		} else if (!strcasecmp(v->name, "bindaddr") || !strcasecmp(v->name, "udpbindaddr")) {
 			if (ast_parse_arg(v->value, PARSE_ADDR, &bindaddr))
 				ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
+			if (!ast_sockaddr_port(&bindaddr))
+				ast_sockaddr_set_port(&bindaddr, STANDARD_SIP_PORT);
 		} else if (!strcasecmp(v->name, "localnet")) {
 			struct ast_ha *na;
 			int ha_error = 0;
@@ -26609,19 +26618,26 @@
 	ast_mutex_unlock(&netlock);
 
 	/* Start TCP server */
-	ast_tcptls_server_start(&sip_tcp_desc);
- 	if (sip_tcp_desc.accept_fd == -1 && !ast_sockaddr_isnull(&sip_tcp_desc.local_address)) {
-		/* TCP server start failed. Tell the admin */
-		ast_log(LOG_ERROR, "SIP TCP Server start failed. Not listening on TCP socket.\n");
-		ast_sockaddr_setnull(&sip_tcp_desc.local_address);
-	} else {
-		ast_debug(2, "SIP TCP server started\n");
+	if (sip_cfg.tcp_enabled) {
+		if (ast_sockaddr_isnull(&sip_tcp_desc.local_address))
+			ast_sockaddr_copy(&sip_tcp_desc.local_address, &bindaddr);
+		ast_tcptls_server_start(&sip_tcp_desc);
+		if (sip_tcp_desc.accept_fd == -1) {
+			/* TCP server start failed. Tell the admin */
+			ast_log(LOG_ERROR, "SIP TCP Server start failed. Not listening on TCP socket.\n");
+		} else {
+			ast_debug(2, "SIP TCP server started\n");
+		}
 	}
 
 	/* Start TLS server if needed */
 	memcpy(sip_tls_desc.tls_cfg, &default_tls_cfg, sizeof(default_tls_cfg));
 
 	if (ast_ssl_setup(sip_tls_desc.tls_cfg)) {
+		if (ast_sockaddr_isnull(&sip_tls_desc.local_address)) {
+			ast_sockaddr_copy(&sip_tls_desc.local_address, &bindaddr);
+			ast_sockaddr_set_port(&sip_tls_desc.local_address, STANDARD_TLS_PORT);
+		}
 		ast_tcptls_server_start(&sip_tls_desc);
  		if (default_tls_cfg.enabled && sip_tls_desc.accept_fd == -1) {
 			ast_log(LOG_ERROR, "TLS Server start failed. Not listening on TLS socket.\n");
@@ -26658,8 +26674,9 @@
 				SIP_DOMAIN_AUTO, NULL);
 
 		/* If TLS is running on a different IP than UDP and TCP, then add that too */
-		if (ast_sockaddr_isnull(&sip_tls_desc.local_address) && 
-				!ast_sockaddr_cmp(&bindaddr, &sip_tls_desc.local_address))
+		if (!ast_sockaddr_isnull(&sip_tls_desc.local_address) && 
+				!ast_sockaddr_cmp(&bindaddr, &sip_tls_desc.local_address) && 
+				!ast_sockaddr_cmp(&sip_tcp_desc.local_address, &sip_tls_desc.local_address))
 			add_sip_domain(ast_sockaddr_stringify(&sip_tcp_desc.local_address), 
 				SIP_DOMAIN_AUTO, NULL);
 

Modified: team/group/v6-new/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/channels/sip/include/sip.h?view=diff&rev=271125&r1=271124&r2=271125
==============================================================================
--- team/group/v6-new/channels/sip/include/sip.h (original)
+++ team/group/v6-new/channels/sip/include/sip.h Thu Jun 17 10:16:00 2010
@@ -693,6 +693,7 @@
 	char default_subscribecontext[AST_MAX_CONTEXT];
 	struct ast_ha *contact_ha;  /*! \brief Global list of addresses dynamic peers are not allowed to use */
 	format_t capability;        /*!< Supported codecs */
+	int tcp_enabled;
 };
 
 /*! \brief The SIP socket definition */




More information about the svn-commits mailing list