Browse code

Merge branch '4.2' into lazedo/4.2.1

* 4.2:
core: set log prefix only for sip messages
dialog: reset local variables shortcuts after reply and failure processing
registrar: Fix memory leak around path and outbound header parsing
pv Update error in docs.
evapi Add link to external library. (cherry picked from commit 8370ef43f0fbd2ee447ab65c5b5172677a47f644)
auth_db: added sections ids for functions
acc: fixed computation of extra accounting fields
auth_db: added ids to parameters
tmx: added its for mi functions in doc
tmx: added section ids for functions

Luis Azedo authored on 12/12/2014 11:18:24
Showing 15 changed files
... ...
@@ -396,7 +396,7 @@ void log_prefix_set(sip_msg_t *msg)
396 396
 {
397 397
 	if(log_prefix_pvs == NULL)
398 398
 		return;
399
-	if(msg==NULL) {
399
+	if(msg==NULL || !IS_SIP(msg)) {
400 400
 		log_prefix_val = NULL;
401 401
 		return;
402 402
 	}
... ...
@@ -229,7 +229,7 @@ int acc_log_request( struct sip_msg *rq)
229 229
 	char *p;
230 230
 	int n;
231 231
 	int m;
232
-	int o = 0;
232
+	int o;
233 233
 	int i;
234 234
 	struct tm *t;
235 235
 
... ...
@@ -237,7 +237,7 @@ int acc_log_request( struct sip_msg *rq)
237 237
 	m = core2strar( rq, val_arr, int_arr, type_arr);
238 238
 
239 239
 	/* get extra values */
240
-	o += extra2strar( log_extra, rq, val_arr+m, int_arr+m, type_arr+m);
240
+	o = extra2strar( log_extra, rq, val_arr+m, int_arr+m, type_arr+m);
241 241
 	m += o;
242 242
 
243 243
 	for ( i=0,p=log_msg ; i<m ; i++ ) {
... ...
@@ -476,7 +476,7 @@ int acc_db_request( struct sip_msg *rq)
476 476
 	}
477 477
 
478 478
 	/* extra columns */
479
-	o += extra2strar( db_extra, rq, val_arr+m, int_arr+m, type_arr+m);
479
+	o = extra2strar( db_extra, rq, val_arr+m, int_arr+m, type_arr+m);
480 480
 	m += o;
481 481
 
482 482
 	for( i++ ; i<m; i++)
... ...
@@ -64,7 +64,7 @@
64 64
 
65 65
 	<section>
66 66
 	<title>Parameters</title>
67
-	<section>
67
+	<section id="auth_db.p.db_url">
68 68
 		<title><varname>db_url</varname> (string)</title>
69 69
 		<para>
70 70
 		This is URL of the database to be used. Value of the parameter depends 
... ...
@@ -88,7 +88,7 @@ modparam("auth_db", "db_url", "&exampledb;")
88 88
 		</example>
89 89
 	</section>
90 90
 
91
-	<section>
91
+	<section id="auth_db.p.user_column">
92 92
 		<title><varname>user_column</varname> (string)</title>
93 93
 		<para>
94 94
 		This is the name of the column holding usernames. Default value is 
... ...
@@ -107,7 +107,7 @@ modparam("auth_db", "user_column", "user")
107 107
 		</example>
108 108
 	</section>
109 109
 
110
-	<section>
110
+	<section id="auth_db.p.domain_column">
111 111
 		<title><varname>domain_column</varname> (string)</title>
112 112
 		<para>
113 113
 		This is the name of the column holding domains of users. Default value 
... ...
@@ -127,7 +127,7 @@ modparam("auth_db", "domain_column", "domain")
127 127
 		</example>
128 128
 	</section>
129 129
 
130
-	<section>
130
+	<section id="auth_db.p.password_column">
131 131
 		<title><varname>password_column</varname> (string)</title>
132 132
 		<para>
133 133
 		This is the name of the column holding passwords. Passwords can be 
... ...
@@ -149,7 +149,7 @@ modparam("auth_db", "password_column", "password")
149 149
 		</example>
150 150
 	</section>
151 151
 
152
-	<section>
152
+	<section id="auth_db.p.2password_column_2">
153 153
 		<title><varname>password_column_2</varname> (string)</title>
154 154
 		<para>
155 155
 		As described in the previous section this parameter contains name of 
... ...
@@ -171,7 +171,7 @@ modparam("auth_db", "password_column_2", "ha1_2")
171 171
 		</example>
172 172
 	</section>
173 173
 
174
-	<section>
174
+	<section id="auth_db.p.calculate_ha1">
175 175
 		<title><varname>calculate_ha1</varname> (integer)</title>
176 176
 		<para>
177 177
 		This parameter tells the server whether it should use a pre-calculated
... ...
@@ -216,7 +216,7 @@ modparam("auth_db", "calculate_ha1", 1)
216 216
 		</example>
217 217
 	</section>
218 218
 
219
-	<section>
219
+	<section id="auth_db.p.use_domain">
220 220
 		<title><varname>use_domain</varname> (integer)</title>
221 221
 		<para>
222 222
 		If true (not 0), domain will be also used when looking up in the 
... ...
@@ -242,7 +242,7 @@ modparam("auth_db", "use_domain", 1)
242 242
 		</example>
243 243
 	</section>
244 244
 
245
-	<section>
245
+	<section id="auth_db.p.load_credentials">
246 246
 		<title><varname>load_credentials</varname> (string)</title>
247 247
 		<para>
248 248
 		This parameter specifies of credentials to be fetch from database when
... ...
@@ -281,7 +281,7 @@ modparam("auth_db", "load_credentials", "$avp(i:123)=rpid;email_address")
281 281
 		</example>
282 282
 	</section>
283 283
 
284
-	<section>
284
+	<section id="auth_db.p.version_table">
285 285
 		<title><varname>version_table</varname> (integer)</title>
286 286
 		<para>
287 287
 		If set to 0, the module will skip checking the version
... ...
@@ -304,7 +304,7 @@ modparam("auth_db", "version_table", 0)
304 304
 
305 305
 	<section>
306 306
 	<title>Functions</title>
307
-	<section>
307
+	<section id="auth_db.f.www_authenticate">
308 308
 		<title>
309 309
 			<function moreinfo="none">www_authenticate(realm, table [, method])</function>
310 310
 		</title>
... ...
@@ -395,7 +395,7 @@ if (!www_authorize("kamailio.org", "subscriber")) {
395 395
 		</example>
396 396
 	</section>
397 397
 
398
-	<section>
398
+	<section id="auth_db.f.www_authorize">
399 399
 		<title>
400 400
 			<function moreinfo="none">www_authorize(realm, table)</function>
401 401
 		</title>
... ...
@@ -406,7 +406,7 @@ if (!www_authorize("kamailio.org", "subscriber")) {
406 406
 		</para>
407 407
 	</section>
408 408
 
409
-	<section>
409
+	<section id="auth_db.f.proxy_authenticate">
410 410
 		<title>
411 411
 			<function moreinfo="none">proxy_authenticate(realm, table)</function>
412 412
 		</title>
... ...
@@ -469,7 +469,7 @@ if (!proxy_authorize("$fd", "subscriber)) {
469 469
 		</example>
470 470
 	</section>
471 471
 
472
-	<section>
472
+	<section id="auth_db.f.proxy_authorize">
473 473
 		<title>
474 474
 			<function moreinfo="none">proxy_authorize(realm, table)</function>
475 475
 		</title>
... ...
@@ -480,7 +480,7 @@ if (!proxy_authorize("$fd", "subscriber)) {
480 480
 		</para>
481 481
 	</section>
482 482
 
483
-	<section>
483
+	<section id="auth_db.f.auth_check">
484 484
 		<title>
485 485
 			<function moreinfo="none">auth_check(realm, table, flags)</function>
486 486
 		</title>
... ...
@@ -557,9 +557,8 @@ if (!auth_check("$fd", "subscriber", "1")) {
557 557
 		</example>
558 558
 	</section>
559 559
 
560
-
561 560
 	<section>
562
-		<title>
561
+		<title id="auth_db.f.is_subscriber">
563 562
 			<function moreinfo="none">is_subscriber(uri, dbtable, flags)</function>
564 563
 		</title>
565 564
 		<para>The function checks if there is a subscriber corresponding to
... ...
@@ -626,6 +626,16 @@ static int mod_init(void)
626 626
 		return -1;
627 627
 	}
628 628
 
629
+	if (register_script_cb( cb_dlg_locals_reset, POST_SCRIPT_CB|ONREPLY_CB_TYPE,0)<0) {
630
+		LM_ERR("cannot register reply post-script dlg locals reset callback\n");
631
+		return -1;
632
+	}
633
+
634
+	if (register_script_cb( cb_dlg_locals_reset, POST_SCRIPT_CB|FAILURE_CB_TYPE,0)<0) {
635
+		LM_ERR("cannot register failure post-script dlg locals reset callback\n");
636
+		return -1;
637
+	}
638
+
629 639
 	if(dlg_timer_procs<=0) {
630 640
 		if ( register_timer( dlg_timer_routine, 0, 1)<0 ) {
631 641
 			LM_ERR("failed to register timer \n");
... ...
@@ -409,6 +409,27 @@ int remove_profile(dlg_profile_table_t *profile, str *value, str *puid)
409 409
 
410 410
 
411 411
 /*!
412
+ * \brief Callback for cleanup of profile local vars
413
+ * \param msg SIP message
414
+ * \param flags unused
415
+ * \param param unused
416
+ * \return 1
417
+ */
418
+int cb_profile_reset( struct sip_msg *msg, unsigned int flags, void *param )
419
+{
420
+	current_dlg_msg_id = 0;
421
+	current_dlg_msg_pid = 0;
422
+	if (current_pending_linkers) {
423
+		destroy_linkers(current_pending_linkers);
424
+		current_pending_linkers = NULL;
425
+	}
426
+
427
+	/* need to return non-zero - 0 will break the exec of the request */
428
+	return 1;
429
+}
430
+
431
+
432
+/*!
412 433
  * \brief Cleanup a profile
413 434
  * \param msg SIP message
414 435
  * \param flags unused
... ...
@@ -116,6 +116,16 @@ struct dlg_profile_table* search_dlg_profile(str *name);
116 116
 
117 117
 
118 118
 /*!
119
+ * \brief Callback for cleanup of profile local vars
120
+ * \param msg SIP message
121
+ * \param flags unused
122
+ * \param param unused
123
+ * \return 1
124
+ */
125
+int cb_profile_reset( struct sip_msg *msg, unsigned int flags, void *param );
126
+
127
+
128
+/*!
119 129
  * \brief Cleanup a profile
120 130
  * \param msg SIP message
121 131
  * \param flags unused
... ...
@@ -69,6 +69,21 @@ int dlg_cfg_cb(sip_msg_t *msg, unsigned int flags, void *cbp)
69 69
 	return 1;
70 70
 }
71 71
 
72
+int cb_dlg_cfg_reset(sip_msg_t *msg, unsigned int flags, void *cbp)
73
+{
74
+	memset(&_dlg_ctx, 0, sizeof(dlg_ctx_t));
75
+
76
+	return 1;
77
+}
78
+
79
+int cb_dlg_locals_reset(sip_msg_t *msg, unsigned int flags, void *cbp)
80
+{
81
+	LM_DBG("resetting the local dialog shortcuts\n");
82
+	cb_dlg_cfg_reset(msg, flags, cbp);
83
+	cb_profile_reset(msg, flags, cbp);
84
+
85
+	return 1;
86
+}
72 87
 
73 88
 static inline struct dlg_var *new_dlg_var(str *key, str *val)
74 89
 {
... ...
@@ -82,6 +82,8 @@ int pv_get_dlg(sip_msg_t *msg,  pv_param_t *param,
82 82
 int pv_parse_dlg_name(pv_spec_p sp, str *in);
83 83
 
84 84
 int dlg_cfg_cb(sip_msg_t *foo, unsigned int flags, void *bar);
85
+int cb_dlg_cfg_reset(sip_msg_t *msg, unsigned int flags, void *cbp);
86
+int cb_dlg_locals_reset(sip_msg_t *msg, unsigned int flags, void *cbp);
85 87
 
86 88
 void dlg_set_ctx_iuid(dlg_cell_t *dlg);
87 89
 void dlg_reset_ctx_iuid(void);
... ...
@@ -109,7 +109,7 @@ Chapter 1. Admin Guide
109 109
 
110 110
    The following libraries or applications must be installed before
111 111
    running Kamailio with this module loaded:
112
-     * libev
112
+     * libev - http://software.schmorp.de/pkg/libev
113 113
 
114 114
 3. Parameters
115 115
 
... ...
@@ -54,7 +54,7 @@
54 54
 			<itemizedlist>
55 55
 			<listitem>
56 56
 			<para>
57
-				<emphasis>libev</emphasis>
57
+				<emphasis>libev</emphasis> - <ulink url="http://software.schmorp.de/pkg/libev">http://software.schmorp.de/pkg/libev</ulink>
58 58
 			</para>
59 59
 			</listitem>
60 60
 			</itemizedlist>
... ...
@@ -199,7 +199,7 @@ modparam("pv","avp_aliases","email=s:email_addr;tmp=i:100")
199 199
 
200 200
    Example 1.4. pv_isset usage
201 201
 ...
202
-if(pv_isset("$avp("s:x")"))
202
+if(pv_isset("$avp(s:x)"))
203 203
 {
204 204
     ...
205 205
 }
... ...
@@ -216,7 +216,7 @@ if(pv_isset("$avp("s:x")"))
216 216
 
217 217
    Example 1.5. pv_unset usage
218 218
 ...
219
-pv_unset("$avp("s:x")");
219
+pv_unset("$avp(s:x)");
220 220
 ...
221 221
 
222 222
 4.3. is_int(pvar)
... ...
@@ -166,7 +166,7 @@ modparam("pv","avp_aliases","email=s:email_addr;tmp=i:100")
166 166
 		<title><function>pv_isset</function> usage</title>
167 167
 		<programlisting format="linespecific">
168 168
 ...
169
-if(pv_isset("$avp("s:x")"))
169
+if(pv_isset("$avp(s:x)"))
170 170
 {
171 171
     ...
172 172
 }
... ...
@@ -194,7 +194,7 @@ if(pv_isset("$avp("s:x")"))
194 194
 		<title><function>pv_unset</function> usage</title>
195 195
 		<programlisting format="linespecific">
196 196
 ...
197
-pv_unset("$avp("s:x")");
197
+pv_unset("$avp(s:x)");
198 198
 ...
199 199
 </programlisting>
200 200
 		</example>
... ...
@@ -96,6 +96,8 @@ int build_path_vector(struct sip_msg *_m, str *path, str *received)
96 96
 				LM_ERR("failed to parse parameters of first hop\n");
97 97
 				goto error;
98 98
 			}
99
+			/* Not interested in param body - just the hooks */
100
+			free_params(params);
99 101
 
100 102
 			if (hooks.contact.received) {
101 103
 			        uri_str.s = uri_buf;
... ...
@@ -107,14 +109,6 @@ int build_path_vector(struct sip_msg *_m, str *path, str *received)
107 107
 				*received = uri_str;
108 108
 				LM_DBG("received is <%.*s>\n", received->len, received->s);
109 109
 			}
110
-				
111
-			/*for (;params; params = params->next) {
112
-				if (params->type == P_RECEIVED) {
113
-					*received = hooks.contact.received->body;
114
-					break;
115
-				}
116
-			}*/
117
-			free_params(params);
118 110
 		}
119 111
 		free_rr(&route);
120 112
 	}
... ...
@@ -923,17 +923,21 @@ int save(struct sip_msg* _m, udomain_t* _d, int _cflags, str *_uri)
923 923
 			}
924 924
 			if (parse_uri(route->nameaddr.uri.s, route->nameaddr.uri.len, &puri) < 0) {
925 925
 				LM_ERR("Failed to parse Path: URI\n");
926
+				free_rr(&route);
926 927
 				goto error;
927 928
 			}
928 929
 			if (parse_params(&puri.params, CLASS_URI, &hooks, &params) != 0) {
929 930
 				LM_ERR("Failed to parse Path: URI parameters\n");
931
+				free_rr(&route);
930 932
 				goto error;
931 933
 			}
934
+			/* Not interested in param body - just the hooks */
935
+			free_params(params);
932 936
 			if (!hooks.uri.ob) {
933 937
 				/* No ;ob parameter to top Path: URI - no outbound */
934 938
 				use_ob = 0;
935 939
 			}
936
-
940
+			free_rr(&route);
937 941
 		} else {
938 942
 			/* No Path: header - no outbound */
939 943
 			use_ob = 0;
... ...
@@ -83,7 +83,7 @@ modparam("tmx", "precheck_trans", 0)
83 83
 
84 84
 	<section>
85 85
 	<title>Functions</title>
86
-	<section>
86
+	<section id="tmx.f.t_cancel_branches">
87 87
 		<title>
88 88
 		<function moreinfo="none">t_cancel_branches(which)</function>
89 89
 		</title>
... ...
@@ -120,7 +120,7 @@ if (t_cancel_branches("all")) {
120 120
 </programlisting>
121 121
 		</example>
122 122
 	</section>
123
-	<section>
123
+	<section id="tmx.f.t_cancel_callid">
124 124
 		<title>
125 125
 			<function moreinfo="none">t_cancel_callid(callid, cseq, flag [, rcode])
126 126
 			</function>
... ...
@@ -166,7 +166,7 @@ if (t_cancel_callid("123qaz", "5", "22", "200")) {
166 166
 </programlisting>
167 167
 		</example>
168 168
 	</section>
169
-	<section>
169
+	<section id="tmx.f.t_reply_callid">
170 170
 		<title>
171 171
 			<function moreinfo="none">t_reply_callid(callid, cseq, code, reason)
172 172
 			</function>
... ...
@@ -205,7 +205,7 @@ if (t_reply_callid("123qaz", "5", "458", "Replied remotely")) {
205 205
 </programlisting>
206 206
 		</example>
207 207
 	</section>
208
-	<section>
208
+	<section id="tmx.f.t_flush_flags">
209 209
 		<title>
210 210
 		<function moreinfo="none">t_flush_flags()</function>
211 211
 		</title>
... ...
@@ -226,7 +226,7 @@ t_flush_flags();
226 226
 </programlisting>
227 227
 		</example>
228 228
 	</section>
229
-	<section>
229
+	<section id="tmx.f.t_is_failure_route">
230 230
 		<title>
231 231
 		<function moreinfo="none">t_is_failure_route()</function>
232 232
 		</title>
... ...
@@ -251,7 +251,7 @@ route[abc] {
251 251
 </programlisting>
252 252
 		</example>
253 253
 	</section>
254
-	<section>
254
+	<section id="tmx.f.t_is_branch_route">
255 255
 		<title>
256 256
 		<function moreinfo="none">t_is_branch_route()</function>
257 257
 		</title>
... ...
@@ -276,7 +276,7 @@ route[abc] {
276 276
 </programlisting>
277 277
 		</example>
278 278
 	</section>
279
-	<section>
279
+	<section id="tmx.f.t_is_reply_route">
280 280
 		<title>
281 281
 		<function moreinfo="none">t_is_reply_route()</function>
282 282
 		</title>
... ...
@@ -301,7 +301,7 @@ route[abc] {
301 301
 </programlisting>
302 302
 		</example>
303 303
 	</section>
304
-	<section>
304
+	<section id="tmx.f.t_suspend">
305 305
 		<title>
306 306
 		<function moreinfo="none">t_suspend()</function>
307 307
 		</title>
... ...
@@ -327,7 +327,7 @@ if(t_suspend())
327 327
 </programlisting>
328 328
 		</example>
329 329
 	</section>
330
-	<section>
330
+	<section id="tmx.f.t_continue">
331 331
 		<title>
332 332
 			<function moreinfo="none">t_continue(tindex, tlabel, rtname)
333 333
 			</function>
... ...
@@ -367,7 +367,7 @@ t_continue('123', '456', 'MYROUTE');
367 367
 		</example>
368 368
 	</section>
369 369
 
370
-	<section>
370
+	<section id="tmx.f.t_reuse_branch">
371 371
 		<title>
372 372
 		<function moreinfo="none">t_reuse_branch()</function>
373 373
 		</title>
... ...
@@ -465,7 +465,7 @@ event_route [tm:branch-failure:contact] {
465 465
 	<section>
466 466
 	<title>MI Commands</title>
467 467
 
468
-	<section>
468
+	<section id="tmx.mi.t_uac_dlg">
469 469
 		<title>
470 470
 		<function moreinfo="none">t_uac_dlg</function>
471 471
 		</title>
... ...
@@ -503,7 +503,7 @@ event_route [tm:branch-failure:contact] {
503 503
 		</itemizedlist>
504 504
 	</section>
505 505
 
506
-	<section>
506
+	<section id="tmx.mi.t_uac_cancel">
507 507
 		<title>
508 508
 		<function moreinfo="none">t_uac_cancel</function>
509 509
 		</title>
... ...
@@ -523,7 +523,7 @@ event_route [tm:branch-failure:contact] {
523 523
 		</itemizedlist>
524 524
 	</section>
525 525
 
526
-	<section>
526
+	<section id="tmx.mi.t_hash">
527 527
 		<title>
528 528
 		<function moreinfo="none">t_hash</function>
529 529
 		</title>
... ...
@@ -538,7 +538,7 @@ event_route [tm:branch-failure:contact] {
538 538
 		</itemizedlist>
539 539
 	</section>
540 540
 
541
-	<section>
541
+	<section id="tmx.mi.t_reply">
542 542
 		<title>
543 543
 		<function moreinfo="none">t_reply</function>
544 544
 		</title>
... ...
@@ -573,7 +573,7 @@ event_route [tm:branch-failure:contact] {
573 573
 			</para></listitem>
574 574
 		</itemizedlist>
575 575
 	</section>
576
-	<section>
576
+	<section id="tmx.mi.t_reply_callid">
577 577
 		<title>
578 578
 		<function moreinfo="none">t_reply_callid</function>
579 579
 		</title>