Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 31/01/2002 15:27:55
Showing 6 changed files
... ...
@@ -53,7 +53,7 @@ ARCH = $(shell uname -s)
53 53
 
54 54
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
55 55
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
56
-	-DVQ_MALLOC #-DBRUT_HACK #-DEXTRA_DEBUG #-DSTATIC_TM #-DEXTRA_DEBUG
56
+	-DVQ_MALLOC -DUSE_SYNONIM #-DBRUT_HACK #-DEXTRA_DEBUG #-DSTATIC_TM
57 57
 	#-DEXTRA_DEBUG -DBRUT_HACK \
58 58
 	#-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
59 59
 	  #-DDBG_QM_MALLOC #-DVQ_MALLOC #-DNO_DEBUG
... ...
@@ -110,7 +110,10 @@ struct s_table* init_hash_table()
110 110
 
111 111
    /* inits the entrys */
112 112
    for(  i=0 ; i<TABLE_ENTRIES; i++ )
113
+   {
113 114
       init_entry_lock( hash_table , (hash_table->entrys)+i );
115
+      hash_table->entrys[i].next_label = rand();
116
+   }
114 117
 
115 118
    /* inits the timers*/
116 119
    for(  i=0 ; i<NR_OF_TIMER_LISTS ; i++ )
... ...
@@ -214,10 +214,11 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
214 214
 {
215 215
 	unsigned int  dest_ip     = dest_ip_param;
216 216
 	unsigned int  dest_port  = dest_port_param;
217
-	int	       branch;
217
+	int                  branch;
218 218
 	unsigned int  len;
219
-	char                          *buf, *shbuf;
219
+	char               *buf, *shbuf;
220 220
 	struct retrans_buff  *rb;
221
+	struct cell      *T_source = T;
221 222
 
222 223
 	buf=NULL;
223 224
 	shbuf = NULL;
... ...
@@ -247,7 +248,7 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
247 248
 	 * when forwarding an ACK, this condition will be all the time false because
248 249
 	 * the forwarded INVITE is in the retransmission buffer */
249 250
 	if ( T->outbound_request[branch]==NULL )
250
-{
251
+	{
251 252
 		DBG("DEBUG: t_forward: first time forwarding\n");
252 253
 		/* special case : CANCEL */
253 254
 		if ( p_msg->REQ_METHOD==METHOD_CANCEL  )
... ...
@@ -269,6 +270,10 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
269 270
 						to.sin_addr.s_addr;
270 271
 					dest_port = T->T_canceled->outbound_request[branch]->
271 272
 						to.sin_port;
273
+#ifdef USE_SYNONIM
274
+					T_source = T->T_canceled;
275
+					T->label  = T->T_canceled->label;
276
+#endif
272 277
 				} else { /* transaction exists, but nothing to cancel */
273 278
 					DBG("DEBUG: t_forward: it's CANCEL but "
274 279
 						"I have nothing to cancel here\n");
... ...
@@ -280,9 +285,9 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
280 285
 			}
281 286
 		}/* end special case CANCEL*/
282 287
 
283
-		if ( add_branch_label( T, T->inbound_request , branch )==-1)
288
+		if ( add_branch_label( T_source, T->inbound_request , branch )==-1)
284 289
 			goto error;
285
-		if ( add_branch_label( T, p_msg , branch )==-1)
290
+		if ( add_branch_label( T_source, p_msg , branch )==-1)
286 291
 			goto error;
287 292
 		if ( !(buf = build_req_buf_from_sip_req  ( p_msg, &len)))
288 293
 			goto error;
... ...
@@ -15,16 +15,17 @@
15 15
  *       1 - forward successfull
16 16
  *      -1 - error during forward
17 17
  */
18
-int t_forward_nonack( struct sip_msg* p_msg , unsigned int dest_ip_param , 
18
+int t_forward_nonack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
19 19
 	unsigned int dest_port_param )
20 20
 {
21 21
 	unsigned int dest_ip     = dest_ip_param;
22 22
 	unsigned int dest_port  = dest_port_param;
23 23
 	int	branch;
24 24
 	unsigned int len;
25
-   	char               *buf, *shbuf;
25
+	char               *buf, *shbuf;
26 26
 	struct retrans_buff *rb;
27
-	
27
+	struct cell      *T_source = T;
28
+
28 29
 
29 30
 	buf=NULL;
30 31
 	shbuf = NULL;
... ...
@@ -33,7 +34,6 @@ int t_forward_nonack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
33 34
 	if ( T->outbound_request[branch]==NULL )
34 35
 	{
35 36
 		DBG("DEBUG: t_forward: first time forwarding\n");
36
-
37 37
 		/* special case : CANCEL */
38 38
 		if ( p_msg->REQ_METHOD==METHOD_CANCEL  )
39 39
 		{
... ...
@@ -45,7 +45,6 @@ int t_forward_nonack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
45 45
 			/* if found */
46 46
 			if ( T->T_canceled!=T_NULL )
47 47
 			{
48
-		
49 48
 				/* if in 1xx status, send to the same destination */
50 49
 				if ( (T->T_canceled->status/100)==1 )
51 50
 				{
... ...
@@ -55,24 +54,26 @@ int t_forward_nonack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
55 54
 						to.sin_addr.s_addr;
56 55
 					dest_port = T->T_canceled->outbound_request[branch]->
57 56
 						to.sin_port;
57
+#ifdef USE_SYNONIM
58
+					T_source = T->T_canceled;
59
+					T->label  = T->T_canceled->label;
60
+#endif
58 61
 				} else { /* transaction exists, but nothing to cancel */
59
-               				DBG("DEBUG: t_forward: it's CANCEL but "
62
+					DBG("DEBUG: t_forward: it's CANCEL but "
60 63
 						"I have nothing to cancel here\n");
61 64
 					/* forward CANCEL as a stand-alone transaction */
62
-					/*	return 1; */
63 65
 				}
64
- 			} else { /* transaction doesnot exists  */
65
-            			DBG("DEBUG: t_forward: canceled request not found! "
66
+			} else { /* transaction doesnot exists  */
67
+				DBG("DEBUG: t_forward: canceled request not found! "
66 68
 				"nothing to CANCEL\n");
67
-            			return 1;
68
-         		}
69
-      	}/* end special case CANCEL*/
69
+			}
70
+		}/* end special case CANCEL*/
70 71
 
71
-		if ( add_branch_label( T, T->inbound_request , branch )==-1) 
72
+		if ( add_branch_label( T_source, T->inbound_request , branch )==-1)
72 73
 			goto error;
73
-		if ( add_branch_label( T, p_msg , branch )==-1) 
74
+		if ( add_branch_label( T_source, p_msg , branch )==-1)
74 75
 			goto error;
75
-		if ( !(buf = build_req_buf_from_sip_req  ( p_msg, &len))) 
76
+		if ( !(buf = build_req_buf_from_sip_req  ( p_msg, &len)))
76 77
 			goto error;
77 78
 
78 79
 		/* allocates a new retrans_buff for the outbound request */
... ...
@@ -104,7 +105,7 @@ int t_forward_nonack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
104 105
 		rb->bufflen = len ;
105 106
 		memcpy( rb->retr_buffer , buf , len );
106 107
 		/* send the request */
107
-   		/* known to be in network order */
108
+		/* known to be in network order */
108 109
 		rb->to.sin_port     =  dest_port;
109 110
 		rb->to.sin_addr.s_addr =  dest_ip;
110 111
 		rb->to.sin_family = AF_INET;
... ...
@@ -133,17 +134,15 @@ int t_forward_nonack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
133 134
 	{
134 135
 		DBG("DEBUG: t_forward: forwarding CANCEL\n");
135 136
 		/* if no transaction to CANCEL */
136
-      /* or if the canceled transaction has a final status -> drop the CANCEL*/
137
-		if ( T->T_canceled==T_NULL || T->T_canceled->status>=200)
137
+		/* or if the canceled transaction has a final status -> drop the CANCEL*/
138
+		if ( T->T_canceled!=T_NULL && T->T_canceled->status>=200)
138 139
 		{
139 140
 			reset_timer( hash_table, &(rb->fr_timer ));
140 141
 			reset_timer( hash_table, &(rb->retr_timer ));
141
-           		return 1;
142
-       		}
143
-   	}
144
-
145
-
146
-   return 1;
142
+			return 1;
143
+		}
144
+	}
145
+	return 1;
147 146
 
148 147
 error:
149 148
 	if (shbuf) shm_free(shbuf);
... ...
@@ -157,7 +156,7 @@ error:
157 156
 
158 157
 }
159 158
 
160
-int t_forward_ack( struct sip_msg* p_msg , unsigned int dest_ip_param , 
159
+int t_forward_ack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
161 160
 	unsigned int dest_port_param )
162 161
 {
163 162
 
... ...
@@ -178,11 +177,11 @@ int t_forward_ack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
178 177
 	branch=T->relaied_reply_branch;
179 178
 	/* double-check for odd relaying */
180 179
 	if ( branch <0 || branch>=T->nr_of_outgoings ) {
181
-		DBG("DEBUG: t_forward_ack: strange relaied_reply_branch: %d out of %d\n", 
180
+		DBG("DEBUG: t_forward_ack: strange relaied_reply_branch: %d out of %d\n",
182 181
 			branch, T->nr_of_outgoings );
183 182
 		return -1;
184 183
 	}
185
-	
184
+
186 185
 	DBG("DEBUG: t_forward: forwarding ACK [%d]\n",branch);
187 186
 	/* not able to build branch -- then better give up */
188 187
 	if ( add_branch_label( T, p_msg , branch )==-1) {
... ...
@@ -137,8 +137,8 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
137 137
                          //if ( /*to length*/ p_cell->inbound_request->to->body.len == p_msg->to->body.len )
138 138
                             //if ( /*tag length*/ p_cell->tag &&  p_cell->tag->len==p_msg->tag->body.len )
139 139
                             /* so far the lengths are the same -> let's check the contents */
140
-                                if ( /*callid*/ !memcmp( t_msg->callid->body.s , p_msg->callid->body.s , p_msg->callid->body.len ) )
141
-                                   if ( /*cseq_nr*/ !memcmp( get_cseq(t_msg)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len ) )
140
+                                if ( /*callid*/ !memcmp( t_msg->callid->body.s , p_msg->callid->body.s , p_msg->callid->body.len ) && printf("$$$$$$$$$$$$$$$ callid str\n"))
141
+                                   if ( /*cseq_nr*/ !memcmp( get_cseq(t_msg)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len ) && printf("$$$$$$$$$$$$$$$ cseqnr str\n"))
142 142
                                       if (/*URI len*/ EQ_REQ_URI_STR )
143 143
                                          if (/*VIA1*/ EQ_VIA_STR(via1) )
144 144
                                             if ( /*from*/ EQ_STR(from) )
... ...
@@ -199,18 +199,18 @@ struct cell* t_lookupOriginalT(  struct s_table* hash_table , struct sip_msg* p_
199 199
       /* is it the wanted transaction ? */
200 200
       /* first only the length are checked */
201 201
       if ( p_cell->inbound_request->REQ_METHOD!=METHOD_CANCEL )
202
-         if ( /*callid length*/ EQ_LEN(callid) )
202
+         if ( /*callid length*/ EQ_LEN(callid)  )
203 203
             if ( get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len )
204 204
                if ( EQ_REQ_URI_LEN )
205 205
                    if ( EQ_VIA_LEN(via1) )
206
-                  if ( EQ_LEN(from) && EQ_LEN(to) )
206
+                      if ( EQ_LEN(from) && EQ_LEN(to) )
207 207
                         //if ( /*tag length*/ (!p_cell->inbound_request->tag && !p_msg->tag) || (p_cell->inbound_request->tag && p_msg->tag && p_cell->inbound_request->tag->body.len == p_msg->tag->body.len) )
208 208
                            /* so far the lengths are the same -> let's check the contents */
209 209
                             if ( /*callid*/ EQ_STR(callid) )
210
-                               if ( /*cseq_nr*/ memcmp( get_cseq(t_msg)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len )==0 )
210
+                               if ( /*cseq_nr*/ !memcmp( get_cseq(t_msg)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len ) )
211 211
                                   if ( EQ_REQ_URI_STR )
212
-                                  if ( EQ_VIA_STR(via1) )
213
-                                  if ( EQ_STR(from) && EQ_STR(to) )
212
+                                     if ( EQ_VIA_STR(via1) )
213
+                                        if ( EQ_STR(from) )
214 214
                                             //if ( /*tag*/ (!p_cell->inbound_request->tag && !p_msg->tag) || (p_cell->inbound_request->tag && p_msg->tag && memcmp( p_cell->inbound_request->tag->body.s , p_msg->tag->body.s , p_msg->tag->body.len )==0) )
215 215
                                               { /* WE FOUND THE GOLDEN EGG !!!! */
216 216
                                                 DBG("DEBUG: t_lookupOriginalT: canceled transaction found (%x)! \n",p_cell );
... ...
@@ -234,106 +234,119 @@ struct cell* t_lookupOriginalT(  struct s_table* hash_table , struct sip_msg* p_
234 234
   */
235 235
 int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch )
236 236
 {
237
-   struct cell*  p_cell;
238
-   unsigned int hash_index = 0;
239
-   unsigned int entry_label  = 0;
240
-   unsigned int branch_id    = 0;
241
-   char  *hashi, *syni, *branchi, *p, *n;
242
-   int hashl, synl, branchl;
243
-   int scan_space;
244
-
245
-   /* split the branch into pieces: loop_detection_check(ignored),
246
-      hash_table_id, synonym_id, branch_id*/
247
-
248
-   if (! ( p_msg->via1 && p_msg->via1->branch && p_msg->via1->branch->value.s) )
249
-	goto nomatch2;
250
-
251
-   p=p_msg->via1->branch->value.s;
252
-   scan_space=p_msg->via1->branch->value.len;
253
-
254
-   /* loop detection ... ignore */
255
-   n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR );
256
-   scan_space-=n-p;
257
-   if (n==p || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
258
-   p=n+1; scan_space--;
259
-
260
-   /* hash_id */
261
-   n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR);
262
-   hashl=n-p;
263
-   scan_space-=hashl;
264
-   if (!hashl || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
265
-   hashi=p;
266
-   p=n+1;scan_space--;
267
-
268
-
269
-   /* sequence id */
270
-   n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR);
271
-   synl=n-p;
272
-   scan_space-=synl;
273
-   if (!synl || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
274
-   syni=p;
275
-   p=n+1;scan_space--;
276
-
277
-   /* branch id */  /*  should exceed the scan_space */
278
-   n=eat_token_end( p, p+scan_space );
279
-   branchl=n-p;
280
-   if (!branchl ) goto nomatch2;
281
-   branchi=p;
282
-
283
-
284
-   hash_index=reverse_hex2int(hashi, hashl);
285
-   entry_label=reverse_hex2int(syni, synl);
286
-   branch_id=reverse_hex2int(branchi, branchl);
287
-	if (hash_index==-1 || entry_label==-1 || branch_id==-1) {
237
+	struct cell*  p_cell;
238
+	unsigned int loop_code    = 0;
239
+	unsigned int hash_index = 0;
240
+	unsigned int entry_label  = 0;
241
+	unsigned int branch_id    = 0;
242
+	char  *loopi,*hashi, *syni, *branchi, *p, *n;
243
+	int loopl,hashl, synl, branchl;
244
+	int scan_space;
245
+
246
+	/* split the branch into pieces: loop_detection_check(ignored),
247
+	     hash_table_id, synonym_id, branch_id*/
248
+
249
+	if (!( p_msg->via1 && p_msg->via1->branch && p_msg->via1->branch->value.s) )
250
+		goto nomatch2;
251
+
252
+	p=p_msg->via1->branch->value.s;
253
+	scan_space=p_msg->via1->branch->value.len;
254
+
255
+	/* loop detection ... ignore */
256
+	n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR );
257
+	loopl = n-p;
258
+	scan_space-= loopl;
259
+	if (n==p || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
260
+	loopi=p;
261
+	p=n+1; scan_space--;
262
+
263
+	/* hash_id */
264
+	n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR);
265
+	hashl=n-p;
266
+	scan_space-=hashl;
267
+	if (!hashl || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
268
+	hashi=p;
269
+	p=n+1;scan_space--;
270
+
271
+#ifdef USE_SYNONIM
272
+	/* sequence id */
273
+	n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR);
274
+	synl=n-p;
275
+	scan_space-=synl;
276
+	if (!synl || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
277
+	syni=p;
278
+	p=n+1;scan_space--;
279
+#endif
280
+
281
+	/* branch id  -  should exceed the scan_space */
282
+	n=eat_token_end( p, p+scan_space );
283
+	branchl=n-p;
284
+	if (!branchl ) goto nomatch2;
285
+	branchi=p;
286
+
287
+	/* sanity check */
288
+	if ( (hash_index=reverse_hex2int(hashi, hashl))<0 || hash_index >=TABLE_ENTRIES
289
+	  || (branch_id=reverse_hex2int(branchi, branchl))<0 || branch_id>=MAX_FORK
290
+#ifdef USE_SYNONIM
291
+	  || (entry_label=reverse_hex2int(syni, synl))<0
292
+#else
293
+	  || loopl!=32
294
+#endif
295
+	   ) {
288 296
 		DBG("DEBUG: t_reply_matching: poor reply lables %d label %d branch %d\n",
289 297
 			hash_index, entry_label, branch_id );
290 298
 		goto nomatch2;
291 299
 	}
292 300
 
293 301
 
294
-   DBG("DEBUG: t_reply_matching: hash %d label %d branch %d\n",
295
-	hash_index, entry_label, branch_id );
302
+	DBG("DEBUG: t_reply_matching: hash %d label %d branch %d\n",
303
+	   hash_index, entry_label, branch_id );
296 304
 
297
-   /* sanity check */
298
-   if (hash_index<0 || hash_index >=TABLE_ENTRIES ||
299
-    entry_label<0 || branch_id<0 || branch_id>=MAX_FORK ) {
300
-          DBG("DBG: t_reply_matching: snaity check failed\n");
301
-         goto nomatch2;
302
-   }
305
+	/* lock the hole entry*/
306
+	lock( hash_table->entrys[hash_index].mutex );
303 307
 
304
-   /* lock the hole entry*/
305
-   lock( hash_table->entrys[hash_index].mutex );
306
-
307
-   /*all the cells from the entry are scan to detect an entry_label matching */
308
-   p_cell     = hash_table->entrys[hash_index].first_cell;
309
-   while( p_cell )
310
-   {
311
-      /* is it the cell with the wanted entry_label? */
312
-      if ( p_cell->label == entry_label )
313
-         /* has the transaction the wanted branch? */
314
-         if ( p_cell->nr_of_outgoings>branch_id && p_cell->outbound_request[branch_id] )
315
-         {/* WE FOUND THE GOLDEN EGG !!!! */
316
-             T = p_cell;
317
-             *p_branch = branch_id;
318
-             T_REF( T );
319
-             unlock( hash_table->entrys[hash_index].mutex );
320
-             DBG("DEBUG:XXXXXXXXXXXXXXXXXXXXX t_reply_matching: reply matched (T=%p, ref=%x)!\n",T,T->ref_bitmap);
321
-            return 1;
322
-         }
323
-      /* next cell */
324
-      p_cell = p_cell->next_cell;
325
-   } /* while p_cell */
308
+	/*all the cells from the entry are scan to detect an entry_label matching */
309
+	p_cell     = hash_table->entrys[hash_index].first_cell;
310
+	while( p_cell )
311
+	{
312
+		/* is it the cell with the wanted entry_label? */
313
+		if ( (get_cseq(p_msg)->method.len ==
314
+		  get_cseq(p_cell->inbound_request)->method.len)
315
+		&& (get_cseq(p_msg)->method.s[0] ==
316
+		  get_cseq(p_cell->inbound_request)->method.s[0])
317
+#ifdef USE_SYNONIM
318
+		&& (p_cell->label == entry_label )
319
+#else
320
+		&& ( p_cell->inbound_request->add_to_branch_len>=32 &&
321
+		  !memcmp(p_cell->inbound_request->add_to_branch_s,loopi,32))
322
+#endif
323
+		)
324
+			/* has the transaction the wantedbranch? */
325
+			if ( p_cell->nr_of_outgoings>branch_id &&
326
+			p_cell->outbound_request[branch_id] )
327
+ 			{/* WE FOUND THE GOLDEN EGG !!!! */
328
+				T = p_cell;
329
+				*p_branch = branch_id;
330
+				T_REF( T );
331
+				unlock( hash_table->entrys[hash_index].mutex );
332
+				DBG("DEBUG:XXXXXXXXXXXXXXXXXXXXX t_reply_matching:"
333
+				  " reply matched (T=%p,ref=%x)!\n",T,T->ref_bitmap);
334
+				return 1;
335
+			}
336
+		/* next cell */
337
+		p_cell = p_cell->next_cell;
338
+	} /* while p_cell */
326 339
 
327
-   /* nothing found */
328
-   DBG("DEBUG: t_reply_matching: no matching transaction exists\n");
340
+	/* nothing found */
341
+	DBG("DEBUG: t_reply_matching: no matching transaction exists\n");
329 342
 
330 343
 nomatch:
331
-   unlock( hash_table->entrys[hash_index].mutex );
344
+	unlock( hash_table->entrys[hash_index].mutex );
332 345
 nomatch2:
333
-   DBG("DEBUG: t_reply_matching: failure to match a transaction\n");
334
-   *p_branch = -1;
335
-   T = 0;
336
-   return -1;
346
+	DBG("DEBUG: t_reply_matching: failure to match a transaction\n");
347
+	*p_branch = -1;
348
+	T = 0;
349
+	return -1;
337 350
 }
338 351
 
339 352
 
... ...
@@ -403,8 +416,10 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
403 416
 
404 417
 	if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
405 418
 	if (int2reverse_hex( &begin, &size, trans->hash_index)==-1) return -1;
419
+#ifdef USE_SYNONIM
406 420
 	if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
407 421
 	if (int2reverse_hex( &begin, &size, trans->label)==-1) return -1;
422
+#endif
408 423
 	if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
409 424
 	if (int2reverse_hex( &begin, &size, branch)==-1) return -1;
410 425
 
... ...
@@ -379,13 +379,13 @@ static int t_relay_to( struct sip_msg  *p_msg , char *str_ip , char *str_port)
379 379
 	enum addifnew_status status;
380 380
 	int ret;
381 381
 
382
-	status = t_addifnew( p_msg );	
382
+	status = t_addifnew( p_msg );
383 383
 
384 384
 	switch( status ) {
385 385
 		case AIN_ERROR:		/*  fatal error (e.g, parsing) occured */
386 386
 			ret = 0;
387 387
 			break;
388
-			
388
+
389 389
 		case AIN_RETR:		/* it's a retransmission */
390 390
 			if ( !t_retransmit_reply( p_msg ) )
391 391
 			{
... ...
@@ -395,7 +395,7 @@ static int t_relay_to( struct sip_msg  *p_msg , char *str_ip , char *str_port)
395 395
 			break;
396 396
 
397 397
 		case AIN_NEW:		/* it's a new request */
398
-			if ( !t_forward_nonack( p_msg, (unsigned int) str_ip, (unsigned int) str_port )) 
398
+			if ( !t_forward_nonack( p_msg, (unsigned int) str_ip, (unsigned int) str_port ))
399 399
 			{
400 400
 				DBG( "SER:ERROR: t_forward \n");
401 401
 				ret = 0;
... ...
@@ -418,7 +418,7 @@ static int t_relay_to( struct sip_msg  *p_msg , char *str_ip , char *str_port)
418 418
 
419 419
 		case AIN_NEWACK:	/* it's an ACK for which no transaction exists */
420 420
 			DBG( "SER: forwarding ACK  statelessly\n");
421
-			forward_request( p_msg , mk_proxy_from_ip( 
421
+			forward_request( p_msg , mk_proxy_from_ip(
422 422
 				(unsigned int )str_ip, (unsigned int)str_port) ) ;
423 423
 			ret=1;
424 424
 			break;
... ...
@@ -447,7 +447,7 @@ static int t_relay_to( struct sip_msg  *p_msg , char *str_ip , char *str_port)
447 447
 	return ret;
448 448
 }
449 449
 
450
-	
450
+
451 451
 
452 452
 
453 453
 static int t_relay( struct sip_msg  *p_msg , char* foo, char* bar)
... ...
@@ -463,3 +463,55 @@ static int t_relay( struct sip_msg  *p_msg , char* foo, char* bar)
463 463
    return t_relay_to( p_msg , ( char *) ip , (char *) port );
464 464
 }
465 465
 
466
+
467
+
468
+static int t_relay_no_forward( struct sip_msg  *p_msg )
469
+{
470
+
471
+	enum addifnew_status status;
472
+	int ret;
473
+
474
+	status = t_addifnew( p_msg );
475
+
476
+	switch( status ) {
477
+		case AIN_ERROR:		/*  fatal error (e.g, parsing) occured */
478
+			ret = 0;
479
+			break;
480
+
481
+		case AIN_RETR:		/* it's a retransmission */
482
+			if ( !t_retransmit_reply( p_msg ) )
483
+			{
484
+				DBG( "SER: WARNING: bad t_retransmit_reply\n");
485
+			}
486
+			ret = 1;
487
+			break;
488
+
489
+		case AIN_NEW:		/* it's a new request */
490
+			ret = 1;
491
+			break;
492
+
493
+		case AIN_NEWACK:	/* it's an ACK for which no transaction exists */
494
+			ret=1;
495
+			break;
496
+
497
+		case AIN_OLDACK:	/* it's an ACK for an existing transaction */
498
+			DBG( "SER: ACK received -> t_release\n");
499
+			if ( !t_release_transaction( p_msg ) )
500
+			{
501
+				DBG( "SER: WARNING: bad t_release\n");
502
+			}
503
+			ret = 1;
504
+			break;
505
+
506
+		default:
507
+			LOG(L_CRIT, "ERROR: unexpected addifnew return value: %d\n", ret);
508
+			abort();
509
+	};
510
+	if (T) {
511
+		T_UNREF( T );
512
+	}
513
+	return ret;
514
+}
515
+
516
+
517
+