[asterisk-commits] bbryant: branch bbryant/sip-tcptls r73759 - in /team/bbryant/sip-tcptls: chan...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 6 14:17:43 CDT 2007


Author: bbryant
Date: Fri Jul  6 14:17:42 2007
New Revision: 73759

URL: http://svn.digium.com/view/asterisk?view=rev&rev=73759
Log:
Updating my tls branch

Modified:
    team/bbryant/sip-tcptls/channels/chan_sip.c
    team/bbryant/sip-tcptls/configs/sip.conf.sample

Modified: team/bbryant/sip-tcptls/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/bbryant/sip-tcptls/channels/chan_sip.c?view=diff&rev=73759&r1=73758&r2=73759
==============================================================================
--- team/bbryant/sip-tcptls/channels/chan_sip.c (original)
+++ team/bbryant/sip-tcptls/channels/chan_sip.c Fri Jul  6 14:17:42 2007
@@ -1804,11 +1804,6 @@
 	ast_free(ser);
 	ast_free(req.socket.lock);
 
-	if (pvt) {
-		ast_debug(3, "Destroying sip session '%s', %s.", pvt->callid, strerror(errno));
-		sip_destroy(pvt);
-	}
-
 	return NULL;
 }
 
@@ -3280,7 +3275,7 @@
    	   then hostname lookup */
 
 	hostn = peername;
-	portno = port ? atoi(port) : STANDARD_SIP_PORT;
+	portno = port ? atoi(port) : (dialog->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT;
 	if (global_srvlookup) {
 		char service[MAXHOSTNAMELEN];
 		int tportno;
@@ -8604,6 +8599,8 @@
 		}
 	}
 
+	pvt->socket = peer->socket = req->socket;
+
 	/* Look for brackets */
 	curi = contact;
 	if (strchr(contact, '<') == NULL)	/* No <, check for ; and strip it */
@@ -8656,6 +8653,7 @@
 			ast_log(LOG_NOTICE, "Not a valid SIP contact (missing sip:) trying to use anyway\n");
 		port = !ast_strlen_zero(pt) ? atoi(pt) : STANDARD_SIP_PORT;
 	}
+
 	oldsin = peer->addr;
 	if (!ast_test_flag(&peer->flags[0], SIP_NAT_ROUTE)) {
 		/* XXX This could block for a long time XXX */
@@ -8672,8 +8670,6 @@
 		   with */
 		peer->addr = pvt->recv;
 	}
-
-	peer->socket = req->socket;
 
 	/* Save SIP options profile */
 	peer->sipoptions = pvt->sipoptions;
@@ -8693,7 +8689,8 @@
 		ast_sched_add(sched, (expiry + 10) * 1000, expire_register, peer);
 	pvt->expiry = expiry;
 	snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry, peer->username, peer->fullcontact);
-	if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT)) 
+	/* Saving TCP connections is useless, we won't be able to reconnect */
+	if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT) && (peer->socket.type & SIP_TRANSPORT_UDP)) 
 		ast_db_put("SIP/Registry", peer->name, data);
 	manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Registered\r\n", peer->name);
 
@@ -9163,6 +9160,7 @@
 		peer = NULL;
 		res = AUTH_ACL_FAILED;
 	}
+
 	if (peer) {
 		/* Set Frame packetization */
 		if (p->rtp) {
@@ -16431,6 +16429,7 @@
 	
 	p->sa = peer->addr;
 	p->recv = peer->addr;
+	p->socket = peer->socket;
 	ast_copy_flags(&p->flags[0], &peer->flags[0], SIP_FLAGS_TO_COPY);
 	ast_copy_flags(&p->flags[1], &peer->flags[1], SIP_PAGE2_FLAGS_TO_COPY);
 
@@ -17380,9 +17379,10 @@
 		}
 
 		ast_copy_string(peer->tohost, srvlookup, sizeof(peer->tohost));
-		if (!peer->addr.sin_port)
-			peer->addr.sin_port = htons(STANDARD_SIP_PORT);
-	}
+	}
+
+	if (!peer->addr.sin_port)
+		peer->addr.sin_port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
 
 	if (!ast_test_flag(&global_flags[1], SIP_PAGE2_IGNOREREGEXPIRE) && ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC) && realtime) {
 		time_t nowtime = time(NULL);
@@ -18052,14 +18052,10 @@
 
 	server_start(&sip_tcp_desc);
 
-	if (ssl_setup(sip_tls_desc.tls_cfg)) {
+	if (ssl_setup(sip_tls_desc.tls_cfg))
 		server_start(&sip_tls_desc);
-		ast_log(LOG_WARNING, "SSL started on %s:%d\n", ast_inet_ntoa(sip_tls_desc.sin.sin_addr), ntohs(sip_tls_desc.sin.sin_port));
-		ast_log(LOG_WARNING, "\tCertfile: '%s'\n", sip_tls_desc.tls_cfg->certfile);
-		ast_log(LOG_WARNING, "\tCipher: '%s'\n", sip_tls_desc.tls_cfg->cipher);
-		ast_log(LOG_WARNING, "\tFamily: '%s'\n", ((sip_tls_desc.sin.sin_family == AF_INET) ? "AF_INET" : "0"));
-	} else if(sip_tls_desc.tls_cfg->enabled)
-		ast_log(LOG_WARNING, "SIP TLS did not load because of errors.\n");
+	else if(sip_tls_desc.tls_cfg->enabled)
+		ast_log(LOG_WARNING, "SIP TLS server did not load because of errors.\n");
 
 	/* Done, tell the manager */
 	manager_event(EVENT_FLAG_SYSTEM, "ChannelReload", "ChannelType: SIP\r\nReloadReason: %s\r\nRegistry_Count: %d\r\nPeer_Count: %d\r\nUser_Count: %d\r\n\r\n", channelreloadreason2txt(reason), registry_count, peer_count, user_count);

Modified: team/bbryant/sip-tcptls/configs/sip.conf.sample
URL: http://svn.digium.com/view/asterisk/team/bbryant/sip-tcptls/configs/sip.conf.sample?view=diff&rev=73759&r1=73758&r2=73759
==============================================================================
--- team/bbryant/sip-tcptls/configs/sip.conf.sample (original)
+++ team/bbryant/sip-tcptls/configs/sip.conf.sample Fri Jul  6 14:17:42 2007
@@ -41,6 +41,16 @@
 bindport=5060			; UDP Port to bind to (SIP standard port is 5060)
 				; bindport is the local UDP port that Asterisk will listen on
 bindaddr=0.0.0.0		; IP address to bind to (0.0.0.0 binds to all)
+
+tcpenable=yes			; Enable server for incoming TCP connections (default is yes)
+tcpbindaddr=0.0.0.0		; IP adderss for TCP server to bind to (0.0.0.0 binds to all interfaces)
+;tcpbindport=5060		; Set the TCP bind port (default is 5060)
+
+;tlsenable=no			; Enable server for incoming TLS (secure) connections (default is no)
+;tlsbindaddr=0.0.0.0	; IP address for TLS server to bind to (0.0.0.0) binds to all interfaces)
+;tlsbindport=5061		; Set the TLS bind port (default is 5061)
+;tlscertfile=asterisk.pem	; Certificate file (*.pem only) to use for TLS connections 
+						 	; default is to look for "asterisk.pem" in current directory
 srvlookup=yes			; Enable DNS SRV lookups on outbound calls
 				; Note: Asterisk only uses the first host 
 				; in SRV records
@@ -487,7 +497,7 @@
 ; User config options:        Peer configuration:
 ; --------------------        -------------------
 ; context                     context
-; callingpres		      callingpres
+; callingpres                 callingpres
 ; permit                      permit
 ; deny                        deny
 ; secret                      secret




More information about the asterisk-commits mailing list