Browse code

Merge commit 'origin/ser_core_cvs'

* commit 'origin/ser_core_cvs':
tcp: minor optimization
sercmd: minor makefile fix
tcp internal: send timeout is now kept only in ticks
core: typo fix
tcp: typo & minor optimization
Rename Contact parameter select 'method' to 'methods'
Rename Contact parameter 'method' to 'methods'
make install: avoid re-linking lib dependent modules
build system: avoid libraries re-compiling
fixing missing $ in ser_mysql.sh script
Debian packaging - fixing path to mysql sql files in my_create.sh script
The fixup function prototypes of the config variables have been
Strip, prefix, rewriteuser, ... all the SET_* actions preserve the
core: check & fix Content-Length when sending on tcp
tcp: config option for the async write block size
tcp: config option for the read buffer size
tcp: dyn. config fix for tcp_con_lifetime
tcp: diff. connect timeout for async & states cleanup

Conflicts:
Makefile.rules
action.c
cfg.lex
cfg.y
route_struct.h

Andrei Pelinescu-Onciul authored on 20/03/2009 20:47:32
Showing 53 changed files
... ...
@@ -54,6 +54,8 @@
54 54
 #               the modules list can be changed without rebuilding the whole
55 55
 #               ser (andrei)
56 56
 #              added cfg-defs, new target that only rebuilds config.mak
57
+#  2009-03-10  replaced DEFS with C_DEFS (DEFS are now used only for
58
+#              "temporary" defines inside modules or libs) (andrei)
57 59
 #
58 60
 
59 61
 auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
... ...
@@ -203,7 +205,7 @@ ALLDEP=config.mak Makefile Makefile.sources Makefile.rules
203 205
 # hack to force makefile.defs re-inclusion (needed when make calls itself with
204 206
 # other options -- e.g. make bin)
205 207
 #makefile_defs=0
206
-#DEFS:=
208
+#C_DEFS:=
207 209
 
208 210
 
209 211
 # try saved cfg, unless we are in the process of building it
... ...
@@ -331,7 +333,7 @@ config.mak: Makefile.defs
331 333
 	@$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
332 334
 	@$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
333 335
 	@echo "override makefile_defs:=1" >>$@
334
-	@echo "DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(DEFS))" \
336
+	@echo "C_DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(C_DEFS))" \
335 337
 					"\$$(extra_defs)"  >>$@
336 338
 	@echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
337 339
 						"\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
... ...
@@ -538,7 +540,8 @@ man: modules.lst
538 540
 	done; true
539 541
 
540 542
 .PHONY: install
541
-install:all install-bin install-modules install-cfg \
543
+install: export compile_for_install=yes
544
+install: install-bin install-modules install-cfg \
542 545
 	install-doc install-man install-utils install-share
543 546
 
544 547
 .PHONY: dbinstall
... ...
@@ -66,6 +66,9 @@
66 66
 #  2008-06-26  support for make cfg / config.mak and hack to load 
67 67
 #               automatically config.mak when included from a module, lib 
68 68
 #               a.s.o (not from the main Makefile)  (andrei)
69
+#  2009-03-10  replaced DEFS with C_DEFS and INCLUDES with C_INCLUDES (DEFS
70
+#              and INCLUDES are now used only for "temporary" defines/includes
71
+#              inside modules or libs) (andrei)
69 72
 
70 73
 
71 74
 # check if already included/exported
... ...
@@ -460,7 +463,7 @@ endif
460 463
 #		adds support for Application Server interface
461 464
 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
462 465
 
463
-DEFS= $(extra_defs) \
466
+C_DEFS= $(extra_defs) \
464 467
 	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
465 468
 	 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
466 469
 	 -DSER_VER=$(SER_VER) \
... ...
@@ -507,14 +510,14 @@ DEFS= $(extra_defs) \
507 510
 # debugging symbols in all cases (-g). --andrei
508 511
 
509 512
 ifeq ($(CORE_TLS), 1)
510
-	DEFS+= -DUSE_TLS -DCORE_TLS
513
+	C_DEFS+= -DUSE_TLS -DCORE_TLS
511 514
 endif
512 515
 ifeq ($(TLS_HOOKS), 1)
513
-	DEFS+= -DUSE_TLS -DTLS_HOOKS
516
+	C_DEFS+= -DUSE_TLS -DTLS_HOOKS
514 517
 endif
515 518
 
516 519
 ifneq ($(STUN),)
517
-	DEFS+= -DUSE_STUN
520
+	C_DEFS+= -DUSE_STUN
518 521
 endif
519 522
 
520 523
 ifeq ($(mode),)
... ...
@@ -522,7 +525,7 @@ ifeq ($(mode),)
522 525
 endif
523 526
 
524 527
 ifeq ($(mode),debug)
525
-	DEFS+= -DEXTRA_DEBUG
528
+	C_DEFS+= -DEXTRA_DEBUG
526 529
 endif
527 530
 
528 531
 # platform dependent settings
... ...
@@ -598,7 +601,7 @@ endif
598 601
 
599 602
 ifeq ($(ARCH), arm)
600 603
 	use_fast_lock=yes
601
-	DEFS+=-DNOSMP # very unlikely to have an smp arm
604
+	C_DEFS+=-DNOSMP # very unlikely to have an smp arm
602 605
 endif
603 606
 
604 607
 ifeq ($(ARCH), arm6)
... ...
@@ -616,8 +619,8 @@ endif
616 619
 ifeq ($(ARCH), mips)
617 620
 # mips1 arch. (e.g. R3000) - no hardware locking support
618 621
 	use_fast_lock=no
619
-	DEFS+=-DMIPS_HAS_LLSC # likely
620
-	DEFS+=-DNOSMP # very likely
622
+	C_DEFS+=-DMIPS_HAS_LLSC # likely
623
+	C_DEFS+=-DNOSMP # very likely
621 624
 endif
622 625
 
623 626
 ifeq ($(ARCH), mips2)
... ...
@@ -632,24 +635,24 @@ endif
632 635
 
633 636
 ifeq ($(ARCH), alpha)
634 637
 	use_fast_lock=yes
635
-	DEFS+=-DNOSMP # very likely
638
+	C_DEFS+=-DNOSMP # very likely
636 639
 endif
637 640
 
638 641
 ifeq ($(use_fast_lock), yes)
639
-	DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
642
+	C_DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
640 643
 	found_lock_method=yes
641 644
 endif
642 645
 
643 646
 CFLAGS=
644 647
 LDFLAGS=
645
-INCLUDES=
648
+C_INCLUDES=
646 649
 # setting CFLAGS
647 650
 ifeq ($(mode), release)
648 651
 	#if i386
649 652
 ifeq	($(ARCH), i386)
650 653
 		# if gcc 
651 654
 ifeq		($(CC_NAME), gcc)
652
-				DEFS+=-DCC_GCC_LIKE_ASM
655
+				C_DEFS+=-DCC_GCC_LIKE_ASM
653 656
 				#common stuff
654 657
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
655 658
 			#if gcc 4.0+
... ...
@@ -692,7 +695,7 @@ endif			# CC_SHORTVER, 4.x
692 695
 
693 696
 else		# CC_NAME, gcc
694 697
 ifeq		($(CC_NAME), icc)
695
-			DEFS+=-DCC_GCC_LIKE_ASM
698
+			C_DEFS+=-DCC_GCC_LIKE_ASM
696 699
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
697 700
 					 -tpp6 -xK  #-openmp  #optimize for PIII 
698 701
 				# -prefetch doesn't seem to work
... ...
@@ -710,7 +713,7 @@ endif	#ARCH, i386
710 713
 ifeq	($(ARCH), x86_64)
711 714
 		# if gcc 
712 715
 ifeq		($(CC_NAME), gcc)
713
-				DEFS+=-DCC_GCC_LIKE_ASM
716
+				C_DEFS+=-DCC_GCC_LIKE_ASM
714 717
 				#common stuff
715 718
 				CFLAGS=-m64 -g -O9 -funroll-loops  -Wcast-align $(PROFILE)
716 719
 				LDFLAGS+=-m64
... ...
@@ -754,7 +757,7 @@ endif			# CC_SHORTVER, 4.x
754 757
 
755 758
 else		# CC_NAME, gcc
756 759
 ifeq		($(CC_NAME), icc)
757
-			DEFS+=-DCC_GCC_LIKE_ASM
760
+			C_DEFS+=-DCC_GCC_LIKE_ASM
758 761
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
759 762
 					 -tpp6 -xK  #-openmp  #optimize for PIII 
760 763
 				# -prefetch doesn't seem to work
... ...
@@ -772,7 +775,7 @@ endif	#ARCH, x86_64
772 775
 ifeq	($(ARCH), sparc64)
773 776
 			#if gcc
774 777
 ifeq		($(CC_NAME), gcc)
775
-				DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
778
+				C_DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
776 779
 				#common stuff
777 780
 				CFLAGS=-m64 -g -O9 -funroll-loops  $(PROFILE) \
778 781
 					#-Wcast-align \
... ...
@@ -834,7 +837,7 @@ endif			#CC_SHORTVER, 4.x
834 837
 	
835 838
 else		#CC_NAME, gcc
836 839
 ifeq		($(CC_NAME), suncc)
837
-			DEFS+=-DSPARC64_MODE
840
+			C_DEFS+=-DSPARC64_MODE
838 841
 			CFLAGS+= -m64 -g -xO5 -fast -native -xarch=v9 -xCC \
839 842
 					-xc99 # C99 support
840 843
 			# -Dinline="" # add this if cc < 5.3 (define inline as null)
... ...
@@ -849,7 +852,7 @@ endif	#ARCH, sparc64
849 852
 ifeq	($(ARCH), sparc)
850 853
 			#if gcc
851 854
 ifeq		($(CC_NAME), gcc)
852
-				DEFS+=-DCC_GCC_LIKE_ASM
855
+				C_DEFS+=-DCC_GCC_LIKE_ASM
853 856
 				#common stuff
854 857
 				CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
855 858
 					#-Wcast-align \
... ...
@@ -906,7 +909,7 @@ endif	#ARCH, sparc
906 909
 ifeq	($(ARCH), arm)
907 910
 		# if gcc 
908 911
 ifeq		($(CC_NAME), gcc)
909
-				DEFS+=-DCC_GCC_LIKE_ASM
912
+				C_DEFS+=-DCC_GCC_LIKE_ASM
910 913
 				#common stuff
911 914
 				CFLAGS=-O9 -funroll-loops $(PROFILE)
912 915
 			#if gcc 4.x+
... ...
@@ -948,7 +951,7 @@ endif	#ARCH, arm
948 951
 ifeq	($(ARCH), arm6)
949 952
 		# if gcc 
950 953
 ifeq		($(CC_NAME), gcc)
951
-				DEFS+=-DCC_GCC_LIKE_ASM
954
+				C_DEFS+=-DCC_GCC_LIKE_ASM
952 955
 				#common stuff
953 956
 				CFLAGS=-march=armv6 -O9 -funroll-loops \
954 957
 						$(PROFILE)
... ...
@@ -990,7 +993,7 @@ endif	#ARCH, arm6
990 993
 ifeq	($(ARCH), mips)
991 994
 		# if gcc 
992 995
 ifeq		($(CC_NAME), gcc)
993
-				DEFS+=-DCC_GCC_LIKE_ASM
996
+				C_DEFS+=-DCC_GCC_LIKE_ASM
994 997
 				#common stuff
995 998
 				CFLAGS=-O9 -funroll-loops  $(PROFILE)
996 999
 			#if gcc 4.0+
... ...
@@ -1031,7 +1034,7 @@ endif	#ARCH, mips
1031 1034
 ifeq	($(ARCH), mips2)
1032 1035
 		# if gcc 
1033 1036
 ifeq		($(CC_NAME), gcc)
1034
-				DEFS+=-DCC_GCC_LIKE_ASM
1037
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1035 1038
 				#common stuff
1036 1039
 				CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
1037 1040
 			#if gcc 4.0+
... ...
@@ -1070,7 +1073,7 @@ endif	#ARCH, mips2
1070 1073
 ifeq	($(ARCH), mips64)
1071 1074
 		# if gcc 
1072 1075
 ifeq		($(CC_NAME), gcc)
1073
-				DEFS+=-DCC_GCC_LIKE_ASM
1076
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1074 1077
 				#common stuff
1075 1078
 				CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
1076 1079
 			#if gcc 4.0+
... ...
@@ -1109,7 +1112,7 @@ endif	#ARCH, mips64
1109 1112
 ifeq	($(ARCH), alpha)
1110 1113
 		# if gcc 
1111 1114
 ifeq		($(CC_NAME), gcc)
1112
-				DEFS+=-DCC_GCC_LIKE_ASM
1115
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1113 1116
 				#common stuff
1114 1117
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
1115 1118
 			#if gcc 4.0+
... ...
@@ -1149,7 +1152,7 @@ endif	#ARCH, alpha
1149 1152
 ifeq	($(ARCH), ppc)
1150 1153
 		# if gcc 
1151 1154
 ifeq		($(CC_NAME), gcc)
1152
-				DEFS+=-DCC_GCC_LIKE_ASM
1155
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1153 1156
 				#common stuff
1154 1157
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
1155 1158
 			#if gcc 4.0+
... ...
@@ -1190,7 +1193,7 @@ endif	#ARCH, ppc
1190 1193
 ifeq	($(ARCH), ppc64)
1191 1194
 		# if gcc 
1192 1195
 ifeq		($(CC_NAME), gcc)
1193
-				DEFS+=-DCC_GCC_LIKE_ASM
1196
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1194 1197
 				#common stuff
1195 1198
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
1196 1199
 ifeq			($(CC_SHORTVER), 4.x)
... ...
@@ -1269,9 +1272,9 @@ endif
1269 1272
 else	#mode,release
1270 1273
 ifeq	($(CC_NAME), gcc)
1271 1274
 		CFLAGS=-g -Wcast-align $(PROFILE)
1272
-		DEFS+=-DCC_GCC_LIKE_ASM
1275
+		C_DEFS+=-DCC_GCC_LIKE_ASM
1273 1276
 ifeq		($(ARCH), sparc64)
1274
-			DEFS+=SPARC64_MODE
1277
+			C_DEFS+=SPARC64_MODE
1275 1278
 			CFLAGS+= -mcpu=ultrasparc -m64
1276 1279
 			LDFLAGS+=-m64
1277 1280
 endif
... ...
@@ -1292,7 +1295,7 @@ else
1292 1295
 endif
1293 1296
 endif
1294 1297
 ifeq	($(CC_NAME), icc)
1295
-		DEFS+=-DCC_GCC_LIKE_ASM
1298
+		C_DEFS+=-DCC_GCC_LIKE_ASM
1296 1299
 		CFLAGS=-g  $(PROFILE)
1297 1300
 		LDFLAGS+=-g -Wl,-E $(PROFILE)
1298 1301
 		MOD_LDFLAGS:=-shared $(LDFLAGS)
... ...
@@ -1357,27 +1360,27 @@ LIB_SUFFIX:=.so
1357 1360
 ifeq ($(OS), linux)
1358 1361
 # by default use futexes if available
1359 1362
 	use_futex= yes
1360
-	DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1363
+	C_DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1361 1364
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1362 1365
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1363 1366
 	ifneq ($(found_lock_method), yes)
1364
-		#DEFS+= -DUSE_POSIX_SEM
1365
-		DEFS+=-DUSE_PTHREAD_MUTEX
1367
+		#C_DEFS+= -DUSE_POSIX_SEM
1368
+		C_DEFS+=-DUSE_PTHREAD_MUTEX
1366 1369
 		LIBS+= -lpthread
1367
-		#DEFS+= -DUSE_SYSV_SEM  # try posix sems
1370
+		#C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
1368 1371
 		found_lock_method=yes
1369 1372
 	else
1370
-		ifneq (,$(findstring -DUSE_POSIX_SEM, $(DEFS)))
1373
+		ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1371 1374
 			LIBS+=-lpthread
1372 1375
 		endif
1373
-		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(DEFS)))
1376
+		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1374 1377
 			LIBS+=-lpthread
1375 1378
 		endif
1376 1379
 	endif
1377 1380
 	# check for >= 2.5.44
1378 1381
 	ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
1379 1382
 		ifeq ($(NO_EPOLL),)
1380
-			DEFS+=-DHAVE_EPOLL
1383
+			C_DEFS+=-DHAVE_EPOLL
1381 1384
 			# linux + gcc >= 3.0 + -malign-double + epoll => problems
1382 1385
 			CFLAGS_RM+=-malign-double
1383 1386
 			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
... ...
@@ -1386,17 +1389,17 @@ ifeq ($(OS), linux)
1386 1389
 	# check for >= 2.2.0
1387 1390
 	ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
1388 1391
 		ifeq ($(NO_SIGIO),)
1389
-			DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1392
+			C_DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1390 1393
 		endif
1391 1394
 	endif
1392 1395
 	# check for >= 2.5.70
1393 1396
 	ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
1394 1397
 		ifeq ($(use_futex), yes)
1395
-			DEFS+=-DUSE_FUTEX
1398
+			C_DEFS+=-DUSE_FUTEX
1396 1399
 		endif
1397 1400
 	endif
1398 1401
 	ifeq ($(NO_SELECT),)
1399
-		DEFS+=-DHAVE_SELECT
1402
+		C_DEFS+=-DHAVE_SELECT
1400 1403
 	endif
1401 1404
 	# sctp support
1402 1405
 	ifeq ($(SCTP),1)
... ...
@@ -1418,27 +1421,27 @@ $(info "sctp libraries not installed -- sctp disabled")
1418 1421
 		
1419 1422
 		ifeq ($(SCTP),1)
1420 1423
 			# use lksctp
1421
-			DEFS+=-DUSE_SCTP
1424
+			C_DEFS+=-DUSE_SCTP
1422 1425
 			LIBS+=-lsctp
1423 1426
 		endif
1424 1427
 	endif # SCTP
1425 1428
 endif
1426 1429
 
1427 1430
 ifeq  ($(OS), solaris)
1428
-	DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1431
+	C_DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1429 1432
 			-DHAVE_ALLOCA_H -DUSE_SIGACTION
1430 1433
 	ifneq ($(found_lock_method), yes)
1431
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1434
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1432 1435
 		found_lock_method=yes
1433 1436
 	endif
1434 1437
 	# check for ver >= 5.7
1435 1438
 	ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
1436 1439
 		ifeq ($(NO_DEVPOLL),)
1437
-			DEFS+=-DHAVE_DEVPOLL
1440
+			C_DEFS+=-DHAVE_DEVPOLL
1438 1441
 		endif
1439 1442
 	endif
1440 1443
 	ifeq ($(NO_SELECT),)
1441
-		DEFS+=-DHAVE_SELECT
1444
+		C_DEFS+=-DHAVE_SELECT
1442 1445
 	endif
1443 1446
 	# check for filio.h
1444 1447
 	filio_h_locations= /usr/include/sys/filio.h \
... ...
@@ -1448,7 +1451,7 @@ ifeq  ($(OS), solaris)
1448 1451
 						done;\
1449 1452
 				)
1450 1453
 	ifeq ($(has_filio_h), yes)
1451
-		DEFS+=-DHAVE_FILIO_H
1454
+		C_DEFS+=-DHAVE_FILIO_H
1452 1455
 	endif
1453 1456
 	ifeq ($(mode), release)
1454 1457
 		#use these only if you're using gcc with Solaris ld
... ...
@@ -1475,12 +1478,12 @@ endif
1475 1478
 endif
1476 1479
 
1477 1480
 ifeq ($(OS), freebsd)
1478
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1481
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1479 1482
 		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1480 1483
 		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1481 1484
 		-DHAVE_NETINET_IN_SYSTM
1482 1485
 	ifneq ($(found_lock_method), yes)
1483
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1486
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1484 1487
 		found_lock_method=yes
1485 1488
 		LIBS+= -pthread   #dlopen is in libc
1486 1489
 	else
... ...
@@ -1489,11 +1492,11 @@ ifeq ($(OS), freebsd)
1489 1492
 	# check for ver >= 4.1
1490 1493
 	ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
1491 1494
 		ifeq ($(NO_KQUEUE),)
1492
-			DEFS+=-DHAVE_KQUEUE
1495
+			C_DEFS+=-DHAVE_KQUEUE
1493 1496
 		endif
1494 1497
 	endif
1495 1498
 	ifeq ($(NO_SELECT),)
1496
-		DEFS+=-DHAVE_SELECT
1499
+		C_DEFS+=-DHAVE_SELECT
1497 1500
 	endif
1498 1501
 	YACC=yacc
1499 1502
 	# sctp support
... ...
@@ -1512,29 +1515,29 @@ $(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
1512 1515
 		endif
1513 1516
 		
1514 1517
 		ifeq ($(SCTP),1)
1515
-			DEFS+=-DUSE_SCTP
1518
+			C_DEFS+=-DUSE_SCTP
1516 1519
 			LIBS+=  # no extra libs needed on freebsd
1517 1520
 		endif
1518 1521
 	endif # SCTP
1519 1522
 endif
1520 1523
 
1521 1524
 ifeq ($(OS), openbsd)
1522
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
1525
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
1523 1526
 		-DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
1524 1527
 		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1525 1528
 		-DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT
1526 1529
 	ifneq ($(found_lock_method), yes)
1527
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1530
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1528 1531
 		found_lock_method=yes
1529 1532
 	endif
1530 1533
 	# check for ver >=2 9
1531 1534
 	ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
1532 1535
 		ifeq ($(NO_KQUEUE),)
1533
-			DEFS+=-DHAVE_KQUEUE
1536
+			C_DEFS+=-DHAVE_KQUEUE
1534 1537
 		endif
1535 1538
 	endif
1536 1539
 	ifeq ($(NO_SELECT),)
1537
-		DEFS+=-DHAVE_SELECT
1540
+		C_DEFS+=-DHAVE_SELECT
1538 1541
 	endif
1539 1542
 	# (symbols on openbsd are prefixed by "_")
1540 1543
 	YACC=yacc
... ...
@@ -1554,29 +1557,29 @@ endif
1554 1557
 endif
1555 1558
 	
1556 1559
 ifeq ($(OPENBSD_IS_AOUT), yes)
1557
-		DEFS+=-DDLSYM_PREFIX='"_"'
1560
+		C_DEFS+=-DDLSYM_PREFIX='"_"'
1558 1561
 		LDFLAGS=        # openbsd ld doesn't like -O2 or -E
1559 1562
 endif
1560 1563
 endif   # if opensd
1561 1564
 	
1562 1565
 ifeq ($(OS), netbsd)
1563
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1566
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1564 1567
 		-DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
1565 1568
 	ifneq ($(found_lock_method), yes)
1566
-		DEFS+= -DUSE_SYSV_SEM  # try pthread sems
1569
+		C_DEFS+= -DUSE_SYSV_SEM  # try pthread sems
1567 1570
 		found_lock_method=yes
1568 1571
 	endif
1569 1572
 	# check for ver >= 2.0.0
1570 1573
 	ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
1571 1574
 		ifeq ($(NO_KQUEUE),)
1572
-			DEFS+=-DHAVE_KQUEUE
1575
+			C_DEFS+=-DHAVE_KQUEUE
1573 1576
 			# netbsd + kqueue and -malign-double don't work
1574 1577
 			CFLAGS_RM+=-malign-double
1575 1578
 			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1576 1579
 		endif
1577 1580
 	endif
1578 1581
 	ifeq ($(NO_SELECT),)
1579
-		DEFS+=-DHAVE_SELECT
1582
+		C_DEFS+=-DHAVE_SELECT
1580 1583
 	endif
1581 1584
 	YACC=yacc
1582 1585
 	LIBS=  
... ...
@@ -1584,7 +1587,7 @@ endif
1584 1587
 
1585 1588
 # OS X support, same as freebsd
1586 1589
 ifeq ($(OS), darwin)
1587
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1590
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1588 1591
 		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1589 1592
 		-DUSE_ANON_MMAP \
1590 1593
 		-DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
... ...
@@ -1592,18 +1595,18 @@ ifeq ($(OS), darwin)
1592 1595
 	# -DNDEBUG used to turn off assert (assert wants to call
1593 1596
 	# eprintf which doesn't seem to be defined in any shared lib
1594 1597
 	ifneq ($(found_lock_method), yes)
1595
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1598
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1596 1599
 		found_lock_method=yes
1597
-		DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
1600
+		C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
1598 1601
 		                       # processes and unnamed posix sems are not
1599 1602
 		                       # supported)
1600 1603
 	endif
1601 1604
 	LIBS= -lresolv  #dlopen is in libc
1602 1605
 	ifeq ($(NO_KQUEUE),)
1603
-		DEFS+=-DHAVE_KQUEUE
1606
+		C_DEFS+=-DHAVE_KQUEUE
1604 1607
 	endif
1605 1608
 	ifeq ($(NO_SELECT),)
1606
-		DEFS+=-DHAVE_SELECT
1609
+		C_DEFS+=-DHAVE_SELECT
1607 1610
 	endif
1608 1611
 	LDFLAGS=        # darwin doesn't like -O2 or -E
1609 1612
 	# the modules uses symbols from ser => either 
... ...
@@ -1621,34 +1624,34 @@ endif
1621 1624
 
1622 1625
 ifneq (,$(findstring cygwin, $(OS)))
1623 1626
 	# cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
1624
-	#DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS))
1627
+	#C_DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(C_DEFS))
1625 1628
 	DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
1626
-	DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1629
+	C_DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1627 1630
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1628 1631
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1629 1632
 	ifneq ($(found_lock_method), yes)
1630
-		DEFS+= -DUSE_POSIX_SEM
1631
-		#DEFS+= -DUSE_SYSV_SEM  # try posix sems
1633
+		C_DEFS+= -DUSE_POSIX_SEM
1634
+		#C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
1632 1635
 		# PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
1633 1636
 		#LIBS+= -lpthread
1634 1637
 		found_lock_method=yes
1635 1638
 	else
1636
-		ifneq (,$(findstring -DUSE_POSIX_SEM, $(DEFS)))
1639
+		ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1637 1640
 			#LIBS+=-lpthread
1638 1641
 		endif
1639
-		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(DEFS)))
1642
+		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1640 1643
 $(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
1641 1644
 		endif
1642 1645
 	endif
1643 1646
 	# check for >= 2.5.70
1644 1647
 	ifeq ($(NO_SELECT),)
1645
-		DEFS+=-DHAVE_SELECT
1648
+		C_DEFS+=-DHAVE_SELECT
1646 1649
 	endif
1647 1650
 endif
1648 1651
 
1649 1652
 #add libssl if needed
1650 1653
 ifeq ($(CORE_TLS), 1)
1651
-DEFS+= -I$(LOCALBASE)/ssl/include
1654
+C_DEFS+= -I$(LOCALBASE)/ssl/include
1652 1655
 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
1653 1656
 		$(TLS_EXTRA_LIBS)
1654 1657
 # NOTE: depending on the way in which libssl was compiled you might
... ...
@@ -1657,13 +1660,13 @@ LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
1657 1660
 endif
1658 1661
 
1659 1662
 ifneq ($(STUN),)
1660
-DEFS+= -I$(LOCALBASE)/ssl/include
1663
+C_DEFS+= -I$(LOCALBASE)/ssl/include
1661 1664
 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lcrypto
1662 1665
 endif
1663 1666
 
1664 1667
 ifneq ($(found_lock_method), yes)
1665 1668
 $(warning	No locking method found so far, trying SYS V sems)
1666
-		DEFS+= -DUSE_SYSV_SEM  # try sys v sems
1669
+		C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems
1667 1670
 		found_lock_method=yes
1668 1671
 endif
1669 1672
 
... ...
@@ -1685,7 +1688,7 @@ export exported_vars
1685 1688
 #  is run)
1686 1689
 saved_fixed_vars:=	MAIN_NAME \
1687 1690
 		RELEASE OS ARCH \
1688
-		DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS INCLUDES \
1691
+		C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
1689 1692
 		MOD_LDFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \
1690 1693
 		LIB_SUFFIX LIB_PREFIX \
1691 1694
 		LIBS \
... ...
@@ -20,7 +20,7 @@ endif
20 20
 
21 21
 ifneq	(,$(filter install% %install install, $(MAKECMDGOALS)))
22 22
 compile_for_install:=yes
23
-$(info install mode => compile_for_install=$(compile_for_install))
23
+$(info install mode)
24 24
 endif
25 25
 
26 26
 ifeq ($(NAME),)
... ...
@@ -157,8 +157,7 @@ endif
157 157
 .PHONY:install-if-newer
158 158
 install-if-newer: $(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME) 
159 159
 
160
-$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME) $(LIBINAME_F)
161
-	@$(MAKE) install
160
+$(lib_prefix)/$(lib_dir)/$(LIB_RUNTIME_NAME): $(LIB_NAME) $(LIBINAME_F) install
162 161
 
163 162
 
164 163
 ifneq ($(strip $(LIBINAME_F)),)
... ...
@@ -11,6 +11,9 @@
11 11
 #               installed if needed (andrei)
12 12
 #  2008-06-23  added the README & man targets (andrei)
13 13
 #  2008-06-27  make cfg / config.mak support (andrei)
14
+#  2009-03-10  replaced DEFS with C_DEFS and INCLUDES with C_INCLUDES (DEFS
15
+#              and INCLUDES are now used only for "temporary" defines/includes
16
+#              inside modules or libs) (andrei)
14 17
 #
15 18
 
16 19
 MOD_NAME=$(NAME:.so=)
... ...
@@ -26,9 +29,10 @@ override modules=
26 29
 override static_modules=
27 30
 override static_modules_path=
28 31
 
29
-# should be set in Makefile of apart module
32
+# should be set in the Makefile of each module
30 33
 # INCLUDES += -I$(COREPATH)
31 34
 
35
+# temporary def (visible only in the module, not exported)
32 36
 DEFS += -DMOD_NAME='"$(MOD_NAME)"'
33 37
 
34 38
 ifneq ($(makefile_defs_included),1)
... ...
@@ -19,7 +19,7 @@
19 19
 # Radiusclient-ng is often installed from tarballs so we
20 20
 # need to look int /usr/local/lib as well
21 21
 #
22
-DEFS+=-I$(LOCALBASE)/include
22
+INCLUDES+=-I$(LOCALBASE)/include
23 23
 
24 24
 ifneq ($(radiusclient_ng), 4)
25 25
 
... ...
@@ -6,7 +6,8 @@
6 6
 #
7 7
 
8 8
 #
9
-# Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, INCLUDES, LIBS, MKDEP, auto_gen, 
9
+# Uses: NAME, ALLDEP, CC, CFLAGS, C_DEFS, DEFS, C_INCLUDES, INCLUDES, LIBS, 
10
+#       MKDEP, auto_gen, 
10 11
 # auto_gen_others, depends, objs, extra_objs, static_modules, 
11 12
 # static_modules_path, LD_RPATH
12 13
 # (all this must  be defined previously!,  see Makefile.defs & Makefile)
... ...
@@ -20,7 +21,10 @@
20 21
 #              automatically build listed SER_LIBS if needed (andrei)
21 22
 #  2008-06-23  automatically rebuild if make time defines or includes
22 23
 #              changed (via makecfg.lst)
23
-#
24
+#  2009-03-10  support for C_DEFS and C_INCLUDES (DEFS and INCLUDES are now
25
+#              used only for "temporary" defines/includes inside modules or
26
+#              libs, C_DEFS and C_INCLUDES are used for the common stuff)
27
+#              (andrei)
24 28
 
25 29
 
26 30
 # check if the saved cfg corresponds with the current one
... ...
@@ -30,17 +34,18 @@ ifeq (,$(filter $(nodep_targets),$(MAKECMDGOALS)))
30 34
 # if trying  to build a lib automatically and the lib is already compiled,
31 35
 # don't rebuild it if the only differences in DEFS or INCLUDES are covered
32 36
 # by LIB_NOREBUILD_DEFS/LIB_NOREBUILD_INCLUDES
33
-LIB_NOREBUILD_DEFS+= -DMOD_NAME% -D%_MOD_INTERFACE -DMOD_INTERFACE_% -DSR_%
37
+LIB_NOREBUILD_DEFS=
34 38
 
35 39
 # don't rebuild if the differences are covered by NOREBUILD_DEFS or 
36 40
 # NOREBUILD_INCLUDES
37
-ifneq ($(filter-out $(NOREBUILD_DEFS),$(strip $(DEFS))), $(strip $(CFG_DEFS)))
41
+ifneq ($(strip $(filter-out $(NOREBUILD_DEFS),\
42
+		$(C_DEFS) $(DEFS))),$(strip $(CFG_DEFS)))
38 43
 #$(warning different defs: <$(strip $(DEFS))> != )
39 44
 #$(warning               : <$(strip $(CFG_DEFS))>)
40 45
 $(shell rm -f makecfg.lst)
41 46
 endif
42
-ifneq ($(filter-out $(NOREBUILD_INCLUDES), $(strip $(INCLUDES))),\
43
-		$(strip $(CFG_INCLUDES)))
47
+ifneq ($(strip $(filter-out $(NOREBUILD_INCLUDES),\
48
+			$(C_INCLUDES) $(INCLUDES))),$(strip $(CFG_INCLUDES)))
44 49
 $(shell rm -f makecfg.lst)
45 50
 endif
46 51
 endif
... ...
@@ -49,10 +54,10 @@ ALLDEP+=makecfg.lst
49 54
 
50 55
 #implicit rules
51 56
 %.o:%.c  $(ALLDEP)
52
-	$(CC) $(CFLAGS) $(INCLUDES) $(DEFS) -c $< -o $@
57
+	$(CC) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) -c $< -o $@
53 58
 
54 59
 %.d: %.c $(ALLDEP)
55
-	@set -e; $(MKDEP) $(CFLAGS) $(INCLUDES) $(DEFS) $< \
60
+	@set -e; $(MKDEP) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) $<\
56 61
 	    |  sed 's#\(\($(*D)/\)\{0,1\}$(*F)\)\.o[ :]*#$*.o $@ : #g' > $@; \
57 62
 	    test -s $@ || ( rm -f $@; false )
58 63
 
... ...
@@ -66,7 +71,7 @@ ifneq	(,$(filter install install% %install, $(MAKECMDGOALS)))
66 71
 lib_compile_for_install=yes
67 72
 expected_lib_ipath=$(lib_target)
68 73
 else
69
-lib_compile_for_install=no
74
+lib_compile_for_install=$(compile_for_install)
70 75
 # function: expected_lib_ipath ser_lib_dir
71 76
 expected_lib_ipath=$(1)
72 77
 endif
... ...
@@ -144,10 +149,11 @@ librpath.lst: $(ALLDEP)
144 149
 	@echo LIB_RPATH_LST:=$(SER_RPATH_LST) >librpath.lst
145 150
 
146 151
 makecfg.lst:
147
-	@echo CFG_DEFS:=$(subst ',\', $(subst ",\", \
148
-		$(filter-out $(NOREBUILD_DEFS), $(strip $(DEFS))))) >>$@
149
-	@echo CFG_INCLUDES:=$(subst ',\', $(subst ",\", \
150
-		$(filter-out $(NOREBUILD_INCLUDES), $(strip $(INCLUDES))))) >>$@
152
+	@echo CFG_DEFS:=$(subst ',\', $(subst ",\",$(strip \
153
+			$(filter-out $(NOREBUILD_DEFS), $(C_DEFS) $(DEFS))))) >>$@
154
+	@echo CFG_INCLUDES:=$(subst ',\', $(subst ",\",$(strip \
155
+			$(filter-out $(NOREBUILD_INCLUDES),\
156
+				$(C_INCLUDES) $(INCLUDES))))) >>$@
151 157
 .PHONY: all
152 158
 all: $(NAME) modules
153 159
 
... ...
@@ -256,6 +256,20 @@ core:
256 256
                between the short name and long name in cache as CNAME record
257 257
 
258 258
 new config variables:
259
+  tcp_rd_buf_size = buffer size used for tcp reads.
260
+                    A high buffer size increases performance on server with few
261
+                    connections and lot of traffic on them, but also increases
262
+                     memory consumption (so for lots of connection is better 
263
+                    to use a low value). Note also that this value limits the
264
+                    maximum datagram size that can be received over tcp.
265
+                    Default: 4096, can be changed at runtime.
266
+  tcp_wq_blk_size = block size used for tcp async writes. It should be big
267
+                    enough to hold a few datagrams. If it's smaller then a
268
+                    datagram (in fact a tcp write()) size, it will be rounded
269
+                    up. It has no influenced on the number of datagrams 
270
+                    queued (for that see tcp_conn_wq_max or tcp_wq_max).
271
+                    It has mostly debugging and testing value (can be ignored).
272
+                    Default: 2100 (~ 2 INVITEs), can be changed at runtime.
259 273
   tcp_no_connect = yes/no - disable connects, ser will only accept new 
260 274
                      connections, it will never try to open new ones.
261 275
                      Default: no, can be changed at runtime.
... ...
@@ -122,7 +122,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
122 122
 	struct rvalue* rv1;
123 123
 	struct rval_cache c1;
124 124
 	str s;
125
-
125
+	int orig_p2t;
126 126
 
127 127
 	/* reset the value of error to E_UNSPEC so avoid unknowledgable
128 128
 	   functions to return with error (status<0) and not setting it
... ...
@@ -498,18 +498,22 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
498 498
 		case PREFIX_T:
499 499
 		case STRIP_T:
500 500
 		case STRIP_TAIL_T:
501
+		case SET_USERPHONE_T:
501 502
 				user=0;
502 503
 				if (a->type==STRIP_T || a->type==STRIP_TAIL_T) {
503 504
 					if (a->val[0].type!=NUMBER_ST) {
504 505
 						LOG(L_CRIT, "BUG: do_action: bad set*() type %d\n",
505 506
 							a->val[0].type);
507
+						ret=E_BUG;
506 508
 						break;
507 509
 					}
508
-				} else if (a->val[0].type!=STRING_ST){
509
-					LOG(L_CRIT, "BUG: do_action: bad set*() type %d\n",
510
+				} else if (a->type!=SET_USERPHONE_T) {
511
+					if (a->val[0].type!=STRING_ST) {
512
+						LOG(L_CRIT, "BUG: do_action: bad set*() type %d\n",
510 513
 							a->val[0].type);
511
-					ret=E_BUG;
512
-					break;
514
+						ret=E_BUG;
515
+						break;
516
+					}
513 517
 				}
514 518
 				if (a->type==SET_URI_T){
515 519
 					if (msg->new_uri.s) {
... ...
@@ -532,7 +536,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
532 536
 					ret=1;
533 537
 					break;
534 538
 				}
535
-				if (msg->parsed_uri_ok==0) {
539
+				if ((msg->parsed_uri_ok==0) || ((uri.flags & URI_SIP_USER_PHONE)!=0)) {
536 540
 					if (msg->new_uri.s) {
537 541
 						tmp=msg->new_uri.s;
538 542
 						len=msg->new_uri.len;
... ...
@@ -540,16 +544,41 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
540 544
 						tmp=msg->first_line.u.request.uri.s;
541 545
 						len=msg->first_line.u.request.uri.len;
542 546
 					}
547
+					/* don't convert sip:user=phone to tel, otherwise we loose parameters */
548
+					orig_p2t=phone2tel;
549
+					phone2tel=0;
550
+					msg->parsed_uri_ok=0;
543 551
 					if (parse_uri(tmp, len, &uri)<0){
552
+						phone2tel=orig_p2t;
544 553
 						LOG(L_ERR, "ERROR: do_action: bad uri <%s>, dropping"
545 554
 									" packet\n", tmp);
546 555
 						ret=E_UNSPEC;
547 556
 						break;
548 557
 					}
558
+					phone2tel=orig_p2t;
549 559
 				} else {
550 560
 					uri=msg->parsed_uri;
551 561
 				}
552 562
 
563
+				/* skip SET_USERPHONE_T action if the URI is already
564
+				 * a tel: or tels: URI, or contains the user=phone param */
565
+				if ((a->type==SET_USERPHONE_T) 
566
+					&& ((uri.type==TEL_URI_T) || (uri.type==TELS_URI_T)
567
+						|| ((uri.user_param_val.len==5) && (memcmp(uri.user_param_val.s, "phone", 5)==0)))
568
+				) {
569
+					ret=1;
570
+					break;
571
+				}
572
+				/* SET_PORT_T does not work with tel: URIs */
573
+				if ((a->type==SET_PORT_T)
574
+					&& ((uri.type==TEL_URI_T) || (uri.type==TELS_URI_T))
575
+					&& ((uri.flags & URI_SIP_USER_PHONE)==0)
576
+				) {
577
+					LOG(L_ERR, "ERROR: do_action: port number of a tel: URI cannot be set\n");
578
+					ret=E_UNSPEC;
579
+					break;
580
+				}
581
+
553 582
 				new_uri=pkg_malloc(MAX_URI_SIZE);
554 583
 				if (new_uri==0){
555 584
 					LOG(L_ERR, "ERROR: do_action: memory allocation "
... ...
@@ -560,8 +589,57 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
560 589
 				end=new_uri+MAX_URI_SIZE;
561 590
 				crt=new_uri;
562 591
 				/* begin copying */
563
-				len=strlen("sip:"); if(crt+len>end) goto error_uri;
564
-				memcpy(crt,"sip:",len);crt+=len;
592
+				/* Preserve the URI scheme unless the host part needs
593
+				 * to be rewritten, and the shceme is tel: or tels: */
594
+				switch (uri.type) {
595
+				case SIP_URI_T:
596
+					len=s_sip.len;
597
+					tmp=s_sip.s;
598
+					break;
599
+
600
+				case SIPS_URI_T:
601
+					len=s_sips.len;
602
+					tmp=s_sips.s;
603
+					break;
604
+
605
+				case TEL_URI_T:
606
+					if ((uri.flags & URI_SIP_USER_PHONE)
607
+						|| (a->type==SET_HOST_T)
608
+						|| (a->type==SET_HOSTPORT_T)
609
+						|| (a->type==SET_HOSTPORTTRANS_T)
610
+					) {
611
+						len=s_sip.len;
612
+						tmp=s_sip.s;
613
+						break;
614
+					}
615
+					len=s_tel.len;
616
+					tmp=s_tel.s;
617
+					break;
618
+
619
+				case TELS_URI_T:
620
+					if ((uri.flags & URI_SIP_USER_PHONE)
621
+						|| (a->type==SET_HOST_T)
622
+						|| (a->type==SET_HOSTPORT_T)
623
+						|| (a->type==SET_HOSTPORTTRANS_T)
624
+					) {
625
+						len=s_sips.len;
626
+						tmp=s_sips.s;
627
+						break;
628
+					}
629
+					len=s_tels.len;
630
+					tmp=s_tels.s;
631
+					break;
632
+
633
+				default:
634
+					LOG(L_ERR, "ERROR: Unsupported URI scheme (%d), "
635
+						"reverted to sip:\n",
636
+						uri.type);
637
+					len=s_sip.len;
638
+					tmp=s_sip.s;
639
+				}
640
+				if(crt+len+1 /* colon */ >end) goto error_uri;
641
+				memcpy(crt,tmp,len);crt+=len;
642
+				*crt=':'; crt++;
565 643
 
566 644
 				/* user */
567 645
 
... ...
@@ -622,22 +700,28 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
622 700
 					memcpy(crt,tmp,len);crt+=len;
623 701
 				}
624 702
 				/* host */
625
-				if (user || tmp){ /* add @ */
626
-					if(crt+1>end) goto error_uri;
627
-					*crt='@'; crt++;
628
-				}
629 703
 				if ((a->type==SET_HOST_T)
630 704
 						|| (a->type==SET_HOSTPORT_T)
631 705
 						|| (a->type==SET_HOSTALL_T)
632
-						|| (a->type==SET_HOSTPORTTRANS_T)) {
706
+						|| (a->type==SET_HOSTPORTTRANS_T)
707
+				) {
633 708
 					tmp=a->val[0].u.string;
634 709
 					if (tmp) len = strlen(tmp);
635 710
 					else len=0;
636
-				} else {
711
+				} else if ((uri.type==SIP_URI_T)
712
+					|| (uri.type==SIPS_URI_T)
713
+					|| (uri.flags & URI_SIP_USER_PHONE)
714
+				) {
637 715
 					tmp=uri.host.s;
638
-					len = uri.host.len;
716
+					len=uri.host.len;
717
+				} else {
718
+					tmp=0;
639 719
 				}
640 720
 				if (tmp){
721
+					if (user) { /* add @ */
722
+						if(crt+1>end) goto error_uri;
723
+						*crt='@'; crt++;
724
+					}
641 725
 					if(crt+len>end) goto error_uri;
642 726
 					memcpy(crt,tmp,len);crt+=len;
643 727
 				}
... ...
@@ -687,6 +771,22 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
687 771
 						memcpy(crt,tmp,len);crt+=len;
688 772
 					}
689 773
 				}
774
+				/* Add the user=phone param if a tel: or tels:
775
+				 * URI was converted to sip: or sips:.
776
+				 * (host part of a tel/tels URI was set.)
777
+				 * Or in case of sip: URI and SET_USERPHONE_T action */
778
+				if (((((uri.type==TEL_URI_T) || (uri.type==TELS_URI_T))
779
+					&& ((uri.flags & URI_SIP_USER_PHONE)==0))
780
+					&& ((a->type==SET_HOST_T)
781
+						|| (a->type==SET_HOSTPORT_T)
782
+						|| (a->type==SET_HOSTPORTTRANS_T)))
783
+					|| (a->type==SET_USERPHONE_T)
784
+				) {
785
+					tmp=";user=phone";
786
+					len=strlen(tmp);
787
+					if(crt+len>end) goto error_uri;
788
+					memcpy(crt,tmp,len);crt+=len;
789
+				}
690 790
 				/* headers */
691 791
 				tmp=uri.headers.s;
692 792
 				if (tmp){
... ...
@@ -77,6 +77,7 @@
77 77
  *  2008-01-24  added CFG_DESCRIPTION used by cfg_var (Miklos)
78 78
  *  2008-11-28  added support for kamailio pvars and avp/pvar guessing (andrei)
79 79
  *  2008-12-11  added support for "string1" "string2" (andrei)
80
+ *  2009-03-10  added SET_USERPHONE action (Miklos)
80 81
 */
81 82
 
82 83
 
... ...
@@ -183,6 +184,7 @@ REVERT_URI		"revert_uri"
183 184
 PREFIX			"prefix"
184 185
 STRIP			"strip"
185 186
 STRIP_TAIL		"strip_tail"
187
+SET_USERPHONE		"userphone"
186 188
 APPEND_BRANCH	"append_branch"
187 189
 IF				"if"
188 190
 ELSE			"else"
... ...
@@ -332,6 +334,8 @@ TCP_OPT_FD_CACHE	"tcp_fd_cache"
332 334
 TCP_OPT_BUF_WRITE	"tcp_buf_write"|"tcp_async"
333 335
 TCP_OPT_CONN_WQ_MAX	"tcp_conn_wq_max"
334 336
 TCP_OPT_WQ_MAX		"tcp_wq_max"
337
+TCP_OPT_RD_BUF		"tcp_rd_buf_size"
338
+TCP_OPT_WQ_BLK		"tcp_wq_blk_size"
335 339
 TCP_OPT_DEFER_ACCEPT "tcp_defer_accept"
336 340
 TCP_OPT_DELAYED_ACK	"tcp_delayed_ack"
337 341
 TCP_OPT_SYNCNT		"tcp_syncnt"
... ...
@@ -491,6 +495,8 @@ EAT_ABLE	[\ \t\b\r]
491 495
 <INITIAL>{STRIP_TAIL}	{ count(); yylval.strval=yytext; return STRIP_TAIL; }
492 496
 <INITIAL>{APPEND_BRANCH}	{ count(); yylval.strval=yytext;
493 497
 								return APPEND_BRANCH; }
498
+<INITIAL>{SET_USERPHONE}	{ count(); yylval.strval=yytext;
499
+								return SET_USERPHONE; }
494 500
 <INITIAL>{FORCE_RPORT}	{ count(); yylval.strval=yytext; return FORCE_RPORT; }
495 501
 <INITIAL>{FORCE_TCP_ALIAS}	{ count(); yylval.strval=yytext;
496 502
 								return FORCE_TCP_ALIAS; }
... ...
@@ -637,6 +643,10 @@ EAT_ABLE	[\ \t\b\r]
637 643
 									return TCP_OPT_CONN_WQ_MAX; }
638 644
 <INITIAL>{TCP_OPT_WQ_MAX}	{ count(); yylval.strval=yytext;
639 645
 									return TCP_OPT_WQ_MAX; }
646
+<INITIAL>{TCP_OPT_RD_BUF}	{ count(); yylval.strval=yytext;
647
+									return TCP_OPT_RD_BUF; }
648
+<INITIAL>{TCP_OPT_WQ_BLK}	{ count(); yylval.strval=yytext;
649
+									return TCP_OPT_WQ_BLK; }
640 650
 <INITIAL>{TCP_OPT_BUF_WRITE}	{ count(); yylval.strval=yytext;
641 651
 									return TCP_OPT_BUF_WRITE; }
642 652
 <INITIAL>{TCP_OPT_DEFER_ACCEPT}	{ count(); yylval.strval=yytext;
... ...
@@ -94,6 +94,7 @@
94 94
  * 2007-12-06  expression are now evaluated in terms of rvalues;
95 95
  *             NUMBER is now always positive; cleanup (andrei)
96 96
  * 2009-01-26  case/switch() support (andrei)
97
+ * 2009-03-10  added SET_USERPHONE action (Miklos)
97 98
 */
98 99
 
99 100
 %{
... ...
@@ -137,6 +138,7 @@
137 138
 #ifdef CORE_TLS
138 139
 #include "tls/tls_config.h"
139 140
 #endif
141
+#include "timer_ticks.h"
140 142
 
141 143
 #ifdef DEBUG_DMALLOC
142 144
 #include <dmalloc.h>
... ...
@@ -271,6 +273,7 @@ static int case_check_default(struct case_stms* stms);
271 273
 %token PREFIX
272 274
 %token STRIP
273 275
 %token STRIP_TAIL
276
+%token SET_USERPHONE
274 277
 %token APPEND_BRANCH
275 278
 %token SET_USER
276 279
 %token SET_USERPASS
... ...
@@ -396,6 +399,8 @@ static int case_check_default(struct case_stms* stms);
396 399
 %token TCP_OPT_BUF_WRITE
397 400
 %token TCP_OPT_CONN_WQ_MAX
398 401
 %token TCP_OPT_WQ_MAX
402
+%token TCP_OPT_RD_BUF
403
+%token TCP_OPT_WQ_BLK
399 404
 %token TCP_OPT_DEFER_ACCEPT
400 405
 %token TCP_OPT_DELAYED_ACK
401 406
 %token TCP_OPT_SYNCNT
... ...
@@ -839,7 +844,7 @@ assign_stm:
839 844
 	| TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
840 845
 	| TCP_SEND_TIMEOUT EQUAL intno {
841 846
 		#ifdef USE_TCP
842
-			tcp_default_cfg.send_timeout_s=$3;
847
+			tcp_default_cfg.send_timeout=S_TO_TICKS($3);
843 848
 		#else
844 849
 			warn("tcp support not compiled in");
845 850
 		#endif
... ...
@@ -847,7 +852,10 @@ assign_stm:
847 852
 	| TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
848 853
 	| TCP_CON_LIFETIME EQUAL intno {
849 854
 		#ifdef USE_TCP
850
-			tcp_default_cfg.con_lifetime_s=$3;
855
+			if ($3<0)
856
+				tcp_default_cfg.con_lifetime=-1;
857
+			else
858
+				tcp_default_cfg.con_lifetime=S_TO_TICKS($3);
851 859
 		#else
852 860
 			warn("tcp support not compiled in");
853 861
 		#endif
... ...
@@ -953,7 +961,23 @@ assign_stm:
953 961
 			warn("tcp support not compiled in");
954 962
 		#endif
955 963
 	}
956
-	| TCP_OPT_WQ_MAX error { yyerror("boolean value expected"); }
964
+	| TCP_OPT_WQ_MAX error { yyerror("number expected"); }
965
+	| TCP_OPT_RD_BUF EQUAL NUMBER {
966
+		#ifdef USE_TCP
967
+			tcp_default_cfg.rd_buf_size=$3;
968
+		#else
969
+			warn("tcp support not compiled in");
970
+		#endif
971
+	}
972
+	| TCP_OPT_RD_BUF error { yyerror("number expected"); }
973
+	| TCP_OPT_WQ_BLK EQUAL NUMBER {
974
+		#ifdef USE_TCP
975
+			tcp_default_cfg.wq_blk_size=$3;
976
+		#else
977
+			warn("tcp support not compiled in");
978
+		#endif
979
+	}
980
+	| TCP_OPT_WQ_BLK error { yyerror("number expected"); }
957 981
 	| TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
958 982
 		#ifdef USE_TCP
959 983
 			tcp_default_cfg.defer_accept=$3;
... ...
@@ -1315,10 +1339,10 @@ assign_stm:
1315 1339
 	| UDP_MTU EQUAL NUMBER { default_core_cfg.udp_mtu=$3; }
1316 1340
 	| UDP_MTU EQUAL error { yyerror("number expected"); }
1317 1341
 	| FORCE_RPORT EQUAL NUMBER 
1318
-		{ default_core_cfg.force_rport=$3; fix_global_req_flags(0); }
1342
+		{ default_core_cfg.force_rport=$3; fix_global_req_flags(0, 0); }
1319 1343
 	| FORCE_RPORT EQUAL error { yyerror("boolean value expected"); }
1320 1344
 	| UDP_MTU_TRY_PROTO EQUAL proto
1321
-		{ default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0); }
1345
+		{ default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0, 0); }
1322 1346
 	| UDP_MTU_TRY_PROTO EQUAL error
1323 1347
 		{ yyerror("TCP, TLS, SCTP or UDP expected"); }
1324 1348
 	| cfg_var
... ...
@@ -2546,6 +2570,8 @@ cmd:
2546 2570
 	| STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, 1, NUMBER_ST, (void*) $3); }
2547 2571
 	| STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
2548 2572
 	| STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2573
+	| SET_USERPHONE LPAREN RPAREN { $$=mk_action(SET_USERPHONE_T, 0); }
2574
+	| SET_USERPHONE error { $$=0; yyerror("missing '(' or ')' ?"); }
2549 2575
 	| APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
2550 2576
 		qvalue_t q;
2551 2577
 		if (str2q(&q, $5, strlen($5)) < 0) {
... ...
@@ -56,8 +56,8 @@
56 56
 /* variable is read-only */
57 57
 #define CFG_READONLY		(1U<<(2*CFG_INPUT_SHIFT+1))
58 58
 
59
-typedef int (*cfg_on_change)(void *, str *, void **);
60
-typedef void (*cfg_on_set_child)(str *);
59
+typedef int (*cfg_on_change)(void *, str *, str *, void **);
60
+typedef void (*cfg_on_set_child)(str *, str *);
61 61
 
62 62
 /* strutrure to be used by the module interface */
63 63
 typedef struct _cfg_def {
... ...
@@ -258,7 +258,7 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, str *var_name,
258 258
 	cfg_mapping_t	*var;
259 259
 	void		*p, *v;
260 260
 	cfg_block_t	*block = NULL;
261
-	str		s;
261
+	str		s, s2;
262 262
 	char		*old_string = NULL;
263 263
 	char		**replaced = NULL;
264 264
 	cfg_child_cb_t	*child_cb = NULL;
... ...
@@ -300,6 +300,7 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, str *var_name,
300 300
 		There is no need to set a temporary cfg handle,
301 301
 		becaue a single variable is changed */
302 302
 		if (var->def->on_change_cb(*(group->handle),
303
+						group_name,
303 304
 						var_name,
304 305
 						&v) < 0) {
305 306
 			LOG(L_ERR, "ERROR: cfg_set_now(): fixup failed\n");
... ...
@@ -311,9 +312,11 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, str *var_name,
311 312
 	if (var->def->on_set_child_cb) {
312 313
 		/* get the name of the variable from the internal struct,
313 314
 		because var_name may be freed before the callback needs it */
314
-		s.s = var->def->name;
315
-		s.len = var->name_len;
316
-		child_cb = cfg_child_cb_new(&s,
315
+		s.s = group->name;
316
+		s.len = group->name_len;
317
+		s2.s = var->def->name;
318
+		s2.len = var->name_len;
319
+		child_cb = cfg_child_cb_new(&s, &s2,
317 320
 					var->def->on_set_child_cb);
318 321
 		if (!child_cb) {
319 322
 			LOG(L_ERR, "ERROR: cfg_set_now(): not enough shm memory\n");
... ...
@@ -579,6 +582,7 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, str *var_name,
579 582
 		}
580 583
 			
581 584
 		if (var->def->on_change_cb(temp_handle,
585
+						group_name,
582 586
 						var_name,
583 587
 						&v) < 0) {
584 588
 			LOG(L_ERR, "ERROR: cfg_set_delayed(): fixup failed\n");
... ...
@@ -711,7 +715,7 @@ int cfg_commit(cfg_ctx_t *ctx)
711 715
 	cfg_child_cb_t	*child_cb_last = NULL;
712 716
 	int	size;
713 717
 	void	*p;
714
-	str	s;
718
+	str	s, s2;
715 719
 
716 720
 	if (!ctx) {
717 721
 		LOG(L_ERR, "ERROR: cfg_commit(): context is undefined\n");
... ...
@@ -740,9 +744,11 @@ int cfg_commit(cfg_ctx_t *ctx)
740 744
 
741 745
 
742 746
 		if (changed->var->def->on_set_child_cb) {
743
-			s.s = changed->var->def->name;
744
-			s.len = changed->var->name_len;
745
-			child_cb = cfg_child_cb_new(&s,
747
+			s.s = changed->group->name;
748
+			s.len = changed->group->name_len;
749
+			s2.s = changed->var->def->name;
750
+			s2.len = changed->var->name_len;
751
+			child_cb = cfg_child_cb_new(&s, &s2,
746 752
 					changed->var->def->on_set_child_cb);
747 753
 			if (!child_cb) goto error0;
748 754
 
... ...
@@ -317,7 +317,7 @@ int cfg_init(void)
317 317
 	This stucture will be the entry point for the child processes, and
318 318
 	will be freed later, when none of the processes refers to it */
319 319
 	*cfg_child_cb_first = *cfg_child_cb_last =
320
-		cfg_child_cb_new(NULL, NULL);
320
+		cfg_child_cb_new(NULL, NULL, NULL);
321 321
 
322 322
 	if (!*cfg_child_cb_first) goto error;
323 323
 
... ...
@@ -552,7 +552,7 @@ void cfg_install_global(cfg_block_t *block, char **replaced,
552 552
 }
553 553
 
554 554
 /* creates a structure for a per-child process callback */
555
-cfg_child_cb_t *cfg_child_cb_new(str *name, cfg_on_set_child cb)
555
+cfg_child_cb_t *cfg_child_cb_new(str *gname, str *name, cfg_on_set_child cb)
556 556
 {
557 557
 	cfg_child_cb_t	*cb_struct;
558 558
 
... ...
@@ -562,6 +562,10 @@ cfg_child_cb_t *cfg_child_cb_new(str *name, cfg_on_set_child cb)
562 562
 		return NULL;
563 563
 	}
564 564
 	memset(cb_struct, 0, sizeof(cfg_child_cb_t));
565
+	if (gname) {
566
+		cb_struct->gname.s = gname->s;
567
+		cb_struct->gname.len = gname->len;
568
+	}
565 569
 	if (name) {
566 570
 		cb_struct->name.s = name->s;
567 571
 		cb_struct->name.len = name->len;
... ...
@@ -98,7 +98,7 @@ typedef struct _cfg_block {
98 98
 typedef struct _cfg_child_cb {
99 99
 	atomic_t		refcnt; /* number of child processes
100 100
 					referring to the element */
101
-	str			name;	/* name of the variable that has changed */
101
+	str			gname, name;	/* name of the variable that has changed */
102 102
 	cfg_on_set_child	cb;	/* callback function that has to be called */
103 103
 
104 104
 	struct _cfg_child_cb	*next;
... ...
@@ -232,7 +232,7 @@ static inline void cfg_update_local(void)
232 232
 			}
233 233
 		}
234 234
 		/* execute the callback */
235
-		cfg_child_cb->cb(&cfg_child_cb->name);
235
+		cfg_child_cb->cb(&cfg_child_cb->gname, &cfg_child_cb->name);
236 236
 	}
237 237
 }
238 238
 
... ...
@@ -280,7 +280,7 @@ void cfg_install_global(cfg_block_t *block, char **replaced,
280 280
 			cfg_child_cb_t *cb_first, cfg_child_cb_t *cb_last);
281 281
 
282 282
 /* creates a structure for a per-child process callback */
283
-cfg_child_cb_t *cfg_child_cb_new(str *name, cfg_on_set_child cb);
283
+cfg_child_cb_t *cfg_child_cb_new(str *gname, str *name, cfg_on_set_child cb);
284 284
 
285 285
 /* free the memory allocated for a child cb list */
286 286
 void cfg_child_cb_free(cfg_child_cb_t *child_cb_first);
... ...
@@ -567,10 +567,10 @@ static void core_tcp_options(rpc_t* rpc, void* c)
567 567
 	if (!tcp_disable){
568 568
 		tcp_options_get(&t);
569 569
 		rpc->add(c, "{", &handle);
570
-		rpc->struct_add(handle, "ddddddddddddddddddddddd",
570
+		rpc->struct_add(handle, "dddddddddddddddddddddd",
571 571
 			"connect_timeout", t.connect_timeout_s,
572
-			"send_timeout",  t.send_timeout_s,
573
-			"connection_lifetime",  t.con_lifetime_s,
572
+			"send_timeout",  TICKS_TO_S(t.send_timeout),
573
+			"connection_lifetime",  TICKS_TO_S(t.con_lifetime),
574 574
 			"max_connections(soft)", t.max_connections,
575 575
 			"no_connect",	t.no_connect,
576 576
 			"fd_cache",		t.fd_cache,
... ...
@@ -578,7 +578,6 @@ static void core_tcp_options(rpc_t* rpc, void* c)
578 578
 			"connect_wait",	t.tcp_connect_wait,
579 579
 			"conn_wq_max",	t.tcpconn_wq_max,
580 580
 			"wq_max",		t.tcp_wq_max,
581
-			"wq_timeout",	TICKS_TO_S(t.tcp_wq_timeout),
582 581
 			"defer_accept",	t.defer_accept,
583 582
 			"delayed_ack",	t.delayed_ack,
584 583
 			"syncnt",		t.syncnt,
... ...
@@ -265,7 +265,7 @@ void destroy_dns_cache()
265 265
 }
266 266
 
267 267
 /* set the value of dns_flags */
268
-void fix_dns_flags(str *name)
268
+void fix_dns_flags(str *gname, str *name)
269 269
 {
270 270
 	/* restore the original value of dns_cache_flags first
271 271
 	 * (DNS_IPV4_ONLY may have been set only because dns_try_ipv6
... ...
@@ -300,7 +300,7 @@ void fix_dns_flags(str *name)
300 300
 /* fixup function for use_dns_failover
301 301
  * verifies that use_dns_cache is set to 1
302 302
  */
303
-int use_dns_failover_fixup(void *handle, str *name, void **val)
303
+int use_dns_failover_fixup(void *handle, str *gname, str *name, void **val)
304 304
 {
305 305
 	if ((int)(long)(*val) && !cfg_get(core, handle, use_dns_cache)) {
306 306
 		LOG(L_ERR, "ERROR: use_dns_failover_fixup(): "
... ...
@@ -314,7 +314,7 @@ int use_dns_failover_fixup(void *handle, str *name, void **val)
314 314
 /* fixup function for use_dns_cache
315 315
  * verifies that dns_cache_init is set to 1
316 316
  */
317
-int use_dns_cache_fixup(void *handle, str *name, void **val)
317
+int use_dns_cache_fixup(void *handle, str *gname, str *name, void **val)
318 318
 {
319 319
 	if ((int)(long)(*val) && !dns_cache_init) {
320 320
 		LOG(L_ERR, "ERROR: use_dns_cache_fixup(): "
... ...
@@ -332,7 +332,7 @@ int use_dns_cache_fixup(void *handle, str *name, void **val)
332 332
 }
333 333
 
334 334
 /* KByte to Byte conversion */
335
-int dns_cache_max_mem_fixup(void *handle, str *name, void **val)
335
+int dns_cache_max_mem_fixup(void *handle, str *gname, str *name, void **val)
336 336
 {
337 337
 	unsigned int    u;
338 338
 
... ...
@@ -407,7 +407,7 @@ int init_dns_cache()
407 407
 	if (default_core_cfg.use_dns_cache==0)
408 408
 		default_core_cfg.use_dns_failover=0; /* cannot work w/o dns_cache support */
409 409
 	/* fix flags */
410
-	fix_dns_flags(NULL);
410
+	fix_dns_flags(NULL, NULL);
411 411
 
412 412
 	dns_timer_h=timer_alloc();
413 413
 	if (dns_timer_h==0){
... ...
@@ -178,10 +178,10 @@ struct dns_srv_handle{
178 178
 
179 179
 const char* dns_strerror(int err);
180 180
 
181
-void fix_dns_flags(str *name);
182
-int use_dns_failover_fixup(void *handle, str *name, void **val);
183
-int use_dns_cache_fixup(void *handle, str *name, void **val);
184
-int dns_cache_max_mem_fixup(void *handle, str *name, void **val);
181
+void fix_dns_flags(str *gname, str *name);
182
+int use_dns_failover_fixup(void *handle, str *gname, str *name, void **val);
183
+int use_dns_cache_fixup(void *handle, str *gname, str *name, void **val);
184
+int dns_cache_max_mem_fixup(void *handle, str *gname, str *name, void **val);
185 185
 int init_dns_cache();
186 186
 #ifdef USE_DNS_CACHE_STATS
187 187
 int init_dns_cache_stats(int iproc_num);
... ...
@@ -129,7 +129,7 @@ Each row consists of the following items:
129 129
   handle within the fixup function. String and str values are cloned to
130 130
   shm memory by the framework. The callback type is:
131 131
 
132
-  typedef int (*cfg_on_change)(void *temp_handle, str *var_name, void **value);
132
+  typedef int (*cfg_on_change)(void *temp_handle, str *group_name, str *var_name, void **value);
133 133
 
134 134
 - per-child process callback function (optional) that is called by each child
135 135
   process separately, after the new values have been committed, and the
... ...
@@ -137,7 +137,7 @@ Each row consists of the following items:
137 137
   longer be used by the process. (Useful for fix-ups that cannot be done
138 138
   in shm memory, for example regexp compilation.)
139 139
 
140
-  typedef void (*cfg_on_set_child)(str *var_name);
140
+  typedef void (*cfg_on_set_child)(str *group_name, str *var_name);
141 141
 
142 142
 - description of the variable
143 143
 
... ...
@@ -84,7 +84,7 @@ int str2facility(char *s)
84 84
 }
85 85
 
86 86
 /* fixup function for log_facility cfg parameter */
87
-int log_facility_fixup(void *handle, str *name, void **val)
87
+int log_facility_fixup(void *handle, str *gname, str *name, void **val)
88 88
 {
89 89
 	int	i;
90 90
 
... ...
@@ -115,7 +115,7 @@ extern volatile int dprint_crit;
115 115
 #endif
116 116
 
117 117
 int str2facility(char *s);
118
-int log_facility_fixup(void *handle, str *name, void **val);
118
+int log_facility_fixup(void *handle, str *gname, str *name, void **val);
119 119
 
120 120
 
121 121
 /*
... ...
@@ -1176,7 +1176,7 @@ void dst_blst_add(rpc_t* rpc, void* ctx)
1176 1176
 /* fixup function for use_dst_blacklist
1177 1177
  * verifies that dst_blacklist_init is set to 1
1178 1178
  */
1179
-int use_dst_blacklist_fixup(void *handle, str *name, void **val)
1179
+int use_dst_blacklist_fixup(void *handle, str *gname, str *name, void **val)
1180 1180
 {
1181 1181
 	if ((int)(long)(*val) && !dst_blacklist_init) {
1182 1182
 		LOG(L_ERR, "ERROR: use_dst_blacklist_fixup(): "
... ...
@@ -1188,7 +1188,7 @@ int use_dst_blacklist_fixup(void *handle, str *name, void **val)
1188 1188
 }
1189 1189
 
1190 1190
 /* KByte to Byte conversion */
1191
-int blst_max_mem_fixup(void *handle, str *name, void **val)
1191
+int blst_max_mem_fixup(void *handle, str *gname, str *name, void **val)
1192 1192
 {
1193 1193
 	unsigned int	u;
1194 1194
 
... ...
@@ -116,8 +116,8 @@ int dst_blacklist_del(struct dest_info* si, struct sip_msg* msg);
116 116
  */
117 117
 void dst_blst_flush(void);
118 118
 
119
-int use_dst_blacklist_fixup(void *handle, str *name, void **val);
119
+int use_dst_blacklist_fixup(void *handle, str *gname, str *name, void **val);
120 120
 /* KByte to Byte conversion */
121
-int blst_max_mem_fixup(void *handle, str *name, void **val);
121
+int blst_max_mem_fixup(void *handle, str *gname, str *name, void **val);
122 122
 
123 123
 #endif
... ...
@@ -392,7 +392,7 @@ int cancel_b_flags_get(unsigned int* f, int m)
392 392
 
393 393
 /* fixup function for the default cancel branch method/flags
394 394
  * (called by the configuration framework) */
395
-int cancel_b_flags_fixup(void* handle, str* name, void** val)
395
+int cancel_b_flags_fixup(void* handle, str* gname, str* name, void** val)
396 396
 {
397 397
 	unsigned int m,f;
398 398
 	int ret;
... ...
@@ -115,7 +115,7 @@ inline short static should_cancel_branch( struct cell *t, int b, int noreply )
115 115
 
116 116
 const char* rpc_cancel_doc[2];
117 117
 void rpc_cancel(rpc_t* rpc, void* c);
118
-int cancel_b_flags_fixup(void* handle, str* name, void** val);
118
+int cancel_b_flags_fixup(void* handle, str* gname, str* name, void** val);
119 119
 int cancel_b_flags_get(unsigned int* f, int m);
120 120
 
121 121
 #endif
... ...
@@ -1299,7 +1299,7 @@ int t_replicate(struct sip_msg *p_msg,  struct proxy_l *proxy, int proto )
1299 1299
 }
1300 1300
 
1301 1301
 /* fixup function for reparse_on_dns_failover modparam */
1302
-int reparse_on_dns_failover_fixup(void *handle, str *name, void **val)
1302
+int reparse_on_dns_failover_fixup(void *handle, str *gname, str *name, void **val)
1303 1303
 {
1304 1304
 #ifdef USE_DNS_FAILOVER
1305 1305
 	if ((int)(long)(*val) && mhomed) {
... ...
@@ -76,7 +76,7 @@ int t_send_branch( struct cell *t, int branch, struct sip_msg* p_msg ,
76 76
 					struct proxy_l * proxy, int lock_replies);
77 77
 int t_relay_cancel(struct sip_msg* p_msg);
78 78
 
79
-int reparse_on_dns_failover_fixup(void *handle, str *name, void **val);
79
+int reparse_on_dns_failover_fixup(void *handle, str *gname, str *name, void **val);
80 80
 
81 81
 #endif
82 82
 
... ...
@@ -233,7 +233,7 @@ error:
233 233
 /* fixup function for the timer values
234 234
  * (called by the configuration framework)
235 235
  */
236
-int timer_fixup(void *handle, str *name, void **val)
236
+int timer_fixup(void *handle, str *gname, str *name, void **val)
237 237
 {
238 238
 	ticks_t	t;
239 239
 
... ...
@@ -79,7 +79,7 @@ extern struct msgid_var user_noninv_max_lifetime;
79 79
 
80 80
 
81 81
 extern int tm_init_timers();
82
-int timer_fixup(void *handle, str *name, void **val);
82
+int timer_fixup(void *handle, str *gname, str *name, void **val);
83 83
 
84 84
 ticks_t wait_handler(ticks_t t, struct timer_ln *tl, void* data);
85 85
 ticks_t retr_buf_handler(ticks_t t, struct timer_ln *tl, void* data);
... ...
@@ -163,7 +163,7 @@ static unsigned int global_req_flags=0;
163 163
 /** per process fixup function for global_req_flags.
164 164
   * It should be called from the configuration framework.
165 165
   */
166