Browse Source

Merge branch 'master' of ssh://[email protected]/sip-router into sr

* 'master' of ssh://[email protected]/sip-router:
  tcp: config option to disable active connects
  tcp: async mode on by default
  tcp: enable runtime changing for most of the cfg vars
  tcp: use dynamic config framework, part 2
  tcp: use dynamic config framework, part 1
  test: updated parse uri test program
  sctp: rpc info command
  sctp: connection reuse & connection tracking
  sctp: empty  sctp_handle_assoc_change added
  regfree() function call is added to free the memory allocated by regcomp().
Jan Janak 16 years ago
parent
commit
3bc6281523
20 changed files with 1685 additions and 289 deletions
  1. 9 3
      NEWS
  2. 3 0
      cfg.lex
  3. 26 17
      cfg.y
  4. 47 9
      core_cmd.c
  5. 10 1
      forward.c
  6. 1 5
      globals.h
  7. 33 21
      main.c
  8. 14 6
      msg_translator.c
  9. 3 2
      receive.c
  10. 1004 0
      sctp_server.c
  11. 11 0
      sctp_server.h
  12. 3 8
      tcp_conn.h
  13. 1 1
      tcp_info.h
  14. 10 0
      tcp_init.h
  15. 162 168
      tcp_main.c
  16. 247 28
      tcp_options.c
  17. 31 15
      tcp_options.h
  18. 1 1
      tcp_read.c
  19. 68 4
      test/p_uri.c
  20. 1 0
      usr_avp.c

+ 9 - 3
NEWS

@@ -229,12 +229,15 @@ modules:
                         - t_set_retr(t1, t2) - changes the retransmissions
                            intervals on the fly, on a per transaction basis.
 core:
+             - most tcp config vars migrated to the dynamic config framework
+               (can be changed at runtime, e.g. 
+                 sercmd cfg.set_now_int tcp connection_lifetime 180 )
              - fallback to tcp or other congestion controlled transport 
                protocol if a forwarded udp sip request is greater then 
                udp_mtu (config). Default off. See udp_mtu and 
                udp_mtu_try_proto.
              - sctp support (one-to-many, work in progress, for now linux
-               only with no fallback to one-to-one on full send buffers)
+               and freebsd only)
              - partial cygwin (windows) support revived: core+static modules, 
                no ipv6, no tcp, no dynamic modules
              - most of the config variables can now be changed on the fly,
@@ -253,6 +256,9 @@ core:
                between the short name and long name in cache as CNAME record
 
 new config variables:
+  tcp_no_connect = yes/no - disable connects, ser will only accept new 
+                     connections, it will never try to open new ones.
+                     Default: no, can be changed at runtime.
   udp_mtu = number - fallback to another protocol (udp_mtu_try_proto must be
                      set also either globally or per packet) if the constructed
                      request size is greater then udp_mtu.
@@ -293,10 +299,10 @@ new config variables:
      will be cached inside the process calling tcp_send (performance increase
      for sending over tcp at the cost of slightly slower connection closing and
      extra FDs kept open)
-  tcp_async = yes | no (default no) - if enabled all the tcp  writes that 
+  tcp_async = yes | no (default yes) - if enabled all the tcp  writes that 
      would block / wait for connect to finish, will be queued and attempted
      latter (see also tcp_conn_wq_max and tcp_wq_max).
-  tcp_buf_write = synonim for tcp_async
+  tcp_buf_write = obsoleted synonim for tcp_async
   tcp_conn_wq_max = bytes (default 32 K) - maximum bytes queued for write 
      allowed per connection. Attempting to queue more bytes would result
      in an error and in the connection being closed (too slow). If 

+ 3 - 0
cfg.lex

@@ -325,6 +325,7 @@ TCP_CONNECT_TIMEOUT	"tcp_connect_timeout"
 TCP_CON_LIFETIME	"tcp_connection_lifetime"
 TCP_POLL_METHOD		"tcp_poll_method"
 TCP_MAX_CONNECTIONS	"tcp_max_connections"
+TCP_NO_CONNECT		"tcp_no_connect"
 TCP_SOURCE_IPV4		"tcp_source_ipv4"
 TCP_SOURCE_IPV6		"tcp_source_ipv6"
 TCP_OPT_FD_CACHE	"tcp_fd_cache"
@@ -624,6 +625,8 @@ EAT_ABLE	[\ \t\b\r]
 									return TCP_POLL_METHOD; }
 <INITIAL>{TCP_MAX_CONNECTIONS}	{ count(); yylval.strval=yytext;
 									return TCP_MAX_CONNECTIONS; }
+<INITIAL>{TCP_NO_CONNECT}		{ count(); yylval.strval=yytext;
+									return TCP_NO_CONNECT; }
 <INITIAL>{TCP_SOURCE_IPV4}		{ count(); yylval.strval=yytext;
 									return TCP_SOURCE_IPV4; }
 <INITIAL>{TCP_SOURCE_IPV6}		{ count(); yylval.strval=yytext;

+ 26 - 17
cfg.y

@@ -389,6 +389,7 @@ static int case_check_default(struct case_stms* stms);
 %token TCP_CON_LIFETIME
 %token TCP_POLL_METHOD
 %token TCP_MAX_CONNECTIONS
+%token TCP_NO_CONNECT
 %token TCP_SOURCE_IPV4
 %token TCP_SOURCE_IPV6
 %token TCP_OPT_FD_CACHE
@@ -814,7 +815,7 @@ assign_stm:
 	| DISABLE_TCP EQUAL error { yyerror("boolean value expected"); }
 	| TCP_ACCEPT_ALIASES EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_accept_aliases=$3;
+			tcp_default_cfg.accept_aliases=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -830,7 +831,7 @@ assign_stm:
 	| TCP_CHILDREN EQUAL error { yyerror("number expected"); }
 	| TCP_CONNECT_TIMEOUT EQUAL intno {
 		#ifdef USE_TCP
-			tcp_connect_timeout=$3;
+			tcp_default_cfg.connect_timeout_s=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -838,7 +839,7 @@ assign_stm:
 	| TCP_CONNECT_TIMEOUT EQUAL error { yyerror("number expected"); }
 	| TCP_SEND_TIMEOUT EQUAL intno {
 		#ifdef USE_TCP
-			tcp_send_timeout=$3;
+			tcp_default_cfg.send_timeout_s=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -846,7 +847,7 @@ assign_stm:
 	| TCP_SEND_TIMEOUT EQUAL error { yyerror("number expected"); }
 	| TCP_CON_LIFETIME EQUAL intno {
 		#ifdef USE_TCP
-			tcp_con_lifetime=$3;
+			tcp_default_cfg.con_lifetime_s=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -889,6 +890,14 @@ assign_stm:
 		#endif
 	}
 	| TCP_MAX_CONNECTIONS EQUAL error { yyerror("number expected"); }
+	| TCP_NO_CONNECT EQUAL NUMBER {
+		#ifdef USE_TCP
+			tcp_default_cfg.no_connect=$3;
+		#else
+			warn("tcp support not compiled in");
+		#endif
+	}
+	| TCP_NO_CONNECT EQUAL error { yyerror("boolean value expected"); }
 	| TCP_SOURCE_IPV4 EQUAL ipv4 {
 		#ifdef USE_TCP
 			if (tcp_set_src_addr($3)<0)
@@ -915,7 +924,7 @@ assign_stm:
 	| TCP_SOURCE_IPV6 EQUAL error { yyerror("IPv6 address expected"); }
 	| TCP_OPT_FD_CACHE EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.fd_cache=$3;
+			tcp_default_cfg.fd_cache=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -923,7 +932,7 @@ assign_stm:
 	| TCP_OPT_FD_CACHE EQUAL error { yyerror("boolean value expected"); }
 	| TCP_OPT_BUF_WRITE EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.tcp_buf_write=$3;
+			tcp_default_cfg.async=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -931,7 +940,7 @@ assign_stm:
 	| TCP_OPT_BUF_WRITE EQUAL error { yyerror("boolean value expected"); }
 	| TCP_OPT_CONN_WQ_MAX EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.tcpconn_wq_max=$3;
+			tcp_default_cfg.tcpconn_wq_max=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -939,7 +948,7 @@ assign_stm:
 	| TCP_OPT_CONN_WQ_MAX error { yyerror("boolean value expected"); }
 	| TCP_OPT_WQ_MAX EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.tcp_wq_max=$3;
+			tcp_default_cfg.tcp_wq_max=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -947,7 +956,7 @@ assign_stm:
 	| TCP_OPT_WQ_MAX error { yyerror("boolean value expected"); }
 	| TCP_OPT_DEFER_ACCEPT EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.defer_accept=$3;
+			tcp_default_cfg.defer_accept=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -955,7 +964,7 @@ assign_stm:
 	| TCP_OPT_DEFER_ACCEPT EQUAL error { yyerror("boolean value expected"); }
 	| TCP_OPT_DELAYED_ACK EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.delayed_ack=$3;
+			tcp_default_cfg.delayed_ack=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -963,7 +972,7 @@ assign_stm:
 	| TCP_OPT_DELAYED_ACK EQUAL error { yyerror("boolean value expected"); }
 	| TCP_OPT_SYNCNT EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.syncnt=$3;
+			tcp_default_cfg.syncnt=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -971,7 +980,7 @@ assign_stm:
 	| TCP_OPT_SYNCNT EQUAL error { yyerror("number expected"); }
 	| TCP_OPT_LINGER2 EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.linger2=$3;
+			tcp_default_cfg.linger2=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -979,7 +988,7 @@ assign_stm:
 	| TCP_OPT_LINGER2 EQUAL error { yyerror("number expected"); }
 	| TCP_OPT_KEEPALIVE EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.keepalive=$3;
+			tcp_default_cfg.keepalive=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -987,7 +996,7 @@ assign_stm:
 	| TCP_OPT_KEEPALIVE EQUAL error { yyerror("boolean value expected");}
 	| TCP_OPT_KEEPIDLE EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.keepidle=$3;
+			tcp_default_cfg.keepidle=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -995,7 +1004,7 @@ assign_stm:
 	| TCP_OPT_KEEPIDLE EQUAL error { yyerror("number expected"); }
 	| TCP_OPT_KEEPINTVL EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.keepintvl=$3;
+			tcp_default_cfg.keepintvl=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -1003,7 +1012,7 @@ assign_stm:
 	| TCP_OPT_KEEPINTVL EQUAL error { yyerror("number expected"); }
 	| TCP_OPT_KEEPCNT EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.keepcnt=$3;
+			tcp_default_cfg.keepcnt=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif
@@ -1011,7 +1020,7 @@ assign_stm:
 	| TCP_OPT_KEEPCNT EQUAL error { yyerror("number expected"); }
 	| TCP_OPT_CRLF_PING EQUAL NUMBER {
 		#ifdef USE_TCP
-			tcp_options.crlf_ping=$3;
+			tcp_default_cfg.crlf_ping=$3;
 		#else
 			warn("tcp support not compiled in");
 		#endif

+ 47 - 9
core_cmd.c

@@ -41,6 +41,7 @@
 #include "core_cmd.h"
 #ifdef USE_SCTP
 #include "sctp_options.h"
+#include "sctp_server.h"
 #endif
 
 #ifdef USE_DNS_CACHE
@@ -561,19 +562,23 @@ static void core_tcp_options(rpc_t* rpc, void* c)
 {
 #ifdef USE_TCP
 	void *handle;
-	struct tcp_cfg_options t;
+	struct cfg_group_tcp t;
 
 	if (!tcp_disable){
 		tcp_options_get(&t);
 		rpc->add(c, "{", &handle);
-		rpc->struct_add(handle, "ddddddddddddddd",
+		rpc->struct_add(handle, "ddddddddddddddddddddddd",
+			"connect_timeout", t.connect_timeout_s,
+			"send_timeout",  t.send_timeout_s,
+			"connection_lifetime",  t.con_lifetime_s,
+			"max_connections(soft)", t.max_connections,
+			"no_connect",	t.no_connect,
 			"fd_cache",		t.fd_cache,
-			"tcp_buf_write",	t.tcp_buf_write,
-			"tcp_connect_wait",	t.tcp_connect_wait,
-			"tcpconn_wq_max",	t.tcpconn_wq_max,
-			"tcp_wq_max",	t.tcp_wq_max,
-			"tcp_wq_timeout",	TICKS_TO_S(t.tcp_wq_timeout),
-			
+			"async",		t.async,
+			"connect_wait",	t.tcp_connect_wait,
+			"conn_wq_max",	t.tcpconn_wq_max,
+			"wq_max",		t.tcp_wq_max,
+			"wq_timeout",	TICKS_TO_S(t.tcp_wq_timeout),
 			"defer_accept",	t.defer_accept,
 			"delayed_ack",	t.delayed_ack,
 			"syncnt",		t.syncnt,
@@ -582,7 +587,10 @@ static void core_tcp_options(rpc_t* rpc, void* c)
 			"keepidle",		t.keepidle,
 			"keepintvl",	t.keepintvl,
 			"keepcnt",		t.keepcnt,
-			"crlf_ping",	t.crlf_ping
+			"crlf_ping",	t.crlf_ping,
+			"accept_aliases", t.accept_aliases,
+			"alias_flags",	t.alias_flags,
+			"new_conn_alias_flags",	t.new_conn_alias_flags
 		);
 	}else{
 		rpc->fault(c, 500, "tcp support disabled");
@@ -624,6 +632,35 @@ static void core_sctp_options(rpc_t* rpc, void* c)
 
 
 
+static const char* core_sctpinfo_doc[] = {
+	"Returns sctp related info.",    /* Documentation string */
+	0                               /* Method signature(s) */
+};
+
+static void core_sctpinfo(rpc_t* rpc, void* c)
+{
+#ifdef USE_SCTP
+	void *handle;
+	struct sctp_gen_info i;
+
+	if (!sctp_disable){
+		sctp_get_info(&i);
+		rpc->add(c, "{", &handle);
+		rpc->struct_add(handle, "ddd",
+			"opened_connections", i.sctp_connections_no,
+			"tracked_connections", i.sctp_tracked_no,
+			"total_connections", i.sctp_total_connections
+		);
+	}else{
+		rpc->fault(c, 500, "sctp support disabled");
+	}
+#else
+	rpc->fault(c, 500, "sctp support not compiled");
+#endif
+}
+
+
+
 /*
  * RPC Methods exported by this module
  */
@@ -646,6 +683,7 @@ rpc_export_t core_rpc_methods[] = {
 	{"core.tcp_options",       core_tcp_options,       core_tcp_options_doc,0},
 	{"core.sctp_options",      core_sctp_options,      core_sctp_options_doc,
 		0},
+	{"core.sctp_info",         core_sctpinfo,          core_sctpinfo_doc,   0},
 #ifdef USE_DNS_CACHE
 	{"dns.mem_info",          dns_cache_mem_info,     dns_cache_mem_info_doc,     0	},
 	{"dns.debug",          dns_cache_debug,           dns_cache_debug_doc,        0	},

+ 10 - 1
forward.c

@@ -641,11 +641,20 @@ int forward_reply(struct sip_msg* msg)
 	dst.comp=msg->via2->comp_no;
 #endif
 
+#if defined USE_TCP || defined USE_SCTP
+	if (
 #ifdef USE_TCP
-	if (dst.proto==PROTO_TCP
+			dst.proto==PROTO_TCP
 #ifdef USE_TLS
 			|| dst.proto==PROTO_TLS
 #endif
+#ifdef USE_SCTP
+			||
+#endif /* USE_SCTP */
+#endif /* USE_TCP */
+#ifdef USE_SCTP
+			dst.proto==PROTO_SCTP
+#endif /* USE_SCTP */
 			){
 		/* find id in i param if it exists */
 		if (msg->via1->i && msg->via1->i->value.s){

+ 1 - 5
globals.h

@@ -87,12 +87,8 @@ extern int children_no;
 extern int tcp_main_pid;
 extern int tcp_children_no;
 extern int tcp_disable;
-extern int tcp_accept_aliases;
-extern int tcp_connect_timeout;
-extern int tcp_send_timeout;
-extern int tcp_con_lifetime; /* connection lifetime */
 extern enum poll_types tcp_poll_method;
-extern int tcp_max_connections;
+extern int tcp_max_connections; /* maximum connections, hard limit */
 #endif
 #ifdef USE_TLS
 extern int tls_disable;

+ 33 - 21
main.c

@@ -1621,6 +1621,10 @@ int main(int argc, char** argv)
 		}
 	}
 
+	if (endianness_sanity_check() != 0){
+		fprintf(stderr, "BUG: endianness sanity tests failed\n");
+		goto error;
+	}
 	if (init_routes()<0) goto error;
 	if (init_nonsip_hooks()<0) goto error;
 
@@ -1926,6 +1930,27 @@ try_again:
 		goto error;
 	if (init_atomic_ops()==-1)
 		goto error;
+	if (init_basex() != 0){
+		LOG(L_CRIT, "could not initialize base* framework\n");
+		goto error;
+	}
+	if (cfg_init() < 0) {
+		LOG(L_CRIT, "could not initialize configuration framework\n");
+		goto error;
+	}
+	/* declare the core cfg before the module configs */
+	if (cfg_declare("core", core_cfg_def, &default_core_cfg, cfg_sizeof(core),
+			&core_cfg)
+	) {
+		LOG(L_CRIT, "could not declare the core configuration\n");
+		goto error;
+	}
+#ifdef USE_TCP
+	if (tcp_register_cfg()){
+		LOG(L_CRIT, "could not register the tcp configuration\n");
+		goto error;
+	}
+#endif /* USE_TCP */
 	/*init timer, before parsing the cfg!*/
 	if (init_timer()<0){
 		LOG(L_CRIT, "could not initialize timer, exiting...\n");
@@ -1969,6 +1994,14 @@ try_again:
 		}
 	}
 #endif /* USE_TCP */
+#ifdef USE_SCTP
+	if (!sctp_disable){
+		if (init_sctp()<0){
+			LOG(L_CRIT, "Could not initialize sctp, exiting...\n");
+			goto error;
+		}
+	}
+#endif /* USE_SCTP */
 	/* init_daemon? */
 	if (!dont_fork){
 		if ( daemonize(argv[0]) <0 ) goto error;
@@ -1993,27 +2026,6 @@ try_again:
 			set_rt_prio(rt_prio, rt_policy);
 
 	
-	if (cfg_init() < 0) {
-		LOG(L_CRIT, "could not initialize configuration framework\n");
-		goto error;
-	}
-	/* declare the core cfg before the module configs */
-	if (cfg_declare("core", core_cfg_def, &default_core_cfg, cfg_sizeof(core),
-			&core_cfg)
-	) {
-		LOG(L_CRIT, "could not declare the core configuration\n");
-		goto error;
-	}
-
-	if (endianness_sanity_check() != 0){
-		LOG(L_CRIT, "BUG: endianness sanity tests failed\n");
-		goto error;
-	}
-	if (init_basex() != 0){
-		LOG(L_CRIT, "could not initialize base* framework\n");
-		goto error;
-	}
-	
 	if (init_modules() != 0) {
 		fprintf(stderr, "ERROR: error while initializing modules\n");
 		goto error;

+ 14 - 6
msg_translator.c

@@ -2288,7 +2288,7 @@ char* create_via_hf( unsigned int *len,
 	char* via;
 	str extra_params;
 	struct hostport hp;
-#ifdef USE_TCP
+#if defined USE_TCP || defined USE_SCTP
 	char* id_buf;
 	unsigned int id_len;
 
@@ -2300,13 +2300,21 @@ char* create_via_hf( unsigned int *len,
 	extra_params.s=0;
 
 
-#ifdef USE_TCP
+#if defined USE_TCP || defined USE_SCTP
 	/* add id if tcp */
-	if (msg
-	&& ((msg->rcv.proto==PROTO_TCP)
+	if (msg && (
+#ifdef USE_TCP
+		(msg->rcv.proto==PROTO_TCP)
 #ifdef USE_TLS
 			|| (msg->rcv.proto==PROTO_TLS)
 #endif
+#ifdef USE_SCTP
+			||
+#endif /* USE_SCTP */
+#endif /* USE_TCP */
+#ifdef USE_SCTP
+			(msg->rcv.proto==PROTO_SCTP)
+#endif /* USE_SCTP */
 			)){
 		if  ((id_buf=id_builder(msg, &id_len))==0){
 			LOG(L_ERR, "ERROR: create_via_hf:"
@@ -2319,13 +2327,13 @@ char* create_via_hf( unsigned int *len,
 		extra_params.s=id_buf;
 		extra_params.len=id_len;
 	}
-#endif
+#endif /* USE_TCP || USE_SCTP */
 
 	set_hostport(&hp, msg);
 	via = via_builder( len, send_info, branch,
 							extra_params.len?&extra_params:0, &hp);
 
-#ifdef USE_TCP
+#if defined USE_TCP || defined USE_SCTP
 	/* we do not need id_buf any more, the id is already in the new via header */
 	if (id_buf) pkg_free(id_buf);
 #endif

+ 3 - 2
receive.c

@@ -62,7 +62,8 @@
 #include "select_buf.h"
 
 #include "tcp_server.h" /* for tcpconn_add_alias */
-
+#include "tcp_options.h" /* for access to tcp_accept_aliases*/
+#include "cfg/cfg.h"
 
 #ifdef DEBUG_DMALLOC
 #include <mem/dmalloc.h>
@@ -138,7 +139,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 		/* check if necessary to add receive?->moved to forward_req */
 		/* check for the alias stuff */
 #ifdef USE_TCP
-		if (msg->via1->alias && tcp_accept_aliases && 
+		if (msg->via1->alias && cfg_get(tcp, tcp_cfg, accept_aliases) && 
 				(((rcv_info->proto==PROTO_TCP) && !tcp_disable)
 #ifdef USE_TLS
 					|| ((rcv_info->proto==PROTO_TLS) && !tls_disable)

File diff suppressed because it is too large
+ 1004 - 0
sctp_server.c


+ 11 - 0
sctp_server.h

@@ -29,12 +29,23 @@
 
 #include "ip_addr.h"
 
+struct sctp_gen_info{
+	int sctp_connections_no;
+	int sctp_tracked_no;
+	int sctp_total_connections;
+};
+
+int init_sctp();
+void destroy_sctp();
 int sctp_check_compiled_sockopts(char* buf, int size);
 int sctp_check_support();
 int sctp_init_sock(struct socket_info* sock_info);
 int sctp_rcv_loop();
 int sctp_msg_send(struct dest_info* dst, char* buf, unsigned len);
 
+/* generic sctp information (stats a.s.o) */
+void sctp_get_info(struct sctp_gen_info* sinf);
+
 void destroy_sctp();
 
 #endif /* _sctp_server_h */

+ 3 - 8
tcp_conn.h

@@ -42,6 +42,7 @@
 #ifndef _tcp_conn_h
 #define _tcp_conn_h
 
+#include "tcp_init.h"
 #include "tcp_options.h"
 
 #include "ip_addr.h"
@@ -54,12 +55,6 @@
 #define TCP_CON_MAX_ALIASES (4*3) 
 
 #define TCP_BUF_SIZE	4096 
-#define DEFAULT_TCP_CONNECTION_LIFETIME 120 /* in  seconds */
-#define DEFAULT_TCP_SEND_TIMEOUT 10 /* if a send can't write for more then 10s,
-									   timeout */
-#define DEFAULT_TCP_CONNECT_TIMEOUT 10 /* if a connect doesn't complete in this
-										  time, timeout */
-#define DEFAULT_TCP_MAX_CONNECTIONS 2048 /* maximum connections */
 #define TCP_CHILD_TIMEOUT 5 /* after 5 seconds, the child "returns" 
 							 the connection to the tcp master process */
 #define TCP_MAIN_SELECT_TIMEOUT 5 /* how often "tcp main" checks for timeout*/
@@ -137,7 +132,7 @@ struct tcp_conn_alias{
 };
 
 
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	struct tcp_wbuffer{
 		struct tcp_wbuffer* next;
 		unsigned int b_size;
@@ -179,7 +174,7 @@ struct tcp_connection{
 	struct tcp_connection* c_prev;
 	struct tcp_conn_alias con_aliases[TCP_CON_MAX_ALIASES];
 	int aliases; /* aliases number, at least 1 */
-#ifdef TCP_BUF_WRITE
+#ifdef TCP_ASYNC
 	struct tcp_wbuffer_queue wbuf_q;
 #endif
 };

+ 1 - 1
tcp_info.h

@@ -33,7 +33,7 @@
 
 struct tcp_gen_info{
 	int tcp_readers;
-	int tcp_max_connections;
+	int tcp_max_connections; /* startup connection limit, cannot be exceeded*/
 	int tcp_connections_no; /* crt. number */
 	int tcp_write_queued; /* total bytes queued for write, 0 if no
 							 write queued support is enabled */

+ 10 - 0
tcp_init.h

@@ -29,6 +29,16 @@
 #define tcp_init_h
 #include "ip_addr.h"
 
+#define DEFAULT_TCP_CONNECTION_LIFETIME_S 120 /* in  seconds */
+/* maximum accepted lifetime in ticks (maximum possible is  ~ MAXINT/2) */
+#define MAX_TCP_CON_LIFETIME	((1U<<(sizeof(ticks_t)*8-1))-1)
+
+#define DEFAULT_TCP_SEND_TIMEOUT 10 /* if a send can't write for more then 10s,
+									   timeout */
+#define DEFAULT_TCP_CONNECT_TIMEOUT 10 /* if a connect doesn't complete in this
+										  time, timeout */
+#define DEFAULT_TCP_MAX_CONNECTIONS 2048 /* maximum connections */
+
 struct tcp_child{
 	pid_t pid;
 	int proc_no; /* ser proc_no, for debugging */

File diff suppressed because it is too large
+ 162 - 168
tcp_main.c


+ 247 - 28
tcp_options.c

@@ -21,65 +21,253 @@
  * History:
  * --------
  *  2007-11-28  created by andrei
+ *  2009-03-05  use cfg framework (andrei)
  */
 
 #include "tcp_options.h"
 #include "dprint.h"
 #include "globals.h"
 #include "timer_ticks.h"
+#include "cfg/cfg.h"
+#include "tcp_init.h" /* DEFAULT* */
 
 
-struct tcp_cfg_options tcp_options;
+
+/* default/initial values for tcp config options
+   NOTE: all the options are initialized in init_tcp_options()
+   depending on compile time defines */
+struct cfg_group_tcp tcp_default_cfg;
+#if 0
+{
+	1, /* fd_cache, default on */
+	/* tcp async options */
+	0, /* async / tcp_async, default off */
+	1, /* tcp_connect_wait - depends on tcp_async */
+	32*1024, /* tcpconn_wq_max - max. write queue len per connection (32k) */
+	10*1024*1024, /* tcp_wq_max - max.  overall queued bytes  (10MB)*/
+	S_TO_TICKS(tcp_send_timeout), /* tcp_wq_timeout - timeout for queued 
+									 writes, depends on tcp_send_timeout */
+	/* tcp socket options */
+	0, /* defer_accept - on/off*/
+	1, /* delayed_ack - delay ack on connect (on/off)*/
+	0, /* syncnt - numbers of SYNs retrs. before giving up (0 = OS default) */
+	0, /* linger2 - lifetime of orphaned FIN_WAIT2 sockets (0 = OS default)*/
+	1, /* keepalive - on/off */
+	0, /* keepidle - idle time (s) before tcp starts sending keepalives */
+	0, /* keepintvl - interval between keep alives (0 = OS default) */
+	0, /* keepcnt - maximum no. of keepalives (0 = OS default)*/
+	
+	/* other options */
+	1 /* crlf_ping - respond to double CRLF ping/keepalive (on/off) */
+	
+};
+#endif
+
+
+
+static int fix_connect_to(void* cfg_h, str* name, void** val);
+static int fix_send_to(void* cfg_h, str* name, void** val);
+static int fix_con_lt(void* cfg_h, str* name, void** val);
+static int fix_max_conns(void* cfg_h, str* name, void** val);
+
+
+
+/* cfg_group_tcp description (for the config framework)*/
+static cfg_def_t tcp_cfg_def[] = {
+	/*   name        , type |input type| chg type, min, max, fixup, proc. cbk 
+	      description */
+	{ "connect_timeout", CFG_VAR_INT | CFG_ATOMIC,  -1,
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME),  fix_connect_to,   0,
+		"used only in non-async mode, in seconds"},
+	{ "send_timeout", CFG_VAR_INT | CFG_ATOMIC,   -1,
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME),   fix_send_to,     0,
+		"in seconds"},
+	{ "connection_lifetime", CFG_VAR_INT | CFG_ATOMIC,   -1,
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME),   fix_con_lt,      0,
+		"connection lifetime (in seconds)"},
+	{ "max_connections", CFG_VAR_INT | CFG_ATOMIC, 0, (1U<<31)-1,
+													       fix_max_conns,    0,
+		"maximum connection number, soft limit"},
+	{ "no_connect",   CFG_VAR_INT | CFG_ATOMIC,      0,   1,      0,         0,
+		"if set only accept new connections, never actively open new ones"},
+	{ "fd_cache",     CFG_VAR_INT | CFG_READONLY,    0,   1,      0,         0,
+		"file descriptor cache for tcp_send"},
+	/* tcp async options */
+	{ "async",        CFG_VAR_INT | CFG_READONLY,    0,   1,      0,         0,
+		"async mode for writes and connects"},
+	{ "connect_wait", CFG_VAR_INT | CFG_READONLY,    0,   1,      0,         0,
+		"parallel simultaneous connects to the same dst. (0) or one connect"},
+	{ "conn_wq_max",  CFG_VAR_INT | CFG_ATOMIC,      0, 1024*1024, 0,        0,
+		"maximum bytes queued for write per connection (depends on async)"},
+	{ "wq_max",       CFG_VAR_INT | CFG_ATOMIC,      0,  1<<30,    0,        0,
+		"maximum bytes queued for write allowed globally (depends on async)"},
+	/* see also wq_timeout below */
+	/* tcp socket options */
+	{ "defer_accept", CFG_VAR_INT | CFG_READONLY,    0,   3600,   0,         0,
+		"0/1 on linux, seconds on freebsd (see docs)"},
+	{ "delayed_ack",  CFG_VAR_INT | CFG_ATOMIC,      0,      1,   0,         0,
+		"initial ack will be delayed and sent with the first data segment"},
+	{ "syncnt",       CFG_VAR_INT | CFG_ATOMIC,      0,   1024,   0,         0,
+		"number of syn retransmissions before aborting a connect (0=not set)"},
+	{ "linger2",      CFG_VAR_INT | CFG_ATOMIC,      0,   3600,   0,         0,
+		"lifetime of orphaned sockets in FIN_WAIT2 state in s (0=not set)"},
+	{ "keepalive",    CFG_VAR_INT | CFG_ATOMIC,      0,      1,   0,         0,
+		"enables/disables keepalives for tcp"},
+	{ "keepidle",     CFG_VAR_INT | CFG_ATOMIC,      0, 24*3600,  0,         0,
+		"time before sending a keepalive if the connection is idle (linux)"},
+	{ "keepintvl",    CFG_VAR_INT | CFG_ATOMIC,      0, 24*3600,  0,         0,
+		"time interval between keepalive probes on failure (linux)"},
+	{ "keepcnt",     CFG_VAR_INT | CFG_ATOMIC,       0,    1<<10,  0,        0,
+		"number of failed keepalives before dropping the connection (linux)"},
+	/* other options */
+	{ "crlf_ping",   CFG_VAR_INT | CFG_ATOMIC,      0,        1,  0,         0,
+		"enable responding to CRLF SIP-level keepalives "},
+	{ "accept_aliases", CFG_VAR_INT | CFG_ATOMIC,   0,        1,  0,         0,
+		"turn on/off tcp aliases (see tcp_accept_aliases) "},
+	{ "alias_flags", CFG_VAR_INT | CFG_ATOMIC,      0,        2,  0,         0,
+		"flags used for adding new aliases (FORCE_ADD:1 , REPLACE:2) "},
+	{ "new_conn_alias_flags", CFG_VAR_INT | CFG_ATOMIC, 0,    2,  0,         0,
+		"flags for the def. aliases for a new conn. (FORCE_ADD:1, REPLACE:2 "},
+	/* internal and/or "fixed" versions of some vars
+	   (not supposed to be writeable, read will provide only debugging value*/
+	{ "wq_timeout_ticks",   CFG_VAR_INT | CFG_READONLY, 0,
+									MAX_TCP_CON_LIFETIME,         0,         0,
+		"internal send_timeout value in ticks, used in async. mode"},
+	{ "con_lifetime_ticks", CFG_VAR_INT | CFG_READONLY, 0,
+									MAX_TCP_CON_LIFETIME,         0,         0,
+		"internal connection_lifetime value, converted to ticks"},
+	{0, 0, 0, 0, 0, 0, 0}
+};
 
 
+void* tcp_cfg; /* tcp config handle */
+
 /* set defaults */
 void init_tcp_options()
 {
-#ifdef TCP_BUF_WRITE
-	tcp_options.tcp_buf_write=0;
-	tcp_options.tcpconn_wq_max=32*1024; /* 32 k */
-	tcp_options.tcp_wq_max=10*1024*1024; /* 10 MB */
-	tcp_options.tcp_wq_timeout=S_TO_TICKS(tcp_send_timeout);
+	tcp_default_cfg.connect_timeout_s=DEFAULT_TCP_CONNECT_TIMEOUT;
+	tcp_default_cfg.send_timeout_s=DEFAULT_TCP_SEND_TIMEOUT;
+	tcp_default_cfg.con_lifetime_s=DEFAULT_TCP_CONNECTION_LIFETIME_S;
+	tcp_default_cfg.max_connections=tcp_max_connections;
+#ifdef TCP_ASYNC
+	tcp_default_cfg.async=1;
+	tcp_default_cfg.tcpconn_wq_max=32*1024; /* 32 k */
+	tcp_default_cfg.tcp_wq_max=10*1024*1024; /* 10 MB */
+	tcp_default_cfg.tcp_wq_timeout=S_TO_TICKS(tcp_default_cfg.send_timeout_s);
 #ifdef TCP_CONNECT_WAIT
-	tcp_options.tcp_connect_wait=1;
+	tcp_default_cfg.tcp_connect_wait=1;
 #endif /* TCP_CONNECT_WAIT */
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 #ifdef TCP_FD_CACHE
-	tcp_options.fd_cache=1;
+	tcp_default_cfg.fd_cache=1;
 #endif
 #ifdef HAVE_SO_KEEPALIVE
-	tcp_options.keepalive=1;
+	tcp_default_cfg.keepalive=1;
 #endif
 /*
 #if defined HAVE_TCP_DEFER_ACCEPT || defined HAVE_TCP_ACCEPT_FILTER
-	tcp_options.defer_accept=1;
+	tcp_default_cfg.defer_accept=1;
 #endif
 */
 #ifdef HAVE_TCP_QUICKACK
-	tcp_options.delayed_ack=1;
+	tcp_default_cfg.delayed_ack=1;
 #endif
-	tcp_options.crlf_ping=1;
+	tcp_default_cfg.crlf_ping=1;
+	tcp_default_cfg.accept_aliases=0; /* don't accept aliases by default */
+	/* flags used for adding new aliases */
+	tcp_default_cfg.alias_flags=TCP_ALIAS_FORCE_ADD;
+	/* flags used for adding the default aliases of a new tcp connection */
+	tcp_default_cfg.new_conn_alias_flags=TCP_ALIAS_REPLACE;
 }
 
 
 
 #define W_OPT_NC(option) \
-	if (tcp_options.option){\
+	if (tcp_default_cfg.option){\
 		WARN("tcp_options: tcp_" #option \
 				" cannot be enabled (recompile needed)\n"); \
-		tcp_options.option=0; \
+		tcp_default_cfg.option=0; \
 	}
 
 
 
 #define W_OPT_NS(option) \
-	if (tcp_options.option){\
+	if (tcp_default_cfg.option){\
 		WARN("tcp_options: tcp_" #option \
 				" cannot be enabled (no OS support)\n"); \
-		tcp_options.option=0; \
+		tcp_default_cfg.option=0; \
 	}
 
 
+
+/* if *to<0 to=default_val, else if to>max_val to=max_val */
+static void fix_timeout(char* name, int* to, int default_val, unsigned max_val)
+{
+	if (*to < 0) *to=default_val;
+	else if ((unsigned)*to > max_val){
+		WARN("%s: timeout too big (%u), the maximum value is %u\n",
+				name, *to, max_val);
+		*to=max_val;
+	}
+}
+
+
+
+static int fix_connect_to(void* cfg_h, str* name, void** val)
+{
+	int v;
+	v=(int)(long)*val;
+	fix_timeout("tcp_connect_timeout", &v, DEFAULT_TCP_CONNECT_TIMEOUT,
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
+	*val=(void*)(long)v;
+	return 0;
+}
+
+
+static int fix_send_to(void* cfg_h, str* name, void** val)
+{
+	int v;
+	v=(int)(long)*val;
+	fix_timeout("tcp_send_timeout", &v, DEFAULT_TCP_SEND_TIMEOUT,
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
+	*val=(void*)(long)v;
+#ifdef TCP_ASYNC
+	((struct cfg_group_tcp*)cfg_h)->tcp_wq_timeout=S_TO_TICKS(v);
+#endif /* TCP_ASYNC */
+	return 0;
+}
+
+
+static int fix_con_lt(void* cfg_h, str* name, void** val)
+{
+	int v;
+	v=(int)(long)*val;
+	fix_timeout("tcp_connection_lifetime", &v,
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME),
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
+	*val=(void*)(long)v;
+#ifdef TCP_ASYNC
+	((struct cfg_group_tcp*)cfg_h)->con_lifetime=S_TO_TICKS(v);
+#endif /* TCP_ASYNC */
+	return 0;
+}
+
+
+static int fix_max_conns(void* cfg_h, str* name, void** val)
+{
+	int v;
+	v=(int)(long)*val;
+	if (v>tcp_max_connections){
+		INFO("cannot override hard tcp_max_connections limit, please"
+				" restart and increase tcp_max_connections in the cfg.\n");
+		v=tcp_max_connections;
+	}
+	*val=(void*)(long)v;
+	return 0;
+}
+
+
+
 /* checks & warns if some tcp_option cannot be enabled */
 void tcp_options_check()
 {
@@ -87,20 +275,18 @@ void tcp_options_check()
 	W_OPT_NC(defer_accept);
 #endif
 
-#ifndef TCP_BUF_WRITE
-	W_OPT_NC(tcp_buf_write);
+#ifndef TCP_ASYNC
+	W_OPT_NC(async);
 	W_OPT_NC(tcpconn_wq_max);
 	W_OPT_NC(tcp_wq_max);
 	W_OPT_NC(tcp_wq_timeout);
-#endif /* TCP_BUF_WRITE */
+#endif /* TCP_ASYNC */
 #ifndef TCP_CONNECT_WAIT
 	W_OPT_NC(tcp_connect_wait);
 #endif /* TCP_CONNECT_WAIT */
 	
-	if (tcp_options.tcp_connect_wait && !tcp_options.tcp_buf_write){
-		WARN("tcp_options: tcp_connect_wait depends on tcp_buf_write, "
-				" disabling...\n");
-		tcp_options.tcp_connect_wait=0;
+	if (tcp_default_cfg.tcp_connect_wait && !tcp_default_cfg.async){
+		tcp_default_cfg.tcp_connect_wait=0;
 	}
 	
 #if ! defined HAVE_TCP_DEFER_ACCEPT && ! defined HAVE_TCP_ACCEPT_FILTER
@@ -121,8 +307,9 @@ void tcp_options_check()
 #ifndef HAVE_TCP_KEEPCNT
 	W_OPT_NS(keepcnt);
 #endif
-	if (tcp_options.keepintvl || tcp_options.keepidle || tcp_options.keepcnt){
-		tcp_options.keepalive=1; /* force on */
+	if (tcp_default_cfg.keepintvl || tcp_default_cfg.keepidle ||
+			tcp_default_cfg.keepcnt){
+		tcp_default_cfg.keepalive=1; /* force on */
 	}
 #ifndef HAVE_SO_KEEPALIVE
 	W_OPT_NS(keepalive);
@@ -130,11 +317,43 @@ void tcp_options_check()
 #ifndef HAVE_TCP_QUICKACK
 	W_OPT_NS(delayed_ack);
 #endif
+	/* fix various timeouts */
+	fix_timeout("tcp_connect_timeout", &tcp_default_cfg.connect_timeout_s,
+						DEFAULT_TCP_CONNECT_TIMEOUT,
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
+	fix_timeout("tcp_send_timeout", &tcp_default_cfg.send_timeout_s,
+						DEFAULT_TCP_SEND_TIMEOUT,
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
+	fix_timeout("tcp_connection_lifetime", &tcp_default_cfg.con_lifetime_s,
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME),
+						TICKS_TO_S(MAX_TCP_CON_LIFETIME));
+	/* compute timeout in ticks */
+#ifdef TCP_ASYNC
+	tcp_default_cfg.tcp_wq_timeout=S_TO_TICKS(tcp_default_cfg.send_timeout_s);
+#endif /* TCP_ASYNC */
+	tcp_default_cfg.con_lifetime=S_TO_TICKS(tcp_default_cfg.con_lifetime_s);
+	tcp_default_cfg.max_connections=tcp_max_connections;
+}
+
+
+
+void tcp_options_get(struct cfg_group_tcp* t)
+{
+	*t=*(struct cfg_group_tcp*)tcp_cfg;
 }
 
 
 
-void tcp_options_get(struct tcp_cfg_options* t)
+/** register tcp config into the configuration framework.
+ *  @return 0 on succes, -1 on error*/
+int tcp_register_cfg()
 {
-	*t=tcp_options;
+	if (cfg_declare("tcp", tcp_cfg_def, &tcp_default_cfg, cfg_sizeof(tcp),
+					&tcp_cfg))
+		return -1;
+	if (tcp_cfg==0){
+		BUG("null tcp cfg");
+		return -1;
+	}
+	return 0;
 }

+ 31 - 15
tcp_options.h

@@ -28,17 +28,17 @@
 
 #ifdef USE_TCP
 
-#ifndef NO_TCP_BUF_WRITE
-#define TCP_BUF_WRITE /* enabled buffered writing */
-#endif 
+#ifndef NO_TCP_ASYNC
+#define TCP_ASYNC /* enabled async mode */
+#endif
 
-#if !defined(NO_TCP_CONNECT_WAIT) && defined(TCP_BUF_WRITE)
+#if !defined(NO_TCP_CONNECT_WAIT) && defined(TCP_ASYNC)
 #define TCP_CONNECT_WAIT /* enable pending connects support */
 #endif
 
-#if defined(TCP_CONNECT_WAIT) && !defined(TCP_BUF_WRITE)
-/* check for impossible configuration: TCP_CONNECT_WAIT w/o TCP_BUF_WRITE */
-#warning "disabling TCP_CONNECT_WAIT because TCP_BUF_WRITE is not defined"
+#if defined(TCP_CONNECT_WAIT) && !defined(TCP_ASYNC)
+/* check for impossible configuration: TCP_CONNECT_WAIT w/o TCP_ASYNC */
+#warning "disabling TCP_CONNECT_WAIT because TCP_ASYNC is not defined"
 #undef TCP_CONNECT_WAIT
 #endif
 
@@ -109,15 +109,19 @@
 
 #endif /* USE_TCP */
 
-struct tcp_cfg_options{
-	/* ser tcp options */
+struct cfg_group_tcp{
+	/* ser tcp options, low level */
+	int connect_timeout_s; /* in s, used only in non-async mode */
+	int send_timeout_s; /* in s */
+	int con_lifetime_s; /* in s */
+	int max_connections;
+	int no_connect; /* do not open any new tcp connection (but accept them) */
 	int fd_cache; /* on /off */
-	/* tcp buf. write options */
-	int tcp_buf_write; /* on / off */
-	int tcp_connect_wait; /* on / off, depends on tcp_buf_write */
+	/* tcp async options */
+	int async; /* on / off */
+	int tcp_connect_wait; /* on / off, depends on async */
 	unsigned int tcpconn_wq_max; /* maximum queue len per connection */
 	unsigned int tcp_wq_max; /* maximum overall queued bytes */
-	unsigned int tcp_wq_timeout;      /* timeout for queue writes */
 
 	/* tcp socket options */
 	int defer_accept; /* on / off */
@@ -128,14 +132,26 @@ struct tcp_cfg_options{
 	int keepidle;   /* idle time (s) before tcp starts sending keepalives */
 	int keepintvl;  /* interval between keep alives */
 	int keepcnt;    /* maximum no. of keepalives before giving up */
+	
+	/* other options */
 	int crlf_ping;  /* on/off - reply to double CRLF keepalives */
+	int accept_aliases;
+	int alias_flags;
+	int new_conn_alias_flags;
+	/* internal, "fixed" vars */
+	unsigned int tcp_wq_timeout; /* in ticks, timeout for queued writes */
+	unsigned int con_lifetime; /* in ticks, see con_lifetime_s */
 };
 
+extern struct cfg_group_tcp tcp_default_cfg;
+
+/* tcp config handle*/
+extern void* tcp_cfg;
 
-extern struct tcp_cfg_options tcp_options;
 
 void init_tcp_options();
 void tcp_options_check();
-void tcp_options_get(struct tcp_cfg_options* t);
+int tcp_register_cfg();
+void tcp_options_get(struct cfg_group_tcp* t);
 
 #endif /* tcp_options_h */

+ 1 - 1
tcp_read.c

@@ -351,7 +351,7 @@ int tcp_read_headers(struct tcp_connection *c, int* read_flags)
 					case '\n':
 						break;
 					case '\r':
-						if (tcp_options.crlf_ping) {
+						if (cfg_get(tcp, tcp_cfg, crlf_ping)) {
 							r->state=H_SKIP_EMPTY_CR_FOUND;
 							r->start=p;
 						}

+ 68 - 4
test/p_uri.c

@@ -1,21 +1,85 @@
-
+/** uri parser test program. */
+/* compile with:
+    gcc -Wall p_uri.c   -o p_uri -DFAST_LOCK -D__CPU_i386 -DSHM_MEM */
 #include <stdio.h>
 #include <stdlib.h> /* exit() */
 #include <string.h>
+#include <stdarg.h>
 #include "../str.h"
 
 /* ser compat defs */
 #define EXTRA_DEBUG
 #include "../parser/parse_uri.c"
-#include "../dprint.c"
 
 
 int ser_error=0;
-int debug=L_DBG;
 int log_stderr=1;
-int log_facility=LOG_DAEMON;
 int process_no=0;
 struct process_table* pt=0;
+int phone2tel=1;
+volatile int dprint_crit=0;
+int my_pid() {return 0; };
+
+struct cfg_group_core default_core_cfg = {
+	L_DBG, /*  print only msg. < L_WARN */
+	LOG_DAEMON,	/* log_facility -- see syslog(3) */
+#ifdef USE_DST_BLACKLIST
+	/* blacklist */
+	0, /* dst blacklist is disabled by default */
+	DEFAULT_BLST_TIMEOUT,
+	DEFAULT_BLST_MAX_MEM,
+#endif
+	/* resolver */
+#ifdef USE_IPV6
+	1,  /* dns_try_ipv6 -- on by default */
+#else
+	0,  /* dns_try_ipv6 -- off, if no ipv6 support */
+#endif
+	0,  /* dns_try_naptr -- off by default */
+	30,  /* udp transport preference (for naptr) */
+	20,  /* tcp transport preference (for naptr) */
+	10,  /* tls transport preference (for naptr) */
+	20,  /* sctp transport preference (for naptr) */
+	-1, /* dns_retr_time */
+	-1, /* dns_retr_no */
+	-1, /* dns_servers_no */
+	1,  /* dns_search_list */
+	1,  /* dns_search_fmatch */
+	0,  /* dns_reinit */
+	/* DNS cache */
+#ifdef USE_DNS_CACHE
+	1,  /* use_dns_cache -- on by default */
+	0,  /* dns_cache_flags */
+	0,  /* use_dns_failover -- off by default */
+	0,  /* dns_srv_lb -- off by default */
+	DEFAULT_DNS_NEG_CACHE_TTL, /* neg. cache ttl */
+	DEFAULT_DNS_CACHE_MIN_TTL, /* minimum ttl */
+	DEFAULT_DNS_CACHE_MAX_TTL, /* maximum ttl */
+	DEFAULT_DNS_MAX_MEM, /* dns_cache_max_mem */
+	0, /* dns_cache_del_nonexp -- delete only expired entries by default */
+#endif
+#ifdef PKG_MALLOC
+	0, /* mem_dump_pkg */
+#endif
+#ifdef SHM_MEM
+	0, /* mem_dump_shm */
+#endif
+};
+
+void	*core_cfg = &default_core_cfg;
+
+
+void dprint(char * format, ...)
+{
+	va_list ap;
+
+	fprintf(stderr, "%2d(%d) ", process_no, my_pid());
+	va_start(ap, format);
+	vfprintf(stderr,format,ap);
+	fflush(stderr);
+	va_end(ap);
+}
+
 
 
 

+ 1 - 0
usr_avp.c

@@ -1025,6 +1025,7 @@ void free_avp_ident(avp_ident_t* attr)
 			abort();
 #endif
 		} else {
+			regfree(attr->name.re);
 			pkg_free(attr->name.re);
 		}
 	}

Some files were not shown because too many files changed in this diff