Browse code

2 new functions added : t_check_status() and t_flush_flags()

Bogdan-Andrei Iancu authored on 27/11/2003 16:35:56
Showing 2 changed files
... ...
@@ -620,7 +620,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
620 620
 		/* if all_final return lowest */
621 621
 		picked_branch=pick_branch(branch,new_code, Trans, &picked_code);
622 622
 		if (picked_branch==-2) { /* branches open yet */
623
-			*should_store=1;	
623
+			*should_store=1;
624 624
 			*should_relay=-1;
625 625
 			return RPS_STORE;
626 626
 		}
... ...
@@ -103,40 +103,51 @@
103 103
 
104 104
 MODULE_VERSION
105 105
 
106
+/* fixup functions */
107
+static int fixup_t_send_reply(void** param, int param_no);
108
+static int fixup_str2int( void** param, int param_no);
109
+static int fixup_hostport2proxy(void** param, int param_no);
110
+static int fixup_str2regexp(void** param, int param_no);
111
+
112
+
113
+/* init functions */
114
+static int mod_init(void);
115
+static int child_init(int rank);
116
+
117
+
118
+/* exported functions */
106 119
 inline static int w_t_check(struct sip_msg* msg, char* str, char* str2);
107 120
 inline static int w_t_reply(struct sip_msg* msg, char* str, char* str2);
108
-
109 121
 inline static int w_t_release(struct sip_msg* msg, char* str, char* str2);
110
-inline static int fixup_t_send_reply(void** param, int param_no);
111
-inline static int fixup_str2int( void** param, int param_no);
112
-inline static int w_t_retransmit_reply(struct sip_msg* p_msg, char* foo, char* bar );
122
+inline static int w_t_retransmit_reply(struct sip_msg* p_msg, char* foo,
123
+				char* bar );
113 124
 inline static int w_t_newtran(struct sip_msg* p_msg, char* foo, char* bar );
114 125
 inline static int w_t_relay( struct sip_msg  *p_msg , char *_foo, char *_bar);
115 126
 inline static int w_t_relay_to_udp( struct sip_msg  *p_msg , char *proxy, 
116
-				    char *);
127
+				 char *);
117 128
 #ifdef USE_TCP
118 129
 inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg , char *proxy,
119
-				    char *);
130
+				char *);
120 131
 #endif
121 132
 #ifdef USE_TLS
122 133
 inline static int w_t_relay_to_tls( struct sip_msg  *p_msg , char *proxy,
123
-				    char *);
134
+				char *);
124 135
 #endif
125 136
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
126
-				 char *proxy, /* struct proxy_l *proxy expected */
127
-				 char *_foo       /* nothing expected */ );
137
+				char *proxy, /* struct proxy_l *proxy expected */
138
+				char *_foo       /* nothing expected */ );
128 139
 inline static int w_t_replicate_udp( struct sip_msg  *p_msg , 
129
-				     char *proxy, /* struct proxy_l *proxy expected */
130
-				     char *_foo       /* nothing expected */ );
140
+				char *proxy, /* struct proxy_l *proxy expected */
141
+				char *_foo       /* nothing expected */ );
131 142
 #ifdef USE_TCP
132 143
 inline static int w_t_replicate_tcp( struct sip_msg  *p_msg , 
133
-				     char *proxy, /* struct proxy_l *proxy expected */
134
-				     char *_foo       /* nothing expected */ );
144
+				char *proxy, /* struct proxy_l *proxy expected */
145
+				char *_foo       /* nothing expected */ );
135 146
 #endif
136 147
 #ifdef USE_TLS
137 148
 inline static int w_t_replicate_tls( struct sip_msg  *p_msg , 
138
-				     char *proxy, /* struct proxy_l *proxy expected */
139
-				     char *_foo       /* nothing expected */ );
149
+				char *proxy, /* struct proxy_l *proxy expected */
150
+				char *_foo       /* nothing expected */ );
140 151
 #endif
141 152
 inline static int w_t_forward_nonack(struct sip_msg* msg, char* str, char* );
142 153
 inline static int w_t_forward_nonack_uri(struct sip_msg* msg, char* str,char*);
... ...
@@ -147,70 +158,88 @@ inline static int w_t_forward_nonack_tcp(struct sip_msg* msg, char* str,char*);
147 158
 #ifdef USE_TLS
148 159
 inline static int w_t_forward_nonack_tls(struct sip_msg* msg, char* str,char*);
149 160
 #endif
150
-inline static int fixup_hostport2proxy(void** param, int param_no);
151
-inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo );
152
-inline static int w_t_on_reply( struct sip_msg* msg, char *go_to, char *foo );
153
-
154
-
155
-static int mod_init(void);
161
+inline static int w_t_on_negative(struct sip_msg* msg, char *go_to, char *foo);
162
+inline static int w_t_on_reply(struct sip_msg* msg, char *go_to, char *foo );
163
+inline static int t_check_status(struct sip_msg* msg, char *regexp, char *foo);
164
+inline static int t_flush_flags(struct sip_msg* msg, char *dir, char *foo);
156 165
 
157
-static int child_init(int rank);
158 166
 
159 167
 
160 168
 static cmd_export_t cmds[]={
161
-	{"t_newtran",          w_t_newtran,             0, 0,                    REQUEST_ROUTE},
162
-	{"t_lookup_request",   w_t_check,               0, 0,                    REQUEST_ROUTE},
163
-	{T_REPLY,              w_t_reply,               2, fixup_t_send_reply,   
169
+	{"t_newtran",          w_t_newtran,             0, 0,
170
+			REQUEST_ROUTE},
171
+	{"t_lookup_request",   w_t_check,               0, 0,
172
+			REQUEST_ROUTE},
173
+	{T_REPLY,              w_t_reply,               2, fixup_t_send_reply,
164 174
 			REQUEST_ROUTE | FAILURE_ROUTE },
165
-	{"t_retransmit_reply", w_t_retransmit_reply,    0, 0,                    REQUEST_ROUTE},
166
-	{"t_release",          w_t_release,             0, 0,                    REQUEST_ROUTE},
167
-	{T_RELAY_TO_UDP,       w_t_relay_to_udp,        2, fixup_hostport2proxy, REQUEST_ROUTE|FAILURE_ROUTE},
175
+	{"t_retransmit_reply", w_t_retransmit_reply,    0, 0,
176
+			REQUEST_ROUTE},
177
+	{"t_release",          w_t_release,             0, 0,
178
+			REQUEST_ROUTE},
179
+	{T_RELAY_TO_UDP,       w_t_relay_to_udp,        2, fixup_hostport2proxy,
180
+			REQUEST_ROUTE|FAILURE_ROUTE},
168 181
 #ifdef USE_TCP
169
-	{T_RELAY_TO_TCP,       w_t_relay_to_tcp,        2, fixup_hostport2proxy, REQUEST_ROUTE|FAILURE_ROUTE},
182
+	{T_RELAY_TO_TCP,       w_t_relay_to_tcp,        2, fixup_hostport2proxy,
183
+			REQUEST_ROUTE|FAILURE_ROUTE},
170 184
 #endif
171 185
 #ifdef USE_TLS
172
-	{T_RELAY_TO_TLS,       w_t_relay_to_tls,        2, fixup_hostport2proxy, REQUEST_ROUTE|FAILURE_ROUTE},
186
+	{T_RELAY_TO_TLS,       w_t_relay_to_tls,        2, fixup_hostport2proxy,
187
+			REQUEST_ROUTE|FAILURE_ROUTE},
173 188
 #endif
174
-	{"t_replicate",        w_t_replicate,           2, fixup_hostport2proxy, REQUEST_ROUTE},
175
-	{"t_replicate_udp",    w_t_replicate_udp,       2, fixup_hostport2proxy, REQUEST_ROUTE},
189
+	{"t_replicate",        w_t_replicate,           2, fixup_hostport2proxy,
190
+			REQUEST_ROUTE},
191
+	{"t_replicate_udp",    w_t_replicate_udp,       2, fixup_hostport2proxy,
192
+			REQUEST_ROUTE},
176 193
 #ifdef USE_TCP
177
-	{"t_replicate_tcp",    w_t_replicate_tcp,       2, fixup_hostport2proxy, REQUEST_ROUTE},
194
+	{"t_replicate_tcp",    w_t_replicate_tcp,       2, fixup_hostport2proxy,
195
+			REQUEST_ROUTE},
178 196
 #endif
179 197
 #ifdef USE_TLS
180
-	{"t_replicate_tls",    w_t_replicate_tls,       2, fixup_hostport2proxy, REQUEST_ROUTE},
198
+	{"t_replicate_tls",    w_t_replicate_tls,       2, fixup_hostport2proxy,
199
+			REQUEST_ROUTE},
181 200
 #endif
182
-	{T_RELAY,              w_t_relay,               0, 0,                    
201
+	{T_RELAY,              w_t_relay,               0, 0,
183 202
 			REQUEST_ROUTE | FAILURE_ROUTE },
184
-	{T_FORWARD_NONACK,     w_t_forward_nonack,      2, fixup_hostport2proxy, REQUEST_ROUTE},
185
-	{T_FORWARD_NONACK_URI, w_t_forward_nonack_uri,  0, 0,                    REQUEST_ROUTE},
186
-	{T_FORWARD_NONACK_UDP, w_t_forward_nonack_udp,  2, fixup_hostport2proxy, REQUEST_ROUTE},
203
+	{T_FORWARD_NONACK,     w_t_forward_nonack,      2, fixup_hostport2proxy,
204
+			REQUEST_ROUTE},
205
+	{T_FORWARD_NONACK_URI, w_t_forward_nonack_uri,  0, 0,
206
+			REQUEST_ROUTE},
207
+	{T_FORWARD_NONACK_UDP, w_t_forward_nonack_udp,  2, fixup_hostport2proxy,
208
+			REQUEST_ROUTE},
187 209
 #ifdef USE_TCP
188
-	{T_FORWARD_NONACK_TCP, w_t_forward_nonack_tcp,  2, fixup_hostport2proxy, REQUEST_ROUTE},
210
+	{T_FORWARD_NONACK_TCP, w_t_forward_nonack_tcp,  2, fixup_hostport2proxy,
211
+			REQUEST_ROUTE},
189 212
 #endif
190 213
 #ifdef USE_TLS
191
-	{T_FORWARD_NONACK_TLS, w_t_forward_nonack_tls,  2, fixup_hostport2proxy, REQUEST_ROUTE},
214
+	{T_FORWARD_NONACK_TLS, w_t_forward_nonack_tls,  2, fixup_hostport2proxy,
215
+			REQUEST_ROUTE},
192 216
 #endif
193 217
 	{"t_on_failure",       w_t_on_negative,         1, fixup_str2int,
194 218
 			REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE },
195 219
 	{"t_on_reply",         w_t_on_reply,            1, fixup_str2int,
196 220
 			REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE },
221
+	{"t_check_status",     t_check_status,          1, fixup_str2regexp,
222
+			REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE },
223
+	{"t_flush_flags",     t_flush_flags,            1, fixup_str2int,
224
+			REQUEST_ROUTE | FAILURE_ROUTE | ONREPLY_ROUTE },
225
+
197 226
 	/* not applicable from the script */
198
-	{"register_tmcb",      (cmd_function)register_tmcb,     NO_SCRIPT,     0, 0},
199
-	{"load_tm",            (cmd_function)load_tm,           NO_SCRIPT,     0, 0},
200
-	{T_REPLY_WB,           (cmd_function)t_reply_with_body, NO_SCRIPT,     0, 0},
201
-	{T_IS_LOCAL,           (cmd_function)t_is_local,        NO_SCRIPT,     0, 0},
202
-	{T_GET_TI,             (cmd_function)t_get_trans_ident, NO_SCRIPT,     0, 0},
203
-	{T_LOOKUP_IDENT,       (cmd_function)t_lookup_ident,    NO_SCRIPT,     0, 0},
204
-	{T_ADDBLIND,           (cmd_function)add_blind_uac,     NO_SCRIPT,     0, 0},
205
-	{"t_request_within",   (cmd_function)req_within,        NO_SCRIPT,     0, 0},
206
-	{"t_request_outside",  (cmd_function)req_outside,       NO_SCRIPT,     0, 0},
207
-	{"t_request",          (cmd_function)request,           NO_SCRIPT,     0, 0},
208
-	{"new_dlg_uac",        (cmd_function)new_dlg_uac,       NO_SCRIPT,     0, 0},
209
-	{"dlg_response_uac",   (cmd_function)dlg_response_uac,  NO_SCRIPT,     0, 0},
210
-	{"new_dlg_uas",        (cmd_function)new_dlg_uas,       NO_SCRIPT,     0, 0},
211
-	{"dlg_request_uas",    (cmd_function)dlg_request_uas,   NO_SCRIPT,     0, 0},
212
-	{"free_dlg",           (cmd_function)free_dlg,          NO_SCRIPT,     0, 0},
213
-	{"print_dlg",          (cmd_function)print_dlg,         NO_SCRIPT,     0, 0},
227
+	{"register_tmcb",      (cmd_function)register_tmcb,     NO_SCRIPT,   0, 0},
228
+	{"load_tm",            (cmd_function)load_tm,           NO_SCRIPT,   0, 0},
229
+	{T_REPLY_WB,           (cmd_function)t_reply_with_body, NO_SCRIPT,   0, 0},
230
+	{T_IS_LOCAL,           (cmd_function)t_is_local,        NO_SCRIPT,   0, 0},
231
+	{T_GET_TI,             (cmd_function)t_get_trans_ident, NO_SCRIPT,   0, 0},
232
+	{T_LOOKUP_IDENT,       (cmd_function)t_lookup_ident,    NO_SCRIPT,   0, 0},
233
+	{T_ADDBLIND,           (cmd_function)add_blind_uac,     NO_SCRIPT,   0, 0},
234
+	{"t_request_within",   (cmd_function)req_within,        NO_SCRIPT,   0, 0},
235
+	{"t_request_outside",  (cmd_function)req_outside,       NO_SCRIPT,   0, 0},
236
+	{"t_request",          (cmd_function)request,           NO_SCRIPT,   0, 0},
237
+	{"new_dlg_uac",        (cmd_function)new_dlg_uac,       NO_SCRIPT,   0, 0},
238
+	{"dlg_response_uac",   (cmd_function)dlg_response_uac,  NO_SCRIPT,   0, 0},
239
+	{"new_dlg_uas",        (cmd_function)new_dlg_uas,       NO_SCRIPT,   0, 0},
240
+	{"dlg_request_uas",    (cmd_function)dlg_request_uas,   NO_SCRIPT,   0, 0},
241
+	{"free_dlg",           (cmd_function)free_dlg,          NO_SCRIPT,   0, 0},
242
+	{"print_dlg",          (cmd_function)print_dlg,         NO_SCRIPT,   0, 0},
214 243
 	{0,0,0,0,0}
215 244
 };
216 245
 
... ...
@@ -249,7 +278,10 @@ struct module_exports exports= {
249 278
 	child_init /* per-child init function */
250 279
 };
251 280
 
252
-inline static int fixup_str2int( void** param, int param_no)
281
+
282
+
283
+/**************************** fixup functions ******************************/
284
+static int fixup_str2int( void** param, int param_no)
253 285
 {
254 286
 	unsigned long go_to;
255 287
 	int err;
... ...
@@ -269,21 +301,115 @@ inline static int fixup_str2int( void** param, int param_no)
269 301
 	return 0;
270 302
 }
271 303
 
304
+
305
+/* (char *hostname, char *port_nr) ==> (struct proxy_l *, -)  */
306
+static int fixup_hostport2proxy(void** param, int param_no)
307
+{
308
+	unsigned int port;
309
+	char *host;
310
+	int err;
311
+	struct proxy_l *proxy;
312
+	str s;
313
+	
314
+	DBG("TM module: fixup_t_forward(%s, %d)\n", (char*)*param, param_no);
315
+	if (param_no==1){
316
+		DBG("TM module: fixup_t_forward: param 1.. do nothing, wait for #2\n");
317
+		return 0;
318
+	} else if (param_no==2) {
319
+
320
+		host=(char *) (*(param-1)); 
321
+		port=str2s(*param, strlen(*param), &err);
322
+		if (err!=0) {
323
+			LOG(L_ERR, "TM module:fixup_t_forward: bad port number <%s>\n",
324
+				(char*)(*param));
325
+			 return E_UNSPEC;
326
+		}
327
+		s.s = host;
328
+		s.len = strlen(host);
329
+		proxy=mk_proxy(&s, port, 0); /* FIXME: udp or tcp? */
330
+		if (proxy==0) {
331
+			LOG(L_ERR, "ERROR: fixup_t_forwardv6: bad host name in URI <%s>\n",
332
+				host );
333
+			return E_BAD_ADDRESS;
334
+		}
335
+		/* success -- fix the first parameter to proxy now ! */
336
+
337
+		/* FIXME: janakj, mk_proxy doesn't make copy of host !! */
338
+		/*pkg_free( *(param-1)); you're right --andrei*/
339
+		*(param-1)=proxy;
340
+		return 0;
341
+	} else {
342
+		LOG(L_ERR,"ERROR: fixup_t_forwardv6 called with parameter #<>{1,2}\n");
343
+		return E_BUG;
344
+	}
345
+}
346
+
347
+
348
+/* (char *code, char *reason_phrase)==>(int code, r_p as is) */
349
+static int fixup_t_send_reply(void** param, int param_no)
350
+{
351
+	unsigned long code;
352
+	int err;
353
+
354
+	if (param_no==1){
355
+		code=str2s(*param, strlen(*param), &err);
356
+		if (err==0){
357
+			pkg_free(*param);
358
+			*param=(void*)code;
359
+			return 0;
360
+		}else{
361
+			LOG(L_ERR, "TM module:fixup_t_send_reply: bad  number <%s>\n",
362
+					(char*)(*param));
363
+			return E_UNSPEC;
364
+		}
365
+	}
366
+	/* second param => no conversion*/
367
+	return 0;
368
+}
369
+
370
+
371
+static int fixup_str2regexp(void** param, int param_no)
372
+{
373
+	regex_t* re;
374
+
375
+	if (param_no==1) {
376
+		if ((re=pkg_malloc(sizeof(regex_t)))==0)
377
+			return E_OUT_OF_MEM;
378
+		if (regcomp(re, *param, REG_EXTENDED|REG_ICASE|REG_NEWLINE) ) {
379
+			pkg_free(re);
380
+			LOG(L_ERR,"ERROR: %s : bad re %s\n", exports.name, (char*)*param);
381
+			return E_BAD_RE;
382
+		}
383
+		/* free string */
384
+		pkg_free(*param);
385
+		/* replace it with the compiled re */
386
+		*param=re;
387
+	} else {
388
+		LOG(L_ERR,"ERROR: fixup_str2regexp called with parameter != 1\n");
389
+		return E_BUG;
390
+	}
391
+	return 0;
392
+}
393
+
394
+
395
+
396
+
397
+/***************************** init functions *****************************/
272 398
 static int w_t_unref( struct sip_msg *foo, void *bar)
273 399
 {
274 400
 	return t_unref(foo);
275 401
 }
276 402
 
403
+
277 404
 static int script_init( struct sip_msg *foo, void *bar)
278 405
 {   
279 406
 	/* we primarily reset all private memory here to make sure
280
-	   private values left over from previous message will
281
-	   not be used again
282
-    */
407
+	 * private values left over from previous message will
408
+	 * not be used again */
283 409
 
284 410
 	if (foo->first_line.type==SIP_REQUEST){
285 411
 		/* make sure the new message will not inherit previous
286
-	   		message's t_on_negative value
412
+			message's t_on_negative value
287 413
 		*/
288 414
 		t_on_negative( 0 );
289 415
 		t_on_reply(0);
... ...
@@ -293,13 +419,12 @@ static int script_init( struct sip_msg *foo, void *bar)
293 419
 		 * how to behave */
294 420
 		rmode=MODE_REQUEST;
295 421
 	}
296
-
297 422
 	return 1;
298 423
 }
299 424
 
425
+
300 426
 static int mod_init(void)
301 427
 {
302
-
303 428
 	DBG( "TM - initializing...\n");
304 429
 	/* checking if we have sufficient bitmap capacity for given
305 430
 	   maximum number of  branches */
... ...
@@ -379,73 +504,90 @@ static int child_init(int rank) {
379 504
 }
380 505
 
381 506
 
382
-/* (char *hostname, char *port_nr) ==> (struct proxy_l *, -)  */
383 507
 
384
-inline static int fixup_hostport2proxy(void** param, int param_no)
385
-{
386
-	unsigned int port;
387
-	char *host;
388
-	int err;
389
-	struct proxy_l *proxy;
390
-	str s;
391
-	
392
-	DBG("TM module: fixup_t_forward(%s, %d)\n", (char*)*param, param_no);
393
-	if (param_no==1){
394
-		DBG("TM module: fixup_t_forward: param 1.. do nothing, wait for #2\n");
395
-		return 0;
396
-	} else if (param_no==2) {
397 508
 
398
-		host=(char *) (*(param-1)); 
399
-		port=str2s(*param, strlen(*param), &err);
400
-		if (err!=0) {
401
-			LOG(L_ERR, "TM module:fixup_t_forward: bad port number <%s>\n",
402
-				(char*)(*param));
403
-			 return E_UNSPEC;
404
-		}
405
-		s.s = host;
406
-		s.len = strlen(host);
407
-		proxy=mk_proxy(&s, port, 0); /* FIXME: udp or tcp? */
408
-		if (proxy==0) {
409
-			LOG(L_ERR, "ERROR: fixup_t_forwardv6: bad host name in URI <%s>\n",
410
-				host );
411
-			return E_BAD_ADDRESS;
412
-		}
413
-		/* success -- fix the first parameter to proxy now ! */
414 509
 
415
-		/* FIXME: janakj, mk_proxy doesn't make copy of host !! */
416
-		/*pkg_free( *(param-1)); you're right --andrei*/
417
-		*(param-1)=proxy;
418
-		return 0;
419
-	} else {
420
-		LOG(L_ERR, "ERROR: fixup_t_forwardv6 called with parameter #<>{1,2}\n");
421
-		return E_BUG;
510
+/**************************** wrapper functions ***************************/
511
+static int t_check_status(struct sip_msg* msg, char *regexp, char *foo)
512
+{
513
+	regmatch_t pmatch;
514
+	struct cell *t;
515
+	char *status;
516
+	char backup;
517
+	int lowest_status;
518
+	int n;
519
+
520
+	/* first get the transaction */
521
+	if (t_check( msg , 0 )==-1) return -1;
522
+	if ( (t=get_t())==0) {
523
+		LOG(L_ERR, "ERROR: t_check_status: cannot check status for a reply "
524
+			"which has no T-state established\n");
525
+		return -1;
422 526
 	}
527
+	backup = 0;
528
+
529
+	switch (rmode) {
530
+		case MODE_REQUEST:
531
+			/* use the status of the last sent reply */
532
+			status = int2str( t->uas.status, 0);
533
+			break;
534
+		case MODE_ONREPLY:
535
+			/* use the status of the current reply */
536
+			status = msg->first_line.u.reply.status.s;
537
+			backup = status[msg->first_line.u.reply.status.len];
538
+			status[msg->first_line.u.reply.status.len] = 0;
539
+			break;
540
+		case MODE_ONFAILURE:
541
+			/* use the status of the winning reply */
542
+			lowest_status=999;
543
+			for ( n=0; n<t->nr_of_outgoings ; n++ ) {
544
+				if ( t->uac[n].last_received<lowest_status ) {
545
+					lowest_status = t->uac[n].last_received;
546
+				}
547
+			}
548
+			status = int2str( lowest_status , 0);
549
+			break;
550
+		default:
551
+			LOG(L_ERR,"ERROR:t_check_status: unsupported mode %d\n",rmode);
552
+			return -1;
553
+	}
554
+
555
+	DBG("DEBUG:t_check_status: checked status is <%s>\n",status);
556
+	/* do the checking */
557
+	n = regexec((regex_t*)regexp, status, 1, &pmatch, 0);
558
+
559
+	if (backup) status[msg->first_line.u.reply.status.len] = backup;
560
+	if (n!=0) return -1;
561
+	return 1;
423 562
 }
424 563
 
425 564
 
426
-/* (char *code, char *reason_phrase)==>(int code, r_p as is) */
427
-inline static int fixup_t_send_reply(void** param, int param_no)
565
+static int t_flush_flags(struct sip_msg* msg, char *dir, char *foo)
428 566
 {
429
-	unsigned long code;
430
-	int err;
567
+	struct cell *t;
431 568
 
432
-	if (param_no==1){
433
-		code=str2s(*param, strlen(*param), &err);
434
-		if (err==0){
435
-			pkg_free(*param);
436
-			*param=(void*)code;
437
-			return 0;
438
-		}else{
439
-			LOG(L_ERR, "TM module:fixup_t_send_reply: bad  number <%s>\n",
440
-					(char*)(*param));
441
-			return E_UNSPEC;
442
-		}
569
+	/* first get the transaction */
570
+	if (t_check( msg , 0 )==-1) return -1;
571
+	if ( (t=get_t())==0) {
572
+		LOG(L_ERR, "ERROR: t_flush_flags: cannot flush flags for a message "
573
+			"which has no T-state established\n");
574
+		return -1;
443 575
 	}
444
-	/* second param => no conversion*/
445
-	return 0;
446
-}
447
-
448 576
 
577
+	/* do the flush */
578
+	switch ((int)dir) {
579
+		case  1:
580
+			t->uas.request->flags = msg->flags;
581
+			break;
582
+		case  2:
583
+			msg->flags = t->uas.request->flags;
584
+			break;
585
+		default:
586
+			LOG(L_ERR,"ERROR:t_flush_flags: unknown direction %d\n",(int)dir);
587
+			return -1;
588
+	}
589
+	return 1;
590
+}
449 591
 
450 592
 
451 593
 inline static int w_t_check(struct sip_msg* msg, char* str, char* str2)
... ...
@@ -454,7 +596,6 @@ inline static int w_t_check(struct sip_msg* msg, char* str, char* str2)
454 596
 }
455 597
 
456 598
 
457
-
458 599
 inline static int _w_t_forward_nonack(struct sip_msg* msg, char* proxy,
459 600
 																	int proto)
460 601
 {
... ...
@@ -484,18 +625,21 @@ inline static int w_t_forward_nonack( struct sip_msg* msg, char* proxy,
484 625
 	return _w_t_forward_nonack(msg, proxy, PROTO_NONE);
485 626
 }
486 627
 
628
+
487 629
 inline static int w_t_forward_nonack_uri(struct sip_msg* msg, char *foo,
488 630
 																	char *bar)
489 631
 {
490 632
 	return _w_t_forward_nonack(msg, 0, PROTO_NONE);
491 633
 }
492 634
 
635
+
493 636
 inline static int w_t_forward_nonack_udp( struct sip_msg* msg, char* proxy,
494 637
 										char* foo)
495 638
 {
496 639
 	return _w_t_forward_nonack(msg, proxy, PROTO_UDP);
497 640
 }
498 641
 
642
+
499 643
 #ifdef USE_TCP
500 644
 inline static int w_t_forward_nonack_tcp( struct sip_msg* msg, char* proxy,
501 645
 										char* foo)
... ...
@@ -504,6 +648,7 @@ inline static int w_t_forward_nonack_tcp( struct sip_msg* msg, char* proxy,
504 648
 }
505 649
 #endif
506 650
 
651
+
507 652
 #ifdef USE_TLS
508 653
 inline static int w_t_forward_nonack_tls( struct sip_msg* msg, char* proxy,
509 654
 										char* foo)
... ...
@@ -513,7 +658,6 @@ inline static int w_t_forward_nonack_tls( struct sip_msg* msg, char* proxy,
513 658
 #endif
514 659
 
515 660
 
516
-
517 661
 inline static int w_t_reply(struct sip_msg* msg, char* str, char* str2)
518 662
 {
519 663
 	struct cell *t;
... ...
@@ -556,8 +700,6 @@ inline static int w_t_release(struct sip_msg* msg, char* str, char* str2)
556 700
 }
557 701
 
558 702
 
559
-
560
-
561 703
 inline static int w_t_retransmit_reply( struct sip_msg* p_msg, char* foo, char* bar)
562 704
 {
563 705
 	struct cell *t;
... ...
@@ -607,6 +749,8 @@ inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo )
607 749
 	LOG(L_CRIT, "BUG: w_t_on_negative entered in unsupported mode\n");
608 750
 	return -1;
609 751
 }
752
+
753
+
610 754
 inline static int w_t_on_reply( struct sip_msg* msg, char *go_to, char *foo )
611 755
 {
612 756
 	struct cell *t;
... ...
@@ -632,6 +776,7 @@ inline static int w_t_on_reply( struct sip_msg* msg, char *go_to, char *foo )
632 776
 	return -1;
633 777
 }
634 778
 
779
+
635 780
 inline static int _w_t_relay_to( struct sip_msg  *p_msg , 
636 781
 	struct proxy_l *proxy )
637 782
 {
... ...
@@ -656,6 +801,7 @@ inline static int _w_t_relay_to( struct sip_msg  *p_msg ,
656 801
 	return 0;
657 802
 }
658 803
 
804
+
659 805
 inline static int w_t_relay_to_udp( struct sip_msg  *p_msg , 
660 806
 	char *proxy, /* struct proxy_l *proxy expected */
661 807
 	char *_foo       /* nothing expected */ )
... ...
@@ -664,6 +810,7 @@ inline static int w_t_relay_to_udp( struct sip_msg  *p_msg ,
664 810
 	return _w_t_relay_to( p_msg, ( struct proxy_l *) proxy);
665 811
 }
666 812
 
813
+
667 814
 #ifdef USE_TCP
668 815
 inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg , 
669 816
 	char *proxy, /* struct proxy_l *proxy expected */
... ...
@@ -674,6 +821,7 @@ inline static int w_t_relay_to_tcp( struct sip_msg  *p_msg ,
674 821
 }
675 822
 #endif
676 823
 
824
+
677 825
 #ifdef USE_TLS
678 826
 inline static int w_t_relay_to_tls( struct sip_msg  *p_msg , 
679 827
 	char *proxy, /* struct proxy_l *proxy expected */
... ...
@@ -685,7 +833,6 @@ inline static int w_t_relay_to_tls( struct sip_msg  *p_msg ,
685 833
 #endif
686 834
 
687 835
 
688
-
689 836
 inline static int w_t_replicate( struct sip_msg  *p_msg , 
690 837
 	char *proxy, /* struct proxy_l *proxy expected */
691 838
 	char *_foo       /* nothing expected */ )
... ...
@@ -693,6 +840,7 @@ inline static int w_t_replicate( struct sip_msg  *p_msg ,
693 840
 	return t_replicate(p_msg, ( struct proxy_l *) proxy, p_msg->rcv.proto );
694 841
 }
695 842
 
843
+
696 844
 inline static int w_t_replicate_udp( struct sip_msg  *p_msg , 
697 845
 	char *proxy, /* struct proxy_l *proxy expected */
698 846
 	char *_foo       /* nothing expected */ )
... ...
@@ -700,6 +848,7 @@ inline static int w_t_replicate_udp( struct sip_msg  *p_msg ,
700 848
 	return t_replicate(p_msg, ( struct proxy_l *) proxy, PROTO_UDP );
701 849
 }
702 850
 
851
+
703 852
 #ifdef USE_TCP
704 853
 inline static int w_t_replicate_tcp( struct sip_msg  *p_msg , 
705 854
 	char *proxy, /* struct proxy_l *proxy expected */
... ...
@@ -709,6 +858,7 @@ inline static int w_t_replicate_tcp( struct sip_msg  *p_msg ,
709 858
 }
710 859
 #endif
711 860
 
861
+
712 862
 #ifdef USE_TLS
713 863
 inline static int w_t_replicate_tls( struct sip_msg  *p_msg , 
714 864
 	char *proxy, /* struct proxy_l *proxy expected */
... ...
@@ -719,7 +869,6 @@ inline static int w_t_replicate_tls( struct sip_msg  *p_msg ,
719 869
 #endif
720 870
 
721 871
 
722
-
723 872
 inline static int w_t_relay( struct sip_msg  *p_msg , 
724 873
 						char *_foo, char *_bar)
725 874
 {