Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,506 +0,0 @@
1
-/*
2
- * transaction maintenance functions
3
- *
4
- * Copyright (C) 2001-2003 FhG Fokus
5
- *
6
- * This file is part of Kamailio, a free SIP server.
7
- *
8
- * Kamailio is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
12
- *
13
- * Kamailio is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License 
19
- * along with this program; if not, write to the Free Software 
20
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
- */
22
-
23
-#include <limits.h>
24
-#include <string.h>
25
-#include <stdio.h>
26
-#include <errno.h>
27
-#include <stdlib.h>
28
-
29
-#include "../../dprint.h"
30
-#include "../../hash_func.h"
31
-#include "../../dset.h"
32
-#include "../../mem/mem.h"
33
-#include "../../sr_compat.h"
34
-#include "../../pvar.h"
35
-#include "defs.h"
36
-#include "t_funcs.h"
37
-#include "t_fwd.h"
38
-#include "t_lookup.h"
39
-#include "t_reply.h"
40
-#include "config.h"
41
-#include "t_stats.h"
42
-
43
-/* if defined t_relay* error reply generation will be delayed till script
44
- * end (this allows the script writter to send its own error reply) */
45
-#define TM_DELAYED_REPLY
46
-
47
-/* fr_timer AVP specs */
48
-static int     fr_timer_avp_type = 0;
49
-static int_str fr_timer_avp = {0};
50
-static str     fr_timer_str;
51
-static int     fr_timer_index = 0;
52
-int     fr_inv_timer_avp_type = 0;
53
-int_str fr_inv_timer_avp = {0};
54
-static str     fr_inv_timer_str;
55
-static int     fr_inv_timer_index = 0;
56
-
57
-int tm_error = 0; /* delayed tm error */
58
-
59
-struct msgid_var user_cell_set_flags;   /* extra cell->flags to be set */
60
-struct msgid_var user_cell_reset_flags; /* extra cell->flags to be reset */
61
-
62
-/* ----------------------------------------------------- */
63
-int send_pr_buffer(	struct retr_buf *rb, void *buf, int len
64
-#ifdef EXTRA_DEBUG
65
-						, char* file, const char *function, int line
66
-#endif
67
-					)
68
-{
69
-	if (buf && len && rb )
70
-		return msg_send( &rb->dst, buf, len);
71
-	else {
72
-#ifdef EXTRA_DEBUG
73
-		LOG(L_CRIT, "ERROR: send_pr_buffer: sending an empty buffer"
74
-				"from %s: %s (%d)\n", file, function, line );
75
-#else
76
-		LOG(L_CRIT, "ERROR: send_pr_buffer: attempt to send an "
77
-				"empty buffer\n");
78
-#endif
79
-		return -1;
80
-	}
81
-}
82
-
83
-void tm_shutdown()
84
-{
85
-
86
-	DBG("DEBUG: tm_shutdown : start\n");
87
-
88
-	/* destroy the hash table */
89
-	DBG("DEBUG: tm_shutdown : emptying hash table\n");
90
-	free_hash_table( );
91
-	DBG("DEBUG: tm_shutdown : removing semaphores\n");
92
-	lock_cleanup();
93
-	DBG("DEBUG: tm_shutdown : destroying tmcb lists\n");
94
-	destroy_tmcb_lists();
95
-	free_tm_stats();
96
-	DBG("DEBUG: tm_shutdown : done\n");
97
-}
98
-
99
-
100
-/*   returns 1 if everything was OK or -1 for error
101
-*/
102
-int t_release_transaction( struct cell *trans )
103
-{
104
-	set_kr(REQ_RLSD);
105
-
106
-	stop_rb_timers(&trans->uas.response);
107
-	cleanup_uac_timers( trans );
108
-	
109
-	put_on_wait( trans );
110
-	return 1;
111
-}
112
-
113
-
114
-/* -----------------------HELPER FUNCTIONS----------------------- */
115
-
116
-
117
-/*
118
-  */
119
-void put_on_wait(  struct cell  *Trans  )
120
-{
121
-
122
-#ifdef EXTRA_DEBUG
123
-	DBG("DEBUG: put on WAIT \n");
124
-#endif
125
-
126
-
127
-	/* we put the transaction on wait timer; we do it only once
128
-	   in transaction's timelife because putting it multiple-times
129
-	   might result in a second instance of a wait timer to be
130
-	   set after the first one fired; on expiration of the second
131
-	   instance, the transaction would be re-deleted
132
-
133
-			PROCESS1		PROCESS2		TIMER PROCESS
134
-		0. 200/INVITE rx;
135
-		   put_on_wait
136
-		1.					200/INVITE rx;
137
-		2.									WAIT fires; transaction
138
-											about to be deleted
139
-		3.					avoid putting
140
-							on WAIT again
141
-		4.									WAIT timer executed,
142
-											transaction deleted
143
-	*/
144
-	if (timer_add(&Trans->wait_timer, cfg_get(tm, tm_cfg, wait_timeout))==0){
145
-		/* success */
146
-		t_stats_wait();
147
-	}else{
148
-		DBG("tm: put_on_wait: transaction %p already on wait\n", Trans);
149
-	}
150
-}
151
-
152
-
153
-int t_on_wait(tm_cell_t *Trans)
154
-{
155
-	if(Trans->wait_timer.prev!=NULL || Trans->wait_timer.next!=NULL)
156
-		return 1;
157
-	return 0;
158
-}
159
-
160
-/* WARNING: doesn't work from failure route (deadlock, uses t_reply =>
161
- *  tries to get the reply lock again) */
162
-int kill_transaction( struct cell *trans, int error )
163
-{
164
-	char err_buffer[128];
165
-	int sip_err;
166
-	int reply_ret;
167
-	int ret;
168
-
169
-	/*  we reply statefully and enter WAIT state since error might
170
-		have occurred in middle of forking and we do not
171
-		want to put the forking burden on upstream client;
172
-		however, it may fail too due to lack of memory */
173
-
174
-	ret=err2reason_phrase(error, &sip_err,
175
-		err_buffer, sizeof(err_buffer), "TM" );
176
-	if (ret>0) {
177
-		reply_ret=t_reply( trans, trans->uas.request, 
178
-			sip_err, err_buffer);
179
-		/* t_release_transaction( T ); */
180
-		return reply_ret;
181
-	} else {
182
-		LOG(L_ERR, "ERROR: kill_transaction: err2reason failed\n");
183
-		return -1;
184
-	}
185
-}
186
-
187
-/* unsafe version of kill_transaction() that works
188
- * in failure route 
189
- * WARNING: assumes that the reply lock is held!
190
- */
191
-int kill_transaction_unsafe( struct cell *trans, int error )
192
-{
193
-	char err_buffer[128];
194
-	int sip_err;
195
-	int reply_ret;
196
-	int ret;
197
-
198
-	/*  we reply statefully and enter WAIT state since error might
199
-		have occurred in middle of forking and we do not
200
-		want to put the forking burden on upstream client;
201
-		however, it may fail too due to lack of memory */
202
-
203
-	ret=err2reason_phrase(error, &sip_err,
204
-		err_buffer, sizeof(err_buffer), "TM" );
205
-	if (ret>0) {
206
-		reply_ret=t_reply_unsafe( trans, trans->uas.request, 
207
-			sip_err, err_buffer);
208
-		/* t_release_transaction( T ); */
209
-		return reply_ret;
210
-	} else {
211
-		LOG(L_ERR, "ERROR: kill_transaction_unsafe: err2reason failed\n");
212
-		return -1;
213
-	}
214
-}
215
-
216
-
217
-/* WARNING: doesn't work from failure route (deadlock, uses t_reply => tries
218
- *  to get the reply lock again */
219
-int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy, int proto,
220
-				int replicate)
221
-{
222
-	int ret;
223
-	int new_tran;
224
-	/* struct hdr_field *hdr; */
225
-	struct cell *t;
226
-	struct dest_info dst;
227
-	unsigned short port;
228
-	str host;
229
-	short comp;
230
-#ifndef TM_DELAYED_REPLY
231
-	int reply_ret;
232
-#endif
233
-
234
-	ret=0;
235
-	
236
-	/* special case for CANCEL */
237
-	if ( p_msg->REQ_METHOD==METHOD_CANCEL){
238
-		ret=t_forward_cancel(p_msg, proxy, proto, &t);
239
-		if (t) goto handle_ret;
240
-		goto done;
241
-	}
242
-	new_tran = t_newtran( p_msg );
243
-	
244
-	/* parsing error, memory alloc, whatever ... if via is bad
245
-	   and we are forced to reply there, return with 0 (->break),
246
-	   pass error status otherwise
247
-	   MMA: return value E_SCRIPT means that transaction was already started
248
-	   from the script so continue with that transaction
249
-	*/
250
-	if (likely(new_tran!=E_SCRIPT)) {
251
-		if (new_tran<0) {
252
-			ret = (ser_error==E_BAD_VIA && reply_to_via) ? 0 : new_tran;
253
-			goto done;
254
-		}
255
-		/* if that was a retransmission, return we are happily done */
256
-		if (new_tran==0) {
257
-			ret = 1;
258
-			goto done;
259
-		}
260
-	}else if (unlikely(p_msg->REQ_METHOD==METHOD_ACK)) {
261
-			/* transaction previously found (E_SCRIPT) and msg==ACK
262
-			    => ack to neg. reply  or ack to local trans.
263
-			    => process it and exit */
264
-			/* FIXME: there's no way to distinguish here between acks to
265
-			   local trans. and neg. acks */
266
-			/* in normal operation we should never reach this point, if we
267
-			   do WARN(), it might hide some real bug (apart from possibly
268
-			   hiding a bug the most harm done is calling the TMCB_ACK_NEG
269
-			   callbacks twice) */
270
-			WARN("negative or local ACK caught, please report\n");
271
-			t=get_t();
272
-			if (unlikely(has_tran_tmcbs(t, TMCB_ACK_NEG_IN)))
273
-				run_trans_callbacks(TMCB_ACK_NEG_IN, t, p_msg, 0, 
274
-										p_msg->REQ_METHOD);
275
-			t_release_transaction(t);
276
-			ret=1;
277
-			goto done;
278
-	}
279
-
280
-	/* new transaction */
281
-
282
-	/* at this point if the msg is an ACK it is an e2e ACK and
283
-	   e2e ACKs do not establish a transaction and are fwd-ed statelessly */
284
-	if ( p_msg->REQ_METHOD==METHOD_ACK) {
285
-		DBG( "SER: forwarding ACK  statelessly \n");
286
-		if (proxy==0) {
287
-			init_dest_info(&dst);
288
-			dst.proto=proto;
289
-			if (get_uri_send_info(GET_NEXT_HOP(p_msg), &host, &port,
290
-									&dst.proto, &comp)!=0){
291
-				ret=E_BAD_ADDRESS;
292
-				goto done;
293
-			}
294
-#ifdef USE_COMP
295
-			dst.comp=comp;
296
-#endif
297
-			/* dst->send_sock not set, but forward_request will take care
298
-			 * of it */
299
-			ret=forward_request(p_msg, &host, port, &dst);
300
-		} else {
301
-			init_dest_info(&dst);
302
-			dst.proto=get_proto(proto, proxy->proto);
303
-			proxy2su(&dst.to, proxy);
304
-			/* dst->send_sock not set, but forward_request will take care
305
-			 * of it */
306
-			ret=forward_request( p_msg , 0, 0, &dst) ;
307
-		}
308
-		goto done;
309
-	}
310
-
311
-	/* if replication flag is set, mark the transaction as local
312
-	   so that replies will not be relayed */
313
-	t=get_t();
314
-	if (replicate) t->flags|=T_IS_LOCAL_FLAG;
315
-
316
-	/* INVITE processing might take long, particularly because of DNS
317
-	   look-ups -- let upstream know we're working on it */
318
-	if (p_msg->REQ_METHOD==METHOD_INVITE && (t->flags&T_AUTO_INV_100)
319
-		&& (t->uas.status < 100)
320
-	) {
321
-		DBG( "SER: new INVITE\n");
322
-		if (!t_reply( t, p_msg , 100 ,
323
-			cfg_get(tm, tm_cfg, tm_auto_inv_100_r)))
324
-				DBG("SER: ERROR: t_reply (100)\n");
325
-	} 
326
-
327
-	/* now go ahead and forward ... */
328
-	ret=t_forward_nonack(t, p_msg, proxy, proto);
329
-handle_ret:
330
-	if (ret<=0) {
331
-		DBG( "t_forward_nonack returned error %d (%d)\n", ret, ser_error);
332
-		/* we don't want to pass upstream any reply regarding replicating
333
-		 * a request; replicated branch must stop at us*/
334
-		if (likely(!replicate)) {
335
-			if(t->flags&T_DISABLE_INTERNAL_REPLY) {
336
-				/* flag set to don't generate the internal negative reply
337
-				 * - let the transaction live further, processing should
338
-				 *   continue in config */
339
-				DBG("not generating immediate reply for error %d\n", ser_error);
340
-				tm_error=ser_error;
341
-				ret = -4;
342
-				goto done;
343
-			}
344
-#ifdef TM_DELAYED_REPLY
345
-			/* current error in tm_error */
346
-			tm_error=ser_error;
347
-			set_kr(REQ_ERR_DELAYED);
348
-			DBG("%d error reply generation delayed \n", ser_error);
349
-#else
350
-
351
-			reply_ret=kill_transaction( t, ser_error );
352
-			if (reply_ret>0) {
353
-				/* we have taken care of all -- do nothing in
354
-			  	script */
355
-				DBG("ERROR: generation of a stateful reply "
356
-					"on error succeeded\n");
357
-				/*ret=0; -- we don't want to stop the script */
358
-			}  else {
359
-				DBG("ERROR: generation of a stateful reply "
360
-					"on error failed\n");
361
-				t_release_transaction(t);
362
-			}
363
-#endif /* TM_DELAYED_REPLY */
364
-		}else{
365
-			t_release_transaction(t); /* kill it  silently */
366
-		}
367
-	} else {
368
-		DBG( "SER: new transaction fwd'ed\n");
369
-	}
370
-
371
-done:
372
-	return ret;
373
-}
374
-
375
-
376
-
377
-/*
378
- * Initialize parameters containing the ID of
379
- * AVPs with various timers
380
- */
381
-int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param)
382
-{
383
-	pv_spec_t avp_spec;
384
-	unsigned short avp_type;
385
-
386
-	if (fr_timer_param && *fr_timer_param) {
387
-		fr_timer_str.s = fr_timer_param;
388
-		fr_timer_str.len = strlen(fr_timer_str.s);
389
-		LM_WARN("using AVP for TM fr_timer is deprecated,"
390
-				" use t_set_fr(...) instead\n");
391
-
392
-		if(fr_timer_str.s[0]==PV_MARKER) {
393
-			if (pv_parse_spec(&fr_timer_str, &avp_spec)==0
394
-			        || avp_spec.type!=PVT_AVP) {
395
-			        LM_ERR("malformed or non AVP %s AVP definition\n",
396
-							fr_timer_param);
397
-				return -1;
398
-			}
399
-
400
-			if(pv_get_avp_name(0, &avp_spec.pvp, &fr_timer_avp, &avp_type)!=0)
401
-			{
402
-				LM_ERR("[%s]- invalid AVP definition\n", fr_timer_param);
403
-				return -1;
404
-			}
405
-			fr_timer_avp_type = avp_type;
406
-		} else {
407
-			if (parse_avp_spec( &fr_timer_str, &fr_timer_avp_type,
408
-			&fr_timer_avp, &fr_timer_index)<0) {
409
-				LOG(L_CRIT,"ERROR:tm:init_avp_params: invalid fr_timer "
410
-					"AVP specs \"%s\"\n", fr_timer_param);
411
-				return -1;
412
-			}
413
-			/* ser flavour uses the To track of AVPs */
414
-			fr_timer_avp_type |= AVP_TRACK_TO;
415
-		}
416
-	}
417
-
418
-	if (fr_inv_timer_param && *fr_inv_timer_param) {
419
-		fr_inv_timer_str.s = fr_inv_timer_param;
420
-		fr_inv_timer_str.len = strlen(fr_inv_timer_str.s);
421
-		LM_WARN("using AVP for TM fr_inv_timer is deprecated,"
422
-				" use t_set_fr(...) instead\n");
423
-
424
-		if(fr_inv_timer_str.s[0]==PV_MARKER) {
425
-			if (pv_parse_spec(&fr_inv_timer_str, &avp_spec)==0
426
-					|| avp_spec.type!=PVT_AVP) {
427
-				LM_ERR("malformed or non AVP %s AVP definition\n",
428
-					fr_inv_timer_param);
429
-				return -1;
430
-			}
431
-
432
-			if(pv_get_avp_name(0, &avp_spec.pvp, &fr_inv_timer_avp,
433
-								&avp_type)!=0)
434
-			{
435
-				LM_ERR("[%s]- invalid AVP definition\n", fr_inv_timer_param);
436
-				return -1;
437
-			}
438
-			fr_inv_timer_avp_type = avp_type;
439
-		} else {
440
-			if (parse_avp_spec( &fr_inv_timer_str, &fr_inv_timer_avp_type, 
441
-			&fr_inv_timer_avp, &fr_inv_timer_index)<0) {
442
-				LOG(L_CRIT,"ERROR:tm:init_avp_params: invalid fr_inv_timer "
443
-					"AVP specs \"%s\"\n", fr_inv_timer_param);
444
-				return -1;
445
-			}
446
-			/* ser flavour uses the To track of AVPs */
447
-			fr_inv_timer_avp_type |= AVP_TRACK_TO;
448
-		}
449
-	}
450
-
451
-	return 0;
452
-}
453
-
454
-
455
-/** Get the FR_{INV}_TIMER from corresponding AVP.
456
- * @return 0 on success (use *timer) or 1 on failure (avp non-existent,
457
- *  avp present  but empty/0, avp value not numeric).
458
- */
459
-static inline int avp2timer(unsigned int* timer, int type, int_str name)
460
-{
461
-	struct usr_avp *avp;
462
-	int_str val_istr;
463
-	int err;
464
-
465
-	avp = search_first_avp(type, name, &val_istr, 0);
466
-	if (!avp) {
467
-		/*
468
-		 DBG("avp2timer: AVP '%.*s' not found\n", param.s->len, ZSW(param.s->s));
469
-		 */
470
-		return 1;
471
-	}
472
-	
473
-	if (avp->flags & AVP_VAL_STR) {
474
-		*timer = str2s(val_istr.s.s, val_istr.s.len, &err);
475
-		if (err) {
476
-			LOG(L_ERR, "avp2timer: Error while converting string to integer\n");
477
-			return -1;
478
-		}
479
-	} else {
480
-		*timer = val_istr.n;
481
-	}
482
-	return *timer==0; /* 1 if 0 (use default), 0 if !=0 (use *timer) */
483
-}
484
-
485
-
486
-int fr_avp2timer(unsigned int* timer)
487
-{
488
-	if (fr_timer_avp.n!=0)
489
-		return avp2timer( timer, fr_timer_avp_type, fr_timer_avp);
490
-	else
491
-		return 1;
492
-}
493
-
494
-
495
-int fr_inv_avp2timer(unsigned int* timer)
496
-{
497
-	if (fr_inv_timer_avp.n!=0)
498
-		return avp2timer( timer, fr_inv_timer_avp_type, fr_inv_timer_avp);
499
-	else
500
-		return 1;
501
-}
502
-
503
-void unref_cell(struct cell *t)
504
-{
505
-	UNREF(t);
506
-}
Browse code

tm: fix spelling errors catched by lintian #688

Victor Seva authored on 29/06/2016 15:06:41
Showing 1 changed files
... ...
@@ -142,7 +142,7 @@ void put_on_wait(  struct cell  *Trans  )
142 142
 											transaction deleted
143 143
 	*/
144 144
 	if (timer_add(&Trans->wait_timer, cfg_get(tm, tm_cfg, wait_timeout))==0){
145
-		/* sucess */
145
+		/* success */
146 146
 		t_stats_wait();
147 147
 	}else{
148 148
 		DBG("tm: put_on_wait: transaction %p already on wait\n", Trans);
Browse code

tm: init actions context for kemi execution

- needed to catch drop in onreply/branch route callbacks

Daniel-Constantin Mierla authored on 14/04/2016 16:16:32
Showing 1 changed files
... ...
@@ -328,7 +328,7 @@ int t_relay_to( struct sip_msg  *p_msg , struct proxy_l *proxy, int proto,
328 328
 	ret=t_forward_nonack(t, p_msg, proxy, proto);
329 329
 handle_ret:
330 330
 	if (ret<=0) {
331
-		DBG( "ERROR:tm:t_relay_to:  t_forward_nonack returned error \n");
331
+		DBG( "t_forward_nonack returned error %d (%d)\n", ret, ser_error);
332 332
 		/* we don't want to pass upstream any reply regarding replicating
333 333
 		 * a request; replicated branch must stop at us*/
334 334
 		if (likely(!replicate)) {
Browse code

tm: don't free tm cell still linked in wait timer

- wait timer should do the free
- friendlier handling of situation when modules binding to tm do
inconsistent unref operations

Daniel-Constantin Mierla authored on 29/12/2015 23:29:49
Showing 1 changed files
... ...
@@ -150,6 +150,12 @@ void put_on_wait(  struct cell  *Trans  )
150 150
 }
151 151
 
152 152
 
153
+int t_on_wait(tm_cell_t *Trans)
154
+{
155
+	if(Trans->wait_timer.prev!=NULL || Trans->wait_timer.next!=NULL)
156
+		return 1;
157
+	return 0;
158
+}
153 159
 
154 160
 /* WARNING: doesn't work from failure route (deadlock, uses t_reply =>
155 161
  *  tries to get the reply lock again) */
Browse code

tm: reply_lock per transaction made re-entrant

- on a report by Jason Penton
- re-ordered some includes to get rid of cross dependencies in defines

Daniel-Constantin Mierla authored on 28/03/2015 13:31:59
Showing 1 changed files
... ...
@@ -36,6 +36,7 @@
36 36
 #include "t_funcs.h"
37 37
 #include "t_fwd.h"
38 38
 #include "t_lookup.h"
39
+#include "t_reply.h"
39 40
 #include "config.h"
40 41
 #include "t_stats.h"
41 42
 
Browse code

tm Remove svn ID, remove history, rename "ser" to "kamailio"

Olle E. Johansson authored on 03/01/2015 15:48:29
Showing 1 changed files
... ...
@@ -1,23 +1,16 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * transaction maintenance functions
5 3
  *
6 4
  * Copyright (C) 2001-2003 FhG Fokus
7 5
  *
8
- * This file is part of ser, a free SIP server.
6
+ * This file is part of Kamailio, a free SIP server.
9 7
  *
10
- * ser is free software; you can redistribute it and/or modify
8
+ * Kamailio is free software; you can redistribute it and/or modify
11 9
  * it under the terms of the GNU General Public License as published by
12 10
  * the Free Software Foundation; either version 2 of the License, or
13 11
  * (at your option) any later version
14 12
  *
15
- * For a license to use the ser software under conditions
16
- * other than those described here, or to purchase support for this
17
- * software, please contact iptel.org by e-mail at the following addresses:
18
- *    info@iptel.org
19
- *
20
- * ser is distributed in the hope that it will be useful,
13
+ * Kamailio is distributed in the hope that it will be useful,
21 14
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 16
  * GNU General Public License for more details.
... ...
@@ -26,32 +19,6 @@
26 19
  * along with this program; if not, write to the Free Software 
27 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28 21
  */
29
-/*
30
- * History:
31
- * -------
32
- *  2003-03-31  200 for INVITE/UAS resent even for UDP (jiri)
33
- *               info only if compiling w/ -DEXTRA_DEBUG (andrei)
34
- *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
35
- *  2003-03-13  send_pr_buffer is called w/ file/function/line debugging
36
- *  2003-03-01  start_retr changed to retransmit only for UDP
37
- *  2003-02-13  modified send_pr_buffer to use msg_send & rb->dst (andrei)
38
- *  2003-04-14  use protocol from uri (jiri)
39
- *  2003-04-25  do it (^) really everywhere (jiri)
40
- *  2003-04-26  do it (^) really really really everywhere (jiri)
41
- *  2003-07-07  added get_proto calls when proxy!=0 (andrei)
42
- *  2004-02-13  t->is_invite and t->local replaced with flags (bogdan)
43
- *  2005-02-16  fr_*_timer acceps full AVP specifications; empty AVP
44
- *              desable variable timer feature (bogdan)
45
- *  2005-12-11  t_relay doesn't return 0 (stop script) on send error 
46
- *              anymore (andrei)
47
- *  2006-08-11  updated forward_request usage (andrei)
48
- *              t_relay_to releases the transaction if t_forward_non_ack
49
- *              fails and t_kill fails or this is a failed replication (andrei)
50
- *  2007-05-02  t_relay_to() uses now t_forward_cancel for cancels (andrei)
51
- *  2007-06-05  delay t_relay() replies till script end so that they can be
52
- *               overwritten by the script user; generate 100 automatically
53
- *               only if T_NO_100 is not set (andrei)
54
- */
55 22
 
56 23
 #include <limits.h>
57 24
 #include <string.h>
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -24,7 +24,7 @@
24 24
  *
25 25
  * You should have received a copy of the GNU General Public License 
26 26
  * along with this program; if not, write to the Free Software 
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28 28
  */
29 29
 /*
30 30
  * History:
Browse code

tm: re-added the option for no-internal reply on error

- new function t_set_disable_internal_reply(0|1) to disable|enable this
option per transaction
- t_relay_to() flags re-enabled for this option

Daniel-Constantin Mierla authored on 23/08/2013 18:53:55
Showing 1 changed files
... ...
@@ -358,12 +358,22 @@ handle_ret:
358 358
 		/* we don't want to pass upstream any reply regarding replicating
359 359
 		 * a request; replicated branch must stop at us*/
360 360
 		if (likely(!replicate)) {
361
+			if(t->flags&T_DISABLE_INTERNAL_REPLY) {
362
+				/* flag set to don't generate the internal negative reply
363
+				 * - let the transaction live further, processing should
364
+				 *   continue in config */
365
+				DBG("not generating immediate reply for error %d\n", ser_error);
366
+				tm_error=ser_error;
367
+				ret = -4;
368
+				goto done;
369
+			}
361 370
 #ifdef TM_DELAYED_REPLY
362 371
 			/* current error in tm_error */
363 372
 			tm_error=ser_error;
364 373
 			set_kr(REQ_ERR_DELAYED);
365 374
 			DBG("%d error reply generation delayed \n", ser_error);
366 375
 #else
376
+
367 377
 			reply_ret=kill_transaction( t, ser_error );
368 378
 			if (reply_ret>0) {
369 379
 				/* we have taken care of all -- do nothing in
Browse code

modules/tm: forgot to commit new version of t_funcs.c

- reported by Peter Dunkley.

Juha Heinanen authored on 12/12/2012 15:03:42
Showing 1 changed files
... ...
@@ -85,10 +85,6 @@ int     fr_inv_timer_avp_type = 0;
85 85
 int_str fr_inv_timer_avp = {0};
86 86
 static str     fr_inv_timer_str;
87 87
 static int     fr_inv_timer_index = 0;
88
-int     contacts_avp_type = 0;
89
-int_str contacts_avp = {0};
90
-static str     contacts_avp_str;
91
-static int     contacts_avp_index = 0;
92 88
 
93 89
 int tm_error = 0; /* delayed tm error */
94 90
 
... ...
@@ -398,8 +394,7 @@ done:
398 394
  * Initialize parameters containing the ID of
399 395
  * AVPs with various timers
400 396
  */
401
-int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
402
-					char* contacts_avp_param)
397
+int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param)
403 398
 {
404 399
 	pv_spec_t avp_spec;
405 400
 	unsigned short avp_type;
... ...
@@ -469,34 +464,6 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
469 464
 		}
470 465
 	}
471 466
 
472
-	if (contacts_avp_param && *contacts_avp_param) {
473
-		contacts_avp_str.s = contacts_avp_param;
474
-		contacts_avp_str.len = strlen(contacts_avp_str.s);
475
-
476
-		if(contacts_avp_str.s[0]==PV_MARKER) {
477
-			if ((pv_parse_spec(&contacts_avp_str, &avp_spec) == 0) 
478
-					|| (avp_spec.type != PVT_AVP)) {
479
-				LM_ERR("malformed or non AVP definition <%s>\n",
480
-					contacts_avp_param);
481
-				return -1;
482
-			}
483
-
484
-			if(pv_get_avp_name(0, &(avp_spec.pvp), &contacts_avp,
485
-						&avp_type) != 0) {
486
-				LM_ERR("invalid AVP definition <%s>\n", contacts_avp_param);
487
-				return -1;
488
-			}
489
-			contacts_avp_type = avp_type;
490
-		} else {
491
-			if (parse_avp_spec( &contacts_avp_str, &contacts_avp_type,
492
-								&contacts_avp, &contacts_avp_index)<0) {
493
-				LOG(L_CRIT,"ERROR:tm:init_avp_params: invalid contact_avp_params "
494
-					"AVP specs \"%s\"\n", contacts_avp_param);
495
-				return -1;
496
-			}
497
-		}
498
-	}
499
-
500 467
 	return 0;
501 468
 }
502 469
 
Browse code

tm: enforce AVP_TRACK_TO only for ser-style timer AVPs

- ser used the list of AVPs from track To for geting timer values
- kamailio is using mainly track From for AVPs
- for compatibility reasons, if avp name is given in ser style, enforce
AVPs track To, otherwise use default track (From) if none is specified
- reported by Min Wang

Daniel-Constantin Mierla authored on 24/03/2011 22:06:17
Showing 1 changed files
... ...
@@ -431,6 +431,8 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
431 431
 					"AVP specs \"%s\"\n", fr_timer_param);
432 432
 				return -1;
433 433
 			}
434
+			/* ser flavour uses the To track of AVPs */
435
+			fr_timer_avp_type |= AVP_TRACK_TO;
434 436
 		}
435 437
 	}
436 438
 
... ...
@@ -462,6 +464,8 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
462 464
 					"AVP specs \"%s\"\n", fr_inv_timer_param);
463 465
 				return -1;
464 466
 			}
467
+			/* ser flavour uses the To track of AVPs */
468
+			fr_inv_timer_avp_type |= AVP_TRACK_TO;
465 469
 		}
466 470
 	}
467 471
 
... ...
@@ -507,7 +511,7 @@ static inline int avp2timer(unsigned int* timer, int type, int_str name)
507 511
 	int_str val_istr;
508 512
 	int err;
509 513
 
510
-	avp = search_first_avp( type | AVP_TRACK_TO, name, &val_istr, 0);
514
+	avp = search_first_avp(type, name, &val_istr, 0);
511 515
 	if (!avp) {
512 516
 		/*
513 517
 		 DBG("avp2timer: AVP '%.*s' not found\n", param.s->len, ZSW(param.s->s));
Browse code

tm: warnings and avp param init. fixes

- wrong pointer was passed to pv_get_avp_name(): int instead of
unsigned short ( => not the whole int was set and problems on
big endian archs).
- unneeded pointer casts removed
- variables declared at the function start (otherwise older
compilers won't work)

Andrei Pelinescu-Onciul authored on 26/08/2010 19:33:45
Showing 1 changed files
... ...
@@ -402,6 +402,7 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
402 402
 					char* contacts_avp_param)
403 403
 {
404 404
 	pv_spec_t avp_spec;
405
+	unsigned short avp_type;
405 406
 
406 407
 	if (fr_timer_param && *fr_timer_param) {
407 408
 		fr_timer_str.s = fr_timer_param;
... ...
@@ -417,12 +418,12 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
417 418
 				return -1;
418 419
 			}
419 420
 
420
-			if(pv_get_avp_name(0, &avp_spec.pvp, &fr_timer_avp, 
421
-						(unsigned short*)&fr_timer_avp_type)!=0)
421
+			if(pv_get_avp_name(0, &avp_spec.pvp, &fr_timer_avp, &avp_type)!=0)
422 422
 			{
423 423
 				LM_ERR("[%s]- invalid AVP definition\n", fr_timer_param);
424 424
 				return -1;
425 425
 			}
426
+			fr_timer_avp_type = avp_type;
426 427
 		} else {
427 428
 			if (parse_avp_spec( &fr_timer_str, &fr_timer_avp_type,
428 429
 			&fr_timer_avp, &fr_timer_index)<0) {
... ...
@@ -448,11 +449,12 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
448 449
 			}
449 450
 
450 451
 			if(pv_get_avp_name(0, &avp_spec.pvp, &fr_inv_timer_avp,
451
-						(unsigned short*)&fr_inv_timer_avp_type)!=0)
452
+								&avp_type)!=0)
452 453
 			{
453 454
 				LM_ERR("[%s]- invalid AVP definition\n", fr_inv_timer_param);
454 455
 				return -1;
455 456
 			}
457
+			fr_inv_timer_avp_type = avp_type;
456 458
 		} else {
457 459
 			if (parse_avp_spec( &fr_inv_timer_str, &fr_inv_timer_avp_type, 
458 460
 			&fr_inv_timer_avp, &fr_inv_timer_index)<0) {
... ...
@@ -476,10 +478,11 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
476 478
 			}
477 479
 
478 480
 			if(pv_get_avp_name(0, &(avp_spec.pvp), &contacts_avp,
479
-						(unsigned short*)&contacts_avp_type) != 0) {
481
+						&avp_type) != 0) {
480 482
 				LM_ERR("invalid AVP definition <%s>\n", contacts_avp_param);
481 483
 				return -1;
482 484
 			}
485
+			contacts_avp_type = avp_type;
483 486
 		} else {
484 487
 			if (parse_avp_spec( &contacts_avp_str, &contacts_avp_type,
485 488
 								&contacts_avp, &contacts_avp_index)<0) {
Browse code

tm: print deprecated warning for timer APVs

- t_set_fr() is better for setting dynamic timeouts for transactions
- print deprecated warning when initalizing AVP parameter names

Daniel-Constantin Mierla authored on 19/04/2010 19:21:01
Showing 1 changed files
... ...
@@ -406,6 +406,8 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
406 406
 	if (fr_timer_param && *fr_timer_param) {
407 407
 		fr_timer_str.s = fr_timer_param;
408 408
 		fr_timer_str.len = strlen(fr_timer_str.s);
409
+		LM_WARN("using AVP for TM fr_timer is deprecated,"
410
+				" use t_set_fr(...) instead\n");
409 411
 
410 412
 		if(fr_timer_str.s[0]==PV_MARKER) {
411 413
 			if (pv_parse_spec(&fr_timer_str, &avp_spec)==0
... ...
@@ -434,6 +436,8 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
434 436
 	if (fr_inv_timer_param && *fr_inv_timer_param) {
435 437
 		fr_inv_timer_str.s = fr_inv_timer_param;
436 438
 		fr_inv_timer_str.len = strlen(fr_inv_timer_str.s);
439
+		LM_WARN("using AVP for TM fr_inv_timer is deprecated,"
440
+				" use t_set_fr(...) instead\n");
437 441
 
438 442
 		if(fr_inv_timer_str.s[0]==PV_MARKER) {
439 443
 			if (pv_parse_spec(&fr_inv_timer_str, &avp_spec)==0
Browse code

tm: timer avps spec type auto-detected

- detect if is PV spec format or AVP name format
- get rid this way of cfg compat mode

Daniel-Constantin Mierla authored on 19/04/2010 19:13:36
Showing 1 changed files
... ...
@@ -407,7 +407,7 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
407 407
 		fr_timer_str.s = fr_timer_param;
408 408
 		fr_timer_str.len = strlen(fr_timer_str.s);
409 409
 
410
-		if(sr_cfg_compat==SR_COMPAT_KAMAILIO) {
410
+		if(fr_timer_str.s[0]==PV_MARKER) {
411 411
 			if (pv_parse_spec(&fr_timer_str, &avp_spec)==0
412 412
 			        || avp_spec.type!=PVT_AVP) {
413 413
 			        LM_ERR("malformed or non AVP %s AVP definition\n",
... ...
@@ -435,7 +435,7 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
435 435
 		fr_inv_timer_str.s = fr_inv_timer_param;
436 436
 		fr_inv_timer_str.len = strlen(fr_inv_timer_str.s);
437 437
 
438
-		if(sr_cfg_compat==SR_COMPAT_KAMAILIO) {
438
+		if(fr_inv_timer_str.s[0]==PV_MARKER) {
439 439
 			if (pv_parse_spec(&fr_inv_timer_str, &avp_spec)==0
440 440
 					|| avp_spec.type!=PVT_AVP) {
441 441
 				LM_ERR("malformed or non AVP %s AVP definition\n",
... ...
@@ -463,7 +463,7 @@ int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
463 463
 		contacts_avp_str.s = contacts_avp_param;
464 464
 		contacts_avp_str.len = strlen(contacts_avp_str.s);
465 465
 
466
-		if(sr_cfg_compat==SR_COMPAT_KAMAILIO) {
466
+		if(contacts_avp_str.s[0]==PV_MARKER) {
467 467
 			if ((pv_parse_spec(&contacts_avp_str, &avp_spec) == 0) 
468 468
 					|| (avp_spec.type != PVT_AVP)) {
469 469
 				LM_ERR("malformed or non AVP definition <%s>\n",
Browse code

tm: removed commented code

- related to timeout avp and K cfg compat mode

Daniel-Constantin Mierla authored on 17/04/2010 10:41:00
Showing 1 changed files
... ...
@@ -517,16 +517,6 @@ static inline int avp2timer(unsigned int* timer, int type, int_str name)
517 517
 	} else {
518 518
 		*timer = val_istr.n;
519 519
 	}
520
-#if 0
521
-	/* value of AVP is expected to be sec, not milisec lile mod params */
522
-	if(sr_cfg_compat==SR_COMPAT_KAMAILIO) {
523
-		if(*timer>0 && *timer<=120) {
524
-			LM_WARN("too small given timer value: %ums (using T*1000)\n",
525
-					*timer);
526
-			*timer *= 1000;
527
-		}
528
-	}
529
-#endif
530 520
 	return *timer==0; /* 1 if 0 (use default), 0 if !=0 (use *timer) */
531 521
 }
532 522
 
Browse code

tm: don't fix timeout AVP value for K compat mode

- the avps for timeout still expect second values unlike module
parameters that expect miliseconds
- therefore do not adjust the value if it is too low
- reported by Andreas Granig

Daniel-Constantin Mierla authored on 08/04/2010 20:57:48
Showing 1 changed files
... ...
@@ -517,7 +517,8 @@ static inline int avp2timer(unsigned int* timer, int type, int_str name)
517 517
 	} else {
518 518
 		*timer = val_istr.n;
519 519
 	}
520
-
520
+#if 0
521
+	/* value of AVP is expected to be sec, not milisec lile mod params */
521 522
 	if(sr_cfg_compat==SR_COMPAT_KAMAILIO) {
522 523
 		if(*timer>0 && *timer<=120) {
523 524
 			LM_WARN("too small given timer value: %ums (using T*1000)\n",
... ...
@@ -525,6 +526,7 @@ static inline int avp2timer(unsigned int* timer, int type, int_str name)
525 526
 			*timer *= 1000;
526 527
 		}
527 528
 	}
529
+#endif
528 530
 	return *timer==0; /* 1 if 0 (use default), 0 if !=0 (use *timer) */
529 531
 }
530 532
 
Browse code

tm: auto-correct timeout values in K compat mode

- if the value of timer parameters is less than 120 then use T*1000
- SR TM use mili-seconds instead of seconds like in K 1.5
- print warning message if such case happens
(cherry picked from commit 2a34921ba091b10c201f330aa2f7bea336708231)

Daniel-Constantin Mierla authored on 02/11/2009 14:16:16 • Andrei Pelinescu-Onciul committed on 15/01/2010 11:41:43
Showing 1 changed files
... ...
@@ -518,6 +518,13 @@ static inline int avp2timer(unsigned int* timer, int type, int_str name)
518 518
 		*timer = val_istr.n;
519 519
 	}
520 520
 
521
+	if(sr_cfg_compat==SR_COMPAT_KAMAILIO) {
522
+		if(*timer>0 && *timer<=120) {
523
+			LM_WARN("too small given timer value: %ums (using T*1000)\n",
524
+					*timer);
525
+			*timer *= 1000;
526
+		}
527
+	}
521 528
 	return *timer==0; /* 1 if 0 (use default), 0 if !=0 (use *timer) */
522 529
 }
523 530
 
Browse code

tm: avp style for parameters

- when K config compatibility is defined, TM avp parameters use the $avp(name)
format. e.g.:

...
modparam("tm", "fr_timer_avp", "$avp(i:10)")
(cherry picked from commit ed9c6128fdd588f5d9aa19ad666db36cfc0c788d)

Daniel-Constantin Mierla authored on 02/11/2009 13:46:17 • Andrei Pelinescu-Onciul committed on 15/01/2010 11:39:47
Showing 1 changed files
... ...
@@ -63,6 +63,8 @@
63 63
 #include "../../hash_func.h"
64 64
 #include "../../dset.h"
65 65
 #include "../../mem/mem.h"
66
+#include "../../sr_compat.h"
67
+#include "../../pvar.h"
66 68
 #include "defs.h"
67 69
 #include "t_funcs.h"
68 70
 #include "t_fwd.h"
... ...
@@ -399,36 +401,88 @@ done:
399 401
 int init_avp_params(char *fr_timer_param, char *fr_inv_timer_param,
400 402
 					char* contacts_avp_param)
401 403
 {
404
+	pv_spec_t avp_spec;
405
+
402 406
 	if (fr_timer_param && *fr_timer_param) {
403 407
 		fr_timer_str.s = fr_timer_param;
404 408
 		fr_timer_str.len = strlen(fr_timer_str.s);
405
-		if (parse_avp_spec( &fr_timer_str, &fr_timer_avp_type,
406
-		&fr_timer_avp, &fr_timer_index)<0) {
407
-			LOG(L_CRIT,"ERROR:tm:init_avp_params: invalid fr_timer "
408
-				"AVP specs \"%s\"\n", fr_timer_param);
409
-			return -1;
409
+