Browse code

branch fixes

Jiri Kuthan authored on 02/12/2001 18:28:24
Showing 4 changed files
... ...
@@ -276,7 +276,11 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
276 276
       if (!buf)
277 277
          return -1;
278 278
       T->outbound_request[branch]->bufflen = len ;
279
-      T->outbound_request[branch]->buffer   = (char*)sh_malloc( len );
279
+      if ( !(T->outbound_request[branch]->buffer   = (char*)sh_malloc( len ))) {
280
+	LOG(L_ERR, "ERROR: t_forward: shmem allocation failed\n");
281
+	free( buf );
282
+	return -1;
283
+      }
280 284
       memcpy( T->outbound_request[branch]->buffer , buf , len );
281 285
       free( buf ) ;
282 286
 
... ...
@@ -290,7 +294,9 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
290 294
       insert_into_timer_list( hash_table , &(T->outbound_request[branch]->tl[RETRASMISSIONS_LIST]), RETRASMISSIONS_LIST , RETR_T1 );
291 295
    }/* end for the first time */
292 296
 
293
-   DBG("DEBUG: t_forward: sending outbund request from buffer\n");
297
+   DBG("DEBUG: t_forward: sending outbund request from buffer (%d bytes):\n%*s\n", 
298
+	T->outbound_request[branch]->bufflen, T->outbound_request[branch]->bufflen,
299
+	 T->outbound_request[branch]->buffer);
294 300
    /* send the request */
295 301
    udp_send( T->outbound_request[branch]->buffer , T->outbound_request[branch]->bufflen ,
296 302
                     (struct sockaddr*)&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );
... ...
@@ -1131,7 +1137,7 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
1131 1137
 		  MAX_BRANCH_PARAM_LEN - p_msg->add_to_branch_len,
1132 1138
 		 ".%x.%x.%x",
1133 1139
 		 trans->hash_index, trans->label, branch );
1134
-	DBG("DEBUG: branch created now: %s (%d)\n", p_msg->add_to_branch_s, p_msg->add_to_branch_len );
1140
+	DBG("DEBUG: branch created now: %*s (%d)\n", n, p_msg->add_to_branch_s+p_msg->add_to_branch_len );
1135 1141
 	if (n==-1) {
1136 1142
 		LOG(L_ERR, "ERROR: add_branch_label: too small branch buffer\n");
1137 1143
 		return -1;
... ...
@@ -226,9 +226,22 @@ void free_sip_msg(struct sip_msg* msg);
226 226
 /* make sure all HFs needed for transaction identification have been
227 227
    parsed; return 0 if those HFs can't be found
228 228
  */
229
+
230
+/*
229 231
 #define check_transaction_quadruple(msg ) \
230 232
 	(parse_headers(msg, HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ)!=-1 && \
231 233
 	 msg->from && msg->to && msg->callid && msg->cseq)
234
+*/
235
+
236
+/* restored to the original double-check and put macro params
237
+   in parenthesses  -jiri */
238
+
239
+#define check_transaction_quadruple(msg ) \
240
+   ( ((msg)->from || (parse_headers( (msg), HDR_FROM)!=-1 && (msg)->from)) && 	\
241
+   ((msg)->to|| (parse_headers( (msg), HDR_TO)!=-1 && (msg)->to)) &&		\
242
+   ((msg)->callid|| (parse_headers( (msg), HDR_CALLID)!=-1 && (msg)->callid)) &&\
243
+   ((msg)->cseq|| (parse_headers( (msg), HDR_CSEQ)!=-1 && (msg)->cseq)) ) 
244
+
232 245
 
233 246
 
234 247
 #endif
... ...
@@ -204,6 +204,7 @@ char * build_req_buf_from_sip_req(	struct sip_msg* msg,
204 204
 		memcpy(line_buf+via_len, CRLF, CRLF_LEN);
205 205
 		via_len+=CRLF_LEN;
206 206
 		line_buf[via_len]=0; /* null terminate the string*/
207
+		DBG("DEBUG: via branch building finished\n");
207 208
 	}else{
208 209
 		LOG(L_ERR, "build_req_buf_from_sip_req: ERROR: via too long (%d)\n",
209 210
 				via_len);
... ...
@@ -14,7 +14,7 @@ loadmodule "modules/tm/tm.so"
14 14
 route{
15 15
 	log("trying forward to uri");
16 16
 #	forward(uri:host,uri:port);
17
-	forward(127.0.0.1, 5090);
17
+#	forward(127.0.0.1, 5090);
18 18
 	log("after forward");
19 19
 
20 20
 	if ( t_lookup_request()) {
... ...
@@ -34,11 +34,12 @@ route{
34 34
 			t_send_reply( "200", "glad to cancel");
35 35
 		} else {
36 36
 			log("new transaction");
37
-			t_send_reply("100", "trying -- your call is important to us");
37
+			#t_send_reply("100", "trying -- your call is important to us");
38 38
 		};
39
-		rewritehost("xy.com");
39
+		#rewritehost("xy.com");
40 40
 		# XXX ... it wants me to put port nr in ""
41
-		t_forward("fox.iptel.org", "5062" );
41
+		#t_forward("benetnash.fokus.gmd.de", "5080" );
42
+		t_forward("localhost", "5080" );
42 43
 		# XXX ... it doesn't like default port numbers
43 44
 		# t_forward("fox.iptel.org" );
44 45
 		# XXX t_forward_uri ... not done yet