summaryrefslogtreecommitdiff
path: root/net/ser/files
diff options
context:
space:
mode:
Diffstat (limited to 'net/ser/files')
-rw-r--r--net/ser/files/patch-Makefile45
-rw-r--r--net/ser/files/patch-Makefile.defs171
-rw-r--r--net/ser/files/patch-Makefile.rules14
-rw-r--r--net/ser/files/patch-cfg.lex21
-rw-r--r--net/ser/files/patch-cfg.y21
-rw-r--r--net/ser/files/patch-config.h23
-rw-r--r--net/ser/files/patch-daemonize.c14
-rw-r--r--net/ser/files/patch-fifo_server.c14
-rw-r--r--net/ser/files/patch-globals.h13
-rw-r--r--net/ser/files/patch-main.c24
-rw-r--r--net/ser/files/patch-mem__mem.h22
-rw-r--r--net/ser/files/patch-modules__acc__acc_mod.c14
-rw-r--r--net/ser/files/patch-modules__acc__etc__radiusclient.conf42
-rw-r--r--net/ser/files/patch-modules__auth__auth_mod.c60
-rw-r--r--net/ser/files/patch-modules__auth__auth_mod.h27
-rw-r--r--net/ser/files/patch-modules__auth__common.c12
-rw-r--r--net/ser/files/patch-modules__auth__doc__auth_user.sgml44
-rw-r--r--net/ser/files/patch-modules__auth_radius__authrad_mod.c14
-rw-r--r--net/ser/files/patch-modules__check_ua__Makefile19
-rw-r--r--net/ser/files/patch-modules__check_ua__check_ua.c374
-rw-r--r--net/ser/files/patch-modules__check_ua__tailq.h154
-rw-r--r--net/ser/files/patch-modules__group_radius__grouprad_mod.c14
-rw-r--r--net/ser/files/patch-modules__mysql__my_con.c15
-rw-r--r--net/ser/files/patch-modules__nathelper__moh.c434
-rw-r--r--net/ser/files/patch-modules__nathelper__nathelper.c1786
-rw-r--r--net/ser/files/patch-modules__nathelper__nathelper.h82
-rw-r--r--net/ser/files/patch-modules__nathelper__natping.c258
-rw-r--r--net/ser/files/patch-modules__postgres__db_val.c77
-rw-r--r--net/ser/files/patch-modules__postgres__dbase.c57
-rw-r--r--net/ser/files/patch-modules__registrar__doc__registrar_user.sgml51
-rw-r--r--net/ser/files/patch-modules__registrar__reg_mod.c66
-rw-r--r--net/ser/files/patch-modules__registrar__reg_mod.h29
-rw-r--r--net/ser/files/patch-modules__registrar__reply.c23
-rw-r--r--net/ser/files/patch-modules__tm__t_lookup.c36
-rw-r--r--net/ser/files/patch-modules__tm__t_msgbuilder.c55
-rw-r--r--net/ser/files/patch-modules__uri_radius__urirad_mod.c14
-rw-r--r--net/ser/files/patch-modules__usrloc__urecord.c16
-rw-r--r--net/ser/files/patch-msg_translator.c28
-rw-r--r--net/ser/files/patch-parser__msg_parser.h17
-rw-r--r--net/ser/files/patch-parser__parse_hostport.c27
-rw-r--r--net/ser/files/patch-server187
-rw-r--r--net/ser/files/patch-udp_server.c16
-rw-r--r--net/ser/files/ser.in32
43 files changed, 0 insertions, 4462 deletions
diff --git a/net/ser/files/patch-Makefile b/net/ser/files/patch-Makefile
deleted file mode 100644
index 48110d77f7f0..000000000000
--- a/net/ser/files/patch-Makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-
-$FreeBSD$
-
---- Makefile.orig
-+++ Makefile
-@@ -46,13 +46,12 @@
- skip_modules?=
-
- # if not set on the cmd. line or the env, exclude this modules:
--exclude_modules?= cpl ext extcmd \
-- postgres snmp \
-+exclude_modules?= cpl extcmd \
-+ $(POSTGRESQL) snmp \
- im \
-- jabber mysql \
-+ jabber $(MYSQL) \
- cpl-c \
-- auth_radius group_radius uri_radius avp_radius \
-- pa
-+ $(RADIUS) $(PA)
- # always exclude the CVS dir
- override exclude_modules+= CVS $(skip_modules)
-
-@@ -268,7 +267,7 @@
- chmod 644 $(cfg-prefix)/$(cfg-dir)ser.cfg.sample
- if [ -z "${skip_cfg_install}" -a \
- ! -f $(cfg-prefix)/$(cfg-dir)ser.cfg ]; then \
-- mv -f $(cfg-prefix)/$(cfg-dir)ser.cfg.sample \
-+ cp $(cfg-prefix)/$(cfg-dir)ser.cfg.sample \
- $(cfg-prefix)/$(cfg-dir)ser.cfg; \
- fi
- # radius dictionary
-@@ -280,10 +279,10 @@
- $(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/ser
- $(INSTALL-BIN) ser $(bin-prefix)/$(bin-dir)
- $(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/sc
-- $(INSTALL-BIN) scripts/sc $(bin-prefix)/$(bin-dir)
-+ $(INSTALL-SCRIPT) scripts/sc $(bin-prefix)/$(bin-dir)
- mv -f $(bin-prefix)/$(bin-dir)/sc $(bin-prefix)/$(bin-dir)/serctl
- $(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/ser_mysql.sh
-- $(INSTALL-BIN) scripts/ser_mysql.sh $(bin-prefix)/$(bin-dir)
-+ $(INSTALL-SCRIPT) scripts/ser_mysql.sh $(bin-prefix)/$(bin-dir)
- $(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/gen_ha1
- $(INSTALL-BIN) utils/gen_ha1/gen_ha1 $(bin-prefix)/$(bin-dir)
- $(INSTALL-TOUCH) $(bin-prefix)/$(bin-dir)/serunix
diff --git a/net/ser/files/patch-Makefile.defs b/net/ser/files/patch-Makefile.defs
deleted file mode 100644
index f8b6bc9538d4..000000000000
--- a/net/ser/files/patch-Makefile.defs
+++ /dev/null
@@ -1,171 +0,0 @@
-
-$FreeBSD$
-
---- Makefile.defs.orig
-+++ Makefile.defs
-@@ -169,10 +169,11 @@
- INSTALL-TOUCH = touch # used to create the file first (good to
- # make solaris install work)
- INSTALL-CFG = $(INSTALL) -m 644
--INSTALL-BIN = $(INSTALL) -m 755
--INSTALL-MODULES = $(INSTALL) -m 755
--INSTALL-DOC = $(INSTALL) -m 644
--INSTALL-MAN = $(INSTALL) -m 644
-+INSTALL-BIN = $(BSD_INSTALL_PROGRAM)
-+INSTALL-MODULES = $(BSD_INSTALL_PROGRAM)
-+INSTALL-DOC = $(BSD_INSTALL_MAN)
-+INSTALL-MAN = $(BSD_INSTALL_MAN)
-+INSTALL-SCRIPT = $(BSD_INSTALL_SCRIPT)
-
- #set some vars from the environment (and not make builtins)
- CC := $(shell echo "$${CC}")
-@@ -321,14 +322,14 @@
- -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
- -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
- -DCFG_DIR='"$(cfg-target)"'\
-- -DPKG_MALLOC \
- -DSHM_MEM -DSHM_MMAP \
- -DDNS_IP_HACK \
- -DUSE_IPV6 \
- -DUSE_MCAST \
- -DUSE_TCP \
- -DDISABLE_NAGLE \
-- -DF_MALLOC \
-+ #-DPKG_MALLOC \
-+ #-DF_MALLOC \
- #-DDBG_QM_MALLOC \
- #-DDBG_F_MALLOC \
- #-DNO_DEBUG \
-@@ -464,8 +465,8 @@
- found_lock_method=yes
- endif
-
--CFLAGS=
--LDFLAGS=
-+#CFLAGS=
-+#LDFLAGS=
- # setting CFLAGS
- ifeq ($(mode), release)
- #if i386
-@@ -473,15 +474,14 @@
- # if gcc
- ifeq ($(CC_NAME), gcc)
- #common stuff
-- CFLAGS=-g -O9 -funroll-loops -Wcast-align $(PROFILE) \
-+ CFLAGS+=-funroll-loops -Wcast-align $(PROFILE) \
- -Wall
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
- CPU ?= athlon64
- CFLAGS+=-minline-all-stringops -malign-double \
- -falign-loops \
-- -ftree-vectorize \
-- -mtune=$(CPU)
-+ -ftree-vectorize
- else
- #if gcc 3.4+
- ifeq ($(CC_SHORTVER), 3.4)
-@@ -515,7 +515,7 @@
-
- else # CC_NAME, gcc
- ifeq ($(CC_NAME), icc)
-- CFLAGS=-g -O3 -ipo -ipo_obj -unroll $(PROFILE) \
-+ CFLAGS+=-ipo -ipo_obj -unroll $(PROFILE) \
- -tpp6 -xK #-openmp #optimize for PIII
- # -prefetch doesn't seem to work
- #( ty to inline acroos files, unroll loops,prefetch,
-@@ -533,7 +533,7 @@
- # if gcc
- ifeq ($(CC_NAME), gcc)
- #common stuff
-- CFLAGS=-g -O9 -funroll-loops -Wcast-align $(PROFILE) \
-+ CFLAGS+=-funroll-loops -Wcast-align $(PROFILE) \
- -Wall
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
-@@ -575,7 +575,7 @@
-
- else # CC_NAME, gcc
- ifeq ($(CC_NAME), icc)
-- CFLAGS=-g -O3 -ipo -ipo_obj -unroll $(PROFILE) \
-+ CFLAGS+=-ipo -ipo_obj -unroll $(PROFILE) \
- -tpp6 -xK #-openmp #optimize for PIII
- # -prefetch doesn't seem to work
- #( ty to inline acroos files, unroll loops,prefetch,
-@@ -593,7 +593,7 @@
- #if gcc
- ifeq ($(CC_NAME), gcc)
- #common stuff
-- CFLAGS=-g -O9 -funroll-loops $(PROFILE) \
-+ CFLAGS+=-funroll-loops $(PROFILE) \
- -Wall\
- #-Wcast-align \
- #-Wmissing-prototypes
-@@ -667,7 +667,7 @@
- # if gcc
- ifeq ($(CC_NAME), gcc)
- #common stuff
-- CFLAGS=-O9 -funroll-loops -Wcast-align $(PROFILE) \
-+ CFLAGS+=-funroll-loops -Wcast-align $(PROFILE) \
- -Wall
- #if gcc 4.x+
- ifeq ($(CC_SHORTVER), 4.x)
-@@ -709,7 +709,7 @@
- # if gcc
- ifeq ($(CC_NAME), gcc)
- #common stuff
-- CFLAGS=-O9 -funroll-loops -Wcast-align $(PROFILE) \
-+ CFLAGS+=-funroll-loops -Wcast-align $(PROFILE) \
- -Wall
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
-@@ -751,7 +751,7 @@
- # if gcc
- ifeq ($(CC_NAME), gcc)
- #common stuff
-- CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE) \
-+ CFLAGS+= -mips2 -funroll-loops $(PROFILE) \
- -Wall
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
-@@ -932,7 +932,7 @@
- # -andrei
- else #mode,release
- ifeq ($(CC_NAME), gcc)
-- CFLAGS=-g -Wcast-align $(PROFILE)
-+ CFLAGS+=-Wcast-align $(PROFILE)
- ifeq ($(ARCH), sparc64)
- CFLAGS+= -mcpu=ultrasparc
- endif
-@@ -947,12 +947,12 @@
- endif
- endif
- ifeq ($(CC_NAME), icc)
-- CFLAGS=-g $(PROFILE)
-+ CFLAGS+=$(PROFILE)
- LDFLAGS+=-g -Wl,-E $(PROFILE)
- MOD_LDFLAGS=-shared $(LDFLAGS)
- endif
- ifeq ($(CC_NAME), suncc)
-- CFLAGS= -g $(PROFILE)
-+ CFLAGS+= $(PROFILE)
- LDFLAGS+=-g $(PROFILE)
- MOD_LDFLAGS=-G $(LDFLAGS)
- endif
-@@ -1028,13 +1028,14 @@
-
- ifeq ($(OS), freebsd)
- DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
-- -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG
-+ -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG \
-+ -I$(LOCALBASE)/include
- ifneq ($(found_lock_method), yes)
- DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
- found_lock_method=yes
- LIBS= -pthread -lfl #dlopen is in libc
- else
-- LIBS= -lfl #dlopen is in libc
-+ LIBS= -lfl -L$(LOCALBASE)/lib #dlopen is in libc
- endif
- YACC=yacc
- endif
diff --git a/net/ser/files/patch-Makefile.rules b/net/ser/files/patch-Makefile.rules
deleted file mode 100644
index 2df91d4f6265..000000000000
--- a/net/ser/files/patch-Makefile.rules
+++ /dev/null
@@ -1,14 +0,0 @@
-
-$FreeBSD$
-
---- Makefile.rules
-+++ Makefile.rules
-@@ -18,7 +18,7 @@
- $(CC) $(CFLAGS) $(DEFS) -c $< -o $@
-
- %.d: %.c $(ALLDEP)
-- @set -e; $(MKDEP) $(DEFS) $< \
-+ @set -e; $(MKDEP) $(CFLAGS) $(DEFS) $< \
- | sed 's#\(\($*D)\)\?$(*F)\)\.o[ :]*#$*.o $@ : #g' > $@; \
- [ -s $@ ] || rm -f $@
-
diff --git a/net/ser/files/patch-cfg.lex b/net/ser/files/patch-cfg.lex
deleted file mode 100644
index ddfe015b190b..000000000000
--- a/net/ser/files/patch-cfg.lex
+++ /dev/null
@@ -1,21 +0,0 @@
-
-$FreeBSD$
-
---- cfg.lex 2004/06/29 19:08:42 1.1
-+++ cfg.lex 2004/06/29 19:10:36
-@@ -165,6 +165,7 @@
- FIFO fifo
- FIFO_MODE fifo_mode
- SERVER_SIGNATURE server_signature
-+SERVER_NAME server_name
- REPLY_TO_VIA reply_to_via
- USER "user"|"uid"
- GROUP "group"|"gid"
-@@ -332,6 +333,7 @@
- <INITIAL>{FIFO} { count(); yylval.strval=yytext; return FIFO; }
- <INITIAL>{FIFO_MODE} { count(); yylval.strval=yytext; return FIFO_MODE; }
- <INITIAL>{SERVER_SIGNATURE} { count(); yylval.strval=yytext; return SERVER_SIGNATURE; }
-+<INITIAL>{SERVER_NAME} { count(); yylval.strval=yytext; return SERVER_NAME; }
- <INITIAL>{REPLY_TO_VIA} { count(); yylval.strval=yytext; return REPLY_TO_VIA; }
- <INITIAL>{ADVERTISED_ADDRESS} { count(); yylval.strval=yytext;
- return ADVERTISED_ADDRESS; }
diff --git a/net/ser/files/patch-cfg.y b/net/ser/files/patch-cfg.y
deleted file mode 100644
index 87a917abe8ae..000000000000
--- a/net/ser/files/patch-cfg.y
+++ /dev/null
@@ -1,21 +0,0 @@
-
-$FreeBSD$
-
---- cfg.y.orig
-+++ cfg.y
-@@ -210,6 +210,7 @@
- %token UNIX_SOCK_CHILDREN
- %token UNIX_TX_TIMEOUT
- %token SERVER_SIGNATURE
-+%token SERVER_NAME
- %token REPLY_TO_VIA
- %token LOADMODULE
- %token MODPARAM
-@@ -610,6 +611,7 @@
- | TLS_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
- | SERVER_SIGNATURE EQUAL NUMBER { server_signature=$3; }
- | SERVER_SIGNATURE EQUAL error { yyerror("boolean value expected"); }
-+ | SERVER_NAME EQUAL STRING { server_name=$3; }
- | REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
- | REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
- | LISTEN EQUAL id_lst {
diff --git a/net/ser/files/patch-config.h b/net/ser/files/patch-config.h
deleted file mode 100644
index 1a8259c87b8d..000000000000
--- a/net/ser/files/patch-config.h
+++ /dev/null
@@ -1,23 +0,0 @@
-
-$FreeBSD$
-
---- config.h 2004/06/29 19:14:46 1.1
-+++ config.h 2004/06/29 19:33:41
-@@ -72,12 +72,14 @@
- #define CONTENT_LENGTH "Content-Length: "
- #define CONTENT_LENGTH_LEN (sizeof(CONTENT_LENGTH)-1)
-
--#define USER_AGENT "User-Agent: Sip EXpress router"\
-+#define UA_NAME "Sip EXpress router "\
- "(" VERSION " (" ARCH "/" OS"))"
-+#define UA_NAME_LEN (sizeof(UA_NAME)-1)
-+
-+#define USER_AGENT "User-Agent: "
- #define USER_AGENT_LEN (sizeof(USER_AGENT)-1)
-
--#define SERVER_HDR "Server: Sip EXpress router "\
-- "(" VERSION " (" ARCH "/" OS"))"
-+#define SERVER_HDR "Server: "
- #define SERVER_HDR_LEN (sizeof(SERVER_HDR)-1)
-
- #define MAX_WARNING_LEN 256
diff --git a/net/ser/files/patch-daemonize.c b/net/ser/files/patch-daemonize.c
deleted file mode 100644
index 88cd832a0ecc..000000000000
--- a/net/ser/files/patch-daemonize.c
+++ /dev/null
@@ -1,14 +0,0 @@
-
-$FreeBSD$
-
---- daemonize.c
-+++ daemonize.c
-@@ -198,7 +198,7 @@
- }
-
- if (log_stderr==0)
-- openlog(name, LOG_PID|LOG_CONS, log_facility);
-+ openlog(name, LOG_PID, log_facility);
- /* LOG_CONS, LOG_PERRROR ? */
-
- return 0;
diff --git a/net/ser/files/patch-fifo_server.c b/net/ser/files/patch-fifo_server.c
deleted file mode 100644
index 39b5a3647054..000000000000
--- a/net/ser/files/patch-fifo_server.c
+++ /dev/null
@@ -1,14 +0,0 @@
-
-$FreeBSD$
-
---- fifo_server.c.orig Sat Nov 1 20:56:58 2003
-+++ fifo_server.c Tue Jun 29 22:33:53 2004
-@@ -642,7 +657,7 @@
- static int print_version_cmd( FILE *stream, char *response_file )
- {
- if (response_file) {
-- fifo_reply(response_file, "200 ok\n" SERVER_HDR CRLF );
-+ fifo_reply(response_file, "200 ok\n" SERVER_HDR "%s" CRLF, server_name ? server_name : UA_NAME );
- } else {
- LOG(L_ERR, "ERROR: no file for %s\n", "print_version_cmd" );
- }
diff --git a/net/ser/files/patch-globals.h b/net/ser/files/patch-globals.h
deleted file mode 100644
index 0b19a234716a..000000000000
--- a/net/ser/files/patch-globals.h
+++ /dev/null
@@ -1,13 +0,0 @@
-
-$FreeBSD$
-
---- globals.h 2004/06/29 19:08:42 1.1
-+++ globals.h 2004/06/29 19:30:58
-@@ -91,6 +91,7 @@
- /* extern int process_no; */
- extern int sip_warning;
- extern int server_signature;
-+extern char* server_name;
- extern char* user;
- extern char* group;
- extern char* chroot_dir;
diff --git a/net/ser/files/patch-main.c b/net/ser/files/patch-main.c
deleted file mode 100644
index 00ef167417fd..000000000000
--- a/net/ser/files/patch-main.c
+++ /dev/null
@@ -1,24 +0,0 @@
-
-$FreeBSD$
-
---- main.c.orig
-+++ main.c
-@@ -251,6 +251,10 @@
- be default yes, good for trouble-shooting
- */
- int server_signature=1;
-+/*
-+ * Server's signature if different from default.
-+ */
-+char* server_name = 0;
- /* should ser try to locate outbound interface on multihomed
- * host? by default not -- too expensive
- */
-@@ -350,6 +354,7 @@
- void cleanup(show_status)
- {
- /*clean-up*/
-+ setlogmask(LOG_UPTO(LOG_INFO));
- if (mem_lock)
- shm_unlock(); /* hack: force-unlock the shared memory lock in case
- some process crashed and let it locked; this will
diff --git a/net/ser/files/patch-mem__mem.h b/net/ser/files/patch-mem__mem.h
deleted file mode 100644
index 81e7c3d59e99..000000000000
--- a/net/ser/files/patch-mem__mem.h
+++ /dev/null
@@ -1,22 +0,0 @@
-
-$FreeBSD$
-
---- mem/mem.h.orig
-+++ mem/mem.h
-@@ -122,9 +122,13 @@
- #else
- # include <stdlib.h>
- # define pkg_malloc(s) \
-- ( { void *v; v=malloc((s)); \
-- DBG("malloc %p size %d end %p\n", v, s, (char*)v+(s));\
-- v; } )
-+ ( { void *____v123; ____v123=malloc((s)); \
-+ DBG("malloc %p size %lu end %p\n", ____v123, (unsigned long)(s), (char*)____v123+(s));\
-+ ____v123; } )
-+# define pkg_realloc(p, s) \
-+ ( { void *____v123; ____v123=realloc(p, s); \
-+ DBG("realloc %p size %lu end %p\n", ____v123, (unsigned long)(s), (char*)____v123+(s));\
-+ ____v123; } )
- # define pkg_free(p) do{ DBG("free %p\n", (p)); free((p)); }while(0);
- # define pkg_status()
- #endif
diff --git a/net/ser/files/patch-modules__acc__acc_mod.c b/net/ser/files/patch-modules__acc__acc_mod.c
deleted file mode 100644
index 59df9ddd442d..000000000000
--- a/net/ser/files/patch-modules__acc__acc_mod.c
+++ /dev/null
@@ -1,14 +0,0 @@
-
-$FreeBSD$
-
---- modules/acc/acc_mod.c.orig Mon Jul 19 01:56:23 2004
-+++ modules/acc/acc_mod.c Tue Jul 27 21:01:36 2004
-@@ -93,7 +93,7 @@
- int log_level=L_NOTICE;
- char *log_fmt=DEFAULT_LOG_FMT;
- #ifdef RAD_ACC
--static char *radius_config = "/usr/local/etc/radiusclient/radiusclient.conf";
-+static char *radius_config = (CFG_DIR "radiusclient.conf");
- int radius_flag = 0;
- int radius_missed_flag = 0;
- static int service_type = -1;
diff --git a/net/ser/files/patch-modules__acc__etc__radiusclient.conf b/net/ser/files/patch-modules__acc__etc__radiusclient.conf
deleted file mode 100644
index 3d13a5648be6..000000000000
--- a/net/ser/files/patch-modules__acc__etc__radiusclient.conf
+++ /dev/null
@@ -1,42 +0,0 @@
-
-$FreeBSD$
-
---- modules/acc/etc/radiusclient.conf 2003/07/06 17:56:08 1.1
-+++ modules/acc/etc/radiusclient.conf 2003/07/06 17:57:54
-@@ -22,7 +22,7 @@
-
- # name of the issue file. it's only display when no username is passed
- # on the radlogin command line
--issue /usr/local/etc/radiusclient/issue
-+issue %%LOCALBASE%%/etc/radiusclient-ng/issue
-
- # RADIUS settings
-
-@@ -44,23 +44,23 @@
-
- # file holding shared secrets used for the communication
- # between the RADIUS client and server
--servers /home/jiri/sip_router/modules/acc/etc/servers
-+servers %%PREFIX%%/etc/ser/servers
-
-
-
- # dictionary of allowed attributes and values
- # just like in the normal RADIUS distributions
--dictionary /home/jiri/sip_router/modules/acc/etc/sip_dictionary
-+dictionary %%PREFIX%%/etc/ser/sip_dictionary
-
- # program to call for a RADIUS authenticated login
--login_radius /usr/local/sbin/login.radius
-+login_radius %%LOCALBASE%%/sbin/login.radius
-
- # file which holds sequence number for communication with the
- # RADIUS server
- seqfile /var/run/radius.seq
-
- # file which specifies mapping between ttyname and NAS-Port attribute
--mapfile /usr/local/etc/radiusclient/port-id-map
-+mapfile %%LOCALBASE%%/etc/radiusclient-ng/port-id-map
-
- # default authentication realm to append to all usernames if no
- # realm was explicitly specified by the user
diff --git a/net/ser/files/patch-modules__auth__auth_mod.c b/net/ser/files/patch-modules__auth__auth_mod.c
deleted file mode 100644
index 2d08c8f5edff..000000000000
--- a/net/ser/files/patch-modules__auth__auth_mod.c
+++ /dev/null
@@ -1,60 +0,0 @@
-
-$FreeBSD$
-
---- modules/auth/auth_mod.c.orig
-+++ modules/auth/auth_mod.c
-@@ -84,6 +84,9 @@
- int (*sl_reply)(struct sip_msg* _msg, char* _str1, char* _str2);
-
-
-+struct tm_binds tmb;
-+
-+
- /*
- * Module parameter variables
- */
-@@ -93,6 +96,7 @@
- str secret;
- char* sec_rand = 0;
-
-+int use_tm = 0;
-
- /*
- * Default Remote-Party-ID prefix
-@@ -140,6 +144,7 @@
- {"rpid_prefix", STR_PARAM, &rpid_prefix_param },
- {"rpid_suffix", STR_PARAM, &rpid_suffix_param },
- {"realm_prefix", STR_PARAM, &realm_prefix_param},
-+ {"use_tm", INT_PARAM, &use_tm },
- {0, 0, 0}
- };
-
-@@ -190,13 +195,23 @@
-
- static int mod_init(void)
- {
-+ load_tm_f load_tm;
-+
- DBG("auth module - initializing\n");
--
-- sl_reply = find_export("sl_send_reply", 2, 0);
-
-- if (!sl_reply) {
-- LOG(L_ERR, "auth:mod_init(): This module requires sl module\n");
-- return -2;
-+ if (use_tm != 0) {
-+ load_tm = (load_tm_f)find_export("load_tm", NO_SCRIPT, 0);
-+ if (load_tm == NULL || load_tm(&tmb) == -1) {
-+ LOG(L_ERR, "Can't import tm\n");
-+ return -1;
-+ }
-+ } else {
-+ sl_reply = find_export("sl_send_reply", 2, 0);
-+
-+ if (!sl_reply) {
-+ LOG(L_ERR, "auth:mod_init(): This module requires sl module\n");
-+ return -2;
-+ }
- }
-
- /* If the parameter was not used */
diff --git a/net/ser/files/patch-modules__auth__auth_mod.h b/net/ser/files/patch-modules__auth__auth_mod.h
deleted file mode 100644
index 8d3304af4139..000000000000
--- a/net/ser/files/patch-modules__auth__auth_mod.h
+++ /dev/null
@@ -1,27 +0,0 @@
-
-$FreeBSD$
-
---- modules/auth/auth_mod.h.orig
-+++ modules/auth/auth_mod.h
-@@ -36,7 +36,7 @@
-
- #include "../../str.h"
- #include "../../parser/msg_parser.h" /* struct sip_msg */
--
-+#include "../tm/tm_load.h"
-
- /*
- * Module parameters variables
-@@ -46,9 +46,11 @@
- extern str rpid_prefix; /* Remote-Party-ID prefix */
- extern str rpid_suffix; /* Remote-Party-ID suffix */
- extern str realm_prefix; /* strip off auto-generated realm */
--
-+extern int use_tm;
-
- /* Stateless reply function pointer */
- extern int (*sl_reply)(struct sip_msg* _m, char* _str1, char* _str2);
-+
-+extern struct tm_binds tmb;
-
- #endif /* AUTH_MOD_H */
diff --git a/net/ser/files/patch-modules__auth__common.c b/net/ser/files/patch-modules__auth__common.c
deleted file mode 100644
index d15db240bedc..000000000000
--- a/net/ser/files/patch-modules__auth__common.c
+++ /dev/null
@@ -1,12 +0,0 @@
-
-$FreeBSD$
-
---- modules/auth/common.c.orig
-+++ modules/auth/common.c
-@@ -95,5 +95,5 @@
- }
- }
-
-- return sl_reply(_m, (char*)(long)_code, _reason);
-+ return (use_tm != 0) ? tmb.t_reply(_m, _code, _reason) : sl_reply(_m, (char*)(long)_code, _reason);
- }
diff --git a/net/ser/files/patch-modules__auth__doc__auth_user.sgml b/net/ser/files/patch-modules__auth__doc__auth_user.sgml
deleted file mode 100644
index c67c487a48e2..000000000000
--- a/net/ser/files/patch-modules__auth__doc__auth_user.sgml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-$FreeBSD$
-
---- modules/auth/doc/auth_user.sgml
-+++ modules/auth/doc/auth_user.sgml
-@@ -33,7 +33,10 @@
- must be loaded before this module):
- <itemizedlist>
- <listitem>
-- <para><emphasis>sl</emphasis> -- Stateless replies</para>
-+ <para><emphasis>sl</emphasis> -- Stateless replies (if <varname>use_tm</varname> is 0)</para>
-+ </listitem>
-+ <listitem>
-+ <para><emphasis>tm</emphasis> -- Transaction module (if <varname>use_tm</varname> is 1)</para>
- </listitem>
- </itemizedlist>
- </para>
-@@ -103,6 +106,26 @@
- <title>rpid_suffix</title>
- <programlisting format="linespecific">
- modparam("auth", "rpid_suffix", "@1.2.3.4>")
-+</programlisting>
-+ </example>
-+ </section>
-+ <section>
-+ <title><varname>use_tm</varname> (integer)</title>
-+ <para>
-+ If set to 1 then the auth will use <function>t_reply()</function> function from
-+ the tm module instead of <function>sl_send_reply()</function> function from the
-+ sl module for sending replies. This allows challenge responses to be processes
-+ statefully if necessary. When set to 1 script writer need to ensure that transaction
-+ exists when <function>www_challenge()</function> or <function>proxy_challenge()</function>
-+ is called, usually by calling <function>t_newtran()</function>.
-+ </para>
-+ <para>
-+ Default value is 0.
-+ </para>
-+ <example>
-+ <title>use_tm example</title>
-+ <programlisting format="linespecific">
-+modparam("auth", "use_tm", 1)
- </programlisting>
- </example>
- </section>
diff --git a/net/ser/files/patch-modules__auth_radius__authrad_mod.c b/net/ser/files/patch-modules__auth_radius__authrad_mod.c
deleted file mode 100644
index faf1196f43ea..000000000000
--- a/net/ser/files/patch-modules__auth_radius__authrad_mod.c
+++ /dev/null
@@ -1,14 +0,0 @@
-
-$FreeBSD$
-
---- modules/auth_radius/authrad_mod.c.orig
-+++ modules/auth_radius/authrad_mod.c
-@@ -69,7 +69,7 @@
- /*
- * Module parameter variables
- */
--static char* radius_config = "/usr/local/etc/radiusclient/radiusclient.conf";
-+static char* radius_config = (CFG_DIR "radiusclient.conf");
- static int service_type = -1;
-
-
diff --git a/net/ser/files/patch-modules__check_ua__Makefile b/net/ser/files/patch-modules__check_ua__Makefile
deleted file mode 100644
index c851e5e6168f..000000000000
--- a/net/ser/files/patch-modules__check_ua__Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-
-$FreeBSD$
-
---- modules/check_ua/Makefile.orig
-+++ modules/check_ua/Makefile
-@@ -0,0 +1,13 @@
-+# $Id: patch-modules::check_ua::Makefile,v 1.2 2005/04/05 13:10:07 netch Exp $
-+#
-+# example module makefile
-+#
-+#
-+# WARNING: do not run this directly, it should be run by the master Makefile
-+
-+include ../../Makefile.defs
-+auto_gen=
-+NAME=check_ua.so
-+LIBS=
-+
-+include ../../Makefile.modules
diff --git a/net/ser/files/patch-modules__check_ua__check_ua.c b/net/ser/files/patch-modules__check_ua__check_ua.c
deleted file mode 100644
index 2b70a6d83c8d..000000000000
--- a/net/ser/files/patch-modules__check_ua__check_ua.c
+++ /dev/null
@@ -1,374 +0,0 @@
-
-$FreeBSD$
-
---- /dev/null Sun Jan 9 11:17:56 2005
-+++ modules/check_ua/check_ua.c Sun Jan 9 11:17:26 2005
-@@ -0,0 +1,368 @@
-+/*
-+ * $Id: patch-modules::check_ua::check_ua.c,v 1.2 2005/04/05 13:10:07 netch Exp $
-+ *
-+ * CHECK_UA module
-+ *
-+ *
-+ * Copyright (C) 2004-2005 Porta Software Ltd.
-+ * Copyright (C) Valentin Nechayev <netch@portaone.com>
-+ *
-+ * This file is part of ser, a free SIP server.
-+ *
-+ * ser is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2 of the License, or
-+ * (at your option) any later version
-+ *
-+ * For a license to use the ser software under conditions
-+ * other than those described here, or to purchase support for this
-+ * software, please contact iptel.org by e-mail at the following addresses:
-+ * info@iptel.org
-+ *
-+ * ser is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-+ */
-+/* History:
-+ * --------
-+ * 2004-12-15 initial version (netch)
-+ *
-+ * 2005-01-09 style(9) and other minor nits (sobomax, netch)
-+ */
-+
-+
-+#include <sys/types.h>
-+#include <regex.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <unistd.h>
-+
-+#include "../../db/db.h"
-+#include "../../db/db_val.h"
-+#include "../../dprint.h"
-+#include "../../error.h"
-+#include "../../flags.h"
-+#include "../../mem/mem.h"
-+#include "../../sr_module.h"
-+
-+#include "tailq.h"
-+
-+MODULE_VERSION
-+
-+static int check_ua_init(void);
-+static int check_ua_exit(void);
-+static int check_ua_f(struct sip_msg *, char *, char *);
-+static int child_init(int);
-+
-+/* parameters */
-+
-+/* global variables */
-+
-+int check_ua_f(struct sip_msg *, char *, char *);
-+
-+static cmd_export_t cmds[]={
-+ {"check_ua", check_ua_f, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE | FAILURE_ROUTE},
-+ {0, 0, 0, 0, 0}
-+};
-+
-+static char *db_url = NULL;
-+static char *db_table = NULL;
-+static db_con_t *db_handle;
-+static int reread_interval = 300;
-+
-+static param_export_t params[]={
-+ {"db_url", STR_PARAM, &db_url},
-+ {"db_table", STR_PARAM, &db_table},
-+ {"reread_interval", INT_PARAM, &reread_interval},
-+ {0, 0, 0}
-+};
-+
-+struct module_exports exports= {
-+ "check_ua",
-+ cmds,
-+ params,
-+
-+ check_ua_init, /* module initialization function */
-+ (response_function) 0,
-+ (destroy_function) check_ua_exit, /* module exit function */
-+ 0,
-+ child_init /* per-child init function */
-+};
-+
-+typedef struct reglist_entry {
-+ TAILQ_ENTRY(reglist_entry) re_link;
-+ char *re_regexp;
-+ regex_t re_compiled;
-+ int re_has_compiled;
-+ int re_flag_num;
-+} reglist_entry;
-+
-+static TAILQ_HEAD(reglist_head_t, reglist_entry) reglist;
-+typedef struct reglist_head_t reglist_head_t;
-+
-+static time_t last_got;
-+
-+static void reglist_entry_free(reglist_entry *);
-+static int load_reglist(reglist_head_t *);
-+static void check_ua_periodic(void);
-+static str *getUserAgent(struct sip_msg *msg);
-+
-+static db_func_t db_functions;
-+
-+static int
-+check_ua_init(void)
-+{
-+
-+ LOG(L_INFO,"CHECK_UA - initializing\n");
-+ if (bind_dbmod(db_url, &db_functions) != 0) {
-+ LOG(L_ERR, "CHECK_UA: init: bind_dbmod() failed\n");
-+ return -1;
-+ }
-+
-+ return 0;
-+}
-+
-+static int
-+child_init(int child)
-+{
-+
-+ TAILQ_INIT(&reglist);
-+ db_handle = db_functions.init(db_url);
-+ if (!db_handle) {
-+ LOG(L_ERR, "CHECK_UA: cannot connect to database\n");
-+ return -1;
-+ }
-+ if (load_reglist(&reglist) < 0)
-+ return -1;
-+ time(&last_got);
-+ srand(time(NULL) + getpid());
-+ return 0;
-+}
-+
-+static int
-+check_ua_exit(void)
-+{
-+
-+ reglist_entry *re;
-+ LOG(L_INFO, "CHECK_UA - destroing module\n");
-+
-+ /* Free reglist */
-+ while ((re = TAILQ_FIRST(&reglist)) != NULL) {
-+ TAILQ_REMOVE(&reglist, re, re_link);
-+ reglist_entry_free(re);
-+ }
-+
-+ return 0;
-+}
-+
-+static int
-+load_reglist_sub(reglist_head_t *head)
-+{
-+
-+ db_key_t cols[2];
-+ db_res_t *db_res;
-+ reglist_entry *re;
-+ int i;
-+ int ret;
-+
-+ ret = -1;
-+ if (db_functions.use_table(db_handle, db_table) < 0) {
-+ LOG(L_ERR, "check_ua: load_reglist(): can't select table\n");
-+ return -1;
-+ }
-+ cols[0] = "rexp";
-+ cols[1] = "flag";
-+ if (db_functions.query(db_handle, NULL, NULL, NULL, cols, 0, 2, NULL, &db_res) < 0) {
-+ LOG(L_ERR, "check_ua: load_reglist(): query failed\n");
-+ return -1;
-+ }
-+ /* Iterate result */
-+ for (i = 0; i < RES_ROW_N(db_res); ++i) {
-+ db_row_t *row = &RES_ROWS(db_res)[i];
-+ db_val_t *val_regexp;
-+ db_val_t *val_flag;
-+ char *r;
-+ int flags;
-+ str t;
-+
-+ if (row->n != 2) {
-+ LOG(L_ERR, "check_ua: load_reglist(): no required columns\n");
-+ goto cleanup;
-+ }
-+ val_regexp = &ROW_VALUES(row)[0];
-+ val_flag = &ROW_VALUES(row)[1];
-+ re = pkg_malloc(sizeof(*re));
-+ if (re == NULL) {
-+ LOG(L_ERR, "ERROR: check_ua: load_reglist(): no memory\n");
-+ goto cleanup;
-+ }
-+ memset(re, '\0', sizeof(*re));
-+ /* First is weight, either absolute or accumulated */
-+ re->re_flag_num = VAL_INT(val_flag);
-+ if (VAL_TYPE(val_regexp) == DB_STRING) {
-+ t.s = (char *)VAL_STRING(val_regexp);
-+ t.len = strlen(t.s);
-+ } else if (VAL_TYPE(val_regexp) == DB_STR) {
-+ t = VAL_STR(val_regexp);
-+ } else {
-+ LOG(L_ERR, "ERROR: check_ua: load_reglist(): invalid value type\n");
-+ goto cleanup;
-+ }
-+ re->re_regexp = pkg_malloc(t.len + 1);
-+ if (re->re_regexp == NULL) {
-+ LOG(L_ERR, "ERROR: check_ua: load_reglist(): no memory\n");
-+ goto cleanup;
-+ }
-+ memcpy(re->re_regexp, t.s, t.len);
-+ re->re_regexp[t.len] = '\0';
-+ flags = REG_EXTENDED;
-+ r = re->re_regexp;
-+ if (strncmp(r, "\\c", 2) == 0) {
-+ r += 2;
-+ flags |= REG_ICASE;
-+ }
-+ if (regcomp(&re->re_compiled, r, flags) != 0) {
-+ LOG(L_ERR, "ERROR: check_ua: load_reglist(): regcomp() failed\n");
-+ reglist_entry_free(re);
-+ goto cleanup;
-+ }
-+ re->re_has_compiled = 1;
-+ TAILQ_INSERT_TAIL(head, re, re_link);
-+ }
-+ ret = 0;
-+cleanup:
-+ db_functions.free_result(db_handle, db_res);
-+ return ret;
-+}
-+
-+static int
-+load_reglist(reglist_head_t *head)
-+{
-+ reglist_entry *re;
-+ int rc;
-+
-+ rc = load_reglist_sub(head);
-+ if (rc < 0) {
-+ /* Free list. This is too hard to add in subfunction. */
-+ while ((re = TAILQ_FIRST(head)) != NULL) {
-+ TAILQ_REMOVE(head, re, re_link);
-+ reglist_entry_free(re);
-+ }
-+ }
-+ return rc;
-+}
-+
-+static int
-+check_ua_f(struct sip_msg *msg, char *dummy1, char *dummy2)
-+{
-+ str *useragent_str;
-+ char *ua;
-+ reglist_entry *re;
-+ time_t now;
-+ int rval;
-+
-+ time(&now);
-+ if (now < last_got || now >= last_got + reread_interval)
-+ check_ua_periodic();
-+
-+ /* Note that getUserAgent() always returns valid pointer */
-+ useragent_str = getUserAgent(msg);
-+ /*
-+ * Make nul-terminated string copy of user-agent. We can't use
-+ * that is in parsed header.
-+ */
-+ ua = pkg_malloc(useragent_str->len + 1);
-+ if (ua == NULL) {
-+ LOG(L_ERR, "ERROR: check_ua: no memory\n");
-+ return -1;
-+ }
-+ memcpy(ua, useragent_str->s, useragent_str->len);
-+ ua[useragent_str->len] = '\0';
-+
-+ rval = -1;
-+ /* Iterate regexp list and set flags on matching */
-+ TAILQ_FOREACH(re, &reglist, re_link) {
-+ int rc;
-+
-+ rc = regexec(&re->re_compiled, ua, 0, NULL, 0);
-+ if (rc == 0) { /* matched */
-+ setflag(msg, re->re_flag_num);
-+ rval = 1;
-+ } else if (rc != REG_NOMATCH) {
-+ /* What's this? */
-+ LOG(L_ERR, "ERROR: check_ua: unexpected regexec error: %d\n", rc);
-+ rval = -1; /* 0 maybe??? */
-+ break;
-+ }
-+ }
-+ pkg_free(ua);
-+ return rval;
-+}
-+
-+static void
-+check_ua_periodic(void)
-+{
-+ reglist_head_t newhead;
-+ reglist_entry *re;
-+
-+ TAILQ_INIT(&newhead);
-+ /*
-+ * Reread base and recompile expression list.
-+ * As we have no way to check whether regexp list was changed,
-+ * do it unconditionally.
-+ */
-+ if (load_reglist(&newhead) < 0) {
-+ LOG(L_ERR, "check_ua: check_ua_periodic(): error reading new regexp file, keeping list from old one\n");
-+ return;
-+ }
-+ /* Delete old list and move all entries of new list to old one */
-+ while ((re = TAILQ_FIRST(&reglist)) != NULL) {
-+ TAILQ_REMOVE(&reglist, re, re_link);
-+ reglist_entry_free(re);
-+ }
-+ while ((re = TAILQ_FIRST(&newhead)) != NULL) {
-+ TAILQ_REMOVE(&newhead, re, re_link);
-+ TAILQ_INSERT_TAIL(&reglist, re, re_link);
-+ }
-+ time(&last_got);
-+ last_got -= (rand() % 3);
-+}
-+
-+static void
-+reglist_entry_free(reglist_entry *re)
-+{
-+ if (re->re_has_compiled)
-+ regfree(&re->re_compiled);
-+ if (re->re_regexp)
-+ pkg_free(re->re_regexp);
-+ pkg_free(re);
-+}
-+
-+#define UA_DUMMY_STR "Unknown"
-+#define UA_DUMMY_LEN 7
-+
-+/* Extract User-Agent */
-+static str *
-+getUserAgent(struct sip_msg *msg)
-+{
-+ static str notfound = {UA_DUMMY_STR, UA_DUMMY_LEN};
-+
-+ if ((parse_headers(msg, HDR_USERAGENT, 0)!=-1) && msg->user_agent &&
-+ msg->user_agent->body.len>0) {
-+ return &(msg->user_agent->body);
-+ }
-+ if ((parse_headers(msg, HDR_SERVER, 0)!=-1) && msg->server &&
-+ msg->server->body.len>0) {
-+ return &(msg->server->body);
-+ }
-+
-+ notfound.s = UA_DUMMY_STR;
-+ notfound.len = UA_DUMMY_LEN;
-+
-+ return &notfound;
-+}
diff --git a/net/ser/files/patch-modules__check_ua__tailq.h b/net/ser/files/patch-modules__check_ua__tailq.h
deleted file mode 100644
index 3e713ea72af8..000000000000
--- a/net/ser/files/patch-modules__check_ua__tailq.h
+++ /dev/null
@@ -1,154 +0,0 @@
-
-$FreeBSD$
-
---- modules/check_ua/tailq.h.orig
-+++ modules/check_ua/tailq.h
-@@ -0,0 +1,148 @@
-+/*
-+ * Copyright (c) 1991, 1993
-+ * The Regents of the University of California. All rights reserved.
-+ *
-+ * Redistribution and use in source and binary forms, with or without
-+ * modification, are permitted provided that the following conditions
-+ * are met:
-+ * 1. Redistributions of source code must retain the above copyright
-+ * notice, this list of conditions and the following disclaimer.
-+ * 2. Redistributions in binary form must reproduce the above copyright
-+ * notice, this list of conditions and the following disclaimer in the
-+ * documentation and/or other materials provided with the distribution.
-+ * 4. Neither the name of the University nor the names of its contributors
-+ * may be used to endorse or promote products derived from this software
-+ * without specific prior written permission.
-+ *
-+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-+ * SUCH DAMAGE.
-+ *
-+ * @(#)queue.h 8.5 (Berkeley) 8/20/94
-+ * $FreeBSD$
-+ */
-+
-+#ifndef TAILQ_H_
-+#define TAILQ_H_
-+
-+/*
-+ * Tail queue declarations.
-+ */
-+#define TAILQ_HEAD(name, type) \
-+struct name { \
-+ struct type *tqh_first; /* first element */ \
-+ struct type **tqh_last; /* addr of last next element */ \
-+}
-+
-+#define TAILQ_HEAD_INITIALIZER(head) \
-+ { NULL, &(head).tqh_first }
-+
-+#define TAILQ_ENTRY(type) \
-+struct { \
-+ struct type *tqe_next; /* next element */ \
-+ struct type **tqe_prev; /* address of previous next element */ \
-+}
-+
-+/*
-+ * Tail queue functions.
-+ */
-+#define TAILQ_CONCAT(head1, head2, field) do { \
-+ if (!TAILQ_EMPTY(head2)) { \
-+ *(head1)->tqh_last = (head2)->tqh_first; \
-+ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
-+ (head1)->tqh_last = (head2)->tqh_last; \
-+ TAILQ_INIT((head2)); \
-+ } \
-+} while (0)
-+
-+#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
-+
-+#define TAILQ_FIRST(head) ((head)->tqh_first)
-+
-+#define TAILQ_FOREACH(var, head, field) \
-+ for ((var) = TAILQ_FIRST((head)); \
-+ (var); \
-+ (var) = TAILQ_NEXT((var), field))
-+
-+#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
-+ for ((var) = TAILQ_FIRST((head)); \
-+ (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
-+ (var) = (tvar))
-+
-+#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
-+ for ((var) = TAILQ_LAST((head), headname); \
-+ (var); \
-+ (var) = TAILQ_PREV((var), headname, field))
-+
-+#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
-+ for ((var) = TAILQ_LAST((head), headname); \
-+ (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
-+ (var) = (tvar))
-+
-+#define TAILQ_INIT(head) do { \
-+ TAILQ_FIRST((head)) = NULL; \
-+ (head)->tqh_last = &TAILQ_FIRST((head)); \
-+} while (0)
-+
-+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
-+ if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
-+ TAILQ_NEXT((elm), field)->field.tqe_prev = \
-+ &TAILQ_NEXT((elm), field); \
-+ else { \
-+ (head)->tqh_last = &TAILQ_NEXT((elm), field); \
-+ } \
-+ TAILQ_NEXT((listelm), field) = (elm); \
-+ (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
-+} while (0)
-+
-+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
-+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
-+ TAILQ_NEXT((elm), field) = (listelm); \
-+ *(listelm)->field.tqe_prev = (elm); \
-+ (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
-+} while (0)
-+
-+#define TAILQ_INSERT_HEAD(head, elm, field) do { \
-+ if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
-+ TAILQ_FIRST((head))->field.tqe_prev = \
-+ &TAILQ_NEXT((elm), field); \
-+ else \
-+ (head)->tqh_last = &TAILQ_NEXT((elm), field); \
-+ TAILQ_FIRST((head)) = (elm); \
-+ (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
-+} while (0)
-+
-+#define TAILQ_INSERT_TAIL(head, elm, field) do { \
-+ TAILQ_NEXT((elm), field) = NULL; \
-+ (elm)->field.tqe_prev = (head)->tqh_last; \
-+ *(head)->tqh_last = (elm); \
-+ (head)->tqh_last = &TAILQ_NEXT((elm), field); \
-+} while (0)
-+
-+#define TAILQ_LAST(head, headname) \
-+ (*(((struct headname *)((head)->tqh_last))->tqh_last))
-+
-+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-+
-+#define TAILQ_PREV(elm, headname, field) \
-+ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
-+
-+#define TAILQ_REMOVE(head, elm, field) do { \
-+ if ((TAILQ_NEXT((elm), field)) != NULL) \
-+ TAILQ_NEXT((elm), field)->field.tqe_prev = \
-+ (elm)->field.tqe_prev; \
-+ else { \
-+ (head)->tqh_last = (elm)->field.tqe_prev; \
-+ } \
-+ *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
-+} while (0)
-+
-+#endif /* !TAILQ_H_ */
diff --git a/net/ser/files/patch-modules__group_radius__grouprad_mod.c b/net/ser/files/patch-modules__group_radius__grouprad_mod.c
deleted file mode 100644
index 51da6a47c822..000000000000
--- a/net/ser/files/patch-modules__group_radius__grouprad_mod.c
+++ /dev/null
@@ -1,14 +0,0 @@
-
-$FreeBSD$
-
---- modules/group_radius/grouprad_mod.c.orig
-+++ modules/group_radius/grouprad_mod.c
-@@ -57,7 +57,7 @@
- /*
- * Module parameter variables
- */
--static char* radius_config = "/usr/local/etc/radiusclient/radiusclient.conf";
-+static char* radius_config = (CFG_DIR "radiusclient.conf");
- int use_domain = 0; /* By default we use domain */
-
-
diff --git a/net/ser/files/patch-modules__mysql__my_con.c b/net/ser/files/patch-modules__mysql__my_con.c
deleted file mode 100644
index 50c1d6070e42..000000000000
--- a/net/ser/files/patch-modules__mysql__my_con.c
+++ /dev/null
@@ -1,15 +0,0 @@
-
-$FreeBSD$
-
---- modules/mysql/my_con.c
-+++ modules/mysql/my_con.c
-@@ -70,6 +70,9 @@
- goto err;
- }
-
-+ /* Enable reconnection explictly */
-+ ptr->con->reconnect = 1;
-+
- ptr->timestamp = time(0);
-
- ptr->id = id;
diff --git a/net/ser/files/patch-modules__nathelper__moh.c b/net/ser/files/patch-modules__nathelper__moh.c
deleted file mode 100644
index 5c8ae4f33059..000000000000
--- a/net/ser/files/patch-modules__nathelper__moh.c
+++ /dev/null
@@ -1,434 +0,0 @@
-
-$FreeBSD$
-
---- modules/nathelper/moh.c
-+++ modules/nathelper/moh.c
-@@ -0,0 +1,428 @@
-+/* $Id: patch-modules::nathelper::moh.c,v 1.2 2005/04/05 13:10:07 netch Exp $
-+ *
-+ * Copyright (C) 2005 Porta Software Ltd
-+ *
-+ * This file is part of ser, a free SIP server.
-+ *
-+ * ser is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2 of the License, or
-+ * (at your option) any later version
-+ *
-+ * For a license to use the ser software under conditions
-+ * other than those described here, or to purchase support for this
-+ * software, please contact iptel.org by e-mail at the following addresses:
-+ * info@iptel.org
-+ *
-+ * ser is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-+ *
-+ */
-+
-+#include <sys/types.h>
-+#include <sys/uio.h>
-+#include <stdio.h>
-+#include <stdlib.h>
-+#include "../../parser/parser_f.h"
-+#include "../../ut.h"
-+#include "nhelpr_funcs.h"
-+#include "nathelper.h"
-+
-+/*
-+ * The following macro is used in force_rtp_proxy2_f() and twice
-+ * in start_moh()
-+ */
-+
-+#define PARSE_PROXY_REPLY \
-+ do { \
-+ argc = 0; \
-+ memset(argv, 0, sizeof(argv)); \
-+ cpend=cp+strlen(cp); \
-+ next=eat_token_end(cp, cpend); \
-+ for (ap = argv; cp<cpend; cp=next+1, next=eat_token_end(cp, cpend)){ \
-+ *next=0; \
-+ if (*cp != '\0') { \
-+ *ap=cp; \
-+ argc++; \
-+ if ((char*)++ap >= ((char*)argv+sizeof(argv))) \
-+ break; \
-+ } \
-+ } \
-+ } while(0)
-+
-+int
-+is_hold_f(struct sip_msg* msg, char *str1, char *str2)
-+{
-+ /* Look into body and find whether we see 0.0.0.0 as IP address.
-+ * extract_mediaport() is designed to parse address from SDP.
-+ * XXX Check all addresses or only first one? What if have some
-+ * real addresses and some zero ones?
-+ */
-+ str body, ip;
-+ int pf;
-+
-+ if (extract_body(msg, &body) == -1) {
-+ LOG(L_ERR,"ERROR: is_hold: cannot extract body from msg!\n");
-+ return 0;
-+ }
-+ if (extract_mediaip(&body, &ip, &pf) == -1) {
-+ LOG(L_ERR, "ERROR: is_hold: can't extract media IP from the SDP\n");
-+ return 0;
-+ }
-+ return isnulladdr(&ip, pf) ? 1 : -1;
-+}
-+
-+int
-+start_moh_f(struct sip_msg* msg, char* str1, char* str2)
-+{
-+ str callid, from_tag, to_tag;
-+ int asymmetric, flookup, force, real;
-+ int oidx, argc, medianum, c1p_altered, pf, pf1;
-+ int seen_audio, seen_video;
-+ str body, body1, tmpstr1, oldip, newip, oldport, newport;
-+ str medianum_str;
-+ char *cpend, *next, *bodylimit, *v1p, *v2p, *c1p, *c2p, *m1p, *m2p;
-+ char *cp;
-+ char medianum_buf[20], opts[16];
-+ char **ap, *argv[10];
-+ unsigned port;
-+ struct rtpp_node *node;
-+ struct iovec v_create[14] = {
-+ {NULL, 0}, /* command */
-+ {NULL, 0}, /* options */
-+ {" ", 1}, /* separator */
-+ {NULL, 0}, /* callid */
-+ {" ", 1}, /* separator */
-+ {NULL, 7}, /* newip */
-+ {" ", 1}, /* separator */
-+ {NULL, 1}, /* oldport */
-+ {" ", 1}, /* separator */
-+ {NULL, 0}, /* from_tag */
-+ {";", 1}, /* separator */
-+ {NULL, 0}, /* medianum */
-+ {" ", 1}, /* separator */
-+ {NULL, 0} /* to_tag */
-+ };
-+ struct iovec v_play[14] = {
-+ {NULL, 0}, /* command */
-+ {NULL, 0}, /* options */
-+ {" ", 1}, /* separator */
-+ {NULL, 0}, /* callid */
-+ {" ", 1}, /* separator */
-+ {NULL, 7}, /* pname */
-+ {" ", 1}, /* separator */
-+ {NULL, 1}, /* codecs */
-+ {" ", 1}, /* separator */
-+ {NULL, 0}, /* to_tag */
-+ {";", 1}, /* separator */
-+ {NULL, 0}, /* medianum */
-+ {" ", 1}, /* separator */
-+ {NULL, 0} /* from_tag */
-+ };
-+
-+ /* extract_body will also parse all the headers in the message as
-+ * a side effect => don't move get_callid/get_to_tag in front of it
-+ * -- andrei */
-+ if (extract_body(msg, &body) == -1) {
-+ LOG(L_ERR, "ERROR: force_rtp_proxy2: can't extract body "
-+ "from the message\n");
-+ return -1;
-+ }
-+ if (get_callid(msg, &callid) == -1 || callid.len == 0) {
-+ LOG(L_ERR, "ERROR: start_moh: can't get Call-Id field\n");
-+ return -1;
-+ }
-+ if (get_to_tag(msg, &to_tag) == -1 || to_tag.len <= 0) {
-+ LOG(L_ERR, "ERROR: start_moh: can't get To tag\n");
-+ return -1;
-+ }
-+ if (get_from_tag(msg, &from_tag) == -1 || from_tag.len == 0) {
-+ LOG(L_ERR, "ERROR: start_moh: can't get From tag\n");
-+ return -1;
-+ }
-+ /* Setting specific options. XXX Do we really need this? */
-+ v_create[1].iov_base = opts;
-+ asymmetric = flookup = force = real = 0;
-+ force = 1; /* XXX we must force the proxying in this case */
-+ oidx = 2; /* 'UW' */
-+#if 0
-+ for (cp = str1; cp != NULL && *cp != '\0'; cp++) {
-+ switch (*cp) {
-+ case 'a':
-+ case 'A':
-+ opts[oidx++] = 'A';
-+ asymmetric = 1;
-+ real = 1;
-+ break;
-+
-+ case 'i':
-+ case 'I':
-+ opts[oidx++] = 'I';
-+ break;
-+
-+ case 'e':
-+ case 'E':
-+ opts[oidx++] = 'E';
-+ break;
-+
-+ case 'l':
-+ case 'L':
-+ flookup = 1;
-+ break;
-+
-+ case 'f':
-+ case 'F':
-+ force = 1;
-+ break;
-+
-+ case 'r':
-+ case 'R':
-+ real = 1;
-+ break;
-+
-+ default:
-+ LOG(L_ERR, "ERROR: force_rtp_proxy2: unknown option `%c'\n", *cp);
-+ return -1;
-+ }
-+ }
-+#endif
-+ /*
-+ * Parsing of SDP body.
-+ * It can contain a few session descriptions (each start with
-+ * "v=" line), and each session may contain a few media descriptions
-+ * (each start with "m=" line).
-+ * We have to change ports in "m=", and also change IP addresses in
-+ * "c=" which can be placed either in session header (fallback for
-+ * all medias) or media description.
-+ * Ports should be allocated for any media. IPs all should be changed
-+ * to the same value (RTP proxy IP), so we can change all "c="
-+ * unconditionally.
-+ *
-+ * Note start_moh() specifics: use only audio media or video media
-+ * and stop after first of them of both kinds. But, medianum should
-+ * reflect all of them.
-+ */
-+ bodylimit = body.s + body.len;
-+ v2p = v1p = find_sdp_line(body.s, bodylimit, 'v');
-+ if (v1p == NULL) {
-+ LOG(L_ERR, "ERROR: start_moh: no sessions in SDP\n");
-+ return -1;
-+ }
-+ medianum = 0;
-+ for(;;) {
-+ /* Per-session iteration. */
-+ v1p = v2p;
-+ if (v1p == NULL || v1p >= bodylimit)
-+ break; /* No sessions left */
-+ v2p = find_next_sdp_line(v1p, bodylimit, 'v', bodylimit);
-+ /* v2p is text limit for session parsing. */
-+ m1p = find_sdp_line(v1p, v2p, 'm');
-+ /* Have this session media description? */
-+ if (m1p == NULL) {
-+ LOG(L_ERR, "ERROR: start_moh: no m= in session\n");
-+ return -1;
-+ }
-+ /*
-+ * Find c1p only between session begin and first media.
-+ * c1p will give common c= for all medias.
-+ */
-+ c1p = find_sdp_line(v1p, m1p, 'c');
-+ c1p_altered = 0;
-+ /* Have session. Iterate media descriptions in session */
-+ seen_audio = seen_video = 0;
-+ m2p = m1p;
-+ while (!seen_audio || !seen_video) {
-+ int is_audio, is_video;
-+ /* We pass address to proxy and get some port from
-+ * its resources. Then, if old address was empty
-+ * (0.0.0.0), create a play stream for this media.
-+ */
-+ m1p = m2p;
-+ if (m1p == NULL || m1p >= v2p)
-+ break;
-+ m2p = find_next_sdp_line(m1p, v2p, 'm', v2p);
-+ /* c2p will point to per-media "c=" */
-+ c2p = find_sdp_line(m1p, m2p, 'c');
-+ ++medianum;
-+ /*
-+ * start_moh() specifics: work only for audio/video
-+ * media and apply to first of any in session.
-+ */
-+ is_audio = (strncmp(m1p, "m=audio ", 8) == 0);
-+ is_video = (strncmp(m1p, "m=video ", 8) == 0);
-+ if ((is_audio && seen_audio) ||
-+ (is_video && seen_video) ||
-+ (!is_audio && !is_video))
-+ continue;
-+ seen_audio = seen_audio || is_audio;
-+ seen_video = seen_video || is_video;
-+ /* Extract address and port */
-+ tmpstr1.s = c2p ? c2p : c1p;
-+ if (tmpstr1.s == NULL) {
-+ /* No "c=" */
-+ LOG(L_ERR, "ERROR: start_moh: can't find media IP in the message\n");
-+ return -1;
-+ }
-+ tmpstr1.len = v2p - tmpstr1.s; /* limit is session limit text */
-+ if (extract_mediaip(&tmpstr1, &oldip, &pf) == -1) {
-+ LOG(L_ERR, "ERROR: start_moh: can't extract media IP "
-+ "from the message\n");
-+ return -1;
-+ }
-+ tmpstr1.s = m1p;
-+ tmpstr1.len = m2p - m1p;
-+ if (extract_mediaport(&tmpstr1, &oldport) == -1) {
-+ LOG(L_ERR, "ERROR: start_moh: can't extract media port "
-+ "from the message\n");
-+ return -1;
-+ }
-+ if (asymmetric != 0 || real != 0) {
-+ newip = oldip;
-+ } else {
-+ newip.s = ip_addr2a(&msg->rcv.src_ip);
-+ newip.len = strlen(newip.s);
-+ }
-+ /* XXX must compare address families in all addresses */
-+ if (pf == AF_INET6) {
-+ opts[oidx] = '6';
-+ oidx++;
-+ }
-+
-+ /*
-+ * If don't see NULL addr, this is not hold.
-+ * So, skip to next one.
-+ * XXX should also support "a=sendonly"
-+ */
-+ if (!isnulladdr(&oldip, pf))
-+ continue;
-+
-+ /* Prepare proxy command strings. */
-+ snprintf(medianum_buf, sizeof medianum_buf, "%d", medianum);
-+ medianum_str.s = medianum_buf;
-+ medianum_str.len = strlen(medianum_buf);
-+ opts[0] = 'U'; opts[1] = 'W';
-+ v_create[1].iov_len = oidx;
-+ STR2IOVEC(callid, v_create[3]);
-+ STR2IOVEC(newip, v_create[5]);
-+ STR2IOVEC(oldport, v_create[7]);
-+ STR2IOVEC(from_tag, v_create[9]);
-+ STR2IOVEC(medianum_str, v_create[11]);
-+ STR2IOVEC(to_tag, v_create[13]);
-+ STR2IOVEC(callid, v_play[3]);
-+ if (is_audio) {
-+ SZ2IOVEC(pname_audio, v_play[5]);
-+ SZ2IOVEC(codecs_audio, v_play[7]);
-+ } else {
-+ SZ2IOVEC(pname_video, v_play[5]);
-+ SZ2IOVEC(codecs_video, v_play[7]);
-+ }
-+ STR2IOVEC(to_tag, v_play[9]);
-+ STR2IOVEC(medianum_str, v_play[11]);
-+ STR2IOVEC(from_tag, v_play[13]);
-+ SZ2IOVEC("P", v_play[1]);
-+ /* Send command. */
-+ do {
-+ node = select_rtpp_node(callid, 1);
-+ if (!node) {
-+ LOG(L_ERR, "ERROR: start_moh: no available proxies\n");
-+ return -1;
-+ }
-+ cp = send_rtpp_command(node, v_create, 14);
-+ if (cp == NULL)
-+ continue;
-+ LOG(L_DBG, "start_moh: proxy reply to update: %s\n", cp);
-+ PARSE_PROXY_REPLY;
-+ if (argc < 1) {
-+ LOG(L_ERR, "start_moh: no reply from rtp proxy\n");
-+ return -1;
-+ }
-+ port = atoi(argv[0]);
-+ if (port <= 0 || port > 65535) {
-+ LOG(L_ERR, "start_moh: incorrect port in reply from rtp proxy\n");
-+ return -1;
-+ }
-+
-+ pf1 = (argc >= 3 && argv[2][0] == '6') ? AF_INET6 : AF_INET;
-+ newip.s = (argc < 2) ? str2 : argv[1];
-+ newip.len = strlen(newip.s);
-+ newport.s = int2str(port, &newport.len); /* beware static buffer */
-+ /* Alter port. */
-+ body1.s = m1p;
-+ body1.len = bodylimit - body1.s;
-+ if (alter_mediaport(msg, &body1, &oldport, &newport, 0) == -1) {
-+ LOG(L_ERR, "start_mon: alter_mediaport() failed\n");
-+ return -1;
-+ }
-+ /* Alter IP. Don't alter IP common for the session
-+ * more than once.
-+ */
-+ if (c2p != NULL || !c1p_altered) {
-+ body1.s = c2p ? c2p : c1p;
-+ body1.len = m2p - body1.s;
-+ if (alter_mediaip(msg, &body1, &oldip, pf, &newip, pf1, 2) == -1) {
-+ LOG(L_ERR, "start_moh: alter_mediaip() failed\n");
-+ return -1;
-+ }
-+ if (!c2p)
-+ c1p_altered = 1;
-+ }
-+ cp = send_rtpp_command(node, v_play, 14);
-+ LOG(L_DBG, "start_moh: proxy reply to play: %s\n", cp);
-+ if (cp == NULL)
-+ continue;
-+ PARSE_PROXY_REPLY;
-+ if (argc < 1) {
-+ LOG(L_ERR, "start_moh: no reply from rtp proxy\n");
-+ return -1;
-+ }
-+ } while(cp == NULL);
-+ } /* Iterate medias in session */
-+ } /* Iterate sessions */
-+ return 1;
-+}
-+
-+int
-+stop_moh_f(struct sip_msg* msg, char* str1, char* str2)
-+{
-+ str callid, to_tag, from_tag;
-+ struct rtpp_node *node;
-+ struct iovec v_noplay[8] = {{NULL, 0}, {"S", 1}, {" ", 1},
-+ {NULL, 0}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 0}};
-+ struct iovec v_del[8] = {{NULL, 0}, {"DW", 2}, {" ", 1},
-+ {NULL, 0}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 0}};
-+
-+ if (get_callid(msg, &callid) == -1 || callid.len == 0) {
-+ LOG(L_ERR, "ERROR: stop_moh: can't get Call-Id field\n");
-+ return -1;
-+ }
-+ if (get_to_tag(msg, &to_tag) == -1 || to_tag.len <= 0) {
-+ LOG(L_ERR, "ERROR: stop_moh: can't get To tag\n");
-+ return -1;
-+ }
-+ if (get_from_tag(msg, &from_tag) == -1 || from_tag.len == 0) {
-+ LOG(L_ERR, "ERROR: stop_moh: can't get From tag\n");
-+ return -1;
-+ }
-+ /* Ask RTP proxy to stop all plays for this tag. We don't iterate
-+ * separate sessions; RTP proxy has knowledge of them.
-+ */
-+ STR2IOVEC(callid, v_noplay[3]);
-+ STR2IOVEC(to_tag, v_noplay[5]);
-+ STR2IOVEC(from_tag, v_noplay[7]);
-+ node = select_rtpp_node(callid, 1);
-+ send_rtpp_command(node, v_noplay, 8);
-+ /* Ask weak deletion for the session. The same as previous;
-+ * RTP proxy knows all sessions.
-+ */
-+ STR2IOVEC(callid, v_del[3]);
-+ STR2IOVEC(to_tag, v_del[5]);
-+ STR2IOVEC(from_tag, v_del[7]);
-+ send_rtpp_command(node, v_del, 8);
-+ return 1;
-+}
diff --git a/net/ser/files/patch-modules__nathelper__nathelper.c b/net/ser/files/patch-modules__nathelper__nathelper.c
deleted file mode 100644
index d85865e0eaa0..000000000000
--- a/net/ser/files/patch-modules__nathelper__nathelper.c
+++ /dev/null
@@ -1,1786 +0,0 @@
-
-$FreeBSD$
-
---- modules/nathelper/nathelper.c.orig
-+++ modules/nathelper/nathelper.c
-@@ -110,14 +110,45 @@
- *
- * 2004-03-22 Fix get_body position (should be called before get_callid)
- * (andrei)
-+ *
- * 2004-03-24 Fix newport for null ip address case (e.g onhold re-INVITE)
- * (andrei)
-- * 2004-09-30 added received port != via port test (andrei)
-+ *
-+ * 2004-09-30 added received port != via port test (andrei)
-+ *
- * 2004-10-10 force_socket option introduced (jiri)
-+ * 2004-12-21 support for multiple medias added (netch)
-+ * 2005-01-18 proxying on protocol type (RTP/AVP, udp, udptl), not
-+ * media type. (sobomax,netch)
-+ *
-+ * 2005-02-24 Added support for using more than one rtp proxy, in which
-+ * case traffic will be distributed evenly among them. In addition,
-+ * each such proxy can be assigned a weight, which will specify
-+ * which share of the traffic should be placed to this particular
-+ * proxy.
-+ *
-+ * Introduce failover mechanism, so that if SER detects that one
-+ * of many proxies is no longer available it temporarily decreases
-+ * its weight to 0, so that no traffic will be assigned to it.
-+ * Such "disabled" proxies are periodically checked to see if they
-+ * are back to normal in which case respective weight is restored
-+ * resulting in traffic being sent to that proxy again.
- *
-+ * Those features can be enabled by specifying more than one "URI"
-+ * in the rtpproxy_sock parameter, optionally followed by the weight,
-+ * which if absent is assumed to be 1, for example:
-+ *
-+ * rtpproxy_sock="unix:/foo/bar=4 udp:1.2.3.4:3456=3 udp:5.6.7.8:5432=1"
-+ *
-+ * 2005-03-24 music-on-hold implemented (netch)
-+ *
-+ * 2007-04-23 Do NAT pinging in the separate dedicated process. It provides much
-+ * better scalability than doing it in the main one.
- */
-
- #include "nhelpr_funcs.h"
-+#include "nathelper.h"
-+#include "../../action.h"
- #include "../../flags.h"
- #include "../../sr_module.h"
- #include "../../dprint.h"
-@@ -127,6 +158,7 @@
- #include "../../forward.h"
- #include "../../mem/mem.h"
- #include "../../parser/parse_from.h"
-+#include "../../parser/parse_hostport.h"
- #include "../../parser/parse_to.h"
- #include "../../parser/parse_uri.h"
- #include "../../parser/parser_f.h"
-@@ -171,39 +203,32 @@
- #define NAT_UAC_TEST_S_1918 0x08
- #define NAT_UAC_TEST_RPORT 0x10
-
--/* Handy macros */
--#define STR2IOVEC(sx, ix) {(ix).iov_base = (sx).s; (ix).iov_len = (sx).len;}
--
- /* Supported version of the RTP proxy command protocol */
- #define SUP_CPROTOVER 20040107
-+/* Required additional version of the RTP proxy command protocol */
-+#define REQ_CPROTOVER "20050322"
- #define CPORT "22222"
-
- static int nat_uac_test_f(struct sip_msg* msg, char* str1, char* str2);
- static int fix_nated_contact_f(struct sip_msg *, char *, char *);
- static int fix_nated_sdp_f(struct sip_msg *, char *, char *);
--static int extract_mediaip(str *, str *, int *);
--static int extract_mediaport(str *, str *);
--static int alter_mediaip(struct sip_msg *, str *, str *, int, str *, int, int);
--static int alter_mediaport(struct sip_msg *, str *, str *, str *, int);
-+static int fixate_sdp_f(struct sip_msg *, char *, char *);
- static char *gencookie();
--static int rtpp_test(int, int);
--static char *send_rtpp_command(struct iovec *, int);
-+static int rtpp_test(struct rtpp_node*, int, int);
- static int unforce_rtp_proxy_f(struct sip_msg *, char *, char *);
-+static int start_recording_f(struct sip_msg *, char *, char *);
- static int force_rtp_proxy0_f(struct sip_msg *, char *, char *);
- static int force_rtp_proxy1_f(struct sip_msg *, char *, char *);
- static int force_rtp_proxy2_f(struct sip_msg *, char *, char *);
- static int fix_nated_register_f(struct sip_msg *, char *, char *);
- static int add_rcv_param_f(struct sip_msg *, char *, char *);
-+static int rewrite_from_from_f(struct sip_msg *, char *, char *);
-
--static void timer(unsigned int, void *);
- inline static int fixup_str2int(void**, int);
- static int mod_init(void);
-+static void mod_cleanup(void);
- static int child_init(int);
-
--static usrloc_api_t ul;
--
--static int cblen = 0;
--static int natping_interval = 0;
- struct socket_info* force_socket = 0;
-
-
-@@ -218,27 +243,51 @@
- {NULL, 0, 0}
- };
-
--/*
-- * If this parameter is set then the natpinger will ping only contacts
-- * that have the NAT flag set in user location database
-- */
--static int ping_nated_only = 0;
--static const char sbuf[4] = {0, 0, 0, 0};
--static char *rtpproxy_sock = "unix:/var/run/rtpproxy.sock";
-+static str sup_ptypes[] = {
-+ {.s = "udp", .len = 3},
-+ {.s = "udptl", .len = 5},
-+ {.s = "rtp/avp", .len = 7},
-+ {.s = NULL, .len = 0}
-+};
-+
-+static char *rtpproxy_sock = "unix:/var/run/rtpproxy.sock"; /* list */
- static char *force_socket_str = 0;
- static int rtpproxy_disable = 0;
- static int rtpproxy_disable_tout = 60;
- static int rtpproxy_retr = 5;
- static int rtpproxy_tout = 1;
--static int umode = 0;
--static int controlfd;
- static pid_t mypid;
- static unsigned int myseqn = 0;
--static int rcv_avp_no=42;
-+static int rcv_avp_no = 42;
-+char *pname_audio = "-";
-+char *pname_video = "-";
-+char *codecs_audio = "-";
-+char *codecs_video = "-";
-+
-+struct rtpp_head {
-+ struct rtpp_node *rn_first;
-+ struct rtpp_node *rn_last;
-+};
-+
-+struct rtpp_node {
-+ char *rn_url; /* unparsed, deletable */
-+ int rn_umode;
-+ char *rn_address; /* substring of rn_url */
-+ int rn_fd; /* control fd */
-+ int rn_disabled; /* found unaccessible? */
-+ unsigned rn_weight; /* for load balancing */
-+ int rn_recheck_ticks;
-+ struct rtpp_node *rn_next;
-+};
-+
-+/* RTP proxy balancing list */
-+static struct rtpp_head rtpp_list;
-+static int rtpp_node_count = 0;
-
- static cmd_export_t cmds[] = {
- {"fix_nated_contact", fix_nated_contact_f, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE },
- {"fix_nated_sdp", fix_nated_sdp_f, 1, fixup_str2int, REQUEST_ROUTE | ONREPLY_ROUTE | FAILURE_ROUTE },
-+ {"fixate_sdp", fixate_sdp_f, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE },
- {"unforce_rtp_proxy", unforce_rtp_proxy_f, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE | FAILURE_ROUTE },
- {"force_rtp_proxy", force_rtp_proxy0_f, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE },
- {"force_rtp_proxy", force_rtp_proxy1_f, 1, 0, REQUEST_ROUTE | ONREPLY_ROUTE },
-@@ -246,11 +295,17 @@
- {"nat_uac_test", nat_uac_test_f, 1, fixup_str2int, REQUEST_ROUTE | ONREPLY_ROUTE | FAILURE_ROUTE },
- {"fix_nated_register", fix_nated_register_f, 0, 0, REQUEST_ROUTE },
- {"add_rcv_param", add_rcv_param_f, 0, 0, REQUEST_ROUTE },
-+ {"rewrite_from_from", rewrite_from_from_f, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE },
-+ {"is_hold", is_hold_f, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE },
-+ {"start_moh", start_moh_f, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE },
-+ {"stop_moh", stop_moh_f, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE },
-+ {"start_recording", start_recording_f, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE },
- {0, 0, 0, 0, 0}
- };
-
- static param_export_t params[] = {
- {"natping_interval", INT_PARAM, &natping_interval },
-+ {"natping_method", STR_PARAM, &natping_method },
- {"ping_nated_only", INT_PARAM, &ping_nated_only },
- {"rtpproxy_sock", STR_PARAM, &rtpproxy_sock },
- {"rtpproxy_disable", INT_PARAM, &rtpproxy_disable },
-@@ -259,6 +314,10 @@
- {"rtpproxy_tout", INT_PARAM, &rtpproxy_tout },
- {"received_avp", INT_PARAM, &rcv_avp_no },
- {"force_socket", STR_PARAM, &force_socket_str },
-+ {"pname_audio", STR_PARAM, &pname_audio },
-+ {"pname_video", STR_PARAM, &pname_video },
-+ {"codecs_audio", STR_PARAM, &codecs_audio },
-+ {"codecs_video", STR_PARAM, &codecs_video },
- {0, 0, 0}
- };
-
-@@ -268,7 +327,7 @@
- params,
- mod_init,
- 0, /* reply processing */
-- 0, /* destroy function */
-+ mod_cleanup, /* destroy function */
- 0, /* on_break */
- child_init
- };
-@@ -277,8 +336,6 @@
- mod_init(void)
- {
- int i;
-- char *cp;
-- bind_usrloc_t bind_usrloc;
- struct in_addr addr;
- str socket_str;
-
-@@ -288,18 +345,9 @@
- force_socket=grep_sock_info(&socket_str,0,0);
- }
-
-- if (natping_interval > 0) {
-- bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0);
-- if (!bind_usrloc) {
-- LOG(L_ERR, "nathelper: Can't find usrloc module\n");
-- return -1;
-- }
--
-- if (bind_usrloc(&ul) < 0) {
-- return -1;
-- }
--
-- register_timer(timer, NULL, natping_interval);
-+ if (natpinger_init() < 0) {
-+ LOG(L_ERR, "nathelper: natpinger_init() failed\n");
-+ return -1;
- }
-
- /* Prepare 1918 networks list */
-@@ -309,83 +357,154 @@
- nets_1918[i].netaddr = ntohl(addr.s_addr) & nets_1918[i].mask;
- }
-
-+ memset(&rtpp_list, 0, sizeof(rtpp_list));
-+ rtpp_node_count = 0;
- if (rtpproxy_disable == 0) {
-- /* Make rtpproxy_sock writable */
-- cp = pkg_malloc(strlen(rtpproxy_sock) + 1);
-- if (cp == NULL) {
-- LOG(L_ERR, "nathelper: Can't allocate memory\n");
-- return -1;
-- }
-- strcpy(cp, rtpproxy_sock);
-- rtpproxy_sock = cp;
-+ /* Make rtp proxies list. */
-+ char *p, *p1, *p2, *plim;
-
-- if (strncmp(rtpproxy_sock, "udp:", 4) == 0) {
-- umode = 1;
-- rtpproxy_sock += 4;
-- } else if (strncmp(rtpproxy_sock, "udp6:", 5) == 0) {
-- umode = 6;
-- rtpproxy_sock += 5;
-- } else if (strncmp(rtpproxy_sock, "unix:", 5) == 0) {
-- umode = 0;
-- rtpproxy_sock += 5;
-+ p = rtpproxy_sock;
-+ plim = p + strlen(p);
-+ for(;;) {
-+ struct rtpp_node *pnode;
-+ int weight;
-+
-+ weight = 1;
-+ while (*p && isspace(*p))
-+ ++p;
-+ if (p >= plim)
-+ break;
-+ p1 = p;
-+ while (*p && !isspace(*p))
-+ ++p;
-+ if (p <= p1)
-+ break; /* may happen??? */
-+ /* Have weight specified? If yes, scan it */
-+ p2 = memchr(p1, '=', p - p1);
-+ if (p2 != NULL) {
-+ weight = strtoul(p2 + 1, NULL, 10);
-+ } else {
-+ p2 = p;
-+ }
-+ pnode = pkg_malloc(sizeof(struct rtpp_node));
-+ if (pnode == NULL) {
-+ LOG(L_ERR, "nathelper: Can't allocate memory\n");
-+ return -1;
-+ }
-+ memset(pnode, 0, sizeof(*pnode));
-+ pnode->rn_recheck_ticks = 0;
-+ pnode->rn_weight = weight;
-+ pnode->rn_umode = 0;
-+ pnode->rn_fd = -1;
-+ pnode->rn_disabled = 0;
-+ pnode->rn_url = pkg_malloc(p2 - p1 + 1);
-+ if (pnode->rn_url == NULL) {
-+ LOG(L_ERR, "nathelper: Can't allocate memory\n");
-+ return -1;
-+ }
-+ memmove(pnode->rn_url, p1, p2 - p1);
-+ pnode->rn_url[p2 - p1] = 0;
-+ if (rtpp_list.rn_first == NULL) {
-+ rtpp_list.rn_first = pnode;
-+ } else {
-+ rtpp_list.rn_last->rn_next = pnode;
-+ }
-+ rtpp_list.rn_last = pnode;
-+ ++rtpp_node_count;
-+ /* Leave only address in rn_address */
-+ pnode->rn_address = pnode->rn_url;
-+ if (strncmp(pnode->rn_address, "udp:", 4) == 0) {
-+ pnode->rn_umode = 1;
-+ pnode->rn_address += 4;
-+ } else if (strncmp(pnode->rn_address, "udp6:", 5) == 0) {
-+ pnode->rn_umode = 6;
-+ pnode->rn_address += 5;
-+ } else if (strncmp(pnode->rn_address, "unix:", 5) == 0) {
-+ pnode->rn_umode = 0;
-+ pnode->rn_address += 5;
-+ }
- }
- }
-
- return 0;
- }
-
-+static void
-+mod_cleanup(void)
-+{
-+
-+ natpinger_cleanup();
-+}
-+
- static int
- child_init(int rank)
- {
- int n;
- char *cp;
- struct addrinfo hints, *res;
-+ struct rtpp_node *pnode;
-
-- if (rtpproxy_disable == 0) {
-- mypid = getpid();
-- if (umode != 0) {
-- cp = strrchr(rtpproxy_sock, ':');
-- if (cp != NULL) {
-- *cp = '\0';
-- cp++;
-- }
-- if (cp == NULL || *cp == '\0')
-- cp = CPORT;
-+ if (natpinger_child_init(rank) < 0)
-+ return -1;
-
-- memset(&hints, 0, sizeof(hints));
-- hints.ai_flags = 0;
-- hints.ai_family = (umode == 6) ? AF_INET6 : AF_INET;
-- hints.ai_socktype = SOCK_DGRAM;
-- if ((n = getaddrinfo(rtpproxy_sock, cp, &hints, &res)) != 0) {
-- LOG(L_ERR, "nathelper: getaddrinfo: %s\n", gai_strerror(n));
-- return -1;
-- }
-+ /* Iterate known RTP proxies - create sockets */
-+ mypid = getpid();
-+ for (pnode = rtpp_list.rn_first; pnode != NULL; pnode = pnode->rn_next) {
-+ char *old_colon;
-
-- controlfd = socket((umode == 6) ? AF_INET6 : AF_INET, SOCK_DGRAM, 0);
-- if (controlfd == -1) {
-- LOG(L_ERR, "nathelper: can't create socket\n");
-- freeaddrinfo(res);
-- return -1;
-- }
-+ if (pnode->rn_umode == 0)
-+ goto rptest;
-+ /*
-+ * This is UDP or UDP6. Detect host and port; lookup host;
-+ * do connect() in order to specify peer address
-+ */
-+ old_colon = cp = strrchr(pnode->rn_address, ':');
-+ if (cp != NULL) {
-+ old_colon = cp;
-+ *cp = '\0';
-+ cp++;
-+ }
-+ if (cp == NULL || *cp == '\0')
-+ cp = CPORT;
-
-- if (connect(controlfd, res->ai_addr, res->ai_addrlen) == -1) {
-- LOG(L_ERR, "nathelper: can't connect to a RTP proxy\n");
-- close(controlfd);
-- freeaddrinfo(res);
-- return -1;
-- }
-+ memset(&hints, 0, sizeof(hints));
-+ hints.ai_flags = 0;
-+ hints.ai_family = (pnode->rn_umode == 6) ? AF_INET6 : AF_INET;
-+ hints.ai_socktype = SOCK_DGRAM;
-+ if ((n = getaddrinfo(pnode->rn_address, cp, &hints, &res)) != 0) {
-+ LOG(L_ERR, "nathelper: getaddrinfo: %s\n", gai_strerror(n));
-+ return -1;
-+ }
-+ if (old_colon)
-+ *old_colon = ':'; /* restore rn_address */
-+
-+ pnode->rn_fd = socket((pnode->rn_umode == 6)
-+ ? AF_INET6 : AF_INET, SOCK_DGRAM, 0);
-+ if (pnode->rn_fd == -1) {
-+ LOG(L_ERR, "nathelper: can't create socket\n");
- freeaddrinfo(res);
-+ return -1;
- }
-
-- rtpproxy_disable = rtpp_test(0, 1);
-- } else {
-- rtpproxy_disable_tout = -1;
-+ if (connect(pnode->rn_fd, res->ai_addr, res->ai_addrlen) == -1) {
-+ LOG(L_ERR, "nathelper: can't connect to a RTP proxy\n");
-+ close(pnode->rn_fd);
-+ pnode->rn_fd = -1;
-+ freeaddrinfo(res);
-+ return -1;
-+ }
-+ freeaddrinfo(res);
-+rptest:
-+ pnode->rn_disabled = rtpp_test(pnode, 0, 1);
- }
-
-+ if (rtpproxy_disable)
-+ rtpproxy_disable_tout = -1;
-+
- return 0;
- }
-
--static int
-+int
- isnulladdr(str *sx, int pf)
- {
- char *cp;
-@@ -440,7 +559,7 @@
- * assumes the to header is already parsed, so
- * make sure it really is before calling this function
- */
--static inline int
-+int
- get_to_tag(struct sip_msg* _m, str* _tag)
- {
-
-@@ -464,7 +583,7 @@
- /*
- * Extract tag from From header field of a request
- */
--static inline int
-+int
- get_from_tag(struct sip_msg* _m, str* _tag)
- {
-
-@@ -489,7 +608,7 @@
- * (so make sure it is, before calling this function or
- * it might fail even if the message _has_ a callid)
- */
--static inline int
-+int
- get_callid(struct sip_msg* _m, str* _cid)
- {
-
-@@ -563,9 +682,13 @@
- if (anchor == 0)
- return -1;
-
-- hostport = uri.host;
-- if (uri.port.len > 0)
-- hostport.len = uri.port.s + uri.port.len - uri.host.s;
-+ if (uri.maddr_val.len == 0) {
-+ hostport = uri.host;
-+ if (uri.port.len > 0)
-+ hostport.len = uri.port.s + uri.port.len - uri.host.s;
-+ } else {
-+ hostport = uri.maddr_val;
-+ }
-
- cp = ip_addr2a(&msg->rcv.src_ip);
- len = c->uri.len + strlen(cp) + 6 /* :port */ - hostport.len + 1;
-@@ -652,11 +775,22 @@
- {
- struct sip_uri uri;
- contact_t* c;
-+ char t;
-+ str host;
-+ short int port;
-
- if (get_contact_uri(msg, &uri, &c) == -1)
- return -1;
-
-- return (is1918addr(&(uri.host)) == 1) ? 1 : 0;
-+ if (uri.maddr_val.len == 0)
-+ return (is1918addr(&(uri.host)) == 1) ? 1 : 0;
-+ t = uri.maddr_val.s[uri.maddr_val.len];
-+ uri.maddr_val.s[uri.maddr_val.len] = '\0';
-+ parse_hostport(uri.maddr_val.s, &host, &port);
-+ uri.maddr_val.s[uri.maddr_val.len] = t;
-+ if (host.len <= 0)
-+ return 0;
-+ return (is1918addr(&host) == 1) ? 1 : 0;
- }
-
- /*
-@@ -756,8 +890,8 @@
- static int
- fix_nated_sdp_f(struct sip_msg* msg, char* str1, char* str2)
- {
-- str body, body1, oldip, oldip1, newip;
-- int level, pf, pf1;
-+ str body, body1, oldip, newip;
-+ int level, pf;
- char *buf;
- struct lump* anchor;
-
-@@ -804,37 +938,43 @@
- }
-
- if (level & FIX_MEDIP) {
-- if (extract_mediaip(&body, &oldip, &pf) == -1) {
-- LOG(L_ERR, "ERROR: fix_nated_sdp: can't extract media IP from the SDP\n");
-- goto finalize;
-- }
-- if (pf != AF_INET) {
-- LOG(L_ERR, "ERROR: fix_nated_sdp: "
-- "not an IPv4 address in SDP\n");
-- goto finalize;
-- }
-- body1.s = oldip.s + oldip.len;
-- body1.len = body.s + body.len - body1.s;
-- if (extract_mediaip(&body1, &oldip1, &pf1) == -1) {
-- oldip1.len = 0;
-- }
-- if (oldip1.len > 0 && pf != pf1) {
-- LOG(L_ERR, "ERROR: fix_nated_sdp: mismatching "
-- "address families in SDP\n");
-- return -1;
-- }
--
-+ /* Iterate all c= and replace ips in them. */
-+ unsigned hasreplaced = 0;
-+ int pf1 = 0;
-+ str body2;
-+ char* bodylimit = body.s + body.len;
- newip.s = ip_addr2a(&msg->rcv.src_ip);
- newip.len = strlen(newip.s);
-- if (alter_mediaip(msg, &body, &oldip, pf, &newip, pf,
-- 1) == -1) {
-- LOG(L_ERR, "ERROR: fix_nated_sdp: can't alter media IP");
-- return -1;
-+ body1 = body;
-+ for(;;) {
-+ if (extract_mediaip(&body1, &oldip, &pf) == -1)
-+ break;
-+ if (pf != AF_INET) {
-+ LOG(L_ERR, "ERROR: fix_nated_sdp: "
-+ "not an IPv4 address in SDP\n");
-+ goto finalize;
-+ }
-+ if (!pf1)
-+ pf1 = pf;
-+ else if (pf != pf1) {
-+ LOG(L_ERR, "ERROR: fix_nated_sdp: mismatching "
-+ "address families in SDP\n");
-+ return -1;
-+ }
-+ body2.s = oldip.s + oldip.len;
-+ body2.len = bodylimit - body2.s;
-+ if (alter_mediaip(msg, &body1, &oldip, pf, &newip, pf,
-+ 1) == -1)
-+ {
-+ LOG(L_ERR, "ERROR: fix_nated_sdp: can't alter media IP");
-+ return -1;
-+ }
-+ hasreplaced = 1;
-+ body1 = body2;
- }
-- if (oldip1.len > 0 && alter_mediaip(msg, &body, &oldip1, pf1,
-- &newip, pf, 0) == -1) {
-- LOG(L_ERR, "ERROR: fix_nated_sdp: can't alter media IP");
-- return -1;
-+ if (!hasreplaced) {
-+ LOG(L_ERR, "ERROR: fix_nated_sdp: can't extract media IP from the SDP\n");
-+ goto finalize;
- }
- }
-
-@@ -842,7 +982,7 @@
- return 1;
- }
-
--static int
-+int
- extract_mediaip(str *body, str *mediaip, int *pf)
- {
- char *cp, *cp1;
-@@ -856,7 +996,7 @@
- cp = cp1 + 2;
- }
- if (cp1 == NULL) {
-- LOG(L_DBG, "ERROR: extract_mediaip: no `c=' in SDP\n");
-+ LOG(L_ERR, "ERROR: extract_mediaip: no `c=' in SDP\n");
- return -1;
- }
- mediaip->s = cp1 + 2;
-@@ -898,11 +1038,12 @@
- return 1;
- }
-
--static int
-+int
- extract_mediaport(str *body, str *mediaport)
- {
- char *cp, *cp1;
-- int len;
-+ int len, i;
-+ str ptype;
-
- cp1 = NULL;
- for (cp = body->s; (len = body->s + body->len - cp) > 0;) {
-@@ -915,32 +1056,62 @@
- LOG(L_ERR, "ERROR: extract_mediaport: no `m=' in SDP\n");
- return -1;
- }
-- mediaport->s = cp1 + 2;
-+ mediaport->s = cp1 + 2; /* skip `m=' */
- mediaport->len = eat_line(mediaport->s, body->s + body->len -
- mediaport->s) - mediaport->s;
- trim_len(mediaport->len, mediaport->s, *mediaport);
-
-- if (mediaport->len > 6 && memcmp(mediaport->s, "audio", 5) == 0 &&
-- isspace((int)mediaport->s[5])) {
-- mediaport->s += 5;
-- mediaport->len -= 5;
-- } else if (mediaport->len > 12 && memcmp(mediaport->s, "application", 11) == 0 &&
-- isspace((int)mediaport->s[11])) {
-- mediaport->s += 11;
-- mediaport->len -= 11;
-- } else {
-- LOG(L_ERR, "ERROR: extract_mediaport: can't parse `m=' in SDP\n");
-+ /* Skip media supertype and spaces after it */
-+ cp = eat_token_end(mediaport->s, mediaport->s + mediaport->len);
-+ mediaport->len -= cp - mediaport->s;
-+ if (mediaport->len <= 0 || cp == mediaport->s) {
-+ LOG(L_ERR, "ERROR: extract_mediaport: no port in `m='\n");
- return -1;
- }
-+ mediaport->s = cp;
- cp = eat_space_end(mediaport->s, mediaport->s + mediaport->len);
-- mediaport->len = eat_token_end(cp, mediaport->s + mediaport->len) - cp;
-+ mediaport->len -= cp - mediaport->s;
-+ if (mediaport->len <= 0 || cp == mediaport->s) {
-+ LOG(L_ERR, "ERROR: extract_mediaport: no port in `m='\n");
-+ return -1;
-+ }
-+ /* Extract port */
- mediaport->s = cp;
-- return 1;
-+ cp = eat_token_end(mediaport->s, mediaport->s + mediaport->len);
-+ ptype.len = mediaport->len - (cp - mediaport->s);
-+ if (ptype.len <= 0 || cp == mediaport->s) {
-+ LOG(L_ERR, "ERROR: extract_mediaport: no port in `m='\n");
-+ return -1;
-+ }
-+ ptype.s = cp;
-+ mediaport->len = cp - mediaport->s;
-+ /* Skip spaces after port */
-+ cp = eat_space_end(ptype.s, ptype.s + ptype.len);
-+ ptype.len -= cp - ptype.s;
-+ if (ptype.len <= 0 || cp == ptype.s) {
-+ LOG(L_ERR, "ERROR: extract_mediaport: no protocol type in `m='\n");
-+ return -1;
-+ }
-+ /* Extract protocol type */
-+ ptype.s = cp;
-+ cp = eat_token_end(ptype.s, ptype.s + ptype.len);
-+ if (cp == ptype.s) {
-+ LOG(L_ERR, "ERROR: extract_mediaport: no protocol type in `m='\n");
-+ return -1;
-+ }
-+ ptype.len = cp - ptype.s;
-+
-+ for (i = 0; sup_ptypes[i].s != NULL; i++)
-+ if (ptype.len == sup_ptypes[i].len &&
-+ strncasecmp(ptype.s, sup_ptypes[i].s, ptype.len) == 0)
-+ return 0;
-+ /* Unproxyable protocol type. Generally it isn't error. */
-+ return -1;
- }
-
--static int
-+int
- alter_mediaip(struct sip_msg *msg, str *body, str *oldip, int oldpf,
-- str *newip, int newpf, int preserve)
-+ str *newip, int newpf, int flags)
- {
- char *buf;
- int offset;
-@@ -948,7 +1119,7 @@
- str omip, nip, oip;
-
- /* check that updating mediaip is really necessary */
-- if (oldpf == newpf && isnulladdr(oldip, oldpf))
-+ if (oldpf == newpf && isnulladdr(oldip, oldpf) && !(flags & 2))
- return 0;
- if (newip->len == oldip->len &&
- memcmp(newip->s, oldip->s, newip->len) == 0)
-@@ -961,7 +1132,7 @@
- * another request comes.
- */
- #if 0
-- /* disabled:
-+ /* disabled:
- * - alter_mediaip is called twice if 2 c= lines are present
- * in the sdp (and we want to allow it)
- * - the message flags are propagated in the on_reply_route
-@@ -976,7 +1147,7 @@
- }
- #endif
-
-- if (preserve != 0) {
-+ if ((flags & 1) != 0) {
- anchor = anchor_lump(msg, body->s + body->len - msg->buf, 0, 0);
- if (anchor == NULL) {
- LOG(L_ERR, "ERROR: alter_mediaip: anchor_lump failed\n");
-@@ -1052,7 +1223,7 @@
- return 0;
- }
-
--static int
-+int
- alter_mediaport(struct sip_msg *msg, str *body, str *oldport, str *newport,
- int preserve)
- {
-@@ -1128,6 +1299,161 @@
- return 0;
- }
-
-+/*
-+ * Finds specified text in area [*pp...bodylimit) at line beginning.
-+ * Returns pointer to text, updates *pp to position after it.
-+ */
-+
-+static char*
-+find_sdp_text_bol(char **pp, char *plimit, char *text, size_t textlen)
-+{
-+ /* Find text at beginning of line */
-+ if (*pp == NULL)
-+ return NULL;
-+ for(;;) {
-+ char* p;
-+ if (*pp >= plimit)
-+ return NULL;
-+ if (!(p = ser_memmem(*pp, text, plimit - *pp, textlen))) {
-+ *pp = plimit;
-+ return NULL;
-+ }
-+ *pp = p + 1;
-+ if (p[-1] != '\n' && p[-1] != '\r')
-+ continue;
-+ return p;
-+ }
-+ /*UNREACHED*/
-+ return NULL;
-+}
-+
-+static int
-+fixate_sdp_f(struct sip_msg* msg, char* str1, char* str2)
-+{
-+ char *cp;
-+ int newpf;
-+ str body, newip, newport, dest, oldip, oldport;
-+ struct sip_uri ruri;
-+ struct hdr_field *hdr;
-+ struct via_body *rvia;
-+ char *bodylimit, *v1p, *v2p, *m1p, *m2p, *c1p, *c2p;
-+ char *om_ip_pos, *om_port_pos;
-+ int c1_altered;
-+
-+ if (msg->first_line.type == SIP_REQUEST &&
-+ msg->first_line.u.request.method_value == METHOD_INVITE) {
-+ LOG(L_ERR, "DEBUG: fixate_sdp: request\n");
-+ if (msg->parsed_uri_ok) {
-+ dest = msg->parsed_uri.host;
-+ } else {
-+ if (parse_uri(msg->new_uri.s, msg->new_uri.len, &ruri) < 0) {
-+ LOG(L_ERR, "ERROR: fixate_sdp: can't parse request uri\n");
-+ return -1;
-+ }
-+ dest = ruri.host;
-+ }
-+ } else if (msg->first_line.type == SIP_REPLY) {
-+ LOG(L_ERR, "DEBUG: fixate_sdp: reply\n");
-+ rvia = NULL;
-+ for (hdr=msg->headers; hdr; hdr=hdr->next) {
-+ if (hdr->type == HDR_VIA)
-+ rvia = hdr->parsed;
-+ }
-+ if (rvia == NULL) {
-+ LOG(L_ERR, "ERROR: fixate_sdp: no or incorrect Via in reply\n");
-+ return -1;
-+ }
-+ if (rvia->received != NULL) {
-+ dest = rvia->received->value;
-+ } else {
-+ dest = rvia->host;
-+ }
-+ } else {
-+ return -1;
-+ }
-+
-+ if (extract_body(msg, &body) == -1 || body.len == 0) {
-+ LOG(L_ERR, "ERROR: fixate_sdp: can't extract body "
-+ "from the message\n");
-+ return -1;
-+ }
-+ bodylimit = body.s + body.len;
-+ v2p = v1p = find_sdp_line(body.s, bodylimit, 'v');
-+ if (!v1p) {
-+ LOG(L_ERR, "fixate_sdp: no sessions found\n");
-+ return -1;
-+ }
-+ om_ip_pos = body.s;
-+ om_port_pos = body.s;
-+ for(;;) {
-+ v1p = v2p;
-+ if (v1p == NULL || v1p >= bodylimit)
-+ break;
-+ v2p = find_next_sdp_line(v1p, bodylimit, 'v', bodylimit);
-+ m2p = m1p = find_sdp_line(v1p, v2p, 'm');
-+ c1p = find_sdp_line(v1p, v2p, 'c');
-+ c1_altered = 0;
-+ if (!m1p) {
-+ LOG(L_ERR, "fixate_sdp: session without media\n");
-+ return -1;
-+ }
-+ for(;;) {
-+ str tmpstr1;
-+ m1p = m2p;
-+ if (m1p == NULL || m1p >= v2p)
-+ break;
-+ m2p = find_next_sdp_line(m1p, v2p, 'm', v2p);
-+ c2p = find_sdp_line(m1p, m2p, 'c');
-+ /* Set old port and IP. Order doesn't matter. */
-+ tmpstr1.s = m1p;
-+ tmpstr1.len = bodylimit - m1p;
-+ if (extract_mediaport(&tmpstr1, &newport) == -1) {
-+ LOG(L_ERR, "ERROR: fixate_sdp: can't extract media port from the SDP\n");
-+ return -1;
-+ }
-+ cp = find_sdp_text_bol(&om_port_pos, bodylimit, AOLDMEDPRT, AOLDMEDPRT_LEN);
-+ if (cp) {
-+ oldport.s = cp + AOLDMEDPRT_LEN;
-+ oldport.len = eat_line(oldport.s, bodylimit - oldport.s) - oldport.s;
-+ trim_len(oldport.len, oldport.s, oldport);
-+ if (oldport.len != 0 &&
-+ alter_mediaport(msg, &body, &newport, &oldport, 0) == -1)
-+ return -1;
-+ }
-+ if (c2p || !c1_altered) {
-+ tmpstr1.s = c2p ? c2p : c1p;
-+ tmpstr1.len = bodylimit - tmpstr1.s;
-+ if (extract_mediaip(&tmpstr1, &newip, &newpf) == -1) {
-+ LOG(L_ERR, "ERROR: fixate_sdp: can't extract media IP from the SDP\n");
-+ return -1;
-+ }
-+ if (newip.len != dest.len || memcmp(newip.s, dest.s, dest.len) != 0 ||
-+ isnulladdr(&newip, newpf))
-+ return -1;
-+ cp = find_sdp_text_bol(&om_ip_pos, bodylimit, AOLDMEDIP, AOLDMEDIP_LEN);
-+ if (cp) {
-+ oldip.s = cp + AOLDMEDIP_LEN;
-+ oldip.len = eat_line(oldip.s, bodylimit - oldip.s) - oldip.s;
-+ trim_len(oldip.len, oldip.s, oldip);
-+ }
-+ if (newip.len == oldip.len &&
-+ memcmp(newip.s, oldip.s, newip.len) == 0)
-+ oldip.len = 0;
-+
-+ if (oldip.len != 0) {
-+ if (alter_mediaip(msg, &body, &newip, newpf, &oldip, AF_INET,
-+ 0) == -1)
-+ return -1;
-+ }
-+ if (!c2p)
-+ c1_altered = 1;
-+ } /* if rewrite IP */
-+ } /* medias */
-+ } /* sessions */
-+
-+ return 1;
-+}
-+
- static char *
- gencookie()
- {
-@@ -1139,45 +1465,58 @@
- }
-
- static int
--rtpp_test(int isdisabled, int force)
-+rtpp_test(struct rtpp_node *node, int isdisabled, int force)
- {
- int rtpp_ver;
-- static int recheck_ticks = 0;
- char *cp;
- struct iovec v[2] = {{NULL, 0}, {"V", 1}};
-+ struct iovec vf[4] = {{NULL, 0}, {"VF", 2}, {" ", 1},
-+ {REQ_CPROTOVER, 8}};
-
- if (force == 0) {
- if (isdisabled == 0)
- return 0;
-- if (recheck_ticks > get_ticks())
-+ if (node->rn_recheck_ticks > get_ticks())
- return 1;
- }
-- cp = send_rtpp_command(v, 2);
-- if (cp == NULL) {
-- LOG(L_WARN,"WARNING: rtpp_test: can't get version of "
-- "the RTP proxy\n");
-- } else {
-+ do {
-+ cp = send_rtpp_command(node, v, 2);
-+ if (cp == NULL) {
-+ LOG(L_WARN,"WARNING: rtpp_test: can't get version of "
-+ "the RTP proxy\n");
-+ break;
-+ }
- rtpp_ver = atoi(cp);
-- if (rtpp_ver == SUP_CPROTOVER) {
-- LOG(L_INFO, "rtpp_test: RTP proxy found, support for "
-- "it %senabled\n", force == 0 ? "re-" : "");
-- return 0;
-+ if (rtpp_ver != SUP_CPROTOVER) {
-+ LOG(L_WARN, "WARNING: rtpp_test: unsupported "
-+ "version of RTP proxy <%s> found: %d supported, "
-+ "%d present\n", node->rn_url,
-+ SUP_CPROTOVER, rtpp_ver);
-+ break;
- }
-- LOG(L_WARN, "WARNING: rtpp_test: unsupported "
-- "version of RTP proxy found: %d supported, "
-- "%d present\n", SUP_CPROTOVER, rtpp_ver);
-- }
-- LOG(L_WARN, "WARNING: rtpp_test: support for RTP proxy "
-- "has been disabled%s\n",
-+ cp = send_rtpp_command(node, vf, 4);
-+ if (cp[0] == 'E' || atoi(cp) != 1) {
-+ LOG(L_WARN, "WARNING: rtpp_test: of RTP proxy <%s>"
-+ "doesn't support required protocol version %s\n",
-+ node->rn_url, REQ_CPROTOVER);
-+ break;
-+ }
-+ LOG(L_INFO, "rtpp_test: RTP proxy <%s> found, support for "
-+ "it %senabled\n",
-+ node->rn_url, force == 0 ? "re-" : "");
-+ return 0;
-+ } while(0);
-+ LOG(L_WARN, "WARNING: rtpp_test: support for RTP proxy <%s>"
-+ "has been disabled%s\n", node->rn_url,
- rtpproxy_disable_tout < 0 ? "" : " temporarily");
- if (rtpproxy_disable_tout >= 0)
-- recheck_ticks = get_ticks() + rtpproxy_disable_tout;
-+ node->rn_recheck_ticks = get_ticks() + rtpproxy_disable_tout;
-
- return 1;
- }
-
--static char *
--send_rtpp_command(struct iovec *v, int vcnt)
-+char *
-+send_rtpp_command(struct rtpp_node *node, struct iovec *v, int vcnt)
- {
- struct sockaddr_un addr;
- int fd, len, i;
-@@ -1187,10 +1526,10 @@
-
- len = 0;
- cp = buf;
-- if (umode == 0) {
-+ if (node->rn_umode == 0) {
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_LOCAL;
-- strncpy(addr.sun_path, rtpproxy_sock,
-+ strncpy(addr.sun_path, node->rn_address,
- sizeof(addr.sun_path) - 1);
- #ifdef HAVE_SOCKADDR_SA_LEN
- addr.sun_len = strlen(addr.sun_path);
-@@ -1199,12 +1538,12 @@
- fd = socket(AF_LOCAL, SOCK_STREAM, 0);
- if (fd < 0) {
- LOG(L_ERR, "ERROR: send_rtpp_command: can't create socket\n");
-- return NULL;
-+ goto badproxy;
- }
- if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- close(fd);
- LOG(L_ERR, "ERROR: send_rtpp_command: can't connect to RTP proxy\n");
-- return NULL;
-+ goto badproxy;
- }
-
- do {
-@@ -1213,7 +1552,7 @@
- if (len <= 0) {
- close(fd);
- LOG(L_ERR, "ERROR: send_rtpp_command: can't send command to a RTP proxy\n");
-- return NULL;
-+ goto badproxy;
- }
- do {
- len = read(fd, buf, sizeof(buf) - 1);
-@@ -1221,38 +1560,38 @@
- close(fd);
- if (len <= 0) {
- LOG(L_ERR, "ERROR: send_rtpp_command: can't read reply from a RTP proxy\n");
-- return NULL;
-+ goto badproxy;
- }
- } else {
-- fds[0].fd = controlfd;
-+ fds[0].fd = node->rn_fd;
- fds[0].events = POLLIN;
- fds[0].revents = 0;
- /* Drain input buffer */
- while ((poll(fds, 1, 0) == 1) &&
- ((fds[0].revents & POLLIN) != 0)) {
-- recv(controlfd, buf, sizeof(buf) - 1, 0);
-+ recv(node->rn_fd, buf, sizeof(buf) - 1, 0);
- fds[0].revents = 0;
- }
- v[0].iov_base = gencookie();
- v[0].iov_len = strlen(v[0].iov_base);
- for (i = 0; i < rtpproxy_retr; i++) {
- do {
-- len = writev(controlfd, v, vcnt);
-+ len = writev(node->rn_fd, v, vcnt);
- } while (len == -1 && (errno == EINTR || errno == ENOBUFS));
- if (len <= 0) {
- LOG(L_ERR, "ERROR: send_rtpp_command: "
- "can't send command to a RTP proxy\n");
-- return NULL;
-+ goto badproxy;
- }
- while ((poll(fds, 1, rtpproxy_tout * 1000) == 1) &&
- (fds[0].revents & POLLIN) != 0) {
- do {
-- len = recv(controlfd, buf, sizeof(buf) - 1, 0);
-+ len = recv(node->rn_fd, buf, sizeof(buf) - 1, 0);
- } while (len == -1 && errno == EINTR);
- if (len <= 0) {
- LOG(L_ERR, "ERROR: send_rtpp_command: "
- "can't read reply from a RTP proxy\n");
-- return NULL;
-+ goto badproxy;
- }
- if (len >= (v[0].iov_len - 1) &&
- memcmp(buf, v[0].iov_base, (v[0].iov_len - 1)) == 0) {
-@@ -1270,28 +1609,97 @@
- if (i == rtpproxy_retr) {
- LOG(L_ERR, "ERROR: send_rtpp_command: "
- "timeout waiting reply from a RTP proxy\n");
-- return NULL;
-+ goto badproxy;
- }
- }
-
- out:
- cp[len] = '\0';
- return cp;
-+badproxy:
-+ LOG(L_ERR, "send_rtpp_command(): proxy <%s> does not responding, disable it\n", node->rn_url);
-+ node->rn_disabled = 1;
-+ node->rn_recheck_ticks = get_ticks() + rtpproxy_disable_tout;
-+ return NULL;
-+}
-+
-+/*
-+ * Main balancing routine. This does not try to keep the same proxy for
-+ * the call if some proxies were disabled or enabled; proxy death considered
-+ * too rare. Otherwise we should implement "mature" HA clustering, which is
-+ * too expensive here.
-+ */
-+struct rtpp_node *
-+select_rtpp_node(str callid, int do_test)
-+{
-+ unsigned sum, sumcut, weight_sum;
-+ struct rtpp_node* node;
-+ int was_forced;
-+
-+ /* Most popular case: 1 proxy, nothing to calculate */
-+ if (rtpp_node_count == 1) {
-+ node = rtpp_list.rn_first;
-+ return node->rn_disabled ? NULL : node;
-+ }
-+
-+ /* XXX Use quick-and-dirty hashing algo */
-+ for(sum = 0; callid.len > 0; callid.len--)
-+ sum += callid.s[callid.len - 1];
-+ sum &= 0xff;
-+
-+ was_forced = 0;
-+retry:
-+ weight_sum = 0;
-+ for (node = rtpp_list.rn_first; node != NULL; node = node->rn_next) {
-+ if (node->rn_disabled) {
-+ /* Try to enable if it's time to try. */
-+ if (node->rn_recheck_ticks <= get_ticks())
-+ node->rn_disabled = rtpp_test(node, 1, 0);
-+ }
-+ if (!node->rn_disabled)
-+ weight_sum += node->rn_weight;
-+ }
-+ if (weight_sum == 0) {
-+ /* No proxies? Force all to be redetected, if not yet */
-+ if (was_forced)
-+ return NULL;
-+ was_forced = 1;
-+ for (node = rtpp_list.rn_first; node != NULL; node = node->rn_next) {
-+ node->rn_disabled = rtpp_test(node, 1, 1);
-+ }
-+ goto retry;
-+ }
-+ sumcut = sum % weight_sum;
-+ /*
-+ * sumcut here lays from 0 to weight_sum-1.
-+ * Scan proxy list and decrease until appropriate proxy is found.
-+ */
-+ for (node = rtpp_list.rn_first; node != NULL; node = node->rn_next) {
-+ if (node->rn_disabled)
-+ continue;
-+ if (sumcut < node->rn_weight)
-+ goto found;
-+ sumcut -= node->rn_weight;
-+ }
-+ /* No node list */
-+ return NULL;
-+found:
-+ if (do_test) {
-+ node->rn_disabled = rtpp_test(node, node->rn_disabled, 0);
-+ if (node->rn_disabled)
-+ goto retry;
-+ }
-+ return node;
- }
-
- static int
- unforce_rtp_proxy_f(struct sip_msg* msg, char* str1, char* str2)
- {
- str callid, from_tag, to_tag;
-+ struct rtpp_node *node;
- struct iovec v[1 + 4 + 3] = {{NULL, 0}, {"D", 1}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 0}};
- /* 1 */ /* 2 */ /* 3 */ /* 4 */ /* 5 */ /* 6 */ /* 1 */
-
-- rtpproxy_disable = rtpp_test(rtpproxy_disable, 0);
-- if (rtpproxy_disable != 0) {
-- LOG(L_ERR, "ERROR: unforce_rtp_proxy: support for RTP proxy "
-- "is disabled\n");
-- return -1;
-- }
- if (get_callid(msg, &callid) == -1 || callid.len == 0) {
- LOG(L_ERR, "ERROR: unforce_rtp_proxy: can't get Call-Id field\n");
- return -1;
-@@ -1307,29 +1715,185 @@
- STR2IOVEC(callid, v[3]);
- STR2IOVEC(from_tag, v[5]);
- STR2IOVEC(to_tag, v[7]);
-- send_rtpp_command(v, (to_tag.len > 0) ? 8 : 6);
-+ node = select_rtpp_node(callid, 1);
-+ if (!node) {
-+ LOG(L_ERR, "ERROR: unforce_rtp_proxy: no available proxies\n");
-+ return -1;
-+ }
-+ send_rtpp_command(node, v, (to_tag.len > 0) ? 8 : 6);
-+
-+ return 1;
-+}
-+
-+static int
-+start_recording_f(struct sip_msg* msg, char* str1, char* str2)
-+{
-+ int nitems;
-+ str callid, from_tag, to_tag;
-+ struct rtpp_node *node;
-+ struct iovec v[1 + 4 + 3] = {{NULL, 0}, {"R", 1}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 0}};
-+ /* 1 */ /* 2 */ /* 3 */ /* 4 */ /* 5 */ /* 6 */ /* 1 */
-+
-+ if (get_callid(msg, &callid) == -1 || callid.len == 0) {
-+ LOG(L_ERR, "ERROR: start_recording: can't get Call-Id field\n");
-+ return -1;
-+ }
-+ if (get_to_tag(msg, &to_tag) == -1) {
-+ LOG(L_ERR, "ERROR: start_recording: can't get To tag\n");
-+ return -1;
-+ }
-+ if (get_from_tag(msg, &from_tag) == -1 || from_tag.len == 0) {
-+ LOG(L_ERR, "ERROR: start_recording: can't get From tag\n");
-+ return -1;
-+ }
-+ STR2IOVEC(callid, v[3]);
-+ STR2IOVEC(from_tag, v[5]);
-+ STR2IOVEC(to_tag, v[7]);
-+ node = select_rtpp_node(callid, 1);
-+ if (!node) {
-+ LOG(L_ERR, "ERROR: start_recording: no available proxies\n");
-+ return -1;
-+ }
-+ nitems = 8;
-+ if (msg->first_line.type == SIP_REPLY) {
-+ if (to_tag.len == 0)
-+ return -1;
-+ STR2IOVEC(to_tag, v[5]);
-+ STR2IOVEC(from_tag, v[7]);
-+ } else {
-+ STR2IOVEC(from_tag, v[5]);
-+ STR2IOVEC(to_tag, v[7]);
-+ if (to_tag.len <= 0)
-+ nitems = 6;
-+ }
-+ send_rtpp_command(node, v, nitems);
-+
-+ return 1;
-+}
-+
-+/*
-+ * Auxiliary for some functions.
-+ * Returns pointer to first character of found line, or NULL if no such line.
-+ */
-+
-+char*
-+find_sdp_line(char *p, char *plimit, char linechar)
-+{
-+ static char linehead[3] = "x=";
-+ char *cp, *cp1;
-+ linehead[0] = linechar;
-+ /* Iterate thru body */
-+ cp = p;
-+ for (;;) {
-+ if (cp >= plimit)
-+ return NULL;
-+ cp1 = ser_memmem(cp, linehead, plimit-cp, 2);
-+ if (cp1 == NULL)
-+ return NULL;
-+ /*
-+ * As it is body, we assume it has previous line and we can
-+ * lookup previous character.
-+ */
-+ if (cp1[-1] == '\n' || cp1[-1] == '\r')
-+ return cp1;
-+ /*
-+ * Having such data, but not at line beginning.
-+ * Skip them and reiterate. ser_memmem() will find next
-+ * occurrence.
-+ */
-+ if (plimit - cp1 < 2)
-+ return NULL;
-+ cp = cp1 + 2;
-+ }
-+ /*UNREACHED*/
-+ return NULL;
-+}
-+
-+/* This function assumes p points to a line of requested type. */
-
-+char*
-+find_next_sdp_line(char *p, char *plimit, char linechar, char *defptr)
-+{
-+ char* t;
-+ if (p >= plimit || plimit - p < 3)
-+ return defptr;
-+ t = find_sdp_line(p + 2, plimit, linechar);
-+ return t ? t : defptr;
-+}
-+
-+static int
-+alter_line(struct sip_msg *msg, str *where, str *what)
-+{
-+ struct lump *anchor;
-+ anchor = del_lump(msg, where->s - msg->buf, where->len, 0);
-+ if (!anchor) {
-+ LOG(L_ERR, "del_lump() failed\n");
-+ return 0;
-+ }
-+ if (insert_new_lump_after(anchor, what->s, what->len, 0) == 0) {
-+ LOG(L_ERR, "insert_new_lump_after() failed\n");
-+ return 0;
-+ }
- return 1;
- }
-
-+/*
-+ * The following macro is used in force_rtp_proxy2_f() and twice
-+ * in start_moh()
-+ */
-+
-+#define PARSE_PROXY_REPLY \
-+ do { \
-+ argc = 0; \
-+ memset(argv, 0, sizeof(argv)); \
-+ cpend=cp+strlen(cp); \
-+ next=eat_token_end(cp, cpend); \
-+ for (ap = argv; cp<cpend; cp=next+1, next=eat_token_end(cp, cpend)){ \
-+ *next=0; \
-+ if (*cp != '\0') { \
-+ *ap=cp; \
-+ argc++; \
-+ if ((char*)++ap >= ((char*)argv+sizeof(argv))) \
-+ break; \
-+ } \
-+ } \
-+ } while(0)
-+
- static int
- force_rtp_proxy2_f(struct sip_msg* msg, char* str1, char* str2)
- {
-- str body, body1, oldport, oldip, oldip1, newport, newip;
-- str callid, from_tag, to_tag, tmp;
-+ str body, body1, oldport, oldip, newport, newip;
-+ str callid, from_tag, to_tag;
- int create, port, len, asymmetric, flookup, argc, proxied, real;
-+ int create1;
- int oidx, pf, pf1, force;
- char opts[16];
- char *cp, *cp1;
- char *cpend, *next;
- char **ap, *argv[10];
- struct lump* anchor;
-- struct iovec v[1 + 6 + 5] = {{NULL, 0}, {NULL, 0}, {" ", 1}, {NULL, 0},
-- {" ", 1}, {NULL, 7}, {" ", 1}, {NULL, 1}, {" ", 1}, {NULL, 0},
-- {" ", 1}, {NULL, 0}};
-- /* 1 */ /* 2 */ /* 3 */ /* 4 */
-- /* 5 */ /* 6 */ /* 7 */ /* 8 */ /* 9 */ /* 10 */
-- /* 11 */
-+ struct rtpp_node *node;
-+ struct iovec v[14] = {
-+ {NULL, 0}, /* command */
-+ {NULL, 0}, /* options */
-+ {" ", 1}, /* separator */
-+ {NULL, 0}, /* callid */
-+ {" ", 1}, /* separator */
-+ {NULL, 7}, /* newip */
-+ {" ", 1}, /* separator */
-+ {NULL, 1}, /* oldport */
-+ {" ", 1}, /* separator */
-+ {NULL, 0}, /* from_tag */
-+ {";", 1}, /* separator */
-+ {NULL, 0}, /* medianum */
-+ {" ", 1}, /* separator */
-+ {NULL, 0} /* to_tag */
-+ };
-+ char *v1p, *v2p, *c1p, *c2p, *m1p, *m2p, *bodylimit;
-+ char medianum_buf[20];
-+ int medianum, media_multi;
-+ str medianum_str, tmpstr1;
-+ int c1_altered;
-
- v[1].iov_base=opts;
- asymmetric = flookup = force = real = 0;
-@@ -1374,13 +1938,6 @@
- }
- }
-
-- rtpproxy_disable = rtpp_test(rtpproxy_disable, 0);
-- if (rtpproxy_disable != 0) {
-- LOG(L_ERR, "ERROR: force_rtp_proxy2: support for RTP proxy "
-- "is disabled\n");
-- return -1;
-- }
--
- if (msg->first_line.type == SIP_REQUEST &&
- msg->first_line.u.request.method_value == METHOD_INVITE) {
- create = 1;
-@@ -1409,14 +1966,7 @@
- LOG(L_ERR, "ERROR: force_rtp_proxy2: can't get From tag\n");
- return -1;
- }
-- if (flookup != 0) {
-- if (create == 0 || to_tag.len == 0)
-- return -1;
-- create = 0;
-- tmp = from_tag;
-- from_tag = to_tag;
-- to_tag = tmp;
-- }
-+
- proxied = 0;
- for (cp = body.s; (len = body.s + body.len - cp) >= ANORTPPROXY_LEN;) {
- cp1 = ser_memmem(cp, ANORTPPROXY, len, ANORTPPROXY_LEN);
-@@ -1430,88 +1980,207 @@
- }
- if (proxied != 0 && force == 0)
- return -1;
-- if (extract_mediaip(&body, &oldip, &pf) == -1) {
-- LOG(L_ERR, "ERROR: force_rtp_proxy2: can't extract media IP "
-- "from the message\n");
-- return -1;
-- }
-- if (asymmetric != 0 || real != 0) {
-- newip = oldip;
-- } else {
-- newip.s = ip_addr2a(&msg->rcv.src_ip);
-- newip.len = strlen(newip.s);
-- }
-- body1.s = oldip.s + oldip.len;
-- body1.len = body.s + body.len - body1.s;
-- if (extract_mediaip(&body1, &oldip1, &pf1) == -1) {
-- oldip1.len = 0;
-- }
-- if (oldip1.len > 0 && pf != pf1) {
-- LOG(L_ERR, "ERROR: force_rtp_proxy2: mismatching address "
-- "families in SDP\n");
-- return -1;
-- }
-- if (extract_mediaport(&body, &oldport) == -1) {
-- LOG(L_ERR, "ERROR: force_rtp_proxy2: can't extract media port "
-- "from the message\n");
-+ /*
-+ * Parsing of SDP body.
-+ * It can contain a few session descriptions (each start with
-+ * "v=" line), and each session may contain a few media descriptions
-+ * (each start with "m=" line).
-+ * We have to change ports in "m=", and also change IP addresses in
-+ * "c=" which can be placed either in session header (fallback for
-+ * all medias) or media description.
-+ * Ports should be allocated for any media. IPs all should be changed
-+ * to the same value (RTP proxy IP), so we can change all "c="
-+ * unconditionally.
-+ */
-+ bodylimit = body.s + body.len;
-+ v1p = find_sdp_line(body.s, bodylimit, 'v');
-+ if (v1p == NULL) {
-+ LOG(L_ERR, "ERROR: force_rtp_proxy2: no sessions in SDP\n");
- return -1;
- }
-- if (pf == AF_INET6) {
-- opts[oidx] = '6';
-- oidx++;
-- }
-- opts[0] = (create == 0) ? 'L' : 'U';
-- v[1].iov_len = oidx;
-- STR2IOVEC(callid, v[3]);
-- STR2IOVEC(newip, v[5]);
-- STR2IOVEC(oldport, v[7]);
-- STR2IOVEC(from_tag, v[9]);
-- STR2IOVEC(to_tag, v[11]);
-- cp = send_rtpp_command(v, (to_tag.len > 0) ? 12 : 10);
-- if (cp == NULL)
-- return -1;
-- argc = 0;
-- memset(argv, 0, sizeof(argv));
-- cpend=cp+strlen(cp);
-- next=eat_token_end(cp, cpend);
-- for (ap = argv; cp<cpend; cp=next+1, next=eat_token_end(cp, cpend)){
-- *next=0;
-- if (*cp != '\0') {
-- *ap=cp;
-- argc++;
-- if ((char*)++ap >= ((char*)argv+sizeof(argv)))
-- break;
-+ v2p = find_next_sdp_line(v1p, bodylimit, 'v', bodylimit);
-+ media_multi = (v2p != bodylimit);
-+ v2p = v1p;
-+ medianum = 0;
-+ for (;;) {
-+ unsigned nmseen, nmchanged;
-+ /* Per-session iteration. */
-+ v1p = v2p;
-+ if (v1p == NULL || v1p >= bodylimit)
-+ break; /* No sessions left */
-+ v2p = find_next_sdp_line(v1p, bodylimit, 'v', bodylimit);
-+ /* v2p is text limit for session parsing. */
-+ m1p = find_sdp_line(v1p, v2p, 'm');
-+ /* Have this session media description? */
-+ if (m1p == NULL) {
-+ LOG(L_ERR, "ERROR: force_rtp_proxy2: no m= in session\n");
-+ return -1;
- }
-- }
-- if (argc < 1)
-- return -1;
-- port = atoi(argv[0]);
-- if (port <= 0 || port > 65535)
-- return -1;
-+ /*
-+ * Find c1p only between session begin and first media.
-+ * c1p will give common c= for all medias.
-+ */
-+ c1p = find_sdp_line(v1p, m1p, 'c');
-+ c1_altered = 0;
-+ /* Have session. Iterate media descriptions in session */
-+ m2p = m1p;
-+ nmseen = nmchanged = 0;
-+ for (;;) {
-+ create1 = create;
-+ if (flookup != 0) {
-+ if (!create || to_tag.len <= 0) {
-+#if 0
-+ LOG(L_ERR, "force_rtp_proxy(): inappropriate 'l'\n");
-+#endif
-+ return -1;
-+ }
-+ create1 = 0;
-+ }
-+ m1p = m2p;
-+ if (m1p == NULL || m1p >= v2p)
-+ break;
-+ m2p = find_next_sdp_line(m1p, v2p, 'm', v2p);
-+ /* c2p will point to per-media "c=" */
-+ c2p = find_sdp_line(m1p, m2p, 'c');
-+ /* Extract address and port */
-+ tmpstr1.s = c2p ? c2p : c1p;
-+ ++nmseen;
-+ if (tmpstr1.s == NULL) {
-+ /* No "c=" */
-+ LOG(L_ERR, "ERROR: force_rtp_proxy2: can't find media IP "
-+ "in the message\n");
-+ return -1;
-+ }
-+ tmpstr1.len = v2p - tmpstr1.s; /* limit is session limit text */
-+ if (extract_mediaip(&tmpstr1, &oldip, &pf) == -1) {
-+ LOG(L_ERR, "ERROR: force_rtp_proxy2: can't extract media IP "
-+ "from the message\n");
-+ return -1;
-+ }
-+ tmpstr1.s = m1p;
-+ tmpstr1.len = m2p - m1p;
-+ if (extract_mediaport(&tmpstr1, &oldport) == -1) {
-+ LOG(L_ERR, "ERROR: force_rtp_proxy2: can't extract media port "
-+ "from the message\n");
-+ return -1;
-+ }
-+ ++medianum;
-+ if (asymmetric != 0 || real != 0) {
-+ newip = oldip;
-+ } else {
-+ newip.s = ip_addr2a(&msg->rcv.src_ip);
-+ newip.len = strlen(newip.s);
-+ }
-+ /* XXX must compare address families in all addresses */
-+ if (pf == AF_INET6) {
-+ opts[oidx] = '6';
-+ oidx++;
-+ }
-+ snprintf(medianum_buf, sizeof medianum_buf, "%d", medianum);
-+ medianum_str.s = medianum_buf;
-+ medianum_str.len = strlen(medianum_buf);
-+ opts[0] = (create1 == 0) ? 'L' : 'U';
-+ v[1].iov_len = oidx;
-+ STR2IOVEC(callid, v[3]);
-+ STR2IOVEC(newip, v[5]);
-+ STR2IOVEC(oldport, v[7]);
-+ /*assert(!flookup || to_tag.len > 0);*/
-+ STR2IOVEC(flookup ? to_tag : from_tag, v[9]);
-+ if (1 || media_multi) /* XXX */ {
-+ STR2IOVEC(medianum_str, v[11]);
-+ } else {
-+ v[10].iov_len = v[11].iov_len = 0;
-+ }
-+ STR2IOVEC(flookup ? from_tag : to_tag, v[13]);
-+ do {
-+ node = select_rtpp_node(callid, 1);
-+ if (!node) {
-+ LOG(L_ERR, "ERROR: force_rtp_proxy2: no available proxies\n");
-+ return -1;
-+ }
-+ cp = send_rtpp_command(node, v,
-+ (to_tag.len > 0) ? 14 : 12);
-+ } while (cp == NULL);
-+ LOG(L_DBG, "force_rtp_proxy2: proxy reply: %s\n", cp);
-+ PARSE_PROXY_REPLY;
-+ if (argc < 1) {
-+ LOG(L_ERR, "force_rtp_proxy2: no reply from rtp proxy\n");
-+ return -1;
-+ }
-+ port = atoi(argv[0]);
-+ if (port <= 0 || port > 65535) {
-+ /*
-+ * In forced lookup mode absence of session indicated
-+ * by port number being zero is not an error condition
-+ * but merely of indication that there is no such
-+ * session in the proxy exists.
-+ */
-+ if (port != 0 || flookup == 0)
-+ LOG(L_ERR, "force_rtp_proxy2: incorrect port in reply from rtp proxy\n");
-+ return -1;
-+ }
-
-- pf1 = (argc >= 3 && argv[2][0] == '6') ? AF_INET6 : AF_INET;
-+ pf1 = (argc >= 3 && argv[2][0] == '6') ? AF_INET6 : AF_INET;
-
-- if (isnulladdr(&oldip, pf)) {
-- if (pf1 == AF_INET6) {
-- newip.s = "::";
-- newip.len = 2;
-- } else {
-- newip.s = "0.0.0.0";
-- newip.len = 7;
-+ if (isnulladdr(&oldip, pf)) {
-+ if (pf1 == AF_INET6) {
-+ newip.s = "::";
-+ newip.len = 2;
-+ } else {
-+ newip.s = "0.0.0.0";
-+ newip.len = 7;
-+ }
-+ } else {
-+ newip.s = (argc < 2) ? str2 : argv[1];
-+ newip.len = strlen(newip.s);
-+ }
-+ newport.s = int2str(port, &newport.len); /* beware static buffer */
-+ /* Alter port. */
-+ body1.s = m1p;
-+ body1.len = bodylimit - body1.s;
-+ if (alter_mediaport(msg, &body1, &oldport, &newport, 0) == -1)
-+ return -1;
-+ /*
-+ * Alter IP. Don't alter IP common for the session
-+ * more than once.
-+ */
-+ if (c2p != NULL || !c1_altered) {
-+ body1.s = c2p ? c2p : c1p;
-+ body1.len = bodylimit - body1.s;
-+ if (alter_mediaip(msg, &body1, &oldip, pf, &newip, pf1, 0) == -1)
-+ return -1;
-+ if (!c2p)
-+ c1_altered = 1;
-+ }
-+ ++nmchanged;
-+ /*
-+ * Gross hack: turn off flookup here, after first
-+ * media stream. This is used to allow changing number
-+ * of media streams during re-INVITE.
-+ */
-+ flookup = 0;
-+ } /* Iterate medias in session */
-+ if (c1p && nmseen == nmchanged && !c1_altered) {
-+ /* Alter default c-line of this session. */
-+ str c1s, janus;
-+ size_t newlen;
-+ c1s.s = c1p;
-+ c1s.len = eat_line(c1p, bodylimit - c1p) - c1p;
-+ newlen = c1s.len + 6 + 1;
-+ janus.s = pkg_malloc(c1s.len);
-+ if (janus.s == NULL) {
-+ LOG(L_ERR, "pkg_malloc failed\n");
-+ return 0;
-+ }
-+ sprintf(janus.s, "a=oldc:%*.*s",
-+ (int) c1s.len, (int) c1s.len, c1s.s);
-+ janus.len = strlen(janus.s);
-+ if (alter_line(msg, &c1s, &janus) <= 0) {
-+ LOG(L_ERR, "alter_line() failed\n");
-+ return 0;
-+ }
- }
-- } else {
-- newip.s = (argc < 2) ? str2 : argv[1];
-- newip.len = strlen(newip.s);
-- }
-- newport.s = int2str(port, &newport.len); /* beware static buffer */
--
-- if (alter_mediaip(msg, &body, &oldip, pf, &newip, pf1, 0) == -1)
-- return -1;
-- if (oldip1.len > 0 &&
-- alter_mediaip(msg, &body1, &oldip1, pf, &newip, pf1, 0) == -1)
-- return -1;
-- if (alter_mediaport(msg, &body, &oldport, &newport, 0) == -1)
-- return -1;
-+ } /* Iterate sessions */
-
- if (proxied == 0) {
- cp = pkg_malloc(ANORTPPROXY_LEN * sizeof(char));
-@@ -1555,75 +2224,41 @@
- return force_rtp_proxy1_f(msg, arg, NULL);
- }
-
--static void
--timer(unsigned int ticks, void *param)
-+static int
-+rewrite_from_from_f(struct sip_msg* msg, char* str1, char* str2)
- {
-- int rval;
-- void *buf, *cp;
-- str c;
-- struct sip_uri curi;
-- union sockaddr_union to;
-- struct hostent* he;
-- struct socket_info* send_sock;
-+ struct action act;
-+ struct sip_uri uri;
-+ str ruri;
-
-- buf = NULL;
-- if (cblen > 0) {
-- buf = pkg_malloc(cblen);
-- if (buf == NULL) {
-- LOG(L_ERR, "ERROR: nathelper::timer: out of memory\n");
-- return;
-- }
-+ /* parsing from header */
-+ if (parse_from_header(msg) == -1) {
-+ LOG(L_ERR, "rewrite_from_from(): cannot get FROM header\n");
-+ return -1;
- }
-- rval = ul.get_all_ucontacts(buf, cblen, (ping_nated_only ? FL_NAT : 0));
-- if (rval > 0) {
-- if (buf != NULL)
-- pkg_free(buf);
-- cblen = rval * 2;
-- buf = pkg_malloc(cblen);
-- if (buf == NULL) {
-- LOG(L_ERR, "ERROR: nathelper::timer: out of memory\n");
-- return;
-- }
-- rval = ul.get_all_ucontacts(buf, cblen, (ping_nated_only ? FL_NAT : 0));
-- if (rval != 0) {
-- pkg_free(buf);
-- return;
-- }
-+ ruri.len = get_from(msg)->uri.len;
-+ ruri.s = pkg_malloc(ruri.len + 1);
-+ memcpy(ruri.s, get_from(msg)->uri.s, ruri.len + 1);
-+ if (parse_uri(ruri.s, ruri.len, &uri) < 0) {
-+ LOG(L_ERR, "rewrite_from_from(): can't parse FROM URI\n");
-+ pkg_free(ruri.s);
-+ return -1;
-+ }
-+ if (uri.user.len <= 0) {
-+ uri.user.s = "Unknown";
-+ uri.user.len = 7;
-+ } else {
-+ uri.user.s[uri.user.len] = '\0';
- }
-
-- if (buf == NULL)
-- return;
-+ bzero(&act, sizeof(act));
-+ act.type = SET_USER_T;
-+ act.p1_type = STRING_ST;
-+ act.p1.string = uri.user.s;
-+ do_action(&act, msg);
-
-- cp = buf;
-- while (1) {
-- memcpy(&(c.len), cp, sizeof(c.len));
-- if (c.len == 0)
-- break;
-- c.s = (char*)cp + sizeof(c.len);
-- cp = (char*)cp + sizeof(c.len) + c.len;
-- if (parse_uri(c.s, c.len, &curi) < 0) {
-- LOG(L_ERR, "ERROR: nathelper::timer: can't parse contact uri\n");
-- continue;
-- }
-- if (curi.proto != PROTO_UDP && curi.proto != PROTO_NONE)
-- continue;
-- if (curi.port_no == 0)
-- curi.port_no = SIP_PORT;
-- he = sip_resolvehost(&curi.host, &curi.port_no, PROTO_UDP);
-- if (he == NULL){
-- LOG(L_ERR, "ERROR: nathelper::timer: can't resolve_hos\n");
-- continue;
-- }
-- hostent2su(&to, he, 0, curi.port_no);
-- send_sock=force_socket ? force_socket :
-- get_send_socket(0, &to, PROTO_UDP);
-- if (send_sock == NULL) {
-- LOG(L_ERR, "ERROR: nathelper::timer: can't get sending socket\n");
-- continue;
-- }
-- udp_send(send_sock, (char *)sbuf, sizeof(sbuf), &to);
-- }
-- pkg_free(buf);
-+ pkg_free(ruri.s);
-+ return 1;
- }
-
-
diff --git a/net/ser/files/patch-modules__nathelper__nathelper.h b/net/ser/files/patch-modules__nathelper__nathelper.h
deleted file mode 100644
index e47acf6edf18..000000000000
--- a/net/ser/files/patch-modules__nathelper__nathelper.h
+++ /dev/null
@@ -1,82 +0,0 @@
-
-$FreeBSD$
-
---- /dev/null
-+++ modules/nathelper/nathelper.h
-@@ -0,0 +1,76 @@
-+/*
-+ * $Id: patch-modules::nathelper::nathelper.h,v 1.2 2005/04/05 13:10:08 netch Exp $
-+ *
-+ *
-+ * Copyright (C) 2005 Porta Software Ltd.
-+ *
-+ * This file is part of ser, a free SIP server.
-+ *
-+ * ser is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2 of the License, or
-+ * (at your option) any later version
-+ *
-+ * For a license to use the ser software under conditions
-+ * other than those described here, or to purchase support for this
-+ * software, please contact iptel.org by e-mail at the following addresses:
-+ * info@iptel.org
-+ *
-+ * ser is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-+ */
-+
-+#ifndef nathelper_H_
-+#define nathelper_H_
-+
-+/* Handy macros */
-+#define STR2IOVEC(sx, ix) do {(ix).iov_base = (sx).s; (ix).iov_len = (sx).len;} while(0)
-+#define SZ2IOVEC(sx, ix) do {char *_t_p = (ix).iov_base = (sx); (ix).iov_len = strlen(_t_p);} while(0)
-+
-+struct rtpp_node;
-+
-+/* Parameters from nathelper.c */
-+extern struct socket_info* force_socket;
-+
-+/* Functions from nathelper.c */
-+int isnulladdr(str *, int);
-+int get_to_tag(struct sip_msg* _m, str* _tag);
-+int get_from_tag(struct sip_msg* _m, str* _tag);
-+int get_callid(struct sip_msg* _m, str* _cid);
-+int extract_mediaip(str *, str *, int *);
-+int extract_mediaport(str *, str *);
-+int alter_mediaip(struct sip_msg *, str *, str *, int, str *, int, int);
-+int alter_mediaport(struct sip_msg *, str *, str *, str *, int);
-+struct rtpp_node * select_rtpp_node(str, int);
-+char *send_rtpp_command(struct rtpp_node*, struct iovec *, int);
-+char* find_sdp_line(char*, char*, char);
-+char* find_next_sdp_line(char*, char*, char, char*);
-+
-+/* Functions from moh.c */
-+int is_hold_f(struct sip_msg *msg, char *str1, char *str2);
-+int start_moh_f(struct sip_msg *msg, char *str1, char *str2);
-+int stop_moh_f(struct sip_msg *msg, char *str1, char *str2);
-+
-+/* Functions from natping.c */
-+int natpinger_init(void);
-+int natpinger_child_init(int);
-+int natpinger_cleanup(void);
-+
-+/* Variables from moh.c referenced from nathelper.c */
-+extern char *pname_audio;
-+extern char *pname_video;
-+extern char *codecs_audio;
-+extern char *codecs_video;
-+
-+/* Variables from natping.c referenced from nathelper.c */
-+extern int natping_interval;
-+extern int ping_nated_only;
-+extern char *natping_method;
-+
-+#endif
diff --git a/net/ser/files/patch-modules__nathelper__natping.c b/net/ser/files/patch-modules__nathelper__natping.c
deleted file mode 100644
index ecd5ec1b0f3a..000000000000
--- a/net/ser/files/patch-modules__nathelper__natping.c
+++ /dev/null
@@ -1,258 +0,0 @@
-
-$FreeBSD$
-
---- /dev/null
-+++ modules/nathelper/natping.c
-@@ -0,0 +1,252 @@
-+/* $Id: patch-modules::nathelper::natping.c,v 1.4 2005/04/27 13:35:34 sobomax Exp $
-+ *
-+ * Copyright (C) 2005 Porta Software Ltd
-+ *
-+ * This file is part of ser, a free SIP server.
-+ *
-+ * ser is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2 of the License, or
-+ * (at your option) any later version
-+ *
-+ * For a license to use the ser software under conditions
-+ * other than those described here, or to purchase support for this
-+ * software, please contact iptel.org by e-mail at the following addresses:
-+ * info@iptel.org
-+ *
-+ * ser is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-+ *
-+ */
-+
-+#include <unistd.h>
-+#include <signal.h>
-+#include "../usrloc/usrloc.h"
-+#include "../tm/tm_load.h"
-+#include "../../dprint.h"
-+#include "../../parser/parse_hostport.h"
-+#include "../../resolve.h"
-+#include "nathelper.h"
-+
-+int natping_interval = 0;
-+/*
-+ * If this parameter is set then the natpinger will ping only contacts
-+ * that have the NAT flag set in user location database
-+ */
-+int ping_nated_only = 0;
-+
-+/*
-+ * Ping method. Any word except NULL is treated as method name.
-+ */
-+char *natping_method = NULL;
-+
-+static pid_t aux_process = -1;
-+static usrloc_api_t ul;
-+/* TM bind */
-+static struct tm_binds tmb;
-+static int cblen = 0;
-+static const char sbuf[4] = {0, 0, 0, 0};
-+
-+static void natping(unsigned int ticks, void *param);
-+static void natping_cycle(void);
-+
-+int
-+natpinger_init(void)
-+{
-+ bind_usrloc_t bind_usrloc;
-+ load_tm_f load_tm;
-+ char *p;
-+
-+ if (natping_interval > 0) {
-+ bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0);
-+ if (!bind_usrloc) {
-+ LOG(L_ERR, "ERROR: nathelper: natpinger_init: Can't find usrloc module\n");
-+ return -1;
-+ }
-+
-+ if (bind_usrloc(&ul) < 0) {
-+ return -1;
-+ }
-+ if (natping_method != NULL) {
-+ for (p = natping_method; *p != '\0'; ++p)
-+ *p = toupper(*p);
-+ if (strcmp(natping_method, "NULL") == 0)
-+ natping_method = NULL;
-+ }
-+ if (natping_method != NULL) {
-+ /* import the TM auto-loading function */
-+ if (!(load_tm = (load_tm_f)find_export("load_tm", NO_SCRIPT, 0))) {
-+ LOG(L_ERR, "ERROR: nathelper: natpinger_init: can't import load_tm\n");
-+ return -1;
-+ }
-+ /* let the auto-loading function load all TM stuff */
-+ if (load_tm(&tmb) == -1)
-+ return -1;
-+ }
-+
-+ /*
-+ * Use timer only in single process. For forked SER,
-+ * use separate process (see natpinger_child_init())
-+ */
-+ if (dont_fork)
-+ register_timer(natping, NULL, natping_interval);
-+ }
-+
-+ return 0;
-+}
-+
-+int
-+natpinger_child_init(int rank)
-+{
-+
-+ /* If forking is prohibited, use only timer. */
-+ if (dont_fork)
-+ return 0;
-+
-+ /* don't do anything for main process and TCP manager process */
-+ if (rank == PROC_MAIN || rank == PROC_TCP_MAIN)
-+ return 0;
-+
-+ /* only child 1 will fork the aux process */
-+ if (rank != 1)
-+ return 0;
-+
-+ aux_process = fork();
-+ if (aux_process == -1) {
-+ LOG(L_ERR, "natping_child_init(): fork: %s\n", strerror(errno));
-+ return -1;
-+ }
-+ if (aux_process == 0) {
-+ natping_cycle();
-+ /*UNREACHED*/
-+ _exit(1);
-+ }
-+ return 0;
-+}
-+
-+int
-+natpinger_cleanup(void)
-+{
-+
-+ if (aux_process != -1)
-+ kill(aux_process, SIGTERM);
-+ return 0;
-+}
-+
-+static void
-+natping_cycle(void)
-+{
-+
-+ signal(SIGTERM, SIG_DFL); /* no special treat */
-+ for(;;) {
-+ sleep(natping_interval);
-+ natping(0, NULL);
-+ }
-+}
-+
-+static void
-+natping(unsigned int ticks, void *param)
-+{
-+ int rval, n;
-+ void *buf, *cp;
-+ str c;
-+ struct sip_uri curi;
-+ union sockaddr_union to;
-+ struct hostent* he;
-+ struct socket_info* send_sock;
-+ char t;
-+ str p_method, p_from;
-+
-+ buf = NULL;
-+ if (cblen > 0) {
-+ buf = pkg_malloc(cblen);
-+ if (buf == NULL) {
-+ LOG(L_ERR, "ERROR: nathelper::natping: out of memory\n");
-+ return;
-+ }
-+ }
-+ rval = ul.get_all_ucontacts(buf, cblen, (ping_nated_only ? FL_NAT : 0));
-+ if (rval > 0) {
-+ if (buf != NULL)
-+ pkg_free(buf);
-+ cblen = rval * 2;
-+ buf = pkg_malloc(cblen);
-+ if (buf == NULL) {
-+ LOG(L_ERR, "ERROR: nathelper::natping: out of memory\n");
-+ return;
-+ }
-+ rval = ul.get_all_ucontacts(buf, cblen, (ping_nated_only ? FL_NAT : 0));
-+ if (rval != 0) {
-+ pkg_free(buf);
-+ return;
-+ }
-+ }
-+
-+ if (buf == NULL)
-+ return;
-+
-+ cp = buf;
-+ n = 0;
-+ while (1) {
-+ memcpy(&(c.len), cp, sizeof(c.len));
-+ if (c.len == 0)
-+ break;
-+ c.s = (char*)cp + sizeof(c.len);
-+ cp = (char*)cp + sizeof(c.len) + c.len;
-+ if (parse_uri(c.s, c.len, &curi) < 0) {
-+ LOG(L_ERR, "ERROR: nathelper::natping: can't parse contact uri\n");
-+ continue;
-+ }
-+ if (curi.proto != PROTO_UDP && curi.proto != PROTO_NONE)
-+ continue;
-+
-+ if ((++n % 50) == 0)
-+ usleep(1);
-+
-+ if (natping_method != NULL) {
-+ p_method.s = natping_method;
-+ p_method.len = strlen(p_method.s);
-+ p_from.s = "sip:registrar"; /* XXX */
-+ p_from.len = strlen(p_from.s);
-+ if (tmb.t_request(&p_method, &c, &c, &p_from,
-+ NULL, NULL, NULL, NULL) == -1)
-+ {
-+ LOG(L_ERR, "nathelper::natping(): request() failed\n");
-+ }
-+ } else {
-+ if (curi.maddr_val.len != 0) {
-+ t = curi.maddr_val.s[curi.maddr_val.len];
-+ curi.maddr_val.s[curi.maddr_val.len] = '\0';
-+ parse_hostport(curi.maddr_val.s, &curi.host, &curi.port_no);
-+ curi.maddr_val.s[curi.maddr_val.len] = t;
-+ if (curi.host.len <= 0) {
-+ LOG(L_ERR, "ERROR: nathelper::natping: invalid maddr in contact uri\n");
-+ continue;
-+ }
-+ }
-+
-+ if (curi.port_no == 0)
-+ curi.port_no = SIP_PORT;
-+ he = sip_resolvehost(&curi.host, &curi.port_no, PROTO_UDP);
-+ if (he == NULL){
-+ LOG(L_ERR, "ERROR: nathelper::natping: can't resolve host\n");
-+ continue;
-+ }
-+ hostent2su(&to, he, 0, curi.port_no);
-+ send_sock=force_socket ? force_socket :
-+ get_send_socket(0, &to, PROTO_UDP);
-+ if (send_sock == NULL) {
-+ LOG(L_ERR, "ERROR: nathelper::natping: can't get sending socket\n");
-+ continue;
-+ }
-+ udp_send(send_sock, (char *)sbuf, sizeof(sbuf), &to);
-+ }
-+ }
-+ pkg_free(buf);
-+}
diff --git a/net/ser/files/patch-modules__postgres__db_val.c b/net/ser/files/patch-modules__postgres__db_val.c
deleted file mode 100644
index 5cbb27866ac7..000000000000
--- a/net/ser/files/patch-modules__postgres__db_val.c
+++ /dev/null
@@ -1,77 +0,0 @@
-diff -ruN modules/postgres/db_val.c /home/snar/ser-0.9.7/modules/postgres/db_val.c
---- modules/postgres/db_val.c 2005-07-20 21:11:52.000000000 +0400
-+++ modules/postgres/db_val.c 2006-10-25 23:32:10.000000000 +0400
-@@ -166,12 +166,14 @@
- return 0;
- }
-
-+
- /*
- * Does not copy strings
- */
- int str2valp(db_type_t _t, db_val_t* _v, const char* _s, int _l, void *_p)
- {
-- char dbuf[256];
-+#define DBUF_SIZE 256
-+ char dbuf[DBUF_SIZE];
- #ifdef PARANOID
- if (!_v) {
- LOG(L_ERR, "str2valp(): Invalid parameter value\n");
-@@ -185,11 +187,12 @@
- VAL_NULL(_v) = 1;
- return 0;
- }
--
-+ VAL_NULL(_v) = 0;
-+
- switch(_t) {
- case DB_INT:
- case DB_BITMAP:
-- sprintf(dbuf, "got int %s", _s);
-+ snprintf(dbuf, DBUF_SIZE, "got int %s", _s);
- DLOG("str2valp", dbuf);
- if (str2int(_s, &VAL_INT(_v)) < 0) {
- LOG(L_ERR, "str2valp(): Error while converting integer value from string\n");
-@@ -201,7 +204,7 @@
- break;
-
- case DB_DOUBLE:
-- sprintf(dbuf, "got double %s", _s);
-+ snprintf(dbuf, DBUF_SIZE, "got double %s", _s);
- DLOG("str2valp", dbuf);
- if (str2double(_s, &VAL_DOUBLE(_v)) < 0) {
- LOG(L_ERR, "str2valp(): Error while converting double value from string\n");
-@@ -213,7 +216,7 @@
- break;
-
- case DB_STRING:
-- sprintf(dbuf, "got string %s", _s);
-+ snprintf(dbuf, DBUF_SIZE, "got string %s", _s);
- DLOG("str2valp", dbuf);
-
- VAL_STRING(_v) = aug_strdup(_s, _p);
-@@ -228,13 +231,13 @@
- VAL_STR(_v).len = _l;
- VAL_TYPE(_v) = DB_STR;
-
-- sprintf(dbuf, "got len string %d %s", _l, _s);
-+ snprintf(dbuf, DBUF_SIZE, "got len string %d %s", _l, _s);
- DLOG("str2valp", dbuf);
-
- return 0;
-
- case DB_DATETIME:
-- sprintf(dbuf, "got time %s", _s);
-+ snprintf(dbuf, DBUF_SIZE, "got time %s", _s);
- DLOG("str2valp", dbuf);
- if (str2time(_s, &VAL_TIME(_v)) < 0) {
- PLOG("str2valp", "error converting datetime");
-@@ -253,7 +256,7 @@
- VAL_STR(_v).len = _l;
- VAL_TYPE(_v) = DB_BLOB;
-
-- sprintf(dbuf, "got blob %d", _l);
-+ snprintf(dbuf, DBUF_SIZE, "got blob %d", _l);
- DLOG("str2valp", dbuf);
-
- return 0;
diff --git a/net/ser/files/patch-modules__postgres__dbase.c b/net/ser/files/patch-modules__postgres__dbase.c
deleted file mode 100644
index dfdc17ff258e..000000000000
--- a/net/ser/files/patch-modules__postgres__dbase.c
+++ /dev/null
@@ -1,57 +0,0 @@
-diff -ruN modules/postgres/dbase.c /home/snar/ser-0.9.7/modules/postgres/dbase.c
---- modules/postgres/dbase.c 2005-07-20 21:11:52.000000000 +0400
-+++ modules/postgres/dbase.c 2006-10-25 23:32:10.000000000 +0400
-@@ -49,6 +49,9 @@
- #include "con_postgres.h"
- #include "aug_std.h"
-
-+#define ERR_BUF_SIZE 256 /* tmp. buf for building the error message */
-+
-+
- long getpid();
-
- static char sql_buf[SQL_BUF_LEN];
-@@ -124,8 +127,8 @@
- if(parse_sql_url(CON_SQLURL(_h),
- &user,&password,&host,&port,&database) < 0)
- {
-- char buf[256];
-- sprintf(buf, "Error while parsing %s", _db_url);
-+ char buf[ERR_BUF_SIZE];
-+ snprintf(buf, ERR_BUF_SIZE, "Error while parsing %s", _db_url);
- PLOG("connect_db", buf);
-
- aug_free(CON_SQLURL(_h));
-@@ -358,8 +361,8 @@
- /*
- ** log the error
- */
-- char buf[256];
-- sprintf(buf, "query '%s', result '%s'\n",
-+ char buf[ERR_BUF_SIZE];
-+ snprintf(buf, ERR_BUF_SIZE, "query '%s', result '%s'\n",
- _s, PQerrorMessage(CON_CONNECTION(_h)));
- PLOG("submit_query", buf);
- }
-@@ -487,8 +490,8 @@
- /*
- ** our attempt to fix the connection failed
- */
-- char buf[256];
-- sprintf(buf, "no connection, FATAL %d!", rv);
-+ char buf[ERR_BUF_SIZE];
-+ snprintf(buf, ERR_BUF_SIZE, "no connection, FATAL %d!", rv);
- PLOG("begin_transaction",buf);
- return(rv);
- }
-@@ -507,8 +510,8 @@
- mr = PQexec(CON_CONNECTION(_h), "BEGIN");
- if(!mr || PQresultStatus(mr) != PGRES_COMMAND_OK)
- {
-- char buf[256];
-- sprintf("FATAL %s, '%s'!\n",
-+ char buf[ERR_BUF_SIZE];
-+ snprintf(buf, ERR_BUF_SIZE, "FATAL %s, '%s'!\n",
- PQerrorMessage(CON_CONNECTION(_h)), _s);
- PLOG("begin_transaction", buf);
- return(-1);
diff --git a/net/ser/files/patch-modules__registrar__doc__registrar_user.sgml b/net/ser/files/patch-modules__registrar__doc__registrar_user.sgml
deleted file mode 100644
index 24ba9046222b..000000000000
--- a/net/ser/files/patch-modules__registrar__doc__registrar_user.sgml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-$FreeBSD$
-
---- modules/registrar/doc/registrar_user.sgml
-+++ modules/registrar/doc/registrar_user.sgml
-@@ -29,7 +29,12 @@
- </listitem>
- <listitem>
- <para>
-- <emphasis>sl - Stateless Replies</emphasis>.
-+ <emphasis>sl - Stateless Replies (if <varname>use_tm</varname> is 0)</emphasis>.
-+ </para>
-+ </listitem>
-+ <listitem>
-+ <para>
-+ <emphasis>tm - Transaction module (if <varname>use_tm</varname> is 1)</emphasis>.
- </para>
- </listitem>
- </itemizedlist>
-@@ -321,6 +326,31 @@
- modparam("registrar", "retry_after", 30)
- ...
- </programlisting>
-+ </example>
-+ </section>
-+
-+ <section>
-+ <title><varname>use_tm</varname> (integer)</title>
-+ <para>
-+ If set to 1 then the registrar will use <function>t_reply()</function> function from
-+ the tm module instead of <function>sl_send_reply()</function> function from the sl
-+ module for sending replies. This allows registration transactions to be processed
-+ statefully if necessary. When set to 1 script writer need to ensure that transaction
-+ exists when <function>save()</function> is called, usually by calling
-+ <function>t_newtran()</function>.
-+ </para>
-+ <para>
-+ <emphasis>
-+ Default value is 0.
-+ </emphasis>
-+ </para>
-+ <example>
-+ <title>Set <varname>use_tm</varname> parameter</title>
-+ <programlisting format="linespecific">
-+...
-+modparam("registrar", "use_tm", 1)
-+...
-+</programlisting>
- </example>
- </section>
-
diff --git a/net/ser/files/patch-modules__registrar__reg_mod.c b/net/ser/files/patch-modules__registrar__reg_mod.c
deleted file mode 100644
index 14d4f5629dc8..000000000000
--- a/net/ser/files/patch-modules__registrar__reg_mod.c
+++ /dev/null
@@ -1,66 +0,0 @@
-
-$FreeBSD$
-
---- modules/registrar/reg_mod.c.orig
-+++ modules/registrar/reg_mod.c
-@@ -70,6 +70,7 @@
- int use_domain = 0;
- char* realm_pref = ""; /* Realm prefix to be removed */
- str realm_prefix;
-+int use_tm = 0;
-
- #define RCV_NAME "received"
- #define RCV_NAME_LEN (sizeof(RCV_NAME) - 1)
-@@ -84,6 +85,9 @@
- int (*sl_reply)(struct sip_msg* _m, char* _s1, char* _s2);
-
-
-+struct tm_binds tmb;
-+
-+
- /*
- * Exported functions
- */
-@@ -115,6 +119,7 @@
- {"use_domain", INT_PARAM, &use_domain },
- {"max_contacts", INT_PARAM, &max_contacts },
- {"retry_after", INT_PARAM, &retry_after },
-+ {"use_tm", INT_PARAM, &use_tm },
- {0, 0, 0}
- };
-
-@@ -140,17 +145,26 @@
- static int mod_init(void)
- {
- bind_usrloc_t bind_usrloc;
-+ load_tm_f load_tm;
-
- DBG("registrar - initializing\n");
-
-- /*
-- * We will need sl_send_reply from stateless
-- * module for sending replies
-- */
-- sl_reply = find_export("sl_send_reply", 2, 0);
-- if (!sl_reply) {
-- LOG(L_ERR, "registrar: This module requires sl module\n");
-- return -1;
-+ if (use_tm != 0) {
-+ load_tm = (load_tm_f)find_export("load_tm", NO_SCRIPT, 0);
-+ if (load_tm == NULL || load_tm(&tmb) == -1) {
-+ LOG(L_ERR, "Can't import tm\n");
-+ return -1;
-+ }
-+ } else {
-+ /*
-+ * We will need sl_send_reply from stateless
-+ * module for sending replies
-+ */
-+ sl_reply = find_export("sl_send_reply", 2, 0);
-+ if (!sl_reply) {
-+ LOG(L_ERR, "registrar: This module requires sl module\n");
-+ return -1;
-+ }
- }
-
- realm_prefix.s = realm_pref;
diff --git a/net/ser/files/patch-modules__registrar__reg_mod.h b/net/ser/files/patch-modules__registrar__reg_mod.h
deleted file mode 100644
index 6e2dfdd85859..000000000000
--- a/net/ser/files/patch-modules__registrar__reg_mod.h
+++ /dev/null
@@ -1,29 +0,0 @@
-
-$FreeBSD$
-
---- modules/registrar/reg_mod.h.orig
-+++ modules/registrar/reg_mod.h
-@@ -35,6 +35,7 @@
- #include "../../qvalue.h"
- #include "../../usr_avp.h"
- #include "../usrloc/usrloc.h"
-+#include "../tm/tm_load.h"
-
- extern int default_expires;
- extern qvalue_t default_q;
-@@ -48,6 +49,7 @@
- extern int use_domain;
- extern str realm_prefix;
- extern float def_q;
-+extern int use_tm;
-
- extern str rcv_param;
- extern int rcv_avp_no;
-@@ -57,5 +59,7 @@
- usrloc_api_t ul; /* Structure containing pointers to usrloc functions */
-
- extern int (*sl_reply)(struct sip_msg* _m, char* _s1, char* _s2);
-+
-+extern struct tm_binds tmb;
-
- #endif /* REG_MOD_H */
diff --git a/net/ser/files/patch-modules__registrar__reply.c b/net/ser/files/patch-modules__registrar__reply.c
deleted file mode 100644
index f48757ecf6ce..000000000000
--- a/net/ser/files/patch-modules__registrar__reply.c
+++ /dev/null
@@ -1,23 +0,0 @@
-
-$FreeBSD$
-
---- modules/registrar/reply.c.orig
-+++ modules/registrar/reply.c
-@@ -314,6 +314,7 @@
- long code;
- char* msg = MSG_200; /* makes gcc shut up */
- char* buf;
-+ int result;
-
- if (contact.data_len > 0) {
- add_lump_rpl( _m, contact.buf, contact.data_len, LUMP_RPL_HDR|LUMP_RPL_NODUP|LUMP_RPL_NOFREE);
-@@ -347,7 +348,8 @@
- }
- }
-
-- if (sl_reply(_m, (char*)code, msg) == -1) {
-+ result = (use_tm != 0) ? tmb.t_reply(_m, code, msg) : sl_reply(_m, (char*)code, msg);
-+ if (result == -1) {
- LOG(L_ERR, "send_reply(): Error while sending %ld %s\n", code, msg);
- return -1;
- } else return 0;
diff --git a/net/ser/files/patch-modules__tm__t_lookup.c b/net/ser/files/patch-modules__tm__t_lookup.c
deleted file mode 100644
index 18a3ddf1abf4..000000000000
--- a/net/ser/files/patch-modules__tm__t_lookup.c
+++ /dev/null
@@ -1,36 +0,0 @@
-
-$FreeBSD$
-
---- modules/tm/t_lookup.c.orig
-+++ modules/tm/t_lookup.c
-@@ -103,8 +103,8 @@
- #include "t_msgbuilder.h" /* for t_lookup_callid */
-
- #define EQ_VIA_LEN(_via)\
-- ( (p_msg->via1->bsize-(p_msg->_via->name.s-(p_msg->_via->hdr.s+p_msg->_via->hdr.len)))==\
-- (t_msg->via1->bsize-(t_msg->_via->name.s-(t_msg->_via->hdr.s+t_msg->_via->hdr.len))) )
-+ ( (p_msg->_via->port_str.len > 0 ? (p_msg->_via->port_str.s + p_msg->_via->port_str.len - p_msg->_via->name.s) : p_msg->_via->name.len) ==\
-+ (t_msg->_via->port_str.len > 0 ? (t_msg->_via->port_str.s + t_msg->_via->port_str.len - t_msg->_via->name.s) : t_msg->_via->name.len) )
-
-
-
-@@ -122,7 +122,7 @@
- #define EQ_VIA_STR(_via)\
- ( memcmp( t_msg->_via->name.s,\
- p_msg->_via->name.s,\
-- (t_msg->via1->bsize-(t_msg->_via->name.s-(t_msg->_via->hdr.s+t_msg->_via->hdr.len)))\
-+ (t_msg->_via->port_str.len > 0 ? (t_msg->_via->port_str.s+t_msg->_via->port_str.len - t_msg->_via->name.s) : t_msg->_via->name.len) \
- )==0 )
-
-
-@@ -264,8 +264,10 @@
- if (memcmp(inv_via->host.s, ack_via->host.s,
- ack_via->host.len)!=0)
- return 0;
-+#if 0
- if (inv_via->port!=ack_via->port)
- return 0;
-+#endif
- if (inv_via->transport.len!=ack_via->transport.len)
- return 0;
- if (memcmp(inv_via->transport.s, ack_via->transport.s,
diff --git a/net/ser/files/patch-modules__tm__t_msgbuilder.c b/net/ser/files/patch-modules__tm__t_msgbuilder.c
deleted file mode 100644
index 159c904895dd..000000000000
--- a/net/ser/files/patch-modules__tm__t_msgbuilder.c
+++ /dev/null
@@ -1,55 +0,0 @@
-
-$FreeBSD$
-
---- modules/tm/t_msgbuilder.c 2004/06/29 19:22:35 1.1
-+++ modules/tm/t_msgbuilder.c 2004/06/29 19:56:19
-@@ -124,7 +124,7 @@
-
- /* User Agent */
- if (server_signature) {
-- *len += USER_AGENT_LEN + CRLF_LEN;
-+ *len += USER_AGENT_LEN + CRLF_LEN + (server_name ? strlen(server_name) : UA_NAME_LEN);
- }
- /* Content Length, EoM */
- *len+=CONTENT_LENGTH_LEN+1 + CRLF_LEN + CRLF_LEN;
-@@ -164,7 +164,13 @@
-
- /* User Agent header */
- if (server_signature) {
-- append_mem_block(p,USER_AGENT CRLF, USER_AGENT_LEN+CRLF_LEN );
-+ append_mem_block(p, USER_AGENT, USER_AGENT_LEN);
-+ if (server_name) {
-+ append_mem_block(p, server_name, strlen(server_name));
-+ } else {
-+ append_mem_block(p, UA_NAME, UA_NAME_LEN);
-+ }
-+ append_mem_block(p, CRLF, CRLF_LEN);
- }
- /* Content Length, EoM */
- append_mem_block(p, CONTENT_LENGTH "0" CRLF CRLF ,
-@@ -397,7 +403,7 @@
- *len += CSEQ_LEN + cseq.len + 1 + method->len + CRLF_LEN; /* CSeq */
- *len += calculate_routeset_length(dialog); /* Route set */
- *len += (body ? (CONTENT_LENGTH_LEN + content_length.len + CRLF_LEN) : 0); /* Content-Length */
-- *len += (server_signature ? (USER_AGENT_LEN + CRLF_LEN) : 0); /* Signature */
-+ *len += (server_signature ? (USER_AGENT_LEN + CRLF_LEN + (server_name ? strlen(server_name) : UA_NAME_LEN)) : 0);/* Signature */
- *len += (headers ? headers->len : 0); /* Additional headers */
- *len += (body ? body->len : 0); /* Message body */
- *len += CRLF_LEN; /* End of Header */
-@@ -426,7 +432,15 @@
- }
-
- /* Server signature */
-- if (server_signature) memapp(w, USER_AGENT CRLF, USER_AGENT_LEN + CRLF_LEN);
-+ if (server_signature) {
-+ memapp(w, USER_AGENT, USER_AGENT_LEN);
-+ if (server_name) {
-+ memapp(w, server_name, strlen(server_name));
-+ } else {
-+ memapp(w, UA_NAME, UA_NAME_LEN);
-+ }
-+ memapp(w, CRLF, CRLF_LEN);
-+ }
- if (headers) memapp(w, headers->s, headers->len);
- memapp(w, CRLF, CRLF_LEN);
- if (body) memapp(w, body->s, body->len);
diff --git a/net/ser/files/patch-modules__uri_radius__urirad_mod.c b/net/ser/files/patch-modules__uri_radius__urirad_mod.c
deleted file mode 100644
index dcb04ae5aa28..000000000000
--- a/net/ser/files/patch-modules__uri_radius__urirad_mod.c
+++ /dev/null
@@ -1,14 +0,0 @@
-
-$FreeBSD$
-
---- modules/uri_radius/urirad_mod.c.orig Mon Jul 19 01:56:24 2004
-+++ modules/uri_radius/urirad_mod.c Tue Jul 27 21:01:37 2004
-@@ -51,7 +51,7 @@
- /*
- * Module parameter variables
- */
--static char* radius_config = "/usr/local/etc/radiusclient/radiusclient.conf";
-+static char* radius_config = (CFG_DIR "radiusclient.conf");
- static int service_type = -1;
-
- /*
diff --git a/net/ser/files/patch-modules__usrloc__urecord.c b/net/ser/files/patch-modules__usrloc__urecord.c
deleted file mode 100644
index 33be6b49cd95..000000000000
--- a/net/ser/files/patch-modules__usrloc__urecord.c
+++ /dev/null
@@ -1,16 +0,0 @@
-
-$FreeBSD$
-
---- modules/usrloc/urecord.c
-+++ modules/usrloc/urecord.c
-@@ -502,8 +502,8 @@
-
- ptr = _r->contacts;
- while(ptr) {
-- if ((_c->len == ptr->c.len) &&
-- !memcmp(_c->s, ptr->c.s, _c->len)) {
-+ if (_c == NULL || ((_c->len == ptr->c.len) &&
-+ !memcmp(_c->s, ptr->c.s, _c->len))) {
- *_co = ptr;
- return 0;
- }
diff --git a/net/ser/files/patch-msg_translator.c b/net/ser/files/patch-msg_translator.c
deleted file mode 100644
index a88cb932c4ba..000000000000
--- a/net/ser/files/patch-msg_translator.c
+++ /dev/null
@@ -1,28 +0,0 @@
-
-$FreeBSD$
-
---- msg_translator.c 2004/06/29 19:19:33 1.1
-+++ msg_translator.c 2004/06/29 19:55:57
-@@ -1657,7 +1657,7 @@
- }
- /* server header */
- if (server_signature)
-- len += SERVER_HDR_LEN + CRLF_LEN;
-+ len += SERVER_HDR_LEN + CRLF_LEN + (server_name ? strlen(server_name) : UA_NAME_LEN);
- /* warning hdr */
- if (sip_warning) {
- warning_buf = warning_builder(msg,&warning_len);
-@@ -1788,6 +1788,13 @@
- if (server_signature) {
- memcpy( p, SERVER_HDR , SERVER_HDR_LEN );
- p+=SERVER_HDR_LEN;
-+ if (server_name) {
-+ memcpy( p, server_name, strlen(server_name) );
-+ p+=strlen(server_name);
-+ } else {
-+ memcpy( p, UA_NAME, UA_NAME_LEN );
-+ p+=UA_NAME_LEN;
-+ }
- memcpy( p, CRLF, CRLF_LEN );
- p+=CRLF_LEN;
- }
diff --git a/net/ser/files/patch-parser__msg_parser.h b/net/ser/files/patch-parser__msg_parser.h
deleted file mode 100644
index 56625ccee28c..000000000000
--- a/net/ser/files/patch-parser__msg_parser.h
+++ /dev/null
@@ -1,17 +0,0 @@
-
-$FreeBSD$
-
---- parser/msg_parser.h.orig
-+++ parser/msg_parser.h
-@@ -287,7 +288,11 @@
-
- /* topmost Via is part of transaction key as well ! */
- src[5]= msg->via1->host;
-+#if 0
- src[6]= msg->via1->port_str;
-+#else
-+ src[6].len = 0;
-+#endif
- if (msg->via1->branch) {
- src[7]= msg->via1->branch->value;
- MDStringArray ( cv, src, 8 );
diff --git a/net/ser/files/patch-parser__parse_hostport.c b/net/ser/files/patch-parser__parse_hostport.c
deleted file mode 100644
index b00d03bd6219..000000000000
--- a/net/ser/files/patch-parser__parse_hostport.c
+++ /dev/null
@@ -1,27 +0,0 @@
-
-$FreeBSD$
-
---- parser/parse_hostport.c.orig
-+++ parser/parse_hostport.c
-@@ -25,8 +25,6 @@
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
--#ifdef _OBSOLETED
--
- #include "parse_hostport.h"
- #include <string.h> /* strlen */
- #include "../dprint.h"
-@@ -43,7 +41,6 @@
- if (*tmp==0) {
- *port=0;
- } else {
-- *tmp=0;
- *port=str2s((unsigned char*)(tmp+1), strlen(tmp+1), &err);
- if (err ){
- LOG(L_INFO,
-@@ -56,4 +53,3 @@
- return host->s;
- }
-
--#endif
diff --git a/net/ser/files/patch-server b/net/ser/files/patch-server
deleted file mode 100644
index 38c0da21007a..000000000000
--- a/net/ser/files/patch-server
+++ /dev/null
@@ -1,187 +0,0 @@
-Index: parser/case_serv.h
-===================================================================
-RCS file: parser/case_serv.h
-diff -N parser/case_serv.h
---- /dev/null 1 Jan 1970 00:00:00 -0000
-+++ parser/case_serv.h 20 Dec 2004 18:52:54 -0000 1.1
-@@ -0,0 +1,45 @@
-+/*
-+ * $Id: patch-server,v 1.2 2005/04/05 13:10:08 netch Exp $
-+ *
-+ * Subject Header Field Name Parsing Macros
-+ *
-+ * Copyright (C) 2001-2003 Fhg Fokus
-+ *
-+ * This file is part of ser, a free SIP server.
-+ *
-+ * ser is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2 of the License, or
-+ * (at your option) any later version
-+ *
-+ * For a license to use the ser software under conditions
-+ * other than those described here, or to purchase support for this
-+ * software, please contact iptel.org by e-mail at the following addresses:
-+ * info@iptel.org
-+ *
-+ * ser is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-+ */
-+
-+
-+#ifndef CASE_SERV_H
-+#define CASE_SERV_H
-+
-+
-+#define serv_CASE \
-+ p += 4; \
-+ if (LOWER_BYTE(*p) == 'e' && LOWER_BYTE(p[1]) == 'r') { \
-+ hdr->type = HDR_SERVER; \
-+ p+= 2; \
-+ goto dc_end; \
-+ } \
-+ goto other;
-+
-+
-+#endif /* CASE_SERV_H */
-Index: parser/hf.c
-===================================================================
-RCS file: /cvsroot/ser/sip_router/parser/hf.c,v
-retrieving revision 1.21
-retrieving revision 1.22
-diff -d -u -d -u -r1.21 -r1.22
---- parser/hf.c 3 Dec 2004 17:11:36 -0000 1.21
-+++ parser/hf.c 20 Dec 2004 18:52:54 -0000 1.22
-@@ -130,10 +130,10 @@
-
- case HDR_ACCEPTLANGUAGE:
- break;
--
-+
- case HDR_ORGANIZATION:
- break;
--
-+
- case HDR_PRIORITY:
- break;
-
-@@ -156,6 +156,9 @@
-
- case HDR_RPID:
- free_to(hf->parsed);
-+ break;
-+
-+ case HDR_SERVER:
- break;
-
- default:
-Index: parser/hf.h
-===================================================================
-RCS file: /cvsroot/ser/sip_router/parser/hf.h,v
-retrieving revision 1.16
-retrieving revision 1.17
-diff -d -u -d -u -r1.16 -r1.17
---- parser/hf.h 3 Dec 2004 17:11:36 -0000 1.16
-+++ parser/hf.h 20 Dec 2004 18:52:54 -0000 1.17
-@@ -73,7 +73,8 @@
- #define HDR_CONTENTDISPOSITION (1 << 27) /* Content-Disposition hdr field */
- #define HDR_DIVERSION (1 << 28) /* Diversion header field */
- #define HDR_RPID (1 << 29) /* Remote-Party-ID header field */
--#define HDR_OTHER (1 << 30) /* Some other header field */
-+#define HDR_SERVER (1 << 30) /* Server header field */
-+#define HDR_OTHER (1 << 31) /* Some other header field */
-
-
- /* returns true if the header links allocated memory on parse field */
-Index: parser/keys.h
-===================================================================
-RCS file: /cvsroot/ser/sip_router/parser/keys.h,v
-retrieving revision 1.11
-retrieving revision 1.12
-diff -d -u -d -u -r1.11 -r1.12
---- parser/keys.h 3 Dec 2004 17:11:36 -0000 1.11
-+++ parser/keys.h 20 Dec 2004 18:52:54 -0000 1.12
-@@ -115,6 +115,8 @@
- #define _pt_d_ 0x64617470 /* "pt-d" */
- #define _ispo_ 0x6f707369 /* "ispo" */
- #define _siti_ 0x69746973 /* "siti" */
-+
-+#define _serv_ 0x76726573 /* "serv" */
-
- #define _dive_ 0x65766964 /* "dive" */
- #define _rsio_ 0x6f697372 /* "rsio" */
-Index: parser/msg_parser.c
-===================================================================
-RCS file: /cvsroot/ser/sip_router/parser/msg_parser.c,v
-retrieving revision 1.44
-retrieving revision 1.45
-diff -d -u -d -u -r1.44 -r1.45
---- parser/msg_parser.c 3 Dec 2004 17:11:36 -0000 1.44
-+++ parser/msg_parser.c 20 Dec 2004 18:52:54 -0000 1.45
-@@ -204,6 +204,7 @@
- case HDR_ACCEPTDISPOSITION:
- case HDR_DIVERSION:
- case HDR_RPID:
-+ case HDR_SERVER:
- case HDR_OTHER:
- /* just skip over it */
- hdr->body.s=tmp;
-@@ -406,6 +407,10 @@
- case HDR_RPID:
- if (msg->rpid==0) msg->rpid = hf;
- msg->parsed_flag|=HDR_RPID;
-+ break;
-+ case HDR_SERVER:
-+ if (msg->server==0) msg->server = hf;
-+ msg->parsed_flag|=HDR_SERVER;
- break;
- case HDR_VIA:
- msg->parsed_flag|=HDR_VIA;
-Index: parser/msg_parser.h
-===================================================================
-RCS file: /cvsroot/ser/sip_router/parser/msg_parser.h,v
-retrieving revision 1.49
-retrieving revision 1.50
-diff -d -u -d -u -r1.49 -r1.50
---- parser/msg_parser.h 3 Dec 2004 17:11:36 -0000 1.49
-+++ parser/msg_parser.h 20 Dec 2004 18:52:54 -0000 1.50
-@@ -193,6 +193,7 @@
- struct hdr_field* accept_disposition;
- struct hdr_field* diversion;
- struct hdr_field* rpid;
-+ struct hdr_field* server;
-
- char* eoh; /* pointer to the end of header (if found) or null */
- char* unparsed; /* here we stopped parsing*/
-Index: parser/parse_hname2.c
-===================================================================
-RCS file: /cvsroot/ser/sip_router/parser/parse_hname2.c,v
-retrieving revision 1.19
-retrieving revision 1.20
-diff -d -u -d -u -r1.19 -r1.20
---- parser/parse_hname2.c 3 Dec 2004 17:11:36 -0000 1.19
-+++ parser/parse_hname2.c 20 Dec 2004 18:52:54 -0000 1.20
-@@ -84,6 +84,7 @@
- #include "case_supp.h" /* Supported */
- #include "case_dive.h" /* Diversion */
- #include "case_remo.h" /* Remote-Party-ID */
-+#include "case_serv.h" /* Server */
-
-
- #define READ(val) \
-@@ -114,7 +115,8 @@
- case _subj_: subj_CASE; \
- case _user_: user_CASE; \
- case _dive_: dive_CASE; \
-- case _remo_: remo_CASE;
-+ case _remo_: remo_CASE; \
-+ case _serv_: serv_CASE;
-
-
- #define PARSE_COMPACT(id) \
diff --git a/net/ser/files/patch-udp_server.c b/net/ser/files/patch-udp_server.c
deleted file mode 100644
index 89b155fd5583..000000000000
--- a/net/ser/files/patch-udp_server.c
+++ /dev/null
@@ -1,16 +0,0 @@
-
-$FreeBSD$
-
---- udp_server.c
-+++ udp_server.c
-@@ -432,6 +432,10 @@
- continue; /* goto skip;*/
- else goto error;
- }
-+ if (len < 128) {
-+ /* Message is too short, just drop it already */
-+ continue;
-+ }
- /* we must 0-term the messages, receive_msg expects it */
- buf[len]=0; /* no need to save the previous char */
-
diff --git a/net/ser/files/ser.in b/net/ser/files/ser.in
deleted file mode 100644
index 4c2471e4d7e0..000000000000
--- a/net/ser/files/ser.in
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-# PROVIDE: ser
-# REQUIRE: DAEMON mysql postgresql
-
-# Add the following lines to /etc/rc.conf to enable ser:
-#
-# ser_enable="YES"
-
-. /etc/rc.subr
-
-name="ser"
-rcvar=ser_enable
-command="%%PREFIX%%/sbin/${name}"
-pidfile="/var/run/${name}.pid"
-command_args="-P ${pidfile} > /dev/null"
-
-load_rc_config $name
-
-: ${ser_enable="NO"}
-
-stop_postcmd=stop_postcmd
-
-stop_postcmd()
-{
- rm -f $pidfile
-}
-
-run_rc_command "$1"