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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 10 09:14:19 CDT 2007


Author: russell
Date: Fri Aug 10 09:14:19 2007
New Revision: 78953

URL: http://svn.digium.com/view/asterisk?view=rev&rev=78953
Log:
Attempt to support the sip: URI scheme for TLS connections as well

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=78953&r1=78952&r2=78953
==============================================================================
--- team/bbryant/sip-tcptls/channels/chan_sip.c (original)
+++ team/bbryant/sip-tcptls/channels/chan_sip.c Fri Aug 10 09:14:19 2007
@@ -8618,7 +8618,7 @@
 	struct ast_hostent ahp;
 	int port;
 	char *host, *pt;
-	char *contact;
+	char *contact, *contact2;
 
 
 	if (ast_test_flag(&pvt->flags[0], SIP_NAT_ROUTE)) {
@@ -8631,11 +8631,14 @@
 
 	/* Work on a copy */
 	contact = ast_strdupa(pvt->fullcontact);
+	contact2 = ast_strdupa(pvt->fullcontact);
 	/* We have only the part in <brackets> here so we just need to parse a SIP URI.*/
 
 	if (pvt->socket.type == SIP_TRANSPORT_TLS) {
-		if (parse_uri(contact, "sips:", &contact, NULL, &host, &pt, NULL))
-			ast_log(LOG_NOTICE, "'%s' is not a valid SIP contact (missing sips:) trying to use anyway\n", contact);
+		if (parse_uri(contact, "sips:", &contact, NULL, &host, &pt, NULL)) {
+			if (parse_uri(contact2, "sip:", &contact, NULL, &host, &pt, NULL))
+				ast_log(LOG_NOTICE, "'%s' is not a valid SIP contact (missing sip:) trying to use anyway\n", contact);
+		}
 		port = !ast_strlen_zero(pt) ? atoi(pt) : STANDARD_TLS_PORT;
 	} else {
 		if (parse_uri(contact, "sip:", &contact, NULL, &host, &pt, NULL))
@@ -8667,7 +8670,7 @@
 	char data[BUFSIZ];
 	const char *expires = get_header(req, "Expires");
 	int expiry = atoi(expires);
-	char *curi, *host, *pt;
+	char *curi, *host, *pt, *curi2;
 	int port;
 	const char *useragent;
 	struct hostent *hp;
@@ -8695,6 +8698,7 @@
 	if (strchr(contact, '<') == NULL)	/* No <, check for ; and strip it */
 		strsep(&curi, ";");	/* This is Header options, not URI options */
 	curi = get_in_brackets(contact);
+	curi2 = ast_strdupa(curi);
 
 	/* if they did not specify Contact: or Expires:, they are querying
 	   what we currently have stored as their contact address, so return
@@ -8734,8 +8738,10 @@
 
 	/* Make sure it's a SIP URL */
 	if (pvt->socket.type == SIP_TRANSPORT_TLS) {
-		if (parse_uri(curi, "sips:", &curi, NULL, &host, &pt, NULL))
-			ast_log(LOG_NOTICE, "Not a valid SIP contact (missing sips:) trying to use anyway\n");
+		if (parse_uri(curi, "sips:", &curi, NULL, &host, &pt, NULL)) {
+			if (parse_uri(curi2, "sips:", &curi, NULL, &host, &pt, NULL))
+				ast_log(LOG_NOTICE, "Not a valid SIP contact (missing sip:) trying to use anyway\n");
+		}
 		port = !ast_strlen_zero(pt) ? atoi(pt) : STANDARD_TLS_PORT;
 	} else {
 		if (parse_uri(curi, "sip:", &curi, NULL, &host, &pt, NULL))
@@ -10252,7 +10258,7 @@
 	char from[256];
 	char *dummy;	/* dummy return value for parse_uri */
 	char *domain;	/* dummy return value for parse_uri */
-	char *of;
+	char *of, *of2;
 	char rpid_num[50];
 	const char *rpid;
 	enum check_auth_result res;
@@ -10292,10 +10298,14 @@
 	/* save the URI part of the From header */
 	ast_string_field_set(p, from, of);
 
+	of2 = ast_strdupa(of);
+
 	/* ignore all fields but name */
 	if (p->socket.type == SIP_TRANSPORT_TLS) {
-		if (parse_uri(of, "sips:", &of, &dummy, &domain, &dummy, &dummy))
-			ast_log(LOG_NOTICE, "From address missing 'sips:', using it anyway\n");
+		if (parse_uri(of, "sips:", &of, &dummy, &domain, &dummy, &dummy)) {
+			if (parse_uri(of2, "sip:", &of, &dummy, &domain, &dummy, &dummy))
+				ast_log(LOG_NOTICE, "From address missing 'sip:', using it anyway\n");
+		}
 	} else {
 		if (parse_uri(of, "sip:", &of, &dummy, &domain, &dummy, &dummy))
 			ast_log(LOG_NOTICE, "From address missing 'sip:', using it anyway\n");




More information about the asterisk-commits mailing list