Browse code

Merge remote branch 'origin/sr_3.0'

latest sr_3.0 fixes, after kamailio 3.0 release.

* origin/sr_3.0: (58 commits)
Backport of the changes (see previous commits).
kex: documented missing functions
kex: aliased avp_printf to pv_printf
auth_diameter(k): remove redundant declaration of find_credentials, now in core
- fix bug in encode_contact()
- fix bug when RURI was changed before and newuri will be used
- remove unused code
modules_k/nathelper: removed garbage from documentation (credits to Klaus)
modules_k/nathelper: improved handle_ruri_alias() documentation
modules/lcr and modules_k/nathelper: fixed compiler warnings
modules_k/nathelper: handle_uri_alias() alias handling fix
modules_k/usrloc: changed 'Kamailio' to 'SIP Router' in user agent string.
tm: safer handling for local transactions and drop_replies!=0
sctp: stats: don't increment ASSOC_SHUTDOWN on COMM_LOST
sctp: SCTP_STATS_ASSOC_SHUTDOWN
tm doc: local_ack_mode documentation
tm: new param: local_ack_mode
makefile: fix make bin & basedir
core: fix parsing for avps with the same name as a pv class
tls: name the certificates based on $MAIN_NAME
...

Conflicts:
modules/tm/README
modules_k/nathelper/rtpproxy_stream.c
pkg/debian/rules

Andrei Pelinescu-Onciul authored on 13/01/2010 16:20:23
Showing 160 changed files
... ...
@@ -156,7 +156,7 @@ module_group_standard_dep=acc_db acc_radius auth_db auth_radius avp_db \
156 156
 				presence_b2b rls speeddial uri_db xcap xmlrpc
157 157
 
158 158
 # For db use (db modules, excluding drivers)
159
-module_group_db=acc_db auth_db avp_db db_ops db_flatstore db_text \
159
+module_group_db=acc_db auth_db avp_db db_ops db_text \
160 160
 				uri_db domain lcr msilo speeddial
161 161
 				#dbtext (s) not migrated yet to the new db interface
162 162
 
... ...
@@ -172,7 +172,14 @@ module_group_postgres=$(module_group_postgres_driver) $(module_group_db)
172 172
 module_group_radius=acc_radius auth_radius misc_radius peering
173 173
 
174 174
 # For presence
175
-module_group_presence=dialog pa presence_b2b rls xcap
175
+# kamailio modules
176
+module_group_presence=presence presence_dialoginfo presence_mwi presence_xml \
177
+						pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp \
178
+						rls xcap_client
179
+#ser modules
180
+module_group_presence+=dialog presence_b2b xcap
181
+# obsolete/unmaintained ser modules
182
+#module_group_presence=pa rls
176 183
 
177 184
 # Modules in this group satisfy specific or niche applications, but are 
178 185
 # considered stable for production use. They may or may not have dependencies
... ...
@@ -198,13 +205,13 @@ else
198 198
 	# excluded because they depend on external libraries
199 199
 	exclude_modules?= 		cpl mangler postgres jabber mysql cpl-c \
200 200
 							auth_radius misc_radius \
201
-							acc_radius dialog pa rls presence_b2b xcap xmlrpc\
201
+							acc_radius pa rls presence_b2b xcap xmlrpc\
202 202
 							osp tls oracle \
203 203
 							unixsock dbg print_lib auth_identity ldap \
204 204
 							db_berkeley db_mysql db_postgres db_oracle \
205 205
 							db_unixodbc memcached mi_xmlrpc \
206
-							nat_traversal perl perlvdb purple seas siptrace \
207
-							snmpstats uac_redirect xmpp \
206
+							perl perlvdb purple seas \
207
+							snmpstats xmpp \
208 208
 							carrierroute misc_radius peering \
209 209
 							dialplan lcr utils presence \
210 210
 							presence_dialoginfo presence_xml pua pua_bla \
... ...
@@ -250,6 +257,7 @@ ifeq ($(makefile_defs),1)
250 250
 ifeq ($(quiet),verbose)
251 251
 $(info config.mak loaded)
252 252
 endif # verbose
253
+export makefile_defs
253 254
 # config_make valid & used
254 255
 config_mak=1
255 256
 ifeq ($(MAIN_NAME),)
... ...
@@ -271,6 +279,7 @@ else
271 271
 # config.mak not strictly needed, but try to load it if exists for $(Q)
272 272
 config_mak=skip
273 273
 -include config.mak
274
+export makefile_defs
274 275
 endif
275 276
 endif
276 277
 
... ...
@@ -419,6 +428,15 @@ ifeq ($(config_mak),1)
419 419
 
420 420
 include Makefile.cfg
421 421
 
422
+# fix basedir path (relative -> absolute)
423
+ifneq (,$(basedir))
424
+ifeq (,$(filter /%, $(basedir)))
425
+override basedir:=$(CURDIR)/$(basedir)
426
+# remove basedir from command line overrides
427
+MAKEOVERRIDES:=$(filter-out basedir=%,$ $(MAKEOVERRIDES))
428
+endif # (,$(filter /%, $(basedir)))
429
+endif # (,$(basedir))
430
+
422 431
 else ifneq ($(config_mak),skip)
423 432
 
424 433
 config.mak: Makefile.defs
... ...
@@ -711,7 +729,7 @@ tar: $(auto_gen_keep)
711 711
 .PHONY: bin
712 712
 bin:
713 713
 	mkdir -p tmp/$(MAIN_NAME)/usr/local
714
-	$(MAKE) install basedir=tmp/$(MAIN_NAME) $(mk_params)
714
+	$(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) $(mk_params)
715 715
 	$(TAR) -C tmp/$(MAIN_NAME)/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
716 716
 	rm -rf tmp/$(MAIN_NAME)
717 717
 
... ...
@@ -729,7 +747,8 @@ deb:
729 729
 sunpkg:
730 730
 	mkdir -p tmp/$(MAIN_NAME)
731 731
 	mkdir -p tmp/$(MAIN_NAME)_sun_pkg
732
-	$(MAKE) install basedir=tmp/$(MAIN_NAME) prefix=/usr/local $(mk_params)
732
+	$(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) \
733
+			prefix=/usr/local $(mk_params)
733 734
 	(cd pkg/solaris; \
734 735
 	pkgmk -r ../../tmp/$(MAIN_NAME)/usr/local -o -d ../../tmp/$(MAIN_NAME)_sun_pkg/ -v "$(RELEASE)" ;\
735 736
 	cd ../..)
... ...
@@ -953,6 +972,28 @@ clean-libs:
953 953
 proper-libs realclean-libs distclean-libs maintainer-clean-libs:
954 954
 			$(MAKE) -C lib $(patsubst %-libs,%,$@)
955 955
 
956
+# utils cleaning targets
957
+
958
+.PHONY: clean-utils
959
+clean-utils:
960
+	@for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
961
+		if [ -d "$$r" ]; then \
962
+			 $(MAKE) -C "$$r" clean ; \
963
+		fi ; \
964
+	done
965
+
966
+.PHONY: proper-utils
967
+.PHONY: distclean-utils
968
+.PHONY: realclean-utils
969
+.PHONY: maintainer-clean-utils
970
+proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
971
+ clean_target=$(patsubst %-utils,%,$@)
972
+proper-utils realclean-utils distclean-utils maintainer-clean-utils:
973
+	@for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
974
+		if [ -d "$$r" ]; then \
975
+			 $(MAKE) -C "$$r" $(clean_target); \
976
+		fi ; \
977
+	done
956 978
 
957 979
 # clean extra binary names (common "flavour" names)
958 980
 clean: clean-extra-names
... ...
@@ -671,7 +671,8 @@ ifeq ($(CC_NAME), gcc)
671 671
 						fi)
672 672
 		ASPATH:=$(shell  if [ -z "$(ASGCC)" ] ; then echo "as" ;\
673 673
 						else \
674
-						if $(ASGCC) -V 2>/dev/null 1>/dev/null; then \
674
+						if $(ASGCC) -V 2>/dev/null 1>/dev/null </dev/null; \
675
+						then \
675 676
 							echo $(ASGCC); \
676 677
 						else echo "as" ; \
677 678
 						fi\
... ...
@@ -139,14 +139,45 @@ install-libs:
139 139
 
140 140
 endif # $(SER_LIBS)
141 141
 
142
+.PHONY: utils
143
+.PHONY: clean-utils
144
+.PHONY: proper-utils
145
+.PHONY: distclean-utils
146
+.PHONY: realclean-utils
147
+.PHONY: maintainer-clean-utils
142 148
 ifneq (,$(MOD_INSTALL_UTILS))
143 149
 install-utils:
144 150
 	@for ut in $(MOD_INSTALL_UTILS) ; do \
145 151
 		$(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
146 152
 	done; true
147 153
 
154
+utils:
155
+	@for r in $(MOD_INSTALL_UTILS) ; do \
156
+		$(call try_err, $(MAKE) -C "$$r" ) ;\
157
+	done; true
158
+
159
+clean-utils:
160
+	@for r in $(MOD_INSTALL_UTILS) ; do \
161
+		if [ -d "$$r" ]; then \
162
+			 $(MAKE) -C "$$r" clean ; \
163
+		fi ; \
164
+	done
165
+
166
+proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
167
+ clean_target=$(patsubst %-utils,%,$@)
168
+proper-utils realclean-utils distclean-utils maintainer-clean-utils:
169
+	@for r in $(MOD_INSTALL_UTILS) ; do \
170
+		if [ -d "$$r" ]; then \
171
+			 $(MAKE) -C "$$r" $(clean_target); \
172
+		fi ; \
173
+	done
174
+
148 175
 else
176
+# ! MOD_INSTALL_UTILS
149 177
 install-utils:
178
+utils:
179
+clean-utils:
180
+proper-utils realclean-utils distclean-utils maintainer-clean-utils:
150 181
 
151 182
 endif # $(MOD_INSTALL_UTILS)
152 183
 
... ...
@@ -218,16 +218,6 @@ clean-modules:
218 218
 		fi ; \
219 219
 	done
220 220
 
221
-.PHONY: clean-utils
222
-clean-utils:
223
-	@if [ -n "$(cmodules)" ]; then \
224
-		for r in $(utils_compile) "" ; do \
225
-			if [ -d "$$r" ]; then \
226
-				 $(MAKE) -C "$$r" clean ; \
227
-			fi ; \
228
-		done \
229
-	fi
230
-
231 221
 # make proper for the local directory
232 222
 .PHONY: proper
233 223
 .PHONY: distclean
... ...
@@ -253,21 +243,6 @@ proper-modules realclean-modules distclean-modules maintainer-clean-modules:
253 253
 		fi ; \
254 254
 	done
255 255
 
256
-.PHONY: proper-utils
257
-.PHONY: distclean-utils
258
-.PHONY: realclean-utils
259
-.PHONY: maintainer-clean-utils
260
-proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
261
- clean_target=$(patsubst %-utils,%,$@)
262
-proper-utils realclean-utils distclean-utils maintainer-clean-utils:
263
-	@if [ -n "$(cmodules)" ]; then \
264
-		for r in $(utils_compile) "" ; do \
265
-			if [ -d "$$r" ]; then \
266
-				 $(MAKE) -C "$$r" $(clean_target); \
267
-			fi ; \
268
-		done \
269
-	fi
270
-
271 256
 .PHONY: clean-tmp
272 257
 clean-tmp:
273 258
 	-@rm -f TAGS tags *.dbg .*.swp
... ...
@@ -540,7 +540,7 @@ extern char *finame;
540 540
 %left GT LT GTE LTE
541 541
 %left PLUS MINUS
542 542
 %left STAR SLASH MODULO
543
-%right NOT
543
+%right NOT UNARY
544 544
 %right DEFINED
545 545
 %right INTCAST STRCAST
546 546
 %left DOT
... ...
@@ -730,7 +730,7 @@ id_lst:
730 730
 	;
731 731
 
732 732
 intno: NUMBER
733
-	|  MINUS %prec NOT NUMBER { $$=-$2; }
733
+	|  MINUS NUMBER %prec UNARY { $$=-$2; }
734 734
 	;
735 735
 
736 736
 flags_decl:		FLAGS_DECL	flag_list
... ...
@@ -1840,41 +1840,41 @@ eip_op:		SRCIP		{ $$=SRCIP_O; }
1840 1840
 
1841 1841
 
1842 1842
 exp_elem:
1843
-	METHOD strop %prec EQUAL_T rval_expr
1843
+	METHOD strop rval_expr %prec EQUAL_T
1844 1844
 		{$$= mk_elem($2, METHOD_O, 0, RVE_ST, $3);}
1845
-	| METHOD strop %prec EQUAL_T ID
1845
+	| METHOD strop ID %prec EQUAL_T
1846 1846
 		{$$ = mk_elem($2, METHOD_O, 0, STRING_ST,$3); }
1847 1847
 	| METHOD strop error { $$=0; yyerror("string expected"); }
1848 1848
 	| METHOD error	
1849 1849
 		{ $$=0; yyerror("invalid operator,== , !=, or =~ expected"); }
1850
-	| uri_type strop %prec EQUAL_T rval_expr
1850
+	| uri_type strop rval_expr %prec EQUAL_T
1851 1851
 		{$$ = mk_elem($2, $1, 0, RVE_ST, $3); }
1852
-	| uri_type strop %prec EQUAL_T MYSELF
1852
+	| uri_type strop MYSELF %prec EQUAL_T
1853 1853
 		{$$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
1854
-	| uri_type strop %prec EQUAL_T error
1854
+	| uri_type strop error %prec EQUAL_T
1855 1855
 		{ $$=0; yyerror("string or MYSELF expected"); }
1856 1856
 	| uri_type error
1857 1857
 		{ $$=0; yyerror("invalid operator, == , != or =~ expected"); }
1858
-	| eint_op cmpop %prec GT rval_expr { $$=mk_elem($2, $1, 0, RVE_ST, $3 ); }
1859
-	| eint_op equalop %prec EQUAL_T rval_expr 
1858
+	| eint_op cmpop rval_expr %prec GT { $$=mk_elem($2, $1, 0, RVE_ST, $3 ); }
1859
+	| eint_op equalop rval_expr %prec EQUAL_T
1860 1860
 		{ $$=mk_elem($2, $1, 0, RVE_ST, $3 ); }
1861 1861
 	| eint_op cmpop error   { $$=0; yyerror("number expected"); }
1862 1862
 	| eint_op equalop error { $$=0; yyerror("number expected"); }
1863 1863
 	| eint_op error { $$=0; yyerror("==, !=, <,>, >= or <=  expected"); }
1864
-	| PROTO equalop %prec EQUAL_T proto
1864
+	| PROTO equalop proto %prec EQUAL_T
1865 1865
 		{ $$=mk_elem($2, PROTO_O, 0, NUMBER_ST, (void*)$3 ); }
1866
-	| PROTO equalop %prec EQUAL_T rval_expr
1866
+	| PROTO equalop rval_expr %prec EQUAL_T
1867 1867
 		{ $$=mk_elem($2, PROTO_O, 0, RVE_ST, $3 ); }
1868 1868
 	| PROTO equalop error
1869 1869
 		{ $$=0; yyerror("protocol expected (udp, tcp, tls or sctp)"); }
1870
-	| SNDPROTO equalop %prec EQUAL_T proto
1870
+	| SNDPROTO equalop proto %prec EQUAL_T
1871 1871
 		{ $$=mk_elem($2, SNDPROTO_O, 0, NUMBER_ST, (void*)$3 ); }
1872
-	| SNDPROTO equalop %prec EQUAL_T rval_expr
1872
+	| SNDPROTO equalop rval_expr %prec EQUAL_T
1873 1873
 		{ $$=mk_elem($2, SNDPROTO_O, 0, RVE_ST, $3 ); }
1874 1874
 	| SNDPROTO equalop error
1875 1875
 		{ $$=0; yyerror("protocol expected (udp, tcp, tls or sctp)"); }
1876
-	| eip_op strop %prec EQUAL_T ipnet { $$=mk_elem($2, $1, 0, NET_ST, $3); }
1877
-	| eip_op strop %prec EQUAL_T rval_expr {
1876
+	| eip_op strop ipnet %prec EQUAL_T { $$=mk_elem($2, $1, 0, NET_ST, $3); }
1877
+	| eip_op strop rval_expr %prec EQUAL_T {
1878 1878
 			s_tmp.s=0;
1879 1879
 			$$=0;
1880 1880
 			if (rve_is_constant($3)){
... ...
@@ -1912,29 +1912,29 @@ exp_elem:
1912 1912
 				$$=mk_elem($2, $1, 0, RVE_ST, $3);
1913 1913
 			}
1914 1914
 		}
1915
-	| eip_op strop %prec EQUAL_T host
1915
+	| eip_op strop host %prec EQUAL_T
1916 1916
 		{ $$=mk_elem($2, $1, 0, STRING_ST, $3); }
1917
-	| eip_op strop %prec EQUAL_T MYSELF
1917
+	| eip_op strop MYSELF %prec EQUAL_T
1918 1918
 		{ $$=mk_elem($2, $1, 0, MYSELF_ST, 0); }
1919
-	| eip_op strop %prec EQUAL_T error
1919
+	| eip_op strop error %prec EQUAL_T
1920 1920
 		{ $$=0; yyerror( "ip address or hostname expected" ); }
1921 1921
 	| eip_op error
1922 1922
 		{ $$=0; yyerror("invalid operator, ==, != or =~ expected");}
1923 1923
 	
1924
-	| MYSELF equalop %prec EQUAL_T uri_type
1924
+	| MYSELF equalop uri_type %prec EQUAL_T
1925 1925
 		{ $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
1926
-	| MYSELF equalop %prec EQUAL_T eip_op
1926
+	| MYSELF equalop eip_op %prec EQUAL_T
1927 1927
 		{ $$=mk_elem($2, $3, 0, MYSELF_ST, 0); }
1928
-	| MYSELF equalop %prec EQUAL_T error
1928
+	| MYSELF equalop error %prec EQUAL_T
1929 1929
 		{ $$=0; yyerror(" URI, SRCIP or DSTIP expected"); }
1930 1930
 	| MYSELF error	{ $$=0; yyerror ("invalid operator, == or != expected"); }
1931 1931
 	;
1932 1932
 /*
1933 1933
 exp_elem2:
1934
-	rval_expr cmpop %prec GT rval_expr
1934
+	rval_expr cmpop rval_expr %prec GT
1935 1935
 		{ $$=mk_elem( $2, RVE_ST, $1, RVE_ST, $3);}
1936 1936
 	|
1937
-	rval_expr equalop %prec EQUAL_T rval_expr
1937
+	rval_expr equalop rval_expr %prec EQUAL_T
1938 1938
 		{ $$=mk_elem( $2, RVE_ST, $1, RVE_ST, $3);}
1939 1939
 	| rval_expr LOG_AND rval_expr
1940 1940
 		{ $$=mk_exp_rve(LOGAND_OP, $1, $3);}
... ...
@@ -2435,6 +2435,10 @@ avp_pvar:	AVP_OR_PVAR {
2435 2435
 				s_tmp.s=$1; s_tmp.len=strlen(s_tmp.s);
2436 2436
 				if (pv_parse_spec2(&s_tmp, &lval_tmp->lv.pvs, 1)==0){
2437 2437
 					/* not a pvar, try avps */
2438
+					/* lval_tmp might be partially filled by the failed
2439
+					   pv_parse_spec2() (especially if the avp name is the
2440
+					   same as a pv class) => clean it again */
2441
+					memset(lval_tmp, 0, sizeof(*lval_tmp));
2438 2442
 					lval_tmp->lv.avps.type|= AVP_NAME_STR;
2439 2443
 					lval_tmp->lv.avps.name.s.s = s_tmp.s+1;
2440 2444
 					lval_tmp->lv.avps.name.s.len = s_tmp.len-1;
... ...
@@ -2527,7 +2531,7 @@ rval: intno			{$$=mk_rve_rval(RV_INT, (void*)$1); }
2527 2527
 
2528 2528
 
2529 2529
 rve_un_op: NOT	{ $$=RVE_LNOT_OP; }
2530
-		|  MINUS %prec NOT	{ $$=RVE_UMINUS_OP; } 
2530
+		|  MINUS %prec UNARY	{ $$=RVE_UMINUS_OP; } 
2531 2531
 		/* TODO: RVE_BOOL_OP, RVE_NOT_OP? */
2532 2532
 	;
2533 2533
 
... ...
@@ -2546,7 +2550,7 @@ rval_expr: rval						{ $$=$1;
2546 2546
 											YYERROR;
2547 2547
 										}
2548 2548
 									}
2549
-		| rve_un_op %prec NOT rval_expr	{$$=mk_rve1($1, $2); }
2549
+		| rve_un_op rval_expr %prec UNARY	{$$=mk_rve1($1, $2); }
2550 2550
 		| INTCAST rval_expr				{$$=mk_rve1(RVE_INT_OP, $2); }
2551 2551
 		| STRCAST rval_expr				{$$=mk_rve1(RVE_STR_OP, $2); }
2552 2552
 		| rval_expr PLUS rval_expr		{$$=mk_rve2(RVE_PLUS_OP, $1, $3); }
... ...
@@ -2556,8 +2560,8 @@ rval_expr: rval						{ $$=$1;
2556 2556
 		| rval_expr MODULO rval_expr	{$$=mk_rve2(RVE_MOD_OP, $1, $3); }
2557 2557
 		| rval_expr BIN_OR rval_expr	{$$=mk_rve2(RVE_BOR_OP, $1,  $3); }
2558 2558
 		| rval_expr BIN_AND rval_expr	{$$=mk_rve2(RVE_BAND_OP, $1,  $3);}
2559
-		| rval_expr rve_cmpop %prec GT rval_expr { $$=mk_rve2( $2, $1, $3);}
2560
-		| rval_expr rve_equalop %prec EQUAL_T rval_expr
2559
+		| rval_expr rve_cmpop rval_expr %prec GT { $$=mk_rve2( $2, $1, $3);}
2560
+		| rval_expr rve_equalop rval_expr %prec EQUAL_T
2561 2561
 			{ $$=mk_rve2( $2, $1, $3);}
2562 2562
 		| rval_expr LOG_AND rval_expr	{ $$=mk_rve2(RVE_LAND_OP, $1, $3);}
2563 2563
 		| rval_expr LOG_OR rval_expr	{ $$=mk_rve2(RVE_LOR_OP, $1, $3);}
... ...
@@ -2565,7 +2569,7 @@ rval_expr: rval						{ $$=$1;
2565 2565
 		| STRLEN LPAREN rval_expr RPAREN { $$=mk_rve1(RVE_STRLEN_OP, $3);}
2566 2566
 		| STREMPTY LPAREN rval_expr RPAREN {$$=mk_rve1(RVE_STREMPTY_OP, $3);}
2567 2567
 		| DEFINED rval_expr				{ $$=mk_rve1(RVE_DEFINED_OP, $2);}
2568
-		| rve_un_op %prec NOT error		{ $$=0; yyerror("bad expression"); }
2568
+		| rve_un_op error %prec UNARY 		{ $$=0; yyerror("bad expression"); }
2569 2569
 		| INTCAST error					{ $$=0; yyerror("bad expression"); }
2570 2570
 		| STRCAST error					{ $$=0; yyerror("bad expression"); }
2571 2571
 		| rval_expr PLUS error			{ $$=0; yyerror("bad expression"); }
... ...
@@ -2575,9 +2579,9 @@ rval_expr: rval						{ $$=$1;
2575 2575
 		| rval_expr MODULO error			{ $$=0; yyerror("bad expression"); }
2576 2576
 		| rval_expr BIN_OR error		{ $$=0; yyerror("bad expression"); }
2577 2577
 		| rval_expr BIN_AND error		{ $$=0; yyerror("bad expression"); }
2578
-		| rval_expr rve_cmpop %prec GT error
2578
+		| rval_expr rve_cmpop error %prec GT
2579 2579
 			{ $$=0; yyerror("bad expression"); }
2580
-		| rval_expr rve_equalop %prec EQUAL_T error
2580
+		| rval_expr rve_equalop error %prec EQUAL_T
2581 2581
 			{ $$=0; yyerror("bad expression"); }
2582 2582
 		| rval_expr LOG_AND error		{ $$=0; yyerror("bad expression"); }
2583 2583
 		| rval_expr LOG_OR error		{ $$=0; yyerror("bad expression"); }
... ...
@@ -85,12 +85,12 @@
85 85
 #define CONTENT_LENGTH "Content-Length: "
86 86
 #define CONTENT_LENGTH_LEN (sizeof(CONTENT_LENGTH)-1)
87 87
 
88
-#define USER_AGENT "User-Agent: SIP Router "\
89
-		"(" VERSION " (" ARCH "/" OS_QUOTED "))"
88
+#define USER_AGENT "User-Agent: " NAME \
89
+		" (" VERSION " (" ARCH "/" OS_QUOTED "))"
90 90
 #define USER_AGENT_LEN (sizeof(USER_AGENT)-1)
91 91
 
92
-#define SERVER_HDR "Server: SIP Router "\
93
-		"(" VERSION " (" ARCH "/" OS_QUOTED "))"
92
+#define SERVER_HDR "Server: " NAME \
93
+		" (" VERSION " (" ARCH "/" OS_QUOTED "))"
94 94
 #define SERVER_HDR_LEN (sizeof(SERVER_HDR)-1)
95 95
 
96 96
 #define MAX_WARNING_LEN  256
... ...
@@ -438,21 +438,54 @@ static void core_shmmem(rpc_t* rpc, void* c)
438 438
 {
439 439
 	struct mem_info mi;
440 440
 	void *handle;
441
-
441
+	char* param;
442
+	long rs;
443
+
444
+	rs=0;
445
+	/* look for optional size/divisor parameter */
446
+	if (rpc->scan(c, "*s", &param)>0){
447
+		switch(*param){
448
+			case 'b':
449
+			case 'B':
450
+				rs=0;
451
+				break;
452
+			case 'k':
453
+			case 'K':
454
+				rs=10; /* K -> 1024 */
455
+				break;
456
+			case 'm':
457
+			case 'M':
458
+				rs=20; /* M -> 1048576 */
459
+				break;
460
+			case 'g':
461
+			case 'G':
462
+				rs=30; /* G -> 1024M */
463
+				break;
464
+			default:
465
+				rpc->fault(c, 500, "bad param, (use b|k|m|g)");
466
+				return;
467
+		}
468
+		if (param[1] && ((param[1]!='b' && param[1]!='B') || param[2])){
469
+				rpc->fault(c, 500, "bad param, (use b|k|m|g)");
470
+				return;
471
+		}
472
+	}
442 473
 	shm_info(&mi);
443 474
 	rpc->add(c, "{", &handle);
444 475
 	rpc->struct_add(handle, "dddddd",
445
-		"total", (unsigned int)mi.total_size,
446
-		"free", (unsigned int)mi.free,
447
-		"used", (unsigned int)mi.used,
448
-		"real_used",(unsigned int)mi.real_used,
449
-		"max_used", (unsigned int)mi.max_used,
476
+		"total", (unsigned int)(mi.total_size>>rs),
477
+		"free", (unsigned int)(mi.free>>rs),
478
+		"used", (unsigned int)(mi.used>>rs),
479
+		"real_used",(unsigned int)(mi.real_used>>rs),
480
+		"max_used", (unsigned int)(mi.max_used>>rs),
450 481
 		"fragments", (unsigned int)mi.total_frags
451 482
 	);
452 483
 }
453 484
 
454 485
 static const char* core_shmmem_doc[] = {
455
-	"Returns shared memory info.",  /* Documentation string */
486
+	"Returns shared memory info. It has an optional parameter that specifies"
487
+	" the measuring unit: b - bytes (default), k or kb, m or mb, g or gb. "
488
+	"Note: when using something different from bytes, the value is truncated.",
456 489
 	0                               /* Method signature(s) */
457 490
 };
458 491
 
... ...
@@ -650,7 +683,13 @@ static void core_tcp_options(rpc_t* rpc, void* c)
650 650
 
651 651
 
652 652
 static const char* core_sctp_options_doc[] = {
653
-	"Returns active sctp options.",    /* Documentation string */
653
+	"Returns active sctp options. With one parameter"
654
+	" it returns the sctp options set in the kernel for a specific socket"
655
+	"(debugging), with 0 filled in for non-kernel related options."
656
+	" The parameter can be: \"default\" | \"first\" | address[:port] ."
657
+	" With no parameters it returns ser's idea of the current sctp options"
658
+	 " (intended non-debugging use).",
659
+	/* Documentation string */
654 660
 	0                                 /* Method signature(s) */
655 661
 };
656 662
 
... ...
@@ -659,9 +698,54 @@ static void core_sctp_options(rpc_t* rpc, void* c)
659 659
 #ifdef USE_SCTP
660 660
 	void *handle;
661 661
 	struct cfg_group_sctp t;
662
-
662
+	char* param;
663
+	struct socket_info* si;
664
+	char* host;
665
+	str hs;
666
+	int hlen;
667
+	int port;
668
+	int proto;
669
+
670
+	param=0;
663 671
 	if (!sctp_disable){
664
-		sctp_options_get(&t);
672
+		/* look for optional socket parameter */
673
+		if (rpc->scan(c, "*s", &param)>0){
674
+			si=0;
675
+			if (strcasecmp(param, "default")==0){
676
+				si=sendipv4_sctp?sendipv4_sctp:sendipv6_sctp;
677
+			}else if (strcasecmp(param, "first")==0){
678
+				si=sctp_listen;
679
+			}else{
680
+				if (parse_phostport(param, &host, &hlen, &port, &proto)!=0){
681
+					rpc->fault(c, 500, "bad param (use address, address:port,"
682
+										" default or first)");
683
+					return;
684
+				}
685
+				if (proto && proto!=PROTO_SCTP){
686
+					rpc->fault(c, 500, "bad protocol in param (only SCTP"
687
+										" allowed)");
688
+					return;
689
+				}
690
+				hs.s=host;
691
+				hs.len=hlen;
692
+				si=grep_sock_info(&hs, port, PROTO_SCTP);
693
+				if (si==0){
694
+					rpc->fault(c, 500, "not listening on sctp %s", param);
695
+					return;
696
+				}
697
+			}
698
+			if (si==0 || si->socket==-1){
699
+				rpc->fault(c, 500, "could not find a sctp socket");
700
+				return;
701
+			}
702
+			memset(&t, 0, sizeof(t));
703
+			if (sctp_get_cfg_from_sock(si->socket, &t)!=0){
704
+				rpc->fault(c, 500, "failed to get socket options");
705
+				return;
706
+			}
707
+		}else{
708
+			sctp_options_get(&t);
709
+		}
665 710
 		rpc->add(c, "{", &handle);
666 711
 		rpc->struct_add(handle, "ddddddddddddddddddd",
667 712
 			"sctp_socket_rcvbuf",	t.so_rcvbuf,
... ...
@@ -384,7 +384,9 @@ int lval_assign(struct run_act_ctx* h, struct sip_msg* msg,
384 384
 	ret=0;
385 385
 	rv=rval_expr_eval(h, msg, rve);
386 386
 	if (unlikely(rv==0)){
387
-		ERR("rval expression evaluation failed\n");
387
+		ERR("rval expression evaluation failed (%d,%d-%d,%d)\n",
388
+				rve->fpos.s_line, rve->fpos.s_col,
389
+				rve->fpos.e_line, rve->fpos.e_col);
388 390
 		goto error;
389 391
 	}
390 392
 	switch(lv->type){
... ...
@@ -721,19 +721,19 @@ void handle_sigs()
721 721
 		case SIGCHLD:
722 722
 			while ((chld=waitpid( -1, &chld_status, WNOHANG ))>0) {
723 723
 				if (WIFEXITED(chld_status))
724
-					LOG(L_ALERT, "child process %d exited normally,"
725
-							" status=%d\n", chld,
724
+					LOG(L_ALERT, "child process %ld exited normally,"
725
+							" status=%d\n", (long)chld,
726 726
 							WEXITSTATUS(chld_status));
727 727
 				else if (WIFSIGNALED(chld_status)) {
728
-					LOG(L_ALERT, "child process %d exited by a signal"
729
-							" %d\n", chld, WTERMSIG(chld_status));
728
+					LOG(L_ALERT, "child process %ld exited by a signal"
729
+							" %d\n", (long)chld, WTERMSIG(chld_status));
730 730
 #ifdef WCOREDUMP
731 731
 					LOG(L_ALERT, "core was %sgenerated\n",
732 732
 							 WCOREDUMP(chld_status) ?  "" : "not " );
733 733
 #endif
734 734
 				}else if (WIFSTOPPED(chld_status))
735
-					LOG(L_ALERT, "child process %d stopped by a"
736
-								" signal %d\n", chld,
735
+					LOG(L_ALERT, "child process %ld stopped by a"
736
+								" signal %d\n", (long)chld,
737 737
 								 WSTOPSIG(chld_status));
738 738
 			}
739 739
 #ifndef STOP_JIRIS_CHANGES
... ...
@@ -239,7 +239,8 @@ FIXUP_F2FP_T(igp_pvar_pvar, 1, 3, 1, FPARAM_INT|FPARAM_PVS, FPARAM_PVS)
239 239
 	}
240 240
 
241 241
 
242
+/* format: name, minp, maxp, no_of_spve_params, type_for_rest_params */
242 243
 FIXUP_F_SPVE_T(spve_spve, 1, 2, 2, 0)
243
-FIXUP_F_SPVE_T(spve_uint, 1, 2, 2, FPARAM_INT)
244
-FIXUP_F_SPVE_T(spve_str, 1, 2, 2, FPARAM_STR)
244
+FIXUP_F_SPVE_T(spve_uint, 1, 2, 1, FPARAM_INT)
245
+FIXUP_F_SPVE_T(spve_str, 1, 2, 1, FPARAM_STR)
245 246
 FIXUP_F_SPVE_T(spve_null, 1, 1, 1, 0)
... ...
@@ -31,6 +31,7 @@
31 31
 
32 32
 #ifndef _init_socks_h
33 33
 #define _init_socks_h
34
+#include <sys/types.h>
34 35
 #include <sys/un.h>
35 36
 #include "../../ip_addr.h"
36 37
 
... ...
@@ -2068,16 +2068,9 @@ static int next_gw(struct sip_msg* _m, char* _s1, char* _s2)
2068 2068
          * failure route block => append new branch. */
2069 2069
 	uri_str.s = r_uri;
2070 2070
 	uri_str.len = r_uri_len;
2071
-	memset(&act, '\0', sizeof(act));
2072
-	act.type = APPEND_BRANCH_T;
2073
-	act.val[0].type = STRING_ST;
2074
-	act.val[0].u.str = uri_str;
2075
-	act.val[1].type = NUMBER_ST;
2076
-	act.val[1].u.number = 0;
2077
-	init_run_actions_ctx(&ra_ctx);
2078
-	rval = do_action(&ra_ctx, &act, _m);
2079
-	if (rval != 1) {
2080
-	    LM_ERR("do_action failed with return value <%d>\n", rval);
2071
+	LM_DBG("appending branch <%.*s>\n", uri_str.len, uri_str.s);
2072
+	if (append_branch(_m, &uri_str, 0, 0, Q_UNSPECIFIED, 0, 0) == -1) {
2073
+	    LM_ERR("when appending branch <%.*s>\n", uri_str.len, uri_str.s);
2081 2074
 	    return -1;
2082 2075
 	}
2083 2076
     }
... ...
@@ -23,6 +23,6 @@ include ../../Makefile.modules
23 23
 
24 24
 
25 25
 install-tls-cert: $(cfg_prefix)/$(cfg_dir)
26
-	./$(SCR_NAME)_cert.sh -d $(cfg_prefix)/$(cfg_dir)
26
+	MAIN_NAME=$(MAIN_NAME) ./$(SCR_NAME)_cert.sh -d $(cfg_prefix)/$(cfg_dir)
27 27
 
28 28
 install-cfg:  install-tls-cert
... ...
@@ -3,18 +3,20 @@
3 3
 # $Id$
4 4
 #
5 5
 # This script generates a self-signed TLS/SSL certificate that can be
6
-# immediately used with the TLS module of SER. The file was inspired
6
+# immediately used with the TLS module of SIP Router. The file was inspired
7 7
 # by a script from Debian's uw-imapd package.
8 8
 #
9 9
 
10 10
 #############################################################################
11 11
 # Configuration variables
12 12
 #############################################################################
13
-DEFAULT_DIR="/usr/local/etc/ser"
13
+NAME=$MAIN_NAME
14
+if [ -z "$NAME" ] ; then NAME="sip-router"; fi;
15
+DEFAULT_DIR="/usr/local/etc/$NAME"
14 16
 DEFAULT_DAYS=365
15
-DEFAULT_INFO="Self-signed certificate for SER"
16
-DEFAULT_CERT_FILENAME="ser-selfsigned.pem"
17
-DEFAULT_KEY_FILENAME="ser-selfsigned.key"
17
+DEFAULT_INFO="Self-signed certificate for $NAME"
18
+DEFAULT_CERT_FILENAME="$NAME-selfsigned.pem"
19
+DEFAULT_KEY_FILENAME="$NAME-selfsigned.key"
18 20
 
19 21
 DEFAULT_OPENSSL='openssl'
20 22
 
... ...
@@ -50,19 +52,19 @@ longopts() {
50 50
 usage() {
51 51
 cat <<EOF
52 52
 NAME
53
-  $COMMAND - Generate a self-signed TLS/SSL certificate for use with SER.
53
+  $COMMAND - Generate a self-signed TLS/SSL certificate for use with $NAME.
54 54
 
55 55
 SYNOPSIS
56 56
   $COMMAND [options]
57 57
 
58 58
 DESCRIPTION
59 59
   This is a simple shell script that generates a self signed TLS/SSL
60
-  certificate (and private key) for use with the tls module of SER. The
60
+  certificate (and private key) for use with the tls module of $NAME. The
61 61
   self-signed certificate is suitable for testing and/or private setups.
62 62
   You are encouraged to create a proper authorized one if needed.
63 63
 
64 64
   Both certificate and key files are by default stored in the directory
65
-  containing the configuration file of SER (unless you change it using
65
+  containing the configuration file of $NAME (unless you change it using
66 66
   the options below).
67 67
 
68 68
 OPTIONS
... ...
@@ -100,7 +102,7 @@ AUTHOR
100 100
   Written by Jan Janak <jan@iptel.org>
101 101
 
102 102
 REPORTING BUGS
103
-  Report bugs to <ser-bugs@iptel.org>
103
+  Report bugs to <sr-dev@sip-router.org>
104 104
 EOF
105 105
 } #usage
106 106
 
... ...
@@ -175,7 +177,7 @@ if [ $? != 0 ] ; then
175 175
 	exit 1
176 176
 fi
177 177
 
178
-echo "Creating a new SER self-signed certificate for '$FQDN'" \
178
+echo "Creating a new $NAME self-signed certificate for '$FQDN'" \
179 179
      "valid for $DAYS days."
180 180
 openssl req -new -x509 -days "$DAYS" -nodes -out "$DIR/$CERT_FILENAME" \
181 181
         -keyout "$DIR/$KEY_FILENAME" > /dev/null 2>&1 <<+
... ...
@@ -16,103 +16,105 @@ Juha Heinanen
16 16
      __________________________________________________________________
17 17
 
18 18
    1.1. Overview
19
-   1.2. Known Issues
20
-   1.3. Parameters
21
-
22
-        1.3.1. fr_timer (integer)
23
-        1.3.2. fr_inv_timer (integer)
24
-        1.3.3. max_inv_lifetime (integer)
25
-        1.3.4. max_noninv_lifetime (integer)
26
-        1.3.5. wt_timer (integer)
27
-        1.3.6. delete_timer (integer)
28
-        1.3.7. retr_timer1 (integer)
29
-        1.3.8. retr_timer2 (integer)
30
-        1.3.9. noisy_ctimer (integer)
31
-        1.3.10. restart_fr_on_each_reply (integer)
32
-        1.3.11. auto_inv_100 (integer)
33
-        1.3.12. auto_inv_100_reason (string)
34
-        1.3.13. unix_tx_timeout (integer)
35
-        1.3.14. aggregate_challenges (integer)
36
-        1.3.15. reparse_invite (integer)
37
-        1.3.16. ac_extra_hdrs (string)
38
-        1.3.17. blst_503 (integer)
39
-        1.3.18. blst_503_def_timeout (integer)
40
-        1.3.19. blst_503_min_timeout (integer)
41
-        1.3.20. blst_503_max_timeout (integer)
42
-        1.3.21. blst_methods_add (unsigned integer)
43
-        1.3.22. blst_methods_lookup (unsigned integer)
44
-        1.3.23. cancel_b_method (integer)
45
-        1.3.24. reparse_on_dns_failover (integer)
46
-        1.3.25. on_sl_reply (string)
47
-        1.3.26. fr_inv_timer_next (integer)
48
-        1.3.27. contacts_avp (string)
49
-        1.3.28. fr_timer_avp (string)
50
-        1.3.29. fr_inv_timer_avp (string)
51
-        1.3.30. unmatched_cancel (string)
52
-        1.3.31. ruri_matching (integer)
53
-        1.3.32. via1_matching (integer)
54
-        1.3.33. pass_provisional_replies (integer)
55
-        1.3.34. default_code (integer)
56
-        1.3.35. default_reason (string)
57
-        1.3.36. disable_6xx_block (integer)
58
-
59
-   1.4. Functions
60
-
61
-        1.4.1. t_relay_to_udp(ip, port), t_relay_to_udp(),
19
+   1.2. Serial Forking Based on Q Value
20
+   1.3. Known Issues
21
+   1.4. Parameters
22
+
23
+        1.4.1. fr_timer (integer)
24
+        1.4.2. fr_inv_timer (integer)
25
+        1.4.3. max_inv_lifetime (integer)
26
+        1.4.4. max_noninv_lifetime (integer)
27
+        1.4.5. wt_timer (integer)
28
+        1.4.6. delete_timer (integer)
29
+        1.4.7. retr_timer1 (integer)
30
+        1.4.8. retr_timer2 (integer)
31
+        1.4.9. noisy_ctimer (integer)
32
+        1.4.10. restart_fr_on_each_reply (integer)
33
+        1.4.11. auto_inv_100 (integer)
34
+        1.4.12. auto_inv_100_reason (string)
35
+        1.4.13. unix_tx_timeout (integer)
36
+        1.4.14. aggregate_challenges (integer)
37
+        1.4.15. reparse_invite (integer)
38
+        1.4.16. ac_extra_hdrs (string)
39
+        1.4.17. blst_503 (integer)
40
+        1.4.18. blst_503_def_timeout (integer)
41
+        1.4.19. blst_503_min_timeout (integer)
42
+        1.4.20. blst_503_max_timeout (integer)
43
+        1.4.21. blst_methods_add (unsigned integer)
44
+        1.4.22. blst_methods_lookup (unsigned integer)
45
+        1.4.23. cancel_b_method (integer)
46
+        1.4.24. reparse_on_dns_failover (integer)
47
+        1.4.25. on_sl_reply (string)
48
+        1.4.26. fr_inv_timer_next (integer)
49
+        1.4.27. contacts_avp (string)
50
+        1.4.28. fr_timer_avp (string)
51
+        1.4.29. fr_inv_timer_avp (string)
52
+        1.4.30. unmatched_cancel (string)
53
+        1.4.31. ruri_matching (integer)
54
+        1.4.32. via1_matching (integer)
55
+        1.4.33. pass_provisional_replies (integer)
56
+        1.4.34. default_code (integer)
57
+        1.4.35. default_reason (string)
58
+        1.4.36. disable_6xx_block (integer)
59
+        1.4.37. local_ack_mode (integer)
60
+
61
+   1.5. Functions
62
+
63
+        1.5.1. t_relay_to_udp(ip, port), t_relay_to_udp(),
62 64
                 t_relay_to_tcp(ip, port) t_relay_to_tcp()
63 65
                 t_relay_to_tls(ip, port) t_relay_to_tls()
64 66
                 t_relay_to_sctp(ip, port) t_relay_to_sctp()
65 67
 
66
-        1.4.2. t_relay() t_relay(host, port)
67
-        1.4.3. t_on_failure(failure_route)
68
-        1.4.4. t_on_reply(onreply_route)
69
-        1.4.5. t_on_branch(branch_route)
70
-        1.4.6. append_branch()
71
-        1.4.7. t_newtran()
72
-        1.4.8. t_reply(code, reason_phrase)
73
-        1.4.9. t_lookup_request()
74
-        1.4.10. t_retransmit_reply()
75
-        1.4.11. t_release()
76
-        1.4.12. t_forward_nonack() t_forward_nonack(ip, port)
68
+        1.5.2. t_relay() t_relay(host, port)
69
+        1.5.3. t_on_failure(failure_route)
70
+        1.5.4. t_on_reply(onreply_route)
71
+        1.5.5. t_on_branch(branch_route)
72
+        1.5.6. append_branch()
73
+        1.5.7. t_newtran()
74
+        1.5.8. t_reply(code, reason_phrase)
75
+        1.5.9. t_lookup_request()
76
+        1.5.10. t_retransmit_reply()
77
+        1.5.11. t_release()
78
+        1.5.12. t_forward_nonack() t_forward_nonack(ip, port)
77 79
                 t_forward_nonack_udp(ip, port) t_forward_nonack_tcp(ip,
78 80
                 port) t_forward_nonack_tls(ip, port)
79 81
                 t_forward_nonack_sctp(ip, port)
80 82
 
81
-        1.4.13. t_set_fr(fr_inv_timeout [, fr_timeout])
82
-        1.4.14. t_reset_fr()
83
-        1.4.15. t_set_max_lifetime(inv_lifetime, noninv_lifetime)
84
-        1.4.16. t_reset_max_lifetime()
85
-        1.4.17. t_set_retr(retr_t1_interval, retr_t2_interval)
86
-        1.4.18. t_reset_retr()
87
-        1.4.19. t_set_auto_inv_100(0|1)
88
-        1.4.20. t_branch_timeout()
89
-        1.4.21. t_branch_replied()
90
-        1.4.22. t_any_timeout()
91
-        1.4.23. t_any_replied()
92
-        1.4.24. t_grep_status("code")
93
-        1.4.25. t_is_canceled()
94
-        1.4.26. t_is_expired()
95
-        1.4.27. t_relay_cancel()
96
-        1.4.28. t_lookup_cancel(), t_lookup_cancel(1)
97
-        1.4.29. t_drop_replies()
98
-        1.4.30. t_save_lumps()
99
-        1.4.31. t_load_contacts()
100
-        1.4.32. t_next_contacts()
101
-        1.4.33. t_check_trans()
102
-        1.4.34. t_set_disable_6xx(0|1)
103
-        1.4.35. t_set_disable_failover(0|1)
104
-
105
-   1.5. TM Module API
106
-
107
-        1.5.1. Defines
108
-        1.5.2. Functions
109
-
110
-              1.5.2.1. register_tmcb(cb_type, cb_func)
111
-              1.5.2.2. load_tm(*import_structure)
112
-              1.5.2.3. int t_suspend(struct sip_msg *msg, unsigned int
83
+        1.5.13. t_set_fr(fr_inv_timeout [, fr_timeout])
84
+        1.5.14. t_reset_fr()
85
+        1.5.15. t_set_max_lifetime(inv_lifetime, noninv_lifetime)
86
+        1.5.16. t_reset_max_lifetime()
87
+        1.5.17. t_set_retr(retr_t1_interval, retr_t2_interval)
88
+        1.5.18. t_reset_retr()
89
+        1.5.19. t_set_auto_inv_100(0|1)
90
+        1.5.20. t_branch_timeout()
91
+        1.5.21. t_branch_replied()
92
+        1.5.22. t_any_timeout()
93
+        1.5.23. t_any_replied()
94
+        1.5.24. t_grep_status("code")
95
+        1.5.25. t_is_canceled()
96
+        1.5.26. t_is_expired()
97
+        1.5.27. t_relay_cancel()
98
+        1.5.28. t_lookup_cancel(), t_lookup_cancel(1)
99
+        1.5.29. t_drop_replies()
100
+        1.5.30. t_save_lumps()
101
+        1.5.31. t_load_contacts()
102
+        1.5.32. t_next_contacts()
103
+        1.5.33. t_check_trans()
104
+        1.5.34. t_set_disable_6xx(0|1)
105
+        1.5.35. t_set_disable_failover(0|1)
106
+
107
+   1.6. TM Module API
108
+
109
+        1.6.1. Defines
110
+        1.6.2. Functions
111
+
112
+              1.6.2.1. register_tmcb(cb_type, cb_func)
113
+              1.6.2.2. load_tm(*import_structure)
114
+              1.6.2.3. int t_suspend(struct sip_msg *msg, unsigned int
113 115
                       *hash_index, unsigned int *label)
114 116
 
115
-              1.5.2.4. int t_continue(unsigned int hash_index, unsigned
117
+              1.6.2.4. int t_continue(unsigned int hash_index, unsigned
116 118
                       int label, struct action *route)
117 119
 
118 120
 1.1. Overview
... ...
@@ -170,7 +172,179 @@ Note
170 170
    implemented in the TMX module: "modules_k/tmx". Check it to see if what
171 171
    you are looking for is there.
172 172
 
173
-1.2. Known Issues
173
+1.2. Serial Forking Based on Q Value
174
+
175
+   A single SIP INVITE request may be forked to multiple destinations. We
176
+   call the set of all such destinations a destination set. Individual
177
+   elements within the destination sets are called branches. The script
178
+   writer can add URIs to the destination set from the configuration file,
179
+   or they can be loaded from the user location database, each registered
180
+   contact then becomes one branch in the destination set.
181
+
182
+   The default behavior of the tm module, if it encounters a SIP message
183
+   with multiple branches in the destination set, it to forward the SIP
184
+   message to all the branches in parallel. That means it sends the
185
+   message to all the branch destinations before it waits for replies from
186
+   any of them. This is the default behavior if you call t_relay() and
187
+   similar functions without anything else.
188
+
189
+   Another approach of handling multiple branches in a destination set it
190
+   serial forking. When configured to do serial forking, the server takes
191
+   the first branch out of the destination set, forwards the message to
192
+   its destination and waits for a reply or timeout. Only after a reply
193
+   has been received or the timeout occurred, the server takes another
194
+   destination from the destination set and tries again, until it receives
195
+   a positive final reply or until all branches from the destination set
196
+   have been tried.
197
+
198
+   Yet another, more sophisticated, way of handling multiple branches is
199
+   combined serial/parallel forking, where individual branches within the
200
+   destination set are assigned priorities. The order in which individual
201
+   branches are tried is then determined by their relative priority within
202
+   the destination set. Branches can be tried sequentially in the
203
+   descending priority order and all branches that have the same priority
204
+   can be tried in parallel. Such combined serial/parallel forking can be
205
+   achieved in the tm module with the help of functions t_load_contacts()
206
+   and t_next_contacts().
207
+
208
+   Every branch in the destination set is assigned a priority number, also
209
+   known as the q value. The q value is a floating point number in a range
210
+   0 to 1.0. The higher the q value number, the more priority is the
211
+   particular branch in the destination set is given. Branches with q
212
+   value 1.0 have maximum priority, such branches should be always tried
213
+   first in serial forking. Branches with q value 0 have the lowest
214
+   priority and they should by tried after all other branches with higher
215
+   priority in the destination set.
216
+
217
+   As an example, consider the following simple configuration file. When
218
+   the server receives an INVITE, it creates four branches for it with
219
+   usernames A through D and then forwards the request using t_relay():
220
+route {
221
+  seturi("sip:a@example.com");
222
+  append_branch("sip:b@example.com");
223
+  append_branch("sip:c@example.com");
224
+  append_branch("sip:d@example.com");
225
+
226
+  t_relay();
227
+  break;
228
+}
229
+
230
+   With this configuratin the server forwards the request to all four
231
+   branches at once, performing parallel forking described above. We did
232
+   not set the q value for individual branches in this example but we can
233
+   do that by slightly modifying the arguments given to append_branch():
234
+route {
235
+  seturi("sip:a@example.com");
236
+  append_branch("sip:b@example.com", "0.5");
237
+  append_branch("sip:c@example.com", "0.5");
238
+  append_branch("sip:d@example.com", "1.0");
239
+
240
+  t_relay();
241
+  break;
242
+}
243
+
244
+   Here we assigned q value 0.5 to branches B and C and q value 1.0 to
245
+   branch D. We did not specify any q value for branch A and in that case
246
+   it is assumed that its q value is the lowest from all branches within
247
+   the destination set. If you try to run this example again, you will
248
+   figure out that nothing changed, t_relay() still forward the message to
249
+   all branches in parallel.
250
+
251
+   We now want to implement the combined serial/parallel forking. Branch D
252
+   should be tried first, because its q value is 1.0. Branches B and C
253
+   should be tried in parallel, but only after D finishes. Branch A should
254
+   be tried after B and C finished, because its q value (the default) is
255
+   the lowest of all. To do that, we need to introduce two new functions
256
+   into our example and one tm module parameter:
257
+modparam("tm", "contacts_avp", "tm_contacts");
258
+
259
+route {
260
+  seturi("sip:a@example.com");
261
+  append_branch("sip:b@example.com", "0.5");
262
+  append_branch("sip:c@example.com", "0.5");
263
+  append_branch("sip:d@example.com", "1.0");
264
+
265
+  t_load_contacts();
266
+
267
+  t_next_contacts();
268
+  t_relay();
269
+  break;
270
+}
271
+
272
+   First of all, the tm module parameter is mandatory if the two new
273
+   functions are used. Function t_load_contacts() takes all branches from
274
+   the destination set, sorts them according to their q values and stores
275
+   them in the AVP configured in the modparam. The function also clears
276
+   the destination set, which means that it removes all branches
277
+   configured before with seturi() and append_branch().
278
+
279
+   Function t_next_contacts() takes the AVP created by the previous
280
+   function and extract the branches with highest q values from it. In our
281
+   example it is branch D. That branch is then put back into the
282
+   destination set and when the script finally reaches t_relay(), the
283
+   destination set only contains branch D and the request will be
284
+   forwarded there.
285
+
286
+   We achieved the first step of serial forking, but this is not
287
+   sufficient. Now we also need to forward to other branches with lower
288
+   priority values when branch D finishes. To do that, we need to extend
289
+   the configuration file again and introduce a failure_route section:
290
+modparam("tm", "contacts_avp", "tm_contacts");
291
+
292
+route {
293
+  seturi("sip:a@example.com");
294
+  append_branch("sip:b@example.com", "0.5");
295
+  append_branch("sip:c@example.com", "0.5");
296
+  append_branch("sip:d@example.com", "1.0");
297
+
298
+  t_load_contacts();
299
+
300
+  t_next_contacts();
301
+  t_on_failure("serial");
302
+  t_relay();
303
+  break;
304
+}
305
+
306
+failure_route["serial"]
307
+{
308
+  if (!t_next_contacts()) {
309
+    exit;
310
+  }
311
+
312
+  t_on_failure("serial");
313
+  t_relay();
314
+}
315
+
316
+   The failure_route section will be executed when branch D finishes. It
317
+   executes t_next_contacts() again and this time the function retrieves
318
+   branches B and C from the AVP and adds them to the destination set.
319
+   Here we need to check the return value of the function, because a
320
+   negative value indicates that there were no more branches, in that case
321
+   the failure_route should just terminate and forward the response from
322
+   branch D upstream.
323
+
324
+   If t_next_contact() returns a positive value then we have more new
325
+   branches to try and we need to setup the failure_route again and call
326
+   t_relay(). In our example the request will now be forwarded to branches
327
+   B and C in paralell, because they were both added to the destination
328
+   set by t_next_contacts() at the same time.
329
+
330
+   When branches B and C finish, the failure_route block is executed
331
+   again, this time t_next_contacts() puts the final branch A into the
332
+   destination set and t_relay() forwards the request there.
333
+
334
+   And that's the whole example, we achieved combined serial/parallel
335
+   forking based on the q value of individual branches. In real-world
336
+   configuration files the script writer would need to check the return
337
+   value of all functions and also configure some additional parameters,
338
+   such as fr_inv_timer_next and restart_fr_on_each_reply. Also the
339
+   destination set would not be configured directly in the configuration
340
+   file, but can be retrieved from the user location database, for
341
+   example. In that case registered contacts will be stored in the
342
+   destination set as branches and their q values (provided by UAs) will
343
+   be used.
344
+
345
+1.3. Known Issues
174 346
 
175 347
      * Possibly, performance could be improved by not parsing non-INVITEs,
176 348
        as they do not be replied with 100, and do not result in
... ...
@@ -185,13 +359,19 @@ Note
185 185
      * t_replicate should be done more cleanly--Vias, Routes, etc. should
186 186
        be removed from a message prior to replicating it (well, does not
187 187
        matter any longer so much as there is a new replication module).
188
+     * Function t_next_contacts should restore the value of timer
189
+       fr_inv_timer when there are no more branches to be processed
190
+       serially. The function can restore the timer properly if it has
191
+       been configured through an AVP or with the config framework, but
192
+       may fail to restore timer values configured for individual
193
+       transactions with t_set_fr.
188 194
 
189
-1.3. Parameters
195
+1.4. Parameters
190 196
 
191 197
    Revision History
192 198
    Revision $Revision$ $Date$
193 199
 
194
-1.3.1. fr_timer (integer)
200
+1.4.1. fr_timer (integer)
195 201
 
196 202
    Timer which hits if no final reply for a request or ACK for a negative
197 203
    INVITE reply arrives (in milliseconds).
... ...
@@ -205,7 +385,7 @@ Note
205 205
 modparam("tm", "fr_timer", 10000)
206 206
 ...
207 207
 
208
-1.3.2. fr_inv_timer (integer)
208
+1.4.2. fr_inv_timer (integer)
209 209
 
210 210
    Timer which hits if no final reply for an INVITE arrives after a
211 211
    provisional message was received (in milliseconds).
... ...
@@ -222,7 +402,7 @@ modparam("tm", "fr_timer", 10000)
222 222
 modparam("tm", "fr_inv_timer", 180000)
223 223
 ...
224 224
 
225
-1.3.3. max_inv_lifetime (integer)
225
+1.4.3. max_inv_lifetime (integer)
226 226
 
227 227
    Maximum time an INVITE transaction is allowed to be active (in
228 228
    milliseconds). After this interval has passed from the transaction
... ...
@@ -258,7 +438,7 @@ modparam("tm", "fr_inv_timer", 180000)
258 258
 modparam("tm", "max_inv_lifetime", 150000)
259 259
 ...
260 260
 
261
-1.3.4. max_noninv_lifetime (integer)
261
+1.4.4. max_noninv_lifetime (integer)
262 262
 
263 263
    Maximum time a non-INVITE transaction is allowed to be active (in
264 264
    milliseconds). After this interval has passed from the transaction
... ...
@@ -288,7 +468,7 @@ modparam("tm", "max_inv_lifetime", 150000)
288 288
 modparam("tm", "max_inv_lifetime", 30000)
289 289
 ...
290 290
 
291
-1.3.5. wt_timer (integer)
291
+1.4.5. wt_timer (integer)
292 292
 
293 293
    Time for which a transaction stays in memory to absorb delayed messages
294 294
    after it completed (in milliseconds); also, when this timer hits,
... ...
@@ -303,7 +483,7 @@ modparam("tm", "max_inv_lifetime", 30000)
303 303
 modparam("tm", "wt_timer", 1000)
304 304
 ...
305 305
 
306
-1.3.6. delete_timer (integer)
306
+1.4.6. delete_timer (integer)
307 307
 
308 308
    Time after which a to-be-deleted transaction currently ref-ed by a
309 309
    process will be tried to be deleted again (in milliseconds).
... ...
@@ -318,7 +498,7 @@ modparam("tm", "wt_timer", 1000)
318 318
 modparam("tm", "delete_timer", 100)
319 319
 ...
320 320
 
321
-1.3.7. retr_timer1 (integer)
321
+1.4.7. retr_timer1 (integer)
322 322
 
323 323
    Initial retransmission period (in milliseconds).
324 324
 
... ...
@@ -329,7 +509,7 @@ modparam("tm", "delete_timer", 100)
329 329
 modparam("tm", "retr_timer1", 1000)
330 330
 ...
331 331
 
332
-1.3.8. retr_timer2 (integer)
332
+1.4.8. retr_timer2 (integer)
333 333
 
334 334
    Maximum retransmission period (in milliseconds). The retransmission
335 335
    interval starts with retr_timer1 and increases until it reaches this
... ...
@@ -342,7 +522,7 @@ modparam("tm", "retr_timer1", 1000)
342 342
 modparam("tm", "retr_timer2", 2000)
343 343
 ...
344 344
 
345
-1.3.9. noisy_ctimer (integer)
345
+1.4.9. noisy_ctimer (integer)
346 346
 
347 347
    If set, INVITE transactions that time-out (FR INV timer) will be always
348 348
    replied. If it's not set, the transaction has only one branch and no
... ...
@@ -361,7 +541,7 @@ modparam("tm", "retr_timer2", 2000)
361 361
 modparam("tm", "noisy_ctimer", 1)
362 362
 ...
363 363
 
364
-1.3.10. restart_fr_on_each_reply (integer)
364
+1.4.10. restart_fr_on_each_reply (integer)
365 365
 
366 366
    If set (default), the fr_inv_timer for an INVITE transaction will be
367 367
    restarted for each provisional reply received (rfc3261 mandated
... ...
@@ -383,7 +563,7 @@ modparam("tm", "noisy_ctimer", 1)
383 383
 modparam("tm", "restart_fr_on_each_reply", 0)
384 384
 ...
385 385
 
386
-1.3.11. auto_inv_100 (integer)
386
+1.4.11. auto_inv_100 (integer)
387 387
 
388 388
    If set (default) tm will automatically send and 100 reply to INVITEs.
389 389
 
... ...
@@ -403,7 +583,7 @@ modparam("tm", "restart_fr_on_each_reply", 0)
403 403
 modparam("tm", "auto_inv_100", 0)
404 404
 ...
405 405
 
406
-1.3.12. auto_inv_100_reason (string)
406
+1.4.12. auto_inv_100_reason (string)
407 407
 
408 408
    Set reason text of the automatically send 100 to an INVITE.
409 409
 
... ...
@@ -416,7 +596,7 @@ modparam("tm", "auto_inv_100", 0)
416 416
 modparam("tm", "auto_inv_100_reason", "Trying")
417 417
 ...
418 418
 
419
-1.3.13. unix_tx_timeout (integer)
419
+1.4.13. unix_tx_timeout (integer)
420 420
 
421 421
    Unix socket transmission timeout, in milliseconds.
422 422
 
... ...
@@ -431,7 +611,7 @@ modparam("tm", "auto_inv_100_reason", "Trying")
431 431
 modparam("tm", "unix_tx_timeout", 250)
432 432
 ...
433 433
 
434
-1.3.14. aggregate_challenges (integer)
434
+1.4.14. aggregate_challenges (integer)
435 435
 
436 436
    If set (default), the final reply is a 401 or a 407 and more then one
437 437
    branch received a 401 or 407, then all the WWW-Authenticate and
... ...
@@ -448,7 +628,7 @@ modparam("tm", "unix_tx_timeout", 250)
448 448
 modparam("tm", "aggregate_challenges", 0)
449 449
 ...
450 450
 
451
-1.3.15. reparse_invite (integer)
451
+1.4.15. reparse_invite (integer)
452 452
 
453 453
    If set (default), the CANCEL and negative ACK requests are constructed
454 454
    from the INVITE message which was sent out instead of building them
... ...
@@ -474,7 +654,7 @@ modparam("tm", "aggregate_challenges", 0)
474 474
 modparam("tm", "reparse_invite", 0)
475 475
 ...
476 476
 
477
-1.3.16. ac_extra_hdrs (string)
477
+1.4.16. ac_extra_hdrs (string)
478 478
 
479 479
    Header fields prefixed by this parameter value are included in the
480 480
    CANCEL and negative ACK messages if they were present in the outgoing
... ...
@@ -492,7 +672,7 @@ modparam("tm", "reparse_invite", 0)
492 492
 modparam("tm", "ac_extra_hdrs", "myfavoriteheaders-")
493 493
 ...
494 494
 
495
-1.3.17. blst_503 (integer)
495
+1.4.17. blst_503 (integer)
496 496
 
497 497
    If set and the blacklist support is enabled, every 503 reply source is
498 498
    added to the blacklist. The initial blacklist timeout (or ttl) depends
... ...
@@ -510,7 +690,7 @@ modparam("tm", "ac_extra_hdrs", "myfavoriteheaders-")
510 510
 modparam("tm", "blst_503", 1)
511 511
 ...
512 512
 
513
-1.3.18. blst_503_def_timeout (integer)
513
+1.4.18. blst_503_def_timeout (integer)
514 514
 
515 515
    Blacklist interval in seconds for a 503 reply with no Retry-After
516 516
    header. See also blst_503, blst_503_min_timeout and
... ...
@@ -525,7 +705,7 @@ modparam("tm", "blst_503", 1)
525 525
 modparam("tm", "blst_503_def_timeout", 120)
526 526
 ...
527 527
 
528
-1.3.19. blst_503_min_timeout (integer)
528
+1.4.19. blst_503_min_timeout (integer)
529 529
 
530 530
    Minimum blacklist interval in seconds for a 503 reply with a
531 531
    Retry-After header. It will be used if the Retry-After value is
... ...
@@ -539,7 +719,7 @@ modparam("tm", "blst_503_def_timeout", 120)
539 539
 modparam("tm", "blst_503_min_timeout", 30)
540 540
 ...
541 541
 
542
-1.3.20. blst_503_max_timeout (integer)
542
+1.4.20. blst_503_max_timeout (integer)
543 543
 
544 544
    Maximum blacklist interval in seconds for a 503 reply with a
545 545
    Retry-After header. It will be used if the Retry-After value is
... ...
@@ -553,7 +733,7 @@ modparam("tm", "blst_503_min_timeout", 30)
553 553
 modparam("tm", "blst_503_max_timeout", 604800)
554 554
 ...
555 555
 
556
-1.3.21. blst_methods_add (unsigned integer)
556
+1.4.21. blst_methods_add (unsigned integer)
557 557
 
558 558
    Bitmap of method types that trigger blacklisting on transaction
559 559
    timeouts. (This setting has no effect on blacklisting because of send
... ...
@@ -578,7 +758,7 @@ modparam("tm", "blst_503_max_timeout", 604800)
578 578
 modparam("tm", "blst_methods_add", 33)
579 579
 ...
580 580
 
581
-1.3.22. blst_methods_lookup (unsigned integer)
581
+1.4.22. blst_methods_lookup (unsigned integer)
582 582
 
583 583
    Bitmap of method types that are looked-up in the blacklist before
584 584
    statefull forwarding. See also blst_methods_add
... ...
@@ -592,7 +772,7 @@ modparam("tm", "blst_methods_add", 33)
592 592
 modparam("tm", "blst_methods_lookup", 1)
593 593
 ...
594 594
 
595
-1.3.23. cancel_b_method (integer)
595
+1.4.23. cancel_b_method (integer)
596 596
 
597 597
    Method used when attempting to CANCEL an unreplied transaction branch
598 598
    (a branch where no reply greater the 99 was received). The possible
... ...
@@ -630,7 +810,7 @@ modparam("tm", "blst_methods_lookup", 1)
630 630
 modparam("tm", "cancel_b_method", 1)
631 631
 ...
632 632
 
633
-1.3.24. reparse_on_dns_failover (integer)
633
+1.4.24. reparse_on_dns_failover (integer)
634 634
 
635 635
    If set to 1, the SIP message after a DNS failover is constructed from
636 636
    the outgoing message buffer of the failed branch instead of from the
... ...
@@ -658,7 +838,7 @@ modparam("tm", "cancel_b_method", 1)
658 658
 modparam("tm", "reparse_on_dns_failover", 0)
659 659
 ...
660 660
 
661
-1.3.25. on_sl_reply (string)
661
+1.4.25. on_sl_reply (string)
662 662
 
663 663
    Sets reply route block, to which control is passed when a reply is
664 664
    received that has no associated transaction. The reply is passed to the
... ...
@@ -675,27 +855,56 @@ onreply_route["stateless_replies"] {
675 675
         return 0;
676 676
 }
677 677
 
678
-1.3.26. fr_inv_timer_next (integer)
679
-
680
-   Value of the Final Response timeout for INVITE transactions to be used
681
-   during serial forwarding:
682
-
683
-   Function t_next_contacts() sets fr_inv_timer to fr_inv_timer_next value
684
-   if, after t_next_contacts() is called, there are still lower qvalue
685
-   contacts available, and to fr_inv_timer value if there are not.
686
-
687
-   Default value is 30.
678
+1.4.26. fr_inv_timer_next (integer)
679
+
680
+   This parameter can be used to configure an alternative value for the
681
+   fr_inv_timer timer. This alternative value is used in place of
682
+   fr_inv_timer when serial forking takes place. It is used for all
683
+   branches during serial forking except the last one. The last branch (or
684
+   a set of parallel branches) use the original value from fr_inv_timer
685
+   again.
686
+
687
+   The purpose of the timer is to allow an administrator to configure a
688
+   shorter version of fr_inv_timer that is used only when serial forking
689
+   takes place. Forwarding branches one after another is much more time
690
+   consuming, because every serial branch has to wait for the result of
691
+   the previous one. That can take up to the value of fr_inv_timer and
692
+   this timer is configured to two minutes by default. Hence, if you have
693
+   three serial branches then completing the transaction can take six
694
+   minutes with default timer values.
695
+
696
+   In practise, the transaction will be terminated sooner, because the
697
+   timer max_inv_lifetime hits after three minutes. Thus, some of the
698
+   serial branches might not be forwarded at all. And this is exactly what
699
+   fr_inv_timer_next is for. You can configure the timer to a shorter
700
+   value to ensure that all serial branches are tried before the timer
701
+   max_inv_lifetime hits.
702
+
703
+   Note that if there is only one branch or if the current serial branch
704
+   is the last one (i.e. no more serial forking takes place after this
705
+   branch is finished) then fr_inv_timer_next is not used, instead the
706
+   branch uses the longer fr_inv_timer.
707
+
708
+   Function t_next_contacts() sets fr_inv_timer to fr_inv_timer_next if
709
+   serial forking takes place and there is more than one serial branch.
710
+
711
+   The administrator can configure the value of this timer using the
712
+   configuration framework on the fly. But unlike fr_inv_timer, it is not
713
+   possible to configure the value of this timer on per-transaction basis.
714
+
715
+   The value of this timer is to be specified in milliseconds. The default
716
+   value is 30000ms.
688 717
 
689 718
    Example 26. Set fr_inv_timer_next parameter
690 719
 ...
691
-modparam("tm", "fr_inv_timer_next", 10)
720
+modparam("tm", "fr_inv_timer_next", 10000)
692 721
 ...
693 722
 
694
-1.3.27. contacts_avp (string)
723
+1.4.27. contacts_avp (string)
695 724
 
696
-   Internal AVP that t_load_contacts() function uses to store contacts of
697
-   the destination set and that t_next_contacts() function uses to restore
698
-   those contacts.
725
+   This is the name or Id of an AVP that t_load_contacts() function uses
726
+   to store contacts of the destination set and that t_next_contacts()
727
+   function uses to restore those contacts.
699 728
 
700 729
    Default value is "NULL" (t_load_contacts()/t_next_contacts() functions
701 730
    are disabled).
... ...
@@ -705,7 +914,7 @@ modparam("tm", "fr_inv_timer_next", 10)
705 705
 modparam("tm", "contacts_avp", "$avp(i:25)")
706 706
 ...
707 707
 
708
-1.3.28. fr_timer_avp (string)
708
+1.4.28. fr_timer_avp (string)
709 709
 
710 710
    The value of fr_timer timer can be overriden on per-transaction basis.
711 711
    The administrator can provide a value to be used for a particular
... ...
@@ -734,7 +943,7 @@ Note
734