[asterisk-commits] bbryant: branch bbryant/ssl-tcp-tls r70768 - /team/bbryant/ssl-tcp-tls/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 21 11:29:09 CDT 2007


Author: bbryant
Date: Thu Jun 21 11:29:08 2007
New Revision: 70768

URL: http://svn.digium.com/view/asterisk?view=rev&rev=70768
Log:
There's progress, I can make calls via TCP over SIP ...

Modified:
    team/bbryant/ssl-tcp-tls/channels/chan_sip.c

Modified: team/bbryant/ssl-tcp-tls/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/bbryant/ssl-tcp-tls/channels/chan_sip.c?view=diff&rev=70768&r1=70767&r2=70768
==============================================================================
--- team/bbryant/ssl-tcp-tls/channels/chan_sip.c (original)
+++ team/bbryant/ssl-tcp-tls/channels/chan_sip.c Thu Jun 21 11:29:08 2007
@@ -1715,9 +1715,9 @@
 static void *sip_tcp_helper_thread(void *data) {
 	struct sip_pvt *p;
 	struct server_instance *ser = data;
-	int lockretry, nounlock;
+	int lockretry, nounlock, cl;
 	char buf[1024];
-	struct sip_request req = { 0, };
+	struct sip_request req = { 0, }, reqcpy = { 0, };
 
 	for (;;) {
 		bzero(req.data, sizeof(req.data));
@@ -1728,9 +1728,32 @@
 			if(!fgets(buf, sizeof(buf), ser->f))
 				return NULL;
 
-			strncat(req.data, buf, sizeof(req.data) - req.len - 1);
+			strncat(req.data, buf, sizeof(req.data) - req.len);
 			req.len = strlen(req.data);
 		}
+
+		memcpy(&reqcpy, &req, sizeof(req));
+
+		parse_request(&reqcpy);
+
+		if (sscanf(get_header(&reqcpy, "Content-Length"), "%d", &cl)) {
+			ast_debug(1, "Content-Length is ''%d''\n", cl);
+			while (cl > 0) {
+				ast_debug(2, "\tIteration: cl is %d\n", cl);
+				if (!fread(buf, (cl < sizeof(buf)) ? cl : sizeof(buf), 1, ser->f))
+					return NULL;
+
+				cl -= strlen(buf);
+
+				ast_debug(1, "\t%s", buf);
+
+				strncat(req.data, buf, sizeof(req.data) - req.len);
+				req.len = strlen(req.data);
+			}
+		}
+
+		parse_request(&req);
+		req.method = find_sip_method(req.rlPart1);
 
 		if(sip_debug_test_addr(&ser->requestor))	/* Set the debug flag early on packet level */
 			ast_set_flag(&req, SIP_PKT_DEBUG);
@@ -1739,9 +1762,6 @@
 		if (ast_test_flag(&req, SIP_PKT_DEBUG))
 			ast_verbose("\n<--- SIP read from %s://%s:%d --->\n%s\n<------------->\n", 
 						(ser->parent->tls_cfg ? "TLS" : "TCP"), ast_inet_ntoa(ser->requestor.sin_addr), ntohs(ser->requestor.sin_port), req.data);
-
-		parse_request(&req);
-		req.method = find_sip_method(req.rlPart1);
 
 		if (ast_test_flag(&req, SIP_PKT_DEBUG))
 			ast_verbose("--- (%d headers %d lines)%s ---\n", req.headers, req.lines, (req.headers + req.lines == 0) ? " Nat keepalive" : "");
@@ -2159,6 +2179,10 @@
 	struct sip_pkt *pkt = data, *prev, *cur = NULL;
 	int reschedule = DEFAULT_RETRANS;
 	int xmitres = 0;
+
+	/* Don't retransmit TCP packets */
+	if (!(pkt->owner->transport & SIP_TRANSPORT_UDP))
+		return 0;
 
 	/* Lock channel PVT */
 	sip_pvt_lock(pkt->owner);




More information about the asterisk-commits mailing list