[asterisk-commits] russell: branch bbryant/sip-tcptls r73764 - /team/bbryant/sip-tcptls/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 6 15:54:28 CDT 2007


Author: russell
Date: Fri Jul  6 15:54:27 2007
New Revision: 73764

URL: http://svn.digium.com/view/asterisk?view=rev&rev=73764
Log:
little code cleanups

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

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=73764&r1=73763&r2=73764
==============================================================================
--- team/bbryant/sip-tcptls/channels/chan_sip.c (original)
+++ team/bbryant/sip-tcptls/channels/chan_sip.c Fri Jul  6 15:54:27 2007
@@ -1224,7 +1224,7 @@
 		AST_STRING_FIELD(callback);	/*!< Contact extension */
 		AST_STRING_FIELD(random);
 	);
-	int transport;
+	enum sip_transport transport;
 	int portno;			/*!<  Optional port override */
 	int expire;			/*!< Sched ID of expiration */
 	int expiry;			/*!< Value to use for the Expires header */
@@ -2624,9 +2624,7 @@
 			ast_log(LOG_WARNING, "No closing bracket found in '%s'\n", tmp);
 		}
 	}
-	/* TODO Fix this to something cleaner  */
-	if (!strncmp(tmp, "sips:", 5))
-		sprintf(tmp, "sip%s", tmp+4);
+	
 	return tmp;
 }
 
@@ -5044,8 +5042,9 @@
 {
 	struct sip_registry *reg;
 	int portnum = 0;
-	int transport = SIP_TRANSPORT_UDP;
-	char username[256] = "";
+	enum sip_transport transport = SIP_TRANSPORT_UDP;
+	char buf[256] = "";
+	char *username = NULL;
 	char *hostname=NULL, *secret=NULL, *authuser=NULL;
 	char *porta=NULL;
 	char *callback=NULL;
@@ -5053,33 +5052,29 @@
 
 	if (!value)
 		return -1;
-	ast_copy_string(username, value, sizeof(username));
-
-	trans = strstr(username, "://");
-
-	if (trans) {
-		*trans = '\0';
-
-		if (trans - username == 3 && 
-			(!strncasecmp(username, "udp", 3) ||
-		  	 !strncasecmp(username, "tcp", 3) ||
-		   	 !strncasecmp(username, "tls", 3))) {
-			switch(username[1] + ((username[1] < 97) ? 32 : 0)) { // Ensure lowercase
-				case 'c':
-					transport = SIP_TRANSPORT_TCP;
-					break;
-				case 'l':
-					transport = SIP_TRANSPORT_TLS;
-					break;
-			}
-		} else {
-		    ast_log(LOG_WARNING, "Invalid transport type '%s' given at line %d\n", username, lineno);
-		}
-
-		ast_copy_string(username, trans + 3, sizeof(username));
-	}
-
-	ast_log(LOG_DEBUG, "Transport type is '%d' for register URI '%s'\n", transport, username);
+
+	ast_copy_string(buf, value, sizeof(buf));
+
+	username = strstr(buf, "://");
+
+	if (username) {
+		*username = '\0';
+		username += 3;
+
+		trans = buf;
+
+		if (!strcasecmp(trans, "udp"))
+			transport = SIP_TRANSPORT_UDP;
+		else if (!strcasecmp(trans, "tcp"))
+			transport = SIP_TRANSPORT_TCP;
+		else if (!strcasecmp(trans, "tls"))
+			transport = SIP_TRANSPORT_TLS;
+		else
+			ast_log(LOG_WARNING, "'%s' is not a valid transport value for registration '%s' at line '%d'\n", trans, value, lineno);
+	} else {
+		username = buf;
+		ast_log(LOG_DEBUG, "no trans\n");
+	}
 
 	/* First split around the last '@' then parse the two components. */
 	hostname = strrchr(username, '@'); /* allow @ in the first part */
@@ -17495,8 +17490,7 @@
 	memset(&global_outboundproxy, 0, sizeof(struct sip_proxy));
 	global_outboundproxy.ip.sin_port = htons(STANDARD_SIP_PORT);
 	global_outboundproxy.ip.sin_family = AF_INET;	/* Type of address: IPv4 */
-	ourport = 
-	ourport_tcp = STANDARD_SIP_PORT;
+	ourport = ourport_tcp = STANDARD_SIP_PORT;
 	ourport_tls = STANDARD_TLS_PORT;
 	global_srvlookup = DEFAULT_SRVLOOKUP;
 	global_tos_sip = DEFAULT_TOS_SIP;




More information about the asterisk-commits mailing list