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 203
 # hack to force makefile.defs re-inclusion (needed when make calls itself with
204 204
 # other options -- e.g. make bin)
205 205
 #makefile_defs=0
206
-#DEFS:=
206
+#C_DEFS:=
207 207
 
208 208
 
209 209
 # try saved cfg, unless we are in the process of building it
... ...
@@ -331,7 +333,7 @@ config.mak: Makefile.defs
331 331
 	@$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
332 332
 	@$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
333 333
 	@echo "override makefile_defs:=1" >>$@
334
-	@echo "DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(DEFS))" \
334
+	@echo "C_DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(C_DEFS))" \
335 335
 					"\$$(extra_defs)"  >>$@
336 336
 	@echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
337 337
 						"\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
... ...
@@ -538,7 +540,8 @@ man: modules.lst
538 538
 	done; true
539 539
 
540 540
 .PHONY: install
541
-install:all install-bin install-modules install-cfg \
541
+install: export compile_for_install=yes
542
+install: install-bin install-modules install-cfg \
542 543
 	install-doc install-man install-utils install-share
543 544
 
544 545
 .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 460
 #		adds support for Application Server interface
461 461
 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
462 462
 
463
-DEFS= $(extra_defs) \
463
+C_DEFS= $(extra_defs) \
464 464
 	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
465 465
 	 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
466 466
 	 -DSER_VER=$(SER_VER) \
... ...
@@ -507,14 +510,14 @@ DEFS= $(extra_defs) \
507 507
 # debugging symbols in all cases (-g). --andrei
508 508
 
509 509
 ifeq ($(CORE_TLS), 1)
510
-	DEFS+= -DUSE_TLS -DCORE_TLS
510
+	C_DEFS+= -DUSE_TLS -DCORE_TLS
511 511
 endif
512 512
 ifeq ($(TLS_HOOKS), 1)
513
-	DEFS+= -DUSE_TLS -DTLS_HOOKS
513
+	C_DEFS+= -DUSE_TLS -DTLS_HOOKS
514 514
 endif
515 515
 
516 516
 ifneq ($(STUN),)
517
-	DEFS+= -DUSE_STUN
517
+	C_DEFS+= -DUSE_STUN
518 518
 endif
519 519
 
520 520
 ifeq ($(mode),)
... ...
@@ -522,7 +525,7 @@ ifeq ($(mode),)
522 522
 endif
523 523
 
524 524
 ifeq ($(mode),debug)
525
-	DEFS+= -DEXTRA_DEBUG
525
+	C_DEFS+= -DEXTRA_DEBUG
526 526
 endif
527 527
 
528 528
 # platform dependent settings
... ...
@@ -598,7 +601,7 @@ endif
598 598
 
599 599
 ifeq ($(ARCH), arm)
600 600
 	use_fast_lock=yes
601
-	DEFS+=-DNOSMP # very unlikely to have an smp arm
601
+	C_DEFS+=-DNOSMP # very unlikely to have an smp arm
602 602
 endif
603 603
 
604 604
 ifeq ($(ARCH), arm6)
... ...
@@ -616,8 +619,8 @@ endif
616 616
 ifeq ($(ARCH), mips)
617 617
 # mips1 arch. (e.g. R3000) - no hardware locking support
618 618
 	use_fast_lock=no
619
-	DEFS+=-DMIPS_HAS_LLSC # likely
620
-	DEFS+=-DNOSMP # very likely
619
+	C_DEFS+=-DMIPS_HAS_LLSC # likely
620
+	C_DEFS+=-DNOSMP # very likely
621 621
 endif
622 622
 
623 623
 ifeq ($(ARCH), mips2)
... ...
@@ -632,24 +635,24 @@ endif
632 632
 
633 633
 ifeq ($(ARCH), alpha)
634 634
 	use_fast_lock=yes
635
-	DEFS+=-DNOSMP # very likely
635
+	C_DEFS+=-DNOSMP # very likely
636 636
 endif
637 637
 
638 638
 ifeq ($(use_fast_lock), yes)
639
-	DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
639
+	C_DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
640 640
 	found_lock_method=yes
641 641
 endif
642 642
 
643 643
 CFLAGS=
644 644
 LDFLAGS=
645
-INCLUDES=
645
+C_INCLUDES=
646 646
 # setting CFLAGS
647 647
 ifeq ($(mode), release)
648 648
 	#if i386
649 649
 ifeq	($(ARCH), i386)
650 650
 		# if gcc 
651 651
 ifeq		($(CC_NAME), gcc)
652
-				DEFS+=-DCC_GCC_LIKE_ASM
652
+				C_DEFS+=-DCC_GCC_LIKE_ASM
653 653
 				#common stuff
654 654
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
655 655
 			#if gcc 4.0+
... ...
@@ -692,7 +695,7 @@ endif			# CC_SHORTVER, 4.x
692 692
 
693 693
 else		# CC_NAME, gcc
694 694
 ifeq		($(CC_NAME), icc)
695
-			DEFS+=-DCC_GCC_LIKE_ASM
695
+			C_DEFS+=-DCC_GCC_LIKE_ASM
696 696
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
697 697
 					 -tpp6 -xK  #-openmp  #optimize for PIII 
698 698
 				# -prefetch doesn't seem to work
... ...
@@ -710,7 +713,7 @@ endif	#ARCH, i386
710 710
 ifeq	($(ARCH), x86_64)
711 711
 		# if gcc 
712 712
 ifeq		($(CC_NAME), gcc)
713
-				DEFS+=-DCC_GCC_LIKE_ASM
713
+				C_DEFS+=-DCC_GCC_LIKE_ASM
714 714
 				#common stuff
715 715
 				CFLAGS=-m64 -g -O9 -funroll-loops  -Wcast-align $(PROFILE)
716 716
 				LDFLAGS+=-m64
... ...
@@ -754,7 +757,7 @@ endif			# CC_SHORTVER, 4.x
754 754
 
755 755
 else		# CC_NAME, gcc
756 756
 ifeq		($(CC_NAME), icc)
757
-			DEFS+=-DCC_GCC_LIKE_ASM
757
+			C_DEFS+=-DCC_GCC_LIKE_ASM
758 758
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
759 759
 					 -tpp6 -xK  #-openmp  #optimize for PIII 
760 760
 				# -prefetch doesn't seem to work
... ...
@@ -772,7 +775,7 @@ endif	#ARCH, x86_64
772 772
 ifeq	($(ARCH), sparc64)
773 773
 			#if gcc
774 774
 ifeq		($(CC_NAME), gcc)
775
-				DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
775
+				C_DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
776 776
 				#common stuff
777 777
 				CFLAGS=-m64 -g -O9 -funroll-loops  $(PROFILE) \
778 778
 					#-Wcast-align \
... ...
@@ -834,7 +837,7 @@ endif			#CC_SHORTVER, 4.x
834 834
 	
835 835
 else		#CC_NAME, gcc
836 836
 ifeq		($(CC_NAME), suncc)
837
-			DEFS+=-DSPARC64_MODE
837
+			C_DEFS+=-DSPARC64_MODE
838 838
 			CFLAGS+= -m64 -g -xO5 -fast -native -xarch=v9 -xCC \
839 839
 					-xc99 # C99 support
840 840
 			# -Dinline="" # add this if cc < 5.3 (define inline as null)
... ...
@@ -849,7 +852,7 @@ endif	#ARCH, sparc64
849 849
 ifeq	($(ARCH), sparc)
850 850
 			#if gcc
851 851
 ifeq		($(CC_NAME), gcc)
852
-				DEFS+=-DCC_GCC_LIKE_ASM
852
+				C_DEFS+=-DCC_GCC_LIKE_ASM
853 853
 				#common stuff
854 854
 				CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
855 855
 					#-Wcast-align \
... ...
@@ -906,7 +909,7 @@ endif	#ARCH, sparc
906 906
 ifeq	($(ARCH), arm)
907 907
 		# if gcc 
908 908
 ifeq		($(CC_NAME), gcc)
909
-				DEFS+=-DCC_GCC_LIKE_ASM
909
+				C_DEFS+=-DCC_GCC_LIKE_ASM
910 910
 				#common stuff
911 911
 				CFLAGS=-O9 -funroll-loops $(PROFILE)
912 912
 			#if gcc 4.x+
... ...
@@ -948,7 +951,7 @@ endif	#ARCH, arm
948 948
 ifeq	($(ARCH), arm6)
949 949
 		# if gcc 
950 950
 ifeq		($(CC_NAME), gcc)
951
-				DEFS+=-DCC_GCC_LIKE_ASM
951
+				C_DEFS+=-DCC_GCC_LIKE_ASM
952 952
 				#common stuff
953 953
 				CFLAGS=-march=armv6 -O9 -funroll-loops \
954 954
 						$(PROFILE)
... ...
@@ -990,7 +993,7 @@ endif	#ARCH, arm6
990 990
 ifeq	($(ARCH), mips)
991 991
 		# if gcc 
992 992
 ifeq		($(CC_NAME), gcc)
993
-				DEFS+=-DCC_GCC_LIKE_ASM
993
+				C_DEFS+=-DCC_GCC_LIKE_ASM
994 994
 				#common stuff
995 995
 				CFLAGS=-O9 -funroll-loops  $(PROFILE)
996 996
 			#if gcc 4.0+
... ...
@@ -1031,7 +1034,7 @@ endif	#ARCH, mips
1031 1031
 ifeq	($(ARCH), mips2)
1032 1032
 		# if gcc 
1033 1033
 ifeq		($(CC_NAME), gcc)
1034
-				DEFS+=-DCC_GCC_LIKE_ASM
1034
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1035 1035
 				#common stuff
1036 1036
 				CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
1037 1037
 			#if gcc 4.0+
... ...
@@ -1070,7 +1073,7 @@ endif	#ARCH, mips2
1070 1070
 ifeq	($(ARCH), mips64)
1071 1071
 		# if gcc 
1072 1072
 ifeq		($(CC_NAME), gcc)
1073
-				DEFS+=-DCC_GCC_LIKE_ASM
1073
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1074 1074
 				#common stuff
1075 1075
 				CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
1076 1076
 			#if gcc 4.0+
... ...
@@ -1109,7 +1112,7 @@ endif	#ARCH, mips64
1109 1109
 ifeq	($(ARCH), alpha)
1110 1110
 		# if gcc 
1111 1111
 ifeq		($(CC_NAME), gcc)
1112
-				DEFS+=-DCC_GCC_LIKE_ASM
1112
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1113 1113
 				#common stuff
1114 1114
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
1115 1115
 			#if gcc 4.0+
... ...
@@ -1149,7 +1152,7 @@ endif	#ARCH, alpha
1149 1149
 ifeq	($(ARCH), ppc)
1150 1150
 		# if gcc 
1151 1151
 ifeq		($(CC_NAME), gcc)
1152
-				DEFS+=-DCC_GCC_LIKE_ASM
1152
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1153 1153
 				#common stuff
1154 1154
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
1155 1155
 			#if gcc 4.0+
... ...
@@ -1190,7 +1193,7 @@ endif	#ARCH, ppc
1190 1190
 ifeq	($(ARCH), ppc64)
1191 1191
 		# if gcc 
1192 1192
 ifeq		($(CC_NAME), gcc)
1193
-				DEFS+=-DCC_GCC_LIKE_ASM
1193
+				C_DEFS+=-DCC_GCC_LIKE_ASM
1194 1194
 				#common stuff
1195 1195
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
1196 1196
 ifeq			($(CC_SHORTVER), 4.x)
... ...
@@ -1269,9 +1272,9 @@ endif
1269 1269
 else	#mode,release
1270 1270
 ifeq	($(CC_NAME), gcc)
1271 1271
 		CFLAGS=-g -Wcast-align $(PROFILE)
1272
-		DEFS+=-DCC_GCC_LIKE_ASM
1272
+		C_DEFS+=-DCC_GCC_LIKE_ASM
1273 1273
 ifeq		($(ARCH), sparc64)
1274
-			DEFS+=SPARC64_MODE
1274
+			C_DEFS+=SPARC64_MODE
1275 1275
 			CFLAGS+= -mcpu=ultrasparc -m64
1276 1276
 			LDFLAGS+=-m64
1277 1277
 endif
... ...
@@ -1292,7 +1295,7 @@ else
1292 1292
 endif
1293 1293
 endif
1294 1294
 ifeq	($(CC_NAME), icc)
1295
-		DEFS+=-DCC_GCC_LIKE_ASM
1295
+		C_DEFS+=-DCC_GCC_LIKE_ASM
1296 1296
 		CFLAGS=-g  $(PROFILE)
1297 1297
 		LDFLAGS+=-g -Wl,-E $(PROFILE)
1298 1298
 		MOD_LDFLAGS:=-shared $(LDFLAGS)
... ...
@@ -1357,27 +1360,27 @@ LIB_SUFFIX:=.so
1357 1357
 ifeq ($(OS), linux)
1358 1358
 # by default use futexes if available
1359 1359
 	use_futex= yes
1360
-	DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1360
+	C_DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1361 1361
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1362 1362
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1363 1363
 	ifneq ($(found_lock_method), yes)
1364
-		#DEFS+= -DUSE_POSIX_SEM
1365
-		DEFS+=-DUSE_PTHREAD_MUTEX
1364
+		#C_DEFS+= -DUSE_POSIX_SEM
1365
+		C_DEFS+=-DUSE_PTHREAD_MUTEX
1366 1366
 		LIBS+= -lpthread
1367
-		#DEFS+= -DUSE_SYSV_SEM  # try posix sems
1367
+		#C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
1368 1368
 		found_lock_method=yes
1369 1369
 	else
1370
-		ifneq (,$(findstring -DUSE_POSIX_SEM, $(DEFS)))
1370
+		ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1371 1371
 			LIBS+=-lpthread
1372 1372
 		endif
1373
-		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(DEFS)))
1373
+		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1374 1374
 			LIBS+=-lpthread
1375 1375
 		endif
1376 1376
 	endif
1377 1377
 	# check for >= 2.5.44
1378 1378
 	ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
1379 1379
 		ifeq ($(NO_EPOLL),)
1380
-			DEFS+=-DHAVE_EPOLL
1380
+			C_DEFS+=-DHAVE_EPOLL
1381 1381
 			# linux + gcc >= 3.0 + -malign-double + epoll => problems
1382 1382
 			CFLAGS_RM+=-malign-double
1383 1383
 			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
... ...
@@ -1386,17 +1389,17 @@ ifeq ($(OS), linux)
1386 1386
 	# check for >= 2.2.0
1387 1387
 	ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
1388 1388
 		ifeq ($(NO_SIGIO),)
1389
-			DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1389
+			C_DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1390 1390
 		endif
1391 1391
 	endif
1392 1392
 	# check for >= 2.5.70
1393 1393
 	ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
1394 1394
 		ifeq ($(use_futex), yes)
1395
-			DEFS+=-DUSE_FUTEX
1395
+			C_DEFS+=-DUSE_FUTEX
1396 1396
 		endif
1397 1397
 	endif
1398 1398
 	ifeq ($(NO_SELECT),)
1399
-		DEFS+=-DHAVE_SELECT
1399
+		C_DEFS+=-DHAVE_SELECT
1400 1400
 	endif
1401 1401
 	# sctp support
1402 1402
 	ifeq ($(SCTP),1)
... ...
@@ -1418,27 +1421,27 @@ $(info "sctp libraries not installed -- sctp disabled")
1418 1418
 		
1419 1419
 		ifeq ($(SCTP),1)
1420 1420
 			# use lksctp
1421
-			DEFS+=-DUSE_SCTP
1421
+			C_DEFS+=-DUSE_SCTP
1422 1422
 			LIBS+=-lsctp
1423 1423
 		endif
1424 1424
 	endif # SCTP
1425 1425
 endif
1426 1426
 
1427 1427
 ifeq  ($(OS), solaris)
1428
-	DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1428
+	C_DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1429 1429
 			-DHAVE_ALLOCA_H -DUSE_SIGACTION
1430 1430
 	ifneq ($(found_lock_method), yes)
1431
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1431
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1432 1432
 		found_lock_method=yes
1433 1433
 	endif
1434 1434
 	# check for ver >= 5.7
1435 1435
 	ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
1436 1436
 		ifeq ($(NO_DEVPOLL),)
1437
-			DEFS+=-DHAVE_DEVPOLL
1437
+			C_DEFS+=-DHAVE_DEVPOLL
1438 1438
 		endif
1439 1439
 	endif
1440 1440
 	ifeq ($(NO_SELECT),)
1441
-		DEFS+=-DHAVE_SELECT
1441
+		C_DEFS+=-DHAVE_SELECT
1442 1442
 	endif
1443 1443
 	# check for filio.h
1444 1444
 	filio_h_locations= /usr/include/sys/filio.h \
... ...
@@ -1448,7 +1451,7 @@ ifeq  ($(OS), solaris)
1448 1448
 						done;\
1449 1449
 				)
1450 1450
 	ifeq ($(has_filio_h), yes)
1451
-		DEFS+=-DHAVE_FILIO_H
1451
+		C_DEFS+=-DHAVE_FILIO_H
1452 1452
 	endif
1453 1453
 	ifeq ($(mode), release)
1454 1454
 		#use these only if you're using gcc with Solaris ld
... ...
@@ -1475,12 +1478,12 @@ endif
1475 1475
 endif
1476 1476
 
1477 1477
 ifeq ($(OS), freebsd)
1478
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1478
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1479 1479
 		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1480 1480
 		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1481 1481
 		-DHAVE_NETINET_IN_SYSTM
1482 1482
 	ifneq ($(found_lock_method), yes)
1483
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1483
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1484 1484
 		found_lock_method=yes
1485 1485
 		LIBS+= -pthread   #dlopen is in libc
1486 1486
 	else
... ...
@@ -1489,11 +1492,11 @@ ifeq ($(OS), freebsd)
1489 1489
 	# check for ver >= 4.1
1490 1490
 	ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
1491 1491
 		ifeq ($(NO_KQUEUE),)
1492
-			DEFS+=-DHAVE_KQUEUE
1492
+			C_DEFS+=-DHAVE_KQUEUE
1493 1493
 		endif
1494 1494
 	endif
1495 1495
 	ifeq ($(NO_SELECT),)
1496
-		DEFS+=-DHAVE_SELECT
1496
+		C_DEFS+=-DHAVE_SELECT
1497 1497
 	endif
1498 1498
 	YACC=yacc
1499 1499
 	# sctp support
... ...
@@ -1512,29 +1515,29 @@ $(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
1512 1512
 		endif
1513 1513
 		
1514 1514
 		ifeq ($(SCTP),1)
1515
-			DEFS+=-DUSE_SCTP
1515
+			C_DEFS+=-DUSE_SCTP
1516 1516
 			LIBS+=  # no extra libs needed on freebsd
1517 1517
 		endif
1518 1518
 	endif # SCTP
1519 1519
 endif
1520 1520
 
1521 1521
 ifeq ($(OS), openbsd)
1522
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
1522
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
1523 1523
 		-DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
1524 1524
 		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1525 1525
 		-DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT
1526 1526
 	ifneq ($(found_lock_method), yes)
1527
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1527
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1528 1528
 		found_lock_method=yes
1529 1529
 	endif
1530 1530
 	# check for ver >=2 9
1531 1531
 	ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
1532 1532
 		ifeq ($(NO_KQUEUE),)
1533
-			DEFS+=-DHAVE_KQUEUE
1533
+			C_DEFS+=-DHAVE_KQUEUE
1534 1534
 		endif
1535 1535
 	endif
1536 1536
 	ifeq ($(NO_SELECT),)
1537
-		DEFS+=-DHAVE_SELECT
1537
+		C_DEFS+=-DHAVE_SELECT
1538 1538
 	endif
1539 1539
 	# (symbols on openbsd are prefixed by "_")
1540 1540
 	YACC=yacc
... ...
@@ -1554,29 +1557,29 @@ endif
1554 1554
 endif
1555 1555
 	
1556 1556
 ifeq ($(OPENBSD_IS_AOUT), yes)
1557
-		DEFS+=-DDLSYM_PREFIX='"_"'
1557
+		C_DEFS+=-DDLSYM_PREFIX='"_"'
1558 1558
 		LDFLAGS=        # openbsd ld doesn't like -O2 or -E
1559 1559
 endif
1560 1560
 endif   # if opensd
1561 1561
 	
1562 1562
 ifeq ($(OS), netbsd)
1563
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1563
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1564 1564
 		-DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
1565 1565
 	ifneq ($(found_lock_method), yes)
1566
-		DEFS+= -DUSE_SYSV_SEM  # try pthread sems
1566
+		C_DEFS+= -DUSE_SYSV_SEM  # try pthread sems
1567 1567
 		found_lock_method=yes
1568 1568
 	endif
1569 1569
 	# check for ver >= 2.0.0
1570 1570
 	ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
1571 1571
 		ifeq ($(NO_KQUEUE),)
1572
-			DEFS+=-DHAVE_KQUEUE
1572
+			C_DEFS+=-DHAVE_KQUEUE
1573 1573
 			# netbsd + kqueue and -malign-double don't work
1574 1574
 			CFLAGS_RM+=-malign-double
1575 1575
 			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1576 1576
 		endif
1577 1577
 	endif
1578 1578
 	ifeq ($(NO_SELECT),)
1579
-		DEFS+=-DHAVE_SELECT
1579
+		C_DEFS+=-DHAVE_SELECT
1580 1580
 	endif
1581 1581
 	YACC=yacc
1582 1582
 	LIBS=  
... ...
@@ -1584,7 +1587,7 @@ endif
1584 1584
 
1585 1585
 # OS X support, same as freebsd
1586 1586
 ifeq ($(OS), darwin)
1587
-	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1587
+	C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1588 1588
 		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1589 1589
 		-DUSE_ANON_MMAP \
1590 1590
 		-DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
... ...
@@ -1592,18 +1595,18 @@ ifeq ($(OS), darwin)
1592 1592
 	# -DNDEBUG used to turn off assert (assert wants to call
1593 1593
 	# eprintf which doesn't seem to be defined in any shared lib
1594 1594
 	ifneq ($(found_lock_method), yes)
1595
-		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1595
+		C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1596 1596
 		found_lock_method=yes
1597
-		DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
1597
+		C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
1598 1598
 		                       # processes and unnamed posix sems are not
1599 1599
 		                       # supported)
1600 1600
 	endif
1601 1601
 	LIBS= -lresolv  #dlopen is in libc
1602 1602
 	ifeq ($(NO_KQUEUE),)
1603
-		DEFS+=-DHAVE_KQUEUE
1603
+		C_DEFS+=-DHAVE_KQUEUE
1604 1604
 	endif
1605 1605
 	ifeq ($(NO_SELECT),)
1606
-		DEFS+=-DHAVE_SELECT
1606
+		C_DEFS+=-DHAVE_SELECT
1607 1607
 	endif
1608 1608
 	LDFLAGS=        # darwin doesn't like -O2 or -E
1609 1609
 	# the modules uses symbols from ser => either 
... ...
@@ -1621,34 +1624,34 @@ endif
1621 1621
 
1622 1622
 ifneq (,$(findstring cygwin, $(OS)))
1623 1623
 	# cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
1624
-	#DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS))
1624
+	#C_DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(C_DEFS))
1625 1625
 	DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
1626
-	DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1626
+	C_DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1627 1627
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1628 1628
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1629 1629
 	ifneq ($(found_lock_method), yes)
1630
-		DEFS+= -DUSE_POSIX_SEM
1631
-		#DEFS+= -DUSE_SYSV_SEM  # try posix sems
1630
+		C_DEFS+= -DUSE_POSIX_SEM
1631
+		#C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
1632 1632
 		# PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
1633 1633
 		#LIBS+= -lpthread
1634 1634
 		found_lock_method=yes
1635 1635
 	else
1636
-		ifneq (,$(findstring -DUSE_POSIX_SEM, $(DEFS)))
1636
+		ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1637 1637
 			#LIBS+=-lpthread
1638 1638
 		endif
1639
-		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(DEFS)))
1639
+		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1640 1640
 $(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
1641 1641
 		endif
1642 1642
 	endif
1643 1643
 	# check for >= 2.5.70
1644 1644
 	ifeq ($(NO_SELECT),)
1645
-		DEFS+=-DHAVE_SELECT
1645
+		C_DEFS+=-DHAVE_SELECT
1646 1646
 	endif
1647 1647
 endif
1648 1648
 
1649 1649
 #add libssl if needed
1650 1650
 ifeq ($(CORE_TLS), 1)
1651
-DEFS+= -I$(LOCALBASE)/ssl/include
1651
+C_DEFS+= -I$(LOCALBASE)/ssl/include
1652 1652
 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
1653 1653
 		$(TLS_EXTRA_LIBS)
1654 1654
 # 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 1657
 endif
1658 1658
 
1659 1659
 ifneq ($(STUN),)
1660
-DEFS+= -I$(LOCALBASE)/ssl/include
1660
+C_DEFS+= -I$(LOCALBASE)/ssl/include
1661 1661
 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lcrypto
1662 1662
 endif
1663 1663
 
1664 1664
 ifneq ($(found_lock_method), yes)
1665 1665
 $(warning	No locking method found so far, trying SYS V sems)
1666
-		DEFS+= -DUSE_SYSV_SEM  # try sys v sems
1666
+		C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems
1667 1667
 		found_lock_method=yes
1668 1668
 endif
1669 1669
 
... ...
@@ -1685,7 +1688,7 @@ export exported_vars
1685 1685
 #  is run)
1686 1686
 saved_fixed_vars:=	MAIN_NAME \
1687 1687
 		RELEASE OS ARCH \
1688
-		DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS INCLUDES \
1688
+		C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
1689 1689
 		MOD_LDFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \
1690 1690
 		LIB_SUFFIX LIB_PREFIX \
1691 1691
 		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 26
 override static_modules=
27 27
 override static_modules_path=
28 28
 
29
-# should be set in Makefile of apart module
29
+# should be set in the Makefile of each module
30 30
 # INCLUDES += -I$(COREPATH)
31 31
 
32
+# temporary def (visible only in the module, not exported)
32 33
 DEFS += -DMOD_NAME='"$(MOD_NAME)"'
33 34
 
34 35
 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 20
 #              automatically build listed SER_LIBS if needed (andrei)
21 21
 #  2008-06-23  automatically rebuild if make time defines or includes
22 22
 #              changed (via makecfg.lst)
23
-#
23
+#  2009-03-10  support for C_DEFS and C_INCLUDES (DEFS and INCLUDES are now
24
+#              used only for "temporary" defines/includes inside modules or
25
+#              libs, C_DEFS and C_INCLUDES are used for the common stuff)
26
+#              (andrei)
24 27
 
25 28
 
26 29
 # check if the saved cfg corresponds with the current one
... ...
@@ -30,17 +34,18 @@ ifeq (,$(filter $(nodep_targets),$(MAKECMDGOALS)))
30 30
 # if trying  to build a lib automatically and the lib is already compiled,
31 31
 # don't rebuild it if the only differences in DEFS or INCLUDES are covered
32 32
 # by LIB_NOREBUILD_DEFS/LIB_NOREBUILD_INCLUDES
33
-LIB_NOREBUILD_DEFS+= -DMOD_NAME% -D%_MOD_INTERFACE -DMOD_INTERFACE_% -DSR_%
33
+LIB_NOREBUILD_DEFS=
34 34
 
35 35
 # don't rebuild if the differences are covered by NOREBUILD_DEFS or 
36 36
 # NOREBUILD_INCLUDES
37
-ifneq ($(filter-out $(NOREBUILD_DEFS),$(strip $(DEFS))), $(strip $(CFG_DEFS)))
37
+ifneq ($(strip $(filter-out $(NOREBUILD_DEFS),\
38
+		$(C_DEFS) $(DEFS))),$(strip $(CFG_DEFS)))
38 39
 #$(warning different defs: <$(strip $(DEFS))> != )
39 40
 #$(warning               : <$(strip $(CFG_DEFS))>)
40 41
 $(shell rm -f makecfg.lst)
41 42
 endif
42
-ifneq ($(filter-out $(NOREBUILD_INCLUDES), $(strip $(INCLUDES))),\
43
-		$(strip $(CFG_INCLUDES)))
43
+ifneq ($(strip $(filter-out $(NOREBUILD_INCLUDES),\
44
+			$(C_INCLUDES) $(INCLUDES))),$(strip $(CFG_INCLUDES)))
44 45
 $(shell rm -f makecfg.lst)
45 46
 endif
46 47
 endif
... ...
@@ -49,10 +54,10 @@ ALLDEP+=makecfg.lst
49 49
 
50 50
 #implicit rules
51 51
 %.o:%.c  $(ALLDEP)
52
-	$(CC) $(CFLAGS) $(INCLUDES) $(DEFS) -c $< -o $@
52
+	$(CC) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) -c $< -o $@
53 53
 
54 54
 %.d: %.c $(ALLDEP)
55
-	@set -e; $(MKDEP) $(CFLAGS) $(INCLUDES) $(DEFS) $< \
55
+	@set -e; $(MKDEP) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) $<\
56 56
 	    |  sed 's#\(\($(*D)/\)\{0,1\}$(*F)\)\.o[ :]*#$*.o $@ : #g' > $@; \
57 57
 	    test -s $@ || ( rm -f $@; false )
58 58
 
... ...
@@ -66,7 +71,7 @@ ifneq	(,$(filter install install% %install, $(MAKECMDGOALS)))
66 66
 lib_compile_for_install=yes
67 67
 expected_lib_ipath=$(lib_target)
68 68
 else
69
-lib_compile_for_install=no
69
+lib_compile_for_install=$(compile_for_install)
70 70
 # function: expected_lib_ipath ser_lib_dir
71 71
 expected_lib_ipath=$(1)
72 72
 endif
... ...
@@ -144,10 +149,11 @@ librpath.lst: $(ALLDEP)
144 144
 	@echo LIB_RPATH_LST:=$(SER_RPATH_LST) >librpath.lst
145 145
 
146 146
 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))))) >>$@
147
+	@echo CFG_DEFS:=$(subst ',\', $(subst ",\",$(strip \
148
+			$(filter-out $(NOREBUILD_DEFS), $(C_DEFS) $(DEFS))))) >>$@
149
+	@echo CFG_INCLUDES:=$(subst ',\', $(subst ",\",$(strip \
150
+			$(filter-out $(NOREBUILD_INCLUDES),\
151
+				$(C_INCLUDES) $(INCLUDES))))) >>$@
151 152
 .PHONY: all
152 153
 all: $(NAME) modules
153 154
 
... ...
@@ -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 532
 					ret=1;
533 533
 					break;
534 534
 				}
535
-				if (msg->parsed_uri_ok==0) {
535
+				if ((msg->parsed_uri_ok==0) || ((uri.flags & URI_SIP_USER_PHONE)!=0)) {
536 536
 					if (msg->new_uri.s) {
537 537
 						tmp=msg->new_uri.s;
538 538
 						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 540
 						tmp=msg->first_line.u.request.uri.s;
541 541
 						len=msg->first_line.u.request.uri.len;
542 542
 					}
543
+					/* don't convert sip:user=phone to tel, otherwise we loose parameters */
544
+					orig_p2t=phone2tel;
545
+					phone2tel=0;
546
+					msg->parsed_uri_ok=0;
543 547
 					if (parse_uri(tmp, len, &uri)<0){
548
+						phone2tel=orig_p2t;
544 549
 						LOG(L_ERR, "ERROR: do_action: bad uri <%s>, dropping"
545 550
 									" packet\n", tmp);
546 551
 						ret=E_UNSPEC;
547 552
 						break;
548 553
 					}
554
+					phone2tel=orig_p2t;
549 555
 				} else {
550 556
 					uri=msg->parsed_uri;
551 557
 				}
552 558
 
559
+				/* skip SET_USERPHONE_T action if the URI is already
560
+				 * a tel: or tels: URI, or contains the user=phone param */
561
+				if ((a->type==SET_USERPHONE_T) 
562
+					&& ((uri.type==TEL_URI_T) || (uri.type==TELS_URI_T)
563
+						|| ((uri.user_param_val.len==5) && (memcmp(uri.user_param_val.s, "phone", 5)==0)))
564
+				) {
565
+					ret=1;
566
+					break;
567
+				}
568
+				/* SET_PORT_T does not work with tel: URIs */
569
+				if ((a->type==SET_PORT_T)
570
+					&& ((uri.type==TEL_URI_T) || (uri.type==TELS_URI_T))
571
+					&& ((uri.flags & URI_SIP_USER_PHONE)==0)
572
+				) {
573
+					LOG(L_ERR, "ERROR: do_action: port number of a tel: URI cannot be set\n");
574
+					ret=E_UNSPEC;
575
+					break;
576
+				}
577
+
553 578
 				new_uri=pkg_malloc(MAX_URI_SIZE);
554 579
 				if (new_uri==0){
555 580
 					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 560
 				end=new_uri+MAX_URI_SIZE;
561 561
 				crt=new_uri;
562 562
 				/* begin copying */
563
-				len=strlen("sip:"); if(crt+len>end) goto error_uri;
564
-				memcpy(crt,"sip:",len);crt+=len;
563
+				/* Preserve the URI scheme unless the host part needs
564
+				 * to be rewritten, and the shceme is tel: or tels: */
565
+				switch (uri.type) {
566
+				case SIP_URI_T:
567
+					len=s_sip.len;
568
+					tmp=s_sip.s;
569
+					break;
570
+
571
+				case SIPS_URI_T:
572
+					len=s_sips.len;
573
+					tmp=s_sips.s;
574
+					break;
575
+
576
+				case TEL_URI_T:
577
+					if ((uri.flags & URI_SIP_USER_PHONE)
578
+						|| (a->type==SET_HOST_T)
579
+						|| (a->type==SET_HOSTPORT_T)
580
+						|| (a->type==SET_HOSTPORTTRANS_T)
581
+					) {
582
+						len=s_sip.len;
583
+						tmp=s_sip.s;
584
+						break;
585
+					}
586
+					len=s_tel.len;
587
+					tmp=s_tel.s;
588
+					break;
589
+
590
+				case TELS_URI_T:
591
+					if ((uri.flags & URI_SIP_USER_PHONE)
592
+						|| (a->type==SET_HOST_T)
593
+						|| (a->type==SET_HOSTPORT_T)
594
+						|| (a->type==SET_HOSTPORTTRANS_T)
595
+					) {
596
+						len=s_sips.len;
597
+						tmp=s_sips.s;
598
+						break;
599
+					}
600
+					len=s_tels.len;
601
+					tmp=s_tels.s;
602
+					break;
603
+
604
+				default:
605
+					LOG(L_ERR, "ERROR: Unsupported URI scheme (%d), "
606
+						"reverted to sip:\n",
607
+						uri.type);
608
+					len=s_sip.len;
609
+					tmp=s_sip.s;
610
+				}
611
+				if(crt+len+1 /* colon */ >end) goto error_uri;
612
+				memcpy(crt,tmp,len);crt+=len;
613
+				*crt=':'; crt++;
565 614
 
566 615
 				/* user */
567 616
 
... ...
@@ -622,22 +700,28 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
622 622
 					memcpy(crt,tmp,len);crt+=len;
623 623
 				}
624 624
 				/* host */
625
-				if (user || tmp){ /* add @ */
626
-					if(crt+1>end) goto error_uri;
627
-					*crt='@'; crt++;
628
-				}
629 625
 				if ((a->type==SET_HOST_T)
630 626
 						|| (a->type==SET_HOSTPORT_T)
631 627
 						|| (a->type==SET_HOSTALL_T)
632
-						|| (a->type==SET_HOSTPORTTRANS_T)) {
628
+						|| (a->type==SET_HOSTPORTTRANS_T)
629
+				) {
633 630
 					tmp=a->val[0].u.string;
634 631
 					if (tmp) len = strlen(tmp);
635 632
 					else len=0;
636
-				} else {
633
+				} else if ((uri.type==SIP_URI_T)
634
+					|| (uri.type==SIPS_URI_T)
635
+					|| (uri.flags & URI_SIP_USER_PHONE)
636
+				) {
637 637
 					tmp=uri.host.s;
638
-					len = uri.host.len;
638
+					len=uri.host.len;
639
+				} else {
640
+					tmp=0;
639 641
 				}
640 642
 				if (tmp){
643
+					if (user) { /* add @ */
644
+						if(crt+1>end) goto error_uri;
645
+						*crt='@'; crt++;
646
+					}
641 647
 					if(crt+len>end) goto error_uri;
642 648
 					memcpy(crt,tmp,len);crt+=len;
643 649
 				}
... ...
@@ -687,6 +771,22 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
687 687
 						memcpy(crt,tmp,len);crt+=len;
688 688
 					}
689 689
 				}
690
+				/* Add the user=phone param if a tel: or tels:
691
+				 * URI was converted to sip: or sips:.
692
+				 * (host part of a tel/tels URI was set.)
693
+				 * Or in case of sip: URI and SET_USERPHONE_T action */
694
+				if (((((uri.type==TEL_URI_T) || (uri.type==TELS_URI_T))
695
+					&& ((uri.flags & URI_SIP_USER_PHONE)==0))
696
+					&& ((a->type==SET_HOST_T)
697
+						|| (a->type==SET_HOSTPORT_T)
698
+						|| (a->type==SET_HOSTPORTTRANS_T)))
699
+					|| (a->type==SET_USERPHONE_T)
700
+				) {
701
+					tmp=";user=phone";
702
+					len=strlen(tmp);
703
+					if(crt+len>end) goto error_uri;
704
+					memcpy(crt,tmp,len);crt+=len;
705
+				}
690 706
 				/* headers */
691 707
 				tmp=uri.headers.s;
692 708
 				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 183
 PREFIX			"prefix"
184 184
 STRIP			"strip"
185 185
 STRIP_TAIL		"strip_tail"
186
+SET_USERPHONE		"userphone"
186 187
 APPEND_BRANCH	"append_branch"
187 188
 IF				"if"
188 189
 ELSE			"else"
... ...
@@ -332,6 +334,8 @@ TCP_OPT_FD_CACHE	"tcp_fd_cache"
332 332
 TCP_OPT_BUF_WRITE	"tcp_buf_write"|"tcp_async"
333 333
 TCP_OPT_CONN_WQ_MAX	"tcp_conn_wq_max"
334 334
 TCP_OPT_WQ_MAX		"tcp_wq_max"
335
+TCP_OPT_RD_BUF		"tcp_rd_buf_size"
336
+TCP_OPT_WQ_BLK		"tcp_wq_blk_size"
335 337
 TCP_OPT_DEFER_ACCEPT "tcp_defer_accept"
336 338
 TCP_OPT_DELAYED_ACK	"tcp_delayed_ack"
337 339
 TCP_OPT_SYNCNT		"tcp_syncnt"
... ...
@@ -491,6 +495,8 @@ EAT_ABLE	[\ \t\b\r]
491 491
 <INITIAL>{STRIP_TAIL}	{ count(); yylval.strval=yytext; return STRIP_TAIL; }
492 492
 <INITIAL>{APPEND_BRANCH}	{ count(); yylval.strval=yytext;
493 493
 								return APPEND_BRANCH; }
494
+<INITIAL>{SET_USERPHONE}	{ count(); yylval.strval=yytext;
495
+								return SET_USERPHONE; }
494 496
 <INITIAL>{FORCE_RPORT}	{ count(); yylval.strval=yytext; return FORCE_RPORT; }
495 497
 <INITIAL>{FORCE_TCP_ALIAS}	{ count(); yylval.strval=yytext;
496 498
 								return FORCE_TCP_ALIAS; }
... ...
@@ -637,6 +643,10 @@ EAT_ABLE	[\ \t\b\r]
637 637
 									return TCP_OPT_CONN_WQ_MAX; }
638 638
 <INITIAL>{TCP_OPT_WQ_MAX}	{ count(); yylval.strval=yytext;
639 639
 									return TCP_OPT_WQ_MAX; }
640
+<INITIAL>{TCP_OPT_RD_BUF}	{ count(); yylval.strval=yytext;
641
+									return TCP_OPT_RD_BUF; }
642
+<INITIAL>{TCP_OPT_WQ_BLK}	{ count(); yylval.strval=yytext;
643
+									return TCP_OPT_WQ_BLK; }
640 644
 <INITIAL>{TCP_OPT_BUF_WRITE}	{ count(); yylval.strval=yytext;
641 645
 									return TCP_OPT_BUF_WRITE; }
642 646
 <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 137
 #ifdef CORE_TLS
138 138
 #include "tls/tls_config.h"
139 139
 #endif
140
+#include "timer_ticks.h"
140 141
 
141 142
 #ifdef DEBUG_DMALLOC
142 143
 #include <dmalloc.h>
... ...
@@ -271,6 +273,7 @@ static int case_check_default(struct case_stms* stms);
271 271
 %token PREFIX
272 272
 %token STRIP
273 273
 %token STRIP_TAIL
274
+%token SET_USERPHONE
274 275
 %token APPEND_BRANCH
275 276
 %token SET_USER
276 277
 %token SET_USERPASS
... ...
@@ -396,6 +399,8 @@ static int case_check_default(struct case_stms* stms);
396 396
 %token TCP_OPT_BUF_WRITE
397 397
 %token TCP_OPT_CONN_WQ_MAX
398 398
 %token TCP_OPT_WQ_MAX
399
+%token TCP_OPT_RD_BUF
400
+%token TCP_OPT_WQ_BLK
399 401
 %token TCP_OPT_DEFER_ACCEPT
400 402
 %token TCP_OPT_DELAYED_ACK
401 403
 %token TCP_OPT_SYNCNT
... ...
@@ -839,7 +844,7 @@ assign_stm:
839 839
 	| TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
840 840
 	| TCP_SEND_TIMEOUT EQUAL intno {
841 841
 		#ifdef USE_TCP
842
-			tcp_default_cfg.send_timeout_s=$3;
842
+			tcp_default_cfg.send_timeout=S_TO_TICKS($3);
843 843
 		#else
844 844
 			warn("tcp support not compiled in");
845 845
 		#endif
... ...
@@ -847,7 +852,10 @@ assign_stm:
847 847
 	| TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
848 848
 	| TCP_CON_LIFETIME EQUAL intno {
849 849
 		#ifdef USE_TCP
850
-			tcp_default_cfg.con_lifetime_s=$3;
850
+			if ($3<0)
851
+				tcp_default_cfg.con_lifetime=-1;
852
+			else
853
+				tcp_default_cfg.con_lifetime=S_TO_TICKS($3);
851 854
 		#else
852 855
 			warn("tcp support not compiled in");
853 856
 		#endif
... ...
@@ -953,7 +961,23 @@ assign_stm:
953 953
 			warn("tcp support not compiled in");
954 954
 		#endif
955 955
 	}
956
-	| TCP_OPT_WQ_MAX error { yyerror("boolean value expected"); }
956
+	| TCP_OPT_WQ_MAX error { yyerror("number expected"); }
957
+	| TCP_OPT_RD_BUF EQUAL NUMBER {
958
+		#ifdef USE_TCP
959
+			tcp_default_cfg.rd_buf_size=$3;
960
+		#else
961
+			warn("tcp support not compiled in");
962
+		#endif
963
+	}
964
+	| TCP_OPT_RD_BUF error { yyerror("number expected"); }
965
+	| TCP_OPT_WQ_BLK EQUAL NUMBER {
966
+		#ifdef USE_TCP
967
+			tcp_default_cfg.wq_blk_size=$3;
968
+		#else
969
+			warn("tcp support not compiled in");
970
+		#endif
971
+	}
972
+	| TCP_OPT_WQ_BLK error { yyerror("number expected"); }
957 973
 	| TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
958 974
 		#ifdef USE_TCP
959 975
 			tcp_default_cfg.defer_accept=$3;
... ...
@@ -1315,10 +1339,10 @@ assign_stm:
1315 1315
 	| UDP_MTU EQUAL NUMBER { default_core_cfg.udp_mtu=$3; }
1316 1316
 	| UDP_MTU EQUAL error { yyerror("number expected"); }
1317 1317
 	| FORCE_RPORT EQUAL NUMBER 
1318
-		{ default_core_cfg.force_rport=$3; fix_global_req_flags(0); }
1318
+		{ default_core_cfg.force_rport=$3; fix_global_req_flags(0, 0); }
1319 1319
 	| FORCE_RPORT EQUAL error { yyerror("boolean value expected"); }
1320 1320
 	| UDP_MTU_TRY_PROTO EQUAL proto
1321
-		{ default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0); }
1321
+		{ default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0, 0); }
1322 1322
 	| UDP_MTU_TRY_PROTO EQUAL error
1323 1323
 		{ yyerror("TCP, TLS, SCTP or UDP expected"); }
1324 1324
 	| cfg_var
... ...
@@ -2546,6 +2570,8 @@ cmd:
2546 2546
 	| STRIP LPAREN NUMBER RPAREN { $$=mk_action(STRIP_T, 1, NUMBER_ST, (void*) $3); }
2547 2547
 	| STRIP error { $$=0; yyerror("missing '(' or ')' ?"); }
2548 2548
 	| STRIP LPAREN error RPAREN { $$=0; yyerror("bad argument, number expected"); }
2549
+	| SET_USERPHONE LPAREN RPAREN { $$=mk_action(SET_USERPHONE_T, 0); }
2550
+	| SET_USERPHONE error { $$=0; yyerror("missing '(' or ')' ?"); }
2549 2551
 	| APPEND_BRANCH LPAREN STRING COMMA STRING RPAREN {
2550 2552
 		qvalue_t q;
2551 2553
 		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 311
 	if (var->def->on_set_child_cb) {
312 312
 		/* get the name of the variable from the internal struct,
313 313
 		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,
314
+		s.s = group->name;
315
+		s.len = group->name_len;
316
+		s2.s = var->def->name;
317
+		s2.len = var->name_len;
318
+		child_cb = cfg_child_cb_new(&s, &s2,
317 319
 					var->def->on_set_child_cb);
318 320
 		if (!child_cb) {
319 321
 			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 579
 		}
580 580
 			
581 581
 		if (var->def->on_change_cb(temp_handle,
582
+						group_name,
582 583
 						var_name,
583 584
 						&v) < 0) {
584 585
 			LOG(L_ERR, "ERROR: cfg_set_delayed(): fixup failed\n");
... ...
@@ -711,7 +715,7 @@ int cfg_commit(cfg_ctx_t *ctx)
711 711
 	cfg_child_cb_t	*child_cb_last = NULL;
712 712
 	int	size;
713 713
 	void	*p;
714
-	str	s;
714
+	str	s, s2;
715 715
 
716 716
 	if (!ctx) {
717 717
 		LOG(L_ERR, "ERROR: cfg_commit(): context is undefined\n");
... ...
@@ -740,9 +744,11 @@ int cfg_commit(cfg_ctx_t *ctx)
740 740
 
741 741
 
742 742
 		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,
743
+			s.s = changed->group->name;
744
+			s.len = changed->group->name_len;
745
+			s2.s = changed->var->def->name;
746
+			s2.len = changed->var->name_len;
747
+			child_cb = cfg_child_cb_new(&s, &s2,
746 748
 					changed->var->def->on_set_child_cb);
747 749
 			if (!child_cb) goto error0;
748 750
 
... ...
@@ -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
-void fix_global_req_flags( str* name)