瀏覽代碼

Merge branch 'master' into websocket

Conflicts:
	pkg/kamailio/fedora/16/kamailio.spec
Peter Dunkley 13 年之前
父節點
當前提交
fd2a237fba
共有 53 個文件被更改,包括 778 次插入178 次删除
  1. 1 1
      Makefile.defs
  2. 14 3
      etc/kamailio.cfg
  3. 40 5
      modules/ndb_redis/README
  4. 9 0
      modules/ndb_redis/doc/ndb_redis.xml
  5. 36 4
      modules/ndb_redis/doc/ndb_redis_admin.xml
  6. 23 1
      modules/ndb_redis/ndb_redis_mod.c
  7. 115 15
      modules/ndb_redis/redis_client.c
  8. 1 0
      modules/ndb_redis/redis_client.h
  9. 20 0
      modules/tm/README
  10. 35 0
      modules/tm/doc/functions.xml
  11. 1 1
      modules/tm/h_table.h
  12. 1 1
      modules/tm/t_fwd.c
  13. 2 2
      modules/tm/t_lookup.c
  14. 16 16
      modules/tm/t_reply.c
  15. 3 3
      modules/tm/t_reply.h
  16. 1 1
      modules/tm/timer.c
  17. 59 6
      modules/tm/tm.c
  18. 1 1
      modules/tm/tm_load.c
  19. 9 2
      modules_k/dialog/dlg_profile.c
  20. 2 2
      modules_k/dispatcher/dispatch.c
  21. 23 25
      modules_k/nat_traversal/nat_traversal.c
  22. 7 0
      modules_k/p_usrloc/usrloc.c
  23. 1 9
      modules_k/presence/presence.c
  24. 28 4
      modules_k/presence_xml/README
  25. 29 0
      modules_k/presence_xml/doc/presence_xml_admin.xml
  26. 4 0
      modules_k/presence_xml/presence_xml.c
  27. 32 23
      modules_k/presence_xml/xcap_auth.c
  28. 3 0
      modules_k/pv/pv.c
  29. 60 0
      modules_k/pv/pv_core.c
  30. 6 0
      modules_k/pv/pv_core.h
  31. 12 1
      pkg/kamailio/deb/debian/control
  32. 2 2
      pkg/kamailio/deb/debian/kamailio.init
  33. 2 3
      pkg/kamailio/deb/debian/rules
  34. 10 1
      pkg/kamailio/deb/lenny/control
  35. 2 2
      pkg/kamailio/deb/lenny/kamailio.init
  36. 2 3
      pkg/kamailio/deb/lenny/rules
  37. 12 1
      pkg/kamailio/deb/lucid/control
  38. 2 2
      pkg/kamailio/deb/lucid/kamailio.init
  39. 2 3
      pkg/kamailio/deb/lucid/rules
  40. 12 1
      pkg/kamailio/deb/precise/control
  41. 2 2
      pkg/kamailio/deb/precise/kamailio.init
  42. 2 3
      pkg/kamailio/deb/precise/rules
  43. 12 1
      pkg/kamailio/deb/squeeze/control
  44. 2 2
      pkg/kamailio/deb/squeeze/kamailio.init
  45. 2 3
      pkg/kamailio/deb/squeeze/rules
  46. 12 1
      pkg/kamailio/deb/wheezy/control
  47. 2 2
      pkg/kamailio/deb/wheezy/kamailio.init
  48. 2 3
      pkg/kamailio/deb/wheezy/rules
  49. 1 1
      pkg/kamailio/fedora/16/kamailio.appl
  50. 16 14
      pkg/kamailio/fedora/16/kamailio.spec
  51. 44 0
      pkg/kamailio/fedora/17/kamailio-build.appl
  52. 39 0
      pkg/kamailio/fedora/17/kamailio.appl
  53. 2 2
      usr_avp.h

+ 1 - 1
Makefile.defs

@@ -162,7 +162,7 @@ INSTALL_FLAVOUR=$(FLAVOUR)
 VERSION = 3
 VERSION = 3
 PATCHLEVEL = 4
 PATCHLEVEL = 4
 SUBLEVEL =  0
 SUBLEVEL =  0
-EXTRAVERSION = -dev0
+EXTRAVERSION = -dev1
 
 
 # memory debugger switcher
 # memory debugger switcher
 # 0 - off (release mode)
 # 0 - off (release mode)

+ 14 - 3
etc/kamailio.cfg

@@ -1,6 +1,6 @@
 #!KAMAILIO
 #!KAMAILIO
 #
 #
-# Kamailio (OpenSER) SIP Server v3.3 - default configuration script
+# Kamailio (OpenSER) SIP Server v3.4 - default configuration script
 #     - web: http://www.kamailio.org
 #     - web: http://www.kamailio.org
 #     - git: http://sip-router.org
 #     - git: http://sip-router.org
 #
 #
@@ -571,6 +571,7 @@ route[WITHINDLG] {
 		# sequential request withing a dialog should
 		# sequential request withing a dialog should
 		# take the path determined by record-routing
 		# take the path determined by record-routing
 		if (loose_route()) {
 		if (loose_route()) {
+			route(DLGURI);
 			if (is_method("BYE")) {
 			if (is_method("BYE")) {
 				setflag(FLT_ACC); # do accounting ...
 				setflag(FLT_ACC); # do accounting ...
 				setflag(FLT_ACCFAILED); # ... even if the transaction fails
 				setflag(FLT_ACCFAILED); # ... even if the transaction fails
@@ -738,7 +739,7 @@ route[NATDETECT] {
 		if (is_method("REGISTER")) {
 		if (is_method("REGISTER")) {
 			fix_nated_register();
 			fix_nated_register();
 		} else {
 		} else {
-			fix_nated_contact();
+			add_contact_alias();
 		}
 		}
 		setflag(FLT_NATS);
 		setflag(FLT_NATS);
 	}
 	}
@@ -768,13 +769,23 @@ route[NATMANAGE] {
 	}
 	}
 	if (is_reply()) {
 	if (is_reply()) {
 		if(isbflagset(FLB_NATB)) {
 		if(isbflagset(FLB_NATB)) {
-			fix_nated_contact();
+			add_contact_alias();
 		}
 		}
 	}
 	}
 #!endif
 #!endif
 	return;
 	return;
 }
 }
 
 
+# URI update for dialog requests
+route[DLGURI] {
+#!ifdef WITH_NAT
+	if(!isdsturiset()) {
+		handle_ruri_alias();
+	}
+#!endif
+	return;
+}
+
 # Routing to foreign domains
 # Routing to foreign domains
 route[SIPOUT] {
 route[SIPOUT] {
 	if (!uri==myself)
 	if (!uri==myself)

+ 40 - 5
modules/ndb_redis/README

@@ -10,7 +10,13 @@ Daniel-Constantin Mierla
 
 
    <[email protected]>
    <[email protected]>
 
 
-   Copyright © 2011 asipto.com
+Vicente Hernando
+
+   <[email protected]>
+
+   Copyright © 2011 asipto.com
+
+   Copyright © 2012 www.systemonenoc.com
      __________________________________________________________________
      __________________________________________________________________
 
 
    Table of Contents
    Table of Contents
@@ -30,11 +36,13 @@ Daniel-Constantin Mierla
         4. Functions
         4. Functions
 
 
               4.1. redis_cmd(srvname, command, replyid)
               4.1. redis_cmd(srvname, command, replyid)
+              4.2. redis_free(replyid)
 
 
    List of Examples
    List of Examples
 
 
    1.1. Set server parameter
    1.1. Set server parameter
    1.2. redis_cmd usage
    1.2. redis_cmd usage
+   1.3. redis_free usage
 
 
 Chapter 1. Admin Guide
 Chapter 1. Admin Guide
 
 
@@ -53,6 +61,7 @@ Chapter 1. Admin Guide
    4. Functions
    4. Functions
 
 
         4.1. redis_cmd(srvname, command, replyid)
         4.1. redis_cmd(srvname, command, replyid)
+        4.2. redis_free(replyid)
 
 
 1. Overview
 1. Overview
 
 
@@ -87,9 +96,12 @@ Chapter 1. Admin Guide
 
 
    Specify the details to connect to REDIS server. It takes a list of
    Specify the details to connect to REDIS server. It takes a list of
    attribute=value separated by semicolon, the attributes can be name,
    attribute=value separated by semicolon, the attributes can be name,
-   addr, port and db. Name is a generic identifier to be used with module
-   functions. addr and port are the IP address and the port to connect to
-   REDIS server. db is the DB number to use (defaults to 0 if not
+   unix, addr, port and db. Name is a generic identifier to be used with
+   module functions. unix is the path to the unix domain socket provided
+   by redis server. addr and port are the IP address and the port to
+   connect to REDIS server. unix and (addr, port) are mutually exclusive.
+   If both appear in same server settings unix domain socket is
+   configured. db is the DB number to use (defaults to 0 if not
    specified).
    specified).
 
 
    You can set this parameter many times, in case you want to connect to
    You can set this parameter many times, in case you want to connect to
@@ -102,13 +114,17 @@ Chapter 1. Admin Guide
 ...
 ...
 modparam("ndb_redis", "server", "name=srvN;addr=127.0.0.1;port=6379;db=1")
 modparam("ndb_redis", "server", "name=srvN;addr=127.0.0.1;port=6379;db=1")
 modparam("ndb_redis", "server", "name=srvX;addr=127.0.0.2;port=6379;db=4")
 modparam("ndb_redis", "server", "name=srvX;addr=127.0.0.2;port=6379;db=4")
+
+# Unix domain socket
+modparam("ndb_redis", "server", "name=srvY;unix=/tmp/redis.sock;db=3")
 ...
 ...
 
 
 4. Functions
 4. Functions
 
 
    4.1. redis_cmd(srvname, command, replyid)
    4.1. redis_cmd(srvname, command, replyid)
+   4.2. redis_free(replyid)
 
 
-4.1. redis_cmd(srvname, command, replyid)
+4.1.  redis_cmd(srvname, command, replyid)
 
 
    Send a command to REDIS server identified by srvname. The reply will be
    Send a command to REDIS server identified by srvname. The reply will be
    stored in a local continer identified by replyid. All the parameters
    stored in a local continer identified by replyid. All the parameters
@@ -148,3 +164,22 @@ if(redis_cmd("srvN", "HMGET foo_key field1 field3", "r")) {
     xlog("first values: $redis(r=>value[0]) , $redis(r=>value[1])\n");
     xlog("first values: $redis(r=>value[0]) , $redis(r=>value[1])\n");
 }
 }
 ...
 ...
+
+4.2.  redis_free(replyid)
+
+   Free a previous reply from memory. After this function call, accessing
+   to a freed replyid returns null value.
+
+   It is not necessary to free a reply to use it again in a new redis_cmd
+   function. When ndb_redis module closes, all pending replies are freed
+   automatically, so you only need to use this function if you perform a
+   lot of redis command requests with different replyid.
+
+   Example 1.3. redis_free usage
+...
+After a redis command call:
+        redis_cmd("srvN", "INCR cnt", "r");
+
+when reply not used anymore:
+        redis_free("r");
+...

+ 9 - 0
modules/ndb_redis/doc/ndb_redis.xml

@@ -23,11 +23,20 @@
 		<surname>Mierla</surname>
 		<surname>Mierla</surname>
 		<email>[email protected]</email>
 		<email>[email protected]</email>
 	    </editor>
 	    </editor>
+	    <author>
+		<firstname>Vicente</firstname>
+		<surname>Hernando</surname>
+		<email>[email protected]</email>
+	    </author>
 	</authorgroup>
 	</authorgroup>
 	<copyright>
 	<copyright>
 	    <year>2011</year>
 	    <year>2011</year>
 	    <holder>asipto.com</holder>
 	    <holder>asipto.com</holder>
 	</copyright>
 	</copyright>
+	<copyright>
+	    <year>2012</year>
+	    <holder>www.systemonenoc.com</holder>
+	</copyright>
     </bookinfo>
     </bookinfo>
     <toc></toc>
     <toc></toc>
     
     

+ 36 - 4
modules/ndb_redis/doc/ndb_redis_admin.xml

@@ -64,10 +64,12 @@
 		<para>
 		<para>
 			Specify the details to connect to REDIS server. It takes a list of
 			Specify the details to connect to REDIS server. It takes a list of
 			attribute=value separated by semicolon, the attributes can be
 			attribute=value separated by semicolon, the attributes can be
-			name, addr, port and db. Name is a generic identifier to be used with
-			module functions. addr and port are the IP address and the port to
-			connect to REDIS server. db is the DB number to use (defaults to 0 if
-			not specified).
+			name, unix, addr, port and db. Name is a generic identifier to be used
+			with module functions. unix is the path to the unix domain socket provided
+			by redis server. addr and port are the IP address and the port to
+			connect to REDIS server. unix and (addr, port) are mutually exclusive.
+			If both appear in same server settings unix domain socket is configured.
+			db is the DB number to use (defaults to 0 if not specified).
 		</para>
 		</para>
 		<para>
 		<para>
 			You can set this parameter many times, in case you want to connect to
 			You can set this parameter many times, in case you want to connect to
@@ -85,6 +87,9 @@
 ...
 ...
 modparam("ndb_redis", "server", "name=srvN;addr=127.0.0.1;port=6379;db=1")
 modparam("ndb_redis", "server", "name=srvN;addr=127.0.0.1;port=6379;db=1")
 modparam("ndb_redis", "server", "name=srvX;addr=127.0.0.2;port=6379;db=4")
 modparam("ndb_redis", "server", "name=srvX;addr=127.0.0.2;port=6379;db=4")
+
+# Unix domain socket
+modparam("ndb_redis", "server", "name=srvY;unix=/tmp/redis.sock;db=3")
 ...
 ...
 </programlisting>
 </programlisting>
 		</example>
 		</example>
@@ -158,6 +163,33 @@ if(redis_cmd("srvN", "HMGET foo_key field1 field3", "r")) {
 </programlisting>
 </programlisting>
 	    </example>
 	    </example>
 	</section>
 	</section>
+	<section>
+	<title>
+		<function moreinfo="none">redis_free(replyid)</function>
+	</title>
+	<para>
+		Free a previous reply from memory.
+		After this function call, accessing to a freed replyid returns null value.
+	</para>
+	<para>
+		It is not necessary to free a reply to use it again in a new redis_cmd
+		function. When ndb_redis module closes, all pending replies are freed
+		automatically, so you only need to use this function if you perform a
+		lot of redis command requests with different replyid.
+	</para>
+	<example>
+		<title><function>redis_free</function> usage</title>
+		<programlisting format="linespecific">
+...
+After a redis command call:
+	redis_cmd("srvN", "INCR cnt", "r");
+
+when reply not used anymore:
+	redis_free("r");
+...
+		</programlisting>
+	</example>
+	</section>
 	</section>
 	</section>
 </chapter>
 </chapter>
 
 

+ 23 - 1
modules/ndb_redis/ndb_redis_mod.c

@@ -52,6 +52,8 @@ static int w_redis_cmd6(struct sip_msg* msg, char* ssrv, char* scmd,
 		char *sargv1, char *sargv2, char *sargv3, char* sres);
 		char *sargv1, char *sargv2, char *sargv3, char* sres);
 static int fixup_redis_cmd6(void** param, int param_no);
 static int fixup_redis_cmd6(void** param, int param_no);
 
 
+static int w_redis_free_reply(struct sip_msg* msg, char* res);
+
 static int  mod_init(void);
 static int  mod_init(void);
 static void mod_destroy(void);
 static void mod_destroy(void);
 static int  child_init(int rank);
 static int  child_init(int rank);
@@ -76,6 +78,8 @@ static cmd_export_t cmds[]={
 		0, ANY_ROUTE},
 		0, ANY_ROUTE},
 	{"redis_cmd", (cmd_function)w_redis_cmd6, 6, fixup_redis_cmd6,
 	{"redis_cmd", (cmd_function)w_redis_cmd6, 6, fixup_redis_cmd6,
 		0, ANY_ROUTE},
 		0, ANY_ROUTE},
+	{"redis_free", (cmd_function)w_redis_free_reply, 1, fixup_spve_null,
+		0, ANY_ROUTE},
 	{0, 0, 0, 0, 0, 0}
 	{0, 0, 0, 0, 0, 0}
 };
 };
 
 
@@ -288,6 +292,25 @@ static int fixup_redis_cmd6(void** param, int param_no)
 }
 }
 
 
 
 
+/**
+ *
+ */
+static int w_redis_free_reply(struct sip_msg* msg, char* res)
+{
+	str name;
+
+	if(fixup_get_svalue(msg, (gparam_t*)res, &name)!=0)
+	{
+		LM_ERR("no redis reply name\n");
+		return -1;
+	}
+
+	if(redisc_free_reply(&name)<0)
+		return -1;
+
+	return 1;
+}
+
 /**
 /**
  *
  *
  */
  */
@@ -296,7 +319,6 @@ int redis_srv_param(modparam_t type, void *val)
 	return redisc_add_server((char*)val);
 	return redisc_add_server((char*)val);
 }
 }
 
 
-
 /**
 /**
  *
  *
  */
  */

+ 115 - 15
modules/ndb_redis/redis_client.c

@@ -45,7 +45,7 @@ static redisc_reply_t *_redisc_rpl_list=NULL;
  */
  */
 int redisc_init(void)
 int redisc_init(void)
 {
 {
-	char *addr;
+	char *addr, *unix_sock_path = NULL;
 	unsigned int port, db;
 	unsigned int port, db;
 	redisc_server_t *rsrv=NULL;
 	redisc_server_t *rsrv=NULL;
 	param_t *pit = NULL;
 	param_t *pit = NULL;
@@ -67,7 +67,10 @@ int redisc_init(void)
 		db = 0;
 		db = 0;
 		for (pit = rsrv->attrs; pit; pit=pit->next)
 		for (pit = rsrv->attrs; pit; pit=pit->next)
 		{
 		{
-			if(pit->name.len==4 && strncmp(pit->name.s, "addr", 4)==0) {
+			if(pit->name.len==4 && strncmp(pit->name.s, "unix", 4)==0) {
+				unix_sock_path = pit->body.s;
+				unix_sock_path[pit->body.len] = '\0';
+			} else if(pit->name.len==4 && strncmp(pit->name.s, "addr", 4)==0) {
 				addr = pit->body.s;
 				addr = pit->body.s;
 				addr[pit->body.len] = '\0';
 				addr[pit->body.len] = '\0';
 			} else if(pit->name.len==4 && strncmp(pit->name.s, "port", 4)==0) {
 			} else if(pit->name.len==4 && strncmp(pit->name.s, "port", 4)==0) {
@@ -78,7 +81,14 @@ int redisc_init(void)
 					db = 0;
 					db = 0;
 			}
 			}
 		}
 		}
-		rsrv->ctxRedis = redisConnectWithTimeout(addr, port, tv);
+
+		if(unix_sock_path != NULL) {
+			LM_DBG("Connecting to unix socket: %s\n", unix_sock_path);
+			rsrv->ctxRedis = redisConnectUnixWithTimeout(unix_sock_path, tv);
+		} else {
+			rsrv->ctxRedis = redisConnectWithTimeout(addr, port, tv);
+		}
+
 		if(!rsrv->ctxRedis)
 		if(!rsrv->ctxRedis)
 			goto err;
 			goto err;
 		if (rsrv->ctxRedis->err)
 		if (rsrv->ctxRedis->err)
@@ -93,12 +103,22 @@ int redisc_init(void)
 	return 0;
 	return 0;
 
 
 err2:
 err2:
-	LM_ERR("error communicating with redis server [%.*s] (%s:%d/%d): %s\n",
-		rsrv->sname->len, rsrv->sname->s, addr, port, db, rsrv->ctxRedis->errstr);
+	if (unix_sock_path != NULL) {
+		LM_ERR("error communicating with redis server [%.*s] (unix:%s db:%d): %s\n",
+			   rsrv->sname->len, rsrv->sname->s, unix_sock_path, db, rsrv->ctxRedis->errstr);
+	} else {
+		LM_ERR("error communicating with redis server [%.*s] (%s:%d/%d): %s\n",
+			   rsrv->sname->len, rsrv->sname->s, addr, port, db, rsrv->ctxRedis->errstr);
+	}
 	return -1;
 	return -1;
 err:
 err:
-	LM_ERR("failed to connect to redis server [%.*s] (%s:%d/%d)\n",
-		rsrv->sname->len, rsrv->sname->s, addr, port, db);
+	if (unix_sock_path != NULL) {
+		LM_ERR("failed to connect to redis server [%.*s] (unix:%s db:%d)\n",
+			   rsrv->sname->len, rsrv->sname->s, unix_sock_path, db);
+	} else {
+		LM_ERR("failed to connect to redis server [%.*s] (%s:%d/%d)\n",
+			   rsrv->sname->len, rsrv->sname->s, addr, port, db);
+	}
 	return -1;
 	return -1;
 }
 }
 
 
@@ -107,8 +127,26 @@ err:
  */
  */
 int redisc_destroy(void)
 int redisc_destroy(void)
 {
 {
+	redisc_reply_t *rpl, *next_rpl;
+
 	redisc_server_t *rsrv=NULL;
 	redisc_server_t *rsrv=NULL;
 	redisc_server_t *rsrv1=NULL;
 	redisc_server_t *rsrv1=NULL;
+
+	rpl = _redisc_rpl_list;
+	while(rpl != NULL)
+	{
+		next_rpl = rpl->next;
+		if(rpl->rplRedis)
+			freeReplyObject(rpl->rplRedis);
+
+		if(rpl->rname.s != NULL)
+			pkg_free(rpl->rname.s);
+
+		pkg_free(rpl);
+		rpl = next_rpl;
+	}
+	_redisc_rpl_list = NULL;
+
 	if(_redisc_srv_list==NULL)
 	if(_redisc_srv_list==NULL)
 		return -1;
 		return -1;
 	rsrv=_redisc_srv_list;
 	rsrv=_redisc_srv_list;
@@ -121,6 +159,8 @@ int redisc_destroy(void)
 		free_params(rsrv1->attrs);
 		free_params(rsrv1->attrs);
 		pkg_free(rsrv1);
 		pkg_free(rsrv1);
 	}
 	}
+	_redisc_srv_list = NULL;
+
 	return 0;
 	return 0;
 }
 }
 
 
@@ -201,7 +241,7 @@ redisc_server_t *redisc_get_server(str *name)
  */
  */
 int redisc_reconnect_server(redisc_server_t *rsrv)
 int redisc_reconnect_server(redisc_server_t *rsrv)
 {
 {
-	char *addr;
+	char *addr, *unix_sock_path = NULL;
 	unsigned int port, db;
 	unsigned int port, db;
 	param_t *pit = NULL;
 	param_t *pit = NULL;
 	struct timeval tv;
 	struct timeval tv;
@@ -213,7 +253,10 @@ int redisc_reconnect_server(redisc_server_t *rsrv)
 	db = 0;
 	db = 0;
 	for (pit = rsrv->attrs; pit; pit=pit->next)
 	for (pit = rsrv->attrs; pit; pit=pit->next)
 	{
 	{
-		if(pit->name.len==4 && strncmp(pit->name.s, "addr", 4)==0) {
+		if(pit->name.len==4 && strncmp(pit->name.s, "unix", 4)==0) {
+			unix_sock_path = pit->body.s;
+			unix_sock_path[pit->body.len] = '\0';
+		} else if(pit->name.len==4 && strncmp(pit->name.s, "addr", 4)==0) {
 			addr = pit->body.s;
 			addr = pit->body.s;
 			addr[pit->body.len] = '\0';
 			addr[pit->body.len] = '\0';
 		} else if(pit->name.len==4 && strncmp(pit->name.s, "port", 4)==0) {
 		} else if(pit->name.len==4 && strncmp(pit->name.s, "port", 4)==0) {
@@ -229,7 +272,11 @@ int redisc_reconnect_server(redisc_server_t *rsrv)
 		rsrv->ctxRedis = NULL;
 		rsrv->ctxRedis = NULL;
 	}
 	}
 
 
-	rsrv->ctxRedis = redisConnectWithTimeout(addr, port, tv);
+	if(unix_sock_path != NULL) {
+		rsrv->ctxRedis = redisConnectUnixWithTimeout(unix_sock_path, tv);
+	} else {
+		rsrv->ctxRedis = redisConnectWithTimeout(addr, port, tv);
+	}
 	if(!rsrv->ctxRedis)
 	if(!rsrv->ctxRedis)
 		goto err;
 		goto err;
 	if (rsrv->ctxRedis->err)
 	if (rsrv->ctxRedis->err)
@@ -242,12 +289,21 @@ int redisc_reconnect_server(redisc_server_t *rsrv)
 	return 0;
 	return 0;
 
 
 err2:
 err2:
-	LM_ERR("error communicating with redis server [%.*s] (%s:%d/%d): %s\n",
-		rsrv->sname->len, rsrv->sname->s, addr, port, db, rsrv->ctxRedis->errstr);
-	return -1;
+	if (unix_sock_path != NULL) {
+		LM_ERR("error communicating with redis server [%.*s] (unix:%s db:%d): %s\n",
+			   rsrv->sname->len, rsrv->sname->s, unix_sock_path, db, rsrv->ctxRedis->errstr);
+	} else {
+		LM_ERR("error communicating with redis server [%.*s] (%s:%d/%d): %s\n",
+			   rsrv->sname->len, rsrv->sname->s, addr, port, db, rsrv->ctxRedis->errstr);
+	}
 err:
 err:
-	LM_ERR("failed to connect to redis server [%.*s] (%s:%d/%d)\n",
-		rsrv->sname->len, rsrv->sname->s, addr, port, db);
+	if (unix_sock_path != NULL) {
+		LM_ERR("failed to connect to redis server [%.*s] (unix:%s db:%d)\n",
+			   rsrv->sname->len, rsrv->sname->s, unix_sock_path, db);
+	} else {
+		LM_ERR("failed to connect to redis server [%.*s] (%s:%d/%d)\n",
+			   rsrv->sname->len, rsrv->sname->s, addr, port, db);
+	}
 	return -1;
 	return -1;
 }
 }
 
 
@@ -344,3 +400,47 @@ redisc_reply_t *redisc_get_reply(str *name)
 	_redisc_rpl_list = rpl;
 	_redisc_rpl_list = rpl;
 	return rpl;
 	return rpl;
 }
 }
+
+
+/**
+ *
+ */
+int redisc_free_reply(str *name)
+{
+	redisc_reply_t *rpl, *prev_rpl, *next_rpl;
+	unsigned int hid;
+
+	hid = get_hash1_raw(name->s, name->len);
+
+	prev_rpl = NULL;
+	rpl = _redisc_rpl_list;
+	while(rpl) {
+
+		if(rpl->hname==hid && rpl->rname.len==name->len
+		   && strncmp(rpl->rname.s, name->s, name->len)==0) {
+			next_rpl = rpl->next;
+			if(rpl->rplRedis)
+				freeReplyObject(rpl->rplRedis);
+
+			if(rpl->rname.s != NULL)
+				pkg_free(rpl->rname.s);
+
+			pkg_free(rpl);
+
+			if(prev_rpl==NULL) {
+				/* We delete first element in the list. */
+				_redisc_rpl_list = next_rpl;
+			} else {
+				prev_rpl->next = next_rpl;
+			}
+
+			return 0;
+		}
+
+		prev_rpl = rpl;
+		rpl = rpl->next;
+	}
+
+	/* reply entry not found. */
+	return -1;
+}

+ 1 - 0
modules/ndb_redis/redis_client.h

@@ -60,4 +60,5 @@ typedef struct redisc_pv {
 } redisc_pv_t;
 } redisc_pv_t;
 
 
 redisc_reply_t *redisc_get_reply(str *name);
 redisc_reply_t *redisc_get_reply(str *name);
+int redisc_free_reply(str *name);
 #endif
 #endif

+ 20 - 0
modules/tm/README

@@ -106,6 +106,7 @@ Juha Heinanen
         1.5.43. t_replicate(params)
         1.5.43. t_replicate(params)
         1.5.44. t_relay_to(proxy, flags)
         1.5.44. t_relay_to(proxy, flags)
         1.5.45. t_set_no_e2e_cancel_reason(0|1)
         1.5.45. t_set_no_e2e_cancel_reason(0|1)
+        1.5.46. t_is_set(target)
 
 
    1.6. TM Module API
    1.6. TM Module API
 
 
@@ -2146,6 +2147,25 @@ opying
 ...
 ...
 }
 }
 
 
+1.5.46. t_is_set(target)
+
+   Return true if the attribute specified by 'target' is set for
+   transaction.
+
+   The target parameter can be:
+     * branch_route - the function returns true if a branch route is set
+       to be executed.
+     * failure_route - the function returns true if a failure route is set
+       to be executed.
+     * onreply_route - the function returns true if an onreply route is
+       set to be executed.
+
+   Example 79. t_replicate usage
+...
+if(!t_is_set("failure_route"))
+    LM_DBG("no failure route will be executed for current transaction\n");
+...
+
 1.6. TM Module API
 1.6. TM Module API
 
 
    There are applications which would like to generate SIP transactions
    There are applications which would like to generate SIP transactions

+ 35 - 0
modules/tm/doc/functions.xml

@@ -1535,5 +1535,40 @@ route {
 	</example>
 	</example>
 	</section>
 	</section>
 
 
+	<section id="t_is_set">
+	<title>
+	    <function>t_is_set(target)</function>
+	</title>
+	<para>
+		Return true if the attribute specified by 'target' is set for transaction.
+	</para>
+	<para>The target parameter can be:</para>
+	<itemizedlist>
+	    <listitem>
+		<para><emphasis>branch_route</emphasis> - the function returns true if a
+			branch route is set to be executed.
+		</para>
+	    </listitem>
+	    <listitem>
+		<para><emphasis>failure_route</emphasis> - the function returns true if a
+			failure route is set to be executed.
+		</para>
+	    </listitem>
+	    <listitem>
+		<para><emphasis>onreply_route</emphasis> - the function returns true if an
+			onreply route is set to be executed.
+		</para>
+	    </listitem>
+	</itemizedlist>
+	<example>
+	    <title><function>t_replicate</function> usage</title>
+	    <programlisting>
+...
+if(!t_is_set("failure_route"))
+    LM_DBG("no failure route will be executed for current transaction\n");
+...
+	    </programlisting>
+	</example>
+    </section>
 
 
 </section>
 </section>

+ 1 - 1
modules/tm/h_table.h

@@ -432,7 +432,7 @@ typedef struct cell
 	short relayed_reply_branch;
 	short relayed_reply_branch;
 
 
 	/* the route to take if no final positive reply arrived */
 	/* the route to take if no final positive reply arrived */
-	unsigned short on_negative;
+	unsigned short on_failure;
 	/* the onreply_route to be processed if registered to do so */
 	/* the onreply_route to be processed if registered to do so */
 	unsigned short on_reply;
 	unsigned short on_reply;
 	 /* The route to take for each downstream branch separately */
 	 /* The route to take for each downstream branch separately */

+ 1 - 1
modules/tm/t_fwd.c

@@ -138,7 +138,7 @@ void t_on_branch( unsigned int go_to )
 	if (!t || t==T_UNDEFINED ) {
 	if (!t || t==T_UNDEFINED ) {
 		goto_on_branch=go_to;
 		goto_on_branch=go_to;
 	} else {
 	} else {
-		get_t()->on_branch = go_to;
+		t->on_branch = go_to;
 	}
 	}
 }
 }
 
 

+ 2 - 2
modules/tm/t_lookup.c

@@ -67,7 +67,7 @@
  * 2003-03-30  set_kr for requests only (jiri)
  * 2003-03-30  set_kr for requests only (jiri)
  * 2003-04-04  bug_fix: RESPONSE_IN callback not called for local
  * 2003-04-04  bug_fix: RESPONSE_IN callback not called for local
  *             UAC transactions (jiri)
  *             UAC transactions (jiri)
- * 2003-04-07  new transactions inherit on_negative and on_relpy from script
+ * 2003-04-07  new transactions inherit on_failure and on_relpy from script
  *             variables on instantiation (jiri)
  *             variables on instantiation (jiri)
  * 2003-04-30  t_newtran clean up (jiri)
  * 2003-04-30  t_newtran clean up (jiri)
  * 2003-08-21  request lookups fixed to skip UAC transactions, 
  * 2003-08-21  request lookups fixed to skip UAC transactions, 
@@ -1269,7 +1269,7 @@ static inline void init_new_t(struct cell *new_cell, struct sip_msg *p_msg)
 		if (likely(lifetime==0))
 		if (likely(lifetime==0))
 			lifetime=cfg_get(tm, tm_cfg, tm_max_noninv_lifetime);
 			lifetime=cfg_get(tm, tm_cfg, tm_max_noninv_lifetime);
 	}
 	}
-	new_cell->on_negative=get_on_negative();
+	new_cell->on_failure=get_on_failure();
 	new_cell->on_reply=get_on_reply();
 	new_cell->on_reply=get_on_reply();
 	new_cell->end_of_life=get_ticks_raw()+lifetime;;
 	new_cell->end_of_life=get_ticks_raw()+lifetime;;
 	new_cell->fr_timeout=(ticks_t)get_msgid_val(user_fr_timeout,
 	new_cell->fr_timeout=(ticks_t)get_msgid_val(user_fr_timeout,

+ 16 - 16
modules/tm/t_reply.c

@@ -170,8 +170,8 @@ char tm_tags[TOTAG_VALUE_LEN];
 static str  tm_tag = {tm_tags,TOTAG_VALUE_LEN};
 static str  tm_tag = {tm_tags,TOTAG_VALUE_LEN};
 char *tm_tag_suffix;
 char *tm_tag_suffix;
 
 
-/* where to go if there is no positive reply */
-static int goto_on_negative=0;
+/* where to go if there is no positive reply (>=300) */
+static int goto_on_failure=0;
 /* where to go on receipt of reply */
 /* where to go on receipt of reply */
 static int goto_on_reply=0;
 static int goto_on_reply=0;
 /* where to go on receipt of reply without transaction context */
 /* where to go on receipt of reply without transaction context */
@@ -245,7 +245,7 @@ int t_get_picked_branch(void)
 */
 */
 
 
 
 
-void t_on_negative( unsigned int go_to )
+void t_on_failure( unsigned int go_to )
 {
 {
 	struct cell *t = get_t();
 	struct cell *t = get_t();
 
 
@@ -253,9 +253,9 @@ void t_on_negative( unsigned int go_to )
 	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * created; if not -> use the static variable */
 	 * created; if not -> use the static variable */
 	if (!t || t==T_UNDEFINED )
 	if (!t || t==T_UNDEFINED )
-		goto_on_negative=go_to;
+		goto_on_failure=go_to;
 	else
 	else
-		get_t()->on_negative = go_to;
+		t->on_failure = go_to;
 }
 }
 
 
 
 
@@ -269,13 +269,13 @@ void t_on_reply( unsigned int go_to )
 	if (!t || t==T_UNDEFINED )
 	if (!t || t==T_UNDEFINED )
 		goto_on_reply=go_to;
 		goto_on_reply=go_to;
 	else
 	else
-		get_t()->on_reply = go_to;
+		t->on_reply = go_to;
 }
 }
 
 
 
 
-unsigned int get_on_negative()
+unsigned int get_on_failure()
 {
 {
-	return goto_on_negative;
+	return goto_on_failure;
 }
 }
 unsigned int get_on_reply()
 unsigned int get_on_reply()
 {
 {
@@ -875,7 +875,7 @@ void faked_env( struct cell *t, struct sip_msg *msg)
 int fake_req(struct sip_msg *faked_req,
 int fake_req(struct sip_msg *faked_req,
 		struct sip_msg *shmem_msg, int extra_flags, struct ua_client *uac)
 		struct sip_msg *shmem_msg, int extra_flags, struct ua_client *uac)
 {
 {
-	/* on_negative_reply faked msg now copied from shmem msg (as opposed
+	/* on_failure_reply faked msg now copied from shmem msg (as opposed
 	 * to zero-ing) -- more "read-only" actions (exec in particular) will
 	 * to zero-ing) -- more "read-only" actions (exec in particular) will
 	 * work from reply_route as they will see msg->from, etc.; caution,
 	 * work from reply_route as they will see msg->from, etc.; caution,
 	 * rw actions may append some pkg stuff to msg, which will possibly be
 	 * rw actions may append some pkg stuff to msg, which will possibly be
@@ -986,15 +986,15 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 	/* failure_route for a local UAC? */
 	/* failure_route for a local UAC? */
 	if (!shmem_msg) {
 	if (!shmem_msg) {
 		LOG(L_WARN,"Warning: run_failure_handlers: no UAC support (%d, %d) \n",
 		LOG(L_WARN,"Warning: run_failure_handlers: no UAC support (%d, %d) \n",
-			t->on_negative, t->tmcb_hl.reg_types);
+			t->on_failure, t->tmcb_hl.reg_types);
 		return 0;
 		return 0;
 	}
 	}
 
 
 	/* don't start faking anything if we don't have to */
 	/* don't start faking anything if we don't have to */
-	if (unlikely(!t->on_negative && !has_tran_tmcbs( t, TMCB_ON_FAILURE))) {
+	if (unlikely(!t->on_failure && !has_tran_tmcbs( t, TMCB_ON_FAILURE))) {
 		LOG(L_WARN,
 		LOG(L_WARN,
 			"Warning: run_failure_handlers: no negative handler (%d, %d)\n",
 			"Warning: run_failure_handlers: no negative handler (%d, %d)\n",
-			t->on_negative,
+			t->on_failure,
 			t->tmcb_hl.reg_types);
 			t->tmcb_hl.reg_types);
 		return 1;
 		return 1;
 	}
 	}
@@ -1010,12 +1010,12 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 	if (unlikely(has_tran_tmcbs( t, TMCB_ON_FAILURE)) ) {
 	if (unlikely(has_tran_tmcbs( t, TMCB_ON_FAILURE)) ) {
 		run_trans_callbacks( TMCB_ON_FAILURE, t, &faked_req, rpl, code);
 		run_trans_callbacks( TMCB_ON_FAILURE, t, &faked_req, rpl, code);
 	}
 	}
-	if (t->on_negative) {
+	if (t->on_failure) {
 		/* avoid recursion -- if failure_route forwards, and does not
 		/* avoid recursion -- if failure_route forwards, and does not
 		 * set next failure route, failure_route will not be reentered
 		 * set next failure route, failure_route will not be reentered
 		 * on failure */
 		 * on failure */
-		on_failure = t->on_negative;
-		t->on_negative=0;
+		on_failure = t->on_failure;
+		t->on_failure=0;
 		if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
 		if (exec_pre_script_cb(&faked_req, FAILURE_CB_TYPE)>0) {
 			/* run a failure_route action if some was marked */
 			/* run a failure_route action if some was marked */
 			if (run_top_route(failure_rt.rlist[on_failure], &faked_req, 0)<0)
 			if (run_top_route(failure_rt.rlist[on_failure], &faked_req, 0)<0)
@@ -1287,7 +1287,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
 		replies_dropped = 0;
 		replies_dropped = 0;
 		/* run ON_FAILURE handlers ( route and callbacks) */
 		/* run ON_FAILURE handlers ( route and callbacks) */
 		if (unlikely(has_tran_tmcbs( Trans, TMCB_ON_FAILURE_RO|TMCB_ON_FAILURE)
 		if (unlikely(has_tran_tmcbs( Trans, TMCB_ON_FAILURE_RO|TMCB_ON_FAILURE)
-						|| Trans->on_negative )) {
+						|| Trans->on_failure )) {
 			extra_flags=
 			extra_flags=
 				((Trans->uac[picked_branch].request.flags & F_RB_TIMEOUT)?
 				((Trans->uac[picked_branch].request.flags & F_RB_TIMEOUT)?
 							FL_TIMEOUT:0) | 
 							FL_TIMEOUT:0) | 

+ 3 - 3
modules/tm/t_reply.h

@@ -201,14 +201,14 @@ void set_final_timer( /* struct s_table *h_table,*/ struct cell *t );
 
 
 void cleanup_uac_timers( struct cell *t );
 void cleanup_uac_timers( struct cell *t );
 
 
-void on_negative_reply( struct cell* t, struct sip_msg* msg,
+void on_failure_reply( struct cell* t, struct sip_msg* msg,
 	int code, void *param  );
 	int code, void *param  );
 
 
 /* set which 'reply' structure to take if only negative
 /* set which 'reply' structure to take if only negative
    replies arrive 
    replies arrive 
 */
 */
-void t_on_negative( unsigned int go_to );
-unsigned int get_on_negative(void);
+void t_on_failure( unsigned int go_to );
+unsigned int get_on_failure(void);
 void t_on_reply( unsigned int go_to );
 void t_on_reply( unsigned int go_to );
 unsigned int get_on_reply(void);
 unsigned int get_on_reply(void);
 
 

+ 1 - 1
modules/tm/timer.c

@@ -471,7 +471,7 @@ inline static void final_response_handler(	struct retr_buf* r_buf,
 		&& t->nr_of_outgoings==1
 		&& t->nr_of_outgoings==1
 		/* on_negativ reply handler not installed -- serial forking 
 		/* on_negativ reply handler not installed -- serial forking 
 		 * could occur otherwise */
 		 * could occur otherwise */
-		&& t->on_negative==0
+		&& t->on_failure==0
 		/* the same for FAILURE callbacks */
 		/* the same for FAILURE callbacks */
 		&& !has_tran_tmcbs( t, TMCB_ON_FAILURE_RO|TMCB_ON_FAILURE) 
 		&& !has_tran_tmcbs( t, TMCB_ON_FAILURE_RO|TMCB_ON_FAILURE) 
 		/* something received -- we will not be silent on error */
 		/* something received -- we will not be silent on error */

+ 59 - 6
modules/tm/tm.c

@@ -195,6 +195,7 @@ static int fixup_on_branch(void** param, int param_no);
 static int fixup_t_reply(void** param, int param_no);
 static int fixup_t_reply(void** param, int param_no);
 static int fixup_on_sl_reply(modparam_t type, void* val);
 static int fixup_on_sl_reply(modparam_t type, void* val);
 static int fixup_t_relay_to(void** param, int param_no);
 static int fixup_t_relay_to(void** param, int param_no);
+static int fixup_t_is_set(void** param, int param_no);
 
 
 /* init functions */
 /* init functions */
 static int mod_init(void);
 static int mod_init(void);
@@ -270,7 +271,7 @@ inline static int w_t_forward_nonack_sctp(struct sip_msg*, char* str,char*);
 #endif
 #endif
 inline static int w_t_forward_nonack_to(struct sip_msg* msg, char* str,char*);
 inline static int w_t_forward_nonack_to(struct sip_msg* msg, char* str,char*);
 inline static int w_t_relay_cancel(struct sip_msg *p_msg, char *_foo, char *_bar);
 inline static int w_t_relay_cancel(struct sip_msg *p_msg, char *_foo, char *_bar);
-inline static int w_t_on_negative(struct sip_msg* msg, char *go_to, char *foo);
+inline static int w_t_on_failure(struct sip_msg* msg, char *go_to, char *foo);
 inline static int w_t_on_branch(struct sip_msg* msg, char *go_to, char *foo);
 inline static int w_t_on_branch(struct sip_msg* msg, char *go_to, char *foo);
 inline static int w_t_on_reply(struct sip_msg* msg, char *go_to, char *foo );
 inline static int w_t_on_reply(struct sip_msg* msg, char *go_to, char *foo );
 inline static int t_check_status(struct sip_msg* msg, char *match, char *foo);
 inline static int t_check_status(struct sip_msg* msg, char *match, char *foo);
@@ -298,6 +299,7 @@ static int t_grep_status(struct sip_msg* msg, char*, char*);
 static int w_t_drop_replies(struct sip_msg* msg, char* foo, char* bar);
 static int w_t_drop_replies(struct sip_msg* msg, char* foo, char* bar);
 static int w_t_save_lumps(struct sip_msg* msg, char* foo, char* bar);
 static int w_t_save_lumps(struct sip_msg* msg, char* foo, char* bar);
 static int w_t_check_trans(struct sip_msg* msg, char* foo, char* bar);
 static int w_t_check_trans(struct sip_msg* msg, char* foo, char* bar);
+static int w_t_is_set(struct sip_msg* msg, char* target, char* bar);
 
 
 
 
 /* by default the fr timers avps are not set, so that the avps won't be
 /* by default the fr timers avps are not set, so that the avps won't be
@@ -401,7 +403,7 @@ static cmd_export_t cmds[]={
 			REQUEST_ROUTE},
 			REQUEST_ROUTE},
 	{"t_relay_cancel",     w_t_relay_cancel,        0, 0,
 	{"t_relay_cancel",     w_t_relay_cancel,        0, 0,
 			REQUEST_ROUTE},
 			REQUEST_ROUTE},
-	{"t_on_failure",       w_t_on_negative,         1, fixup_on_failure,
+	{"t_on_failure",       w_t_on_failure,         1, fixup_on_failure,
 			REQUEST_ROUTE | FAILURE_ROUTE | TM_ONREPLY_ROUTE | BRANCH_ROUTE },
 			REQUEST_ROUTE | FAILURE_ROUTE | TM_ONREPLY_ROUTE | BRANCH_ROUTE },
 	{"t_on_reply",         w_t_on_reply,            1, fixup_on_reply,
 	{"t_on_reply",         w_t_on_reply,            1, fixup_on_reply,
 			REQUEST_ROUTE | FAILURE_ROUTE | TM_ONREPLY_ROUTE | BRANCH_ROUTE },
 			REQUEST_ROUTE | FAILURE_ROUTE | TM_ONREPLY_ROUTE | BRANCH_ROUTE },
@@ -462,6 +464,8 @@ static cmd_export_t cmds[]={
 			REQUEST_ROUTE},
 			REQUEST_ROUTE},
 	{"t_check_trans",	  w_t_check_trans,			0, 0,
 	{"t_check_trans",	  w_t_check_trans,			0, 0,
 			REQUEST_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE },
 			REQUEST_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE },
+	{"t_is_set",	      w_t_is_set,				1, fixup_t_is_set,
+			ANY_ROUTE },
 
 
 	{"t_load_contacts", t_load_contacts,            0, 0,
 	{"t_load_contacts", t_load_contacts,            0, 0,
 			REQUEST_ROUTE | FAILURE_ROUTE},
 			REQUEST_ROUTE | FAILURE_ROUTE},
@@ -717,9 +721,9 @@ static int script_init( struct sip_msg *foo, unsigned int flags, void *bar)
 	 * not be used again */
 	 * not be used again */
 
 
 	/* make sure the new message will not inherit previous
 	/* make sure the new message will not inherit previous
-		message's t_on_negative value
+		message's t_on_failure value
 	*/
 	*/
-	t_on_negative( 0 );
+	t_on_failure( 0 );
 	t_on_reply(0);
 	t_on_reply(0);
 	t_on_branch(0);
 	t_on_branch(0);
 	/* reset the kr status */
 	/* reset the kr status */
@@ -1341,9 +1345,9 @@ inline static int w_t_newtran( struct sip_msg* p_msg, char* foo, char* bar )
 }
 }
 
 
 
 
-inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo)
+inline static int w_t_on_failure( struct sip_msg* msg, char *go_to, char *foo)
 {
 {
-	t_on_negative( (unsigned int )(long) go_to );
+	t_on_failure( (unsigned int )(long) go_to );
 	return 1;
 	return 1;
 }
 }
 
 
@@ -1361,6 +1365,55 @@ inline static int w_t_on_reply( struct sip_msg* msg, char *go_to, char *foo )
 }
 }
 
 
 
 
+static int w_t_is_set(struct sip_msg* msg, char *target, char *foo )
+{
+	int r;
+	tm_cell_t *t = NULL;
+	
+	r = 0;
+	t = get_t();
+	if (t==T_UNDEFINED) t = NULL;
+
+	switch(target[0]) {
+		case 'b':
+			if(t==NULL)
+				r = get_on_branch();
+			else
+				r = t->on_branch;
+			break;
+		case 'f':
+			if(t==NULL)
+				r = get_on_failure();
+			else
+				r = t->on_failure;
+			break;
+		case 'o':
+			if(t==NULL)
+				r = get_on_reply();
+			else
+				r = t->on_reply;
+			break;
+	}
+	if(r) return 1;
+	return -1;
+}
+
+static int fixup_t_is_set(void** param, int param_no)
+{
+	int len;
+	if (param_no==1) {
+		len = strlen((char*)*param);
+		if((len==13 && strncmp((char*)*param, "failure_route", 13)==0)
+				|| (len==13 && strncmp((char*)*param, "onreply_route", 13)==0)
+				|| (len==12 && strncmp((char*)*param, "branch_route", 12)==0)) {
+			return 0;
+		}
+
+		LM_ERR("invalid parameter value: %s\n", (char*)*param);
+		return 1;
+	}
+	return 0;
+}
 
 
 inline static int _w_t_relay_to(struct sip_msg  *p_msg ,
 inline static int _w_t_relay_to(struct sip_msg  *p_msg ,
 									struct proxy_l *proxy, int force_proto)
 									struct proxy_l *proxy, int force_proto)

+ 1 - 1
modules/tm/tm_load.c

@@ -157,7 +157,7 @@ int load_xtm(tm_xapi_t *xapi)
 
 
 	memset(xapi, 0, sizeof(tm_xapi_t));
 	memset(xapi, 0, sizeof(tm_xapi_t));
 
 
-	xapi->t_on_failure    = t_on_negative;
+	xapi->t_on_failure    = t_on_failure;
 	xapi->t_on_branch     = t_on_branch;
 	xapi->t_on_branch     = t_on_branch;
 	xapi->t_on_reply      = t_on_reply;
 	xapi->t_on_reply      = t_on_reply;
 	xapi->t_check_trans   = t_check_trans;
 	xapi->t_check_trans   = t_check_trans;

+ 9 - 2
modules_k/dialog/dlg_profile.c

@@ -468,6 +468,13 @@ int set_dlg_profile(struct sip_msg *msg, str *value, struct dlg_profile_table *p
 		/* add linker directly to the dialog and profile */
 		/* add linker directly to the dialog and profile */
 		link_dlg_profile( linker, dlg);
 		link_dlg_profile( linker, dlg);
 	} else {
 	} else {
+		/* if existing linkers are not from current request, just discard them */
+		if (msg->id!=current_dlg_msg_id || msg->pid!=current_dlg_msg_pid) {
+			current_dlg_msg_id = msg->id;
+			current_dlg_msg_pid = msg->pid;
+			destroy_linkers(current_pending_linkers);
+			current_pending_linkers = NULL;
+		}
 		/* no dialog yet -> set linker as pending */
 		/* no dialog yet -> set linker as pending */
 		if (msg->id!=current_dlg_msg_id || msg->pid!=current_dlg_msg_pid) {
 		if (msg->id!=current_dlg_msg_id || msg->pid!=current_dlg_msg_pid) {
 			current_dlg_msg_id = msg->id;
 			current_dlg_msg_id = msg->id;
@@ -838,8 +845,8 @@ struct mi_root * mi_profile_list(struct mi_root *cmd_tree, void *param )
 					ph=ph->next;
 					ph=ph->next;
 				}while( ph!=profile->entries[i].first );
 				}while( ph!=profile->entries[i].first );
 			}
 			}
-			lock_release( &profile->lock );
 		}
 		}
+		lock_release( &profile->lock );
 	} else {
 	} else {
 		/* check for value also */
 		/* check for value also */
 		lock_get( &profile->lock );
 		lock_get( &profile->lock );
@@ -857,8 +864,8 @@ struct mi_root * mi_profile_list(struct mi_root *cmd_tree, void *param )
 					ph=ph->next;
 					ph=ph->next;
 				}while( ph!=profile->entries[i].first );
 				}while( ph!=profile->entries[i].first );
 			}
 			}
-			lock_release( &profile->lock );
 		}
 		}
+		lock_release( &profile->lock );
 	}
 	}
 
 
 	return rpl_tree;
 	return rpl_tree;

+ 2 - 2
modules_k/dispatcher/dispatch.c

@@ -2326,9 +2326,9 @@ static void ds_options_callback( struct cell *t, int type,
 	sip_msg_t *fmsg;
 	sip_msg_t *fmsg;
 	int state;
 	int state;
 
 
-	/* The Param does contain the group, in which the failed host
+	/* The param contains the group, in which the failed host
 	 * can be found.*/
 	 * can be found.*/
-	if (!*ps->param)
+	if (ps->param==NULL)
 	{
 	{
 		LM_DBG("No parameter provided, OPTIONS-Request was finished"
 		LM_DBG("No parameter provided, OPTIONS-Request was finished"
 				" with code %d\n", ps->code);
 				" with code %d\n", ps->code);

+ 23 - 25
modules_k/nat_traversal/nat_traversal.c

@@ -1741,38 +1741,36 @@ mod_init(void)
 
 
     // bind to the dialog API
     // bind to the dialog API
     if (load_dlg_api(&dlg_api)==0) {
     if (load_dlg_api(&dlg_api)==0) {
-        have_dlg_api = True;
-
         // load dlg_flag and default_timeout parameters from the dialog module
         // load dlg_flag and default_timeout parameters from the dialog module
         param = find_param_export(find_module_by_name("dialog"),
         param = find_param_export(find_module_by_name("dialog"),
 				"dlg_flag", INT_PARAM, &type);
 				"dlg_flag", INT_PARAM, &type);
-        if (!param) {
-            LM_ERR("cannot find dlg_flag parameter in the dialog module\n");
-            return -1;
-        }
-        dialog_flag = *param;
+        if (param) {
+		have_dlg_api = True;
 
 
-        param = find_param_export(find_module_by_name("dialog"),
-				"default_timeout", INT_PARAM, &type);
-        if (!param) {
-            LM_ERR("cannot find default_timeout parameter in the dialog module\n");
-            return -1;
-        }
-        dialog_default_timeout = *param;
+		dialog_flag = *param;
 
 
-        // register dialog creation callback
-        if (dlg_api.register_dlgcb(NULL, DLGCB_CREATED, __dialog_created, NULL, NULL) != 0) {
-            LM_ERR("cannot register callback for dialog creation\n");
-            return -1;
-        }
+		param = find_param_export(find_module_by_name("dialog"),
+					"default_timeout", INT_PARAM, &type);
+		if (!param) {
+		    LM_ERR("cannot find default_timeout parameter in the dialog module\n");
+		    return -1;
+		}
+		dialog_default_timeout = *param;
 
 
-        // register a pre-script callback to automatically enable dialog tracing
-        if (register_script_cb(preprocess_request, PRE_SCRIPT_CB|REQUEST_CB, 0)!=0) {
-            LM_ERR("could not register request preprocessing callback\n");
-            return -1;
-        }
+		// register dialog creation callback
+		if (dlg_api.register_dlgcb(NULL, DLGCB_CREATED, __dialog_created, NULL, NULL) != 0) {
+		    LM_ERR("cannot register callback for dialog creation\n");
+		    return -1;
+		}
 
 
-    } else {
+		// register a pre-script callback to automatically enable dialog tracing
+		if (register_script_cb(preprocess_request, PRE_SCRIPT_CB|REQUEST_CB, 0)!=0) {
+		    LM_ERR("could not register request preprocessing callback\n");
+		    return -1;
+		}
+	}
+    }
+    if (!have_dlg_api) {
         LM_NOTICE("keeping alive dialogs is disabled because the dialog module is not loaded\n");
         LM_NOTICE("keeping alive dialogs is disabled because the dialog module is not loaded\n");
     }
     }
 
 

+ 7 - 0
modules_k/p_usrloc/usrloc.c

@@ -65,6 +65,8 @@ int bind_usrloc(usrloc_api_t* api)
 		return -1;
 		return -1;
 	}
 	}
 
 
+	memset(api, 0, sizeof(usrloc_api_t));
+
 	api->register_udomain   = register_udomain;
 	api->register_udomain   = register_udomain;
 	api->get_all_ucontacts  = get_all_ucontacts;
 	api->get_all_ucontacts  = get_all_ucontacts;
 	api->insert_urecord     = insert_urecord;
 	api->insert_urecord     = insert_urecord;
@@ -79,6 +81,11 @@ int bind_usrloc(usrloc_api_t* api)
 	api->update_ucontact    = update_ucontact;
 	api->update_ucontact    = update_ucontact;
 	api->register_ulcb      = register_ulcb;
 	api->register_ulcb      = register_ulcb;
 
 
+	api->get_udomain              = 0;
+	api->get_urecord_by_ruid      = 0;
+	api->get_ucontact_by_instance = 0;
+	api->get_aorhash              = 0;
+
 	api->use_domain = use_domain;
 	api->use_domain = use_domain;
 	api->db_mode    = db_mode;
 	api->db_mode    = db_mode;
 	api->nat_flag   = nat_bflag;
 	api->nat_flag   = nat_bflag;

+ 1 - 9
modules_k/presence/presence.c

@@ -828,17 +828,9 @@ int pres_update_status(subs_t subs, str reason, db_key_t* query_cols,
 		query_vals[q_wuser_col].val.str_val= subs.watcher_user; 
 		query_vals[q_wuser_col].val.str_val= subs.watcher_user; 
 		query_vals[q_wdomain_col].val.str_val= subs.watcher_domain; 
 		query_vals[q_wdomain_col].val.str_val= subs.watcher_domain; 
 
 
-		/* if status is no longer ACTIVE, switch to terminated */
-		if(subs.status!=status && status==ACTIVE_STATUS)
-		{
-			subs.status = TERMINATED_STATUS;
-			subs.reason.s = get_status_str(TERMINATED_STATUS);
-			subs.reason.len = strlen(subs.reason.s);
-		}
-
 		update_vals[u_status_col].val.int_val= subs.status;
 		update_vals[u_status_col].val.int_val= subs.status;
 		update_vals[u_reason_col].val.str_val= subs.reason;
 		update_vals[u_reason_col].val.str_val= subs.reason;
-		
+
 		if (pa_dbf.use_table(pa_db, &watchers_table) < 0) 
 		if (pa_dbf.use_table(pa_db, &watchers_table) < 0) 
 		{
 		{
 			LM_ERR( "in use_table\n");
 			LM_ERR( "in use_table\n");

+ 28 - 4
modules_k/presence_xml/README

@@ -32,6 +32,7 @@ Anca-Maria Vamanu
               3.7. integrated_xcap_server (int)
               3.7. integrated_xcap_server (int)
               3.8. xcap_server (str)
               3.8. xcap_server (str)
               3.9. passive_mode(int)
               3.9. passive_mode(int)
+              3.10. xcapauth_userdel_reason(str)
 
 
         4. Functions
         4. Functions
 
 
@@ -54,8 +55,9 @@ Anca-Maria Vamanu
    1.7. Set integrated_xcap_server parameter
    1.7. Set integrated_xcap_server parameter
    1.8. Set xcap_server parameter
    1.8. Set xcap_server parameter
    1.9. Set passive_mode parameter
    1.9. Set passive_mode parameter
-   1.10. pres_check_basic usage
-   1.11. pres_check_activities usage
+   1.10. Set xcapauth_userdel_reason parameter
+   1.11. pres_check_basic usage
+   1.12. pres_check_activities usage
 
 
 Chapter 1. Admin Guide
 Chapter 1. Admin Guide
 
 
@@ -78,6 +80,7 @@ Chapter 1. Admin Guide
         3.7. integrated_xcap_server (int)
         3.7. integrated_xcap_server (int)
         3.8. xcap_server (str)
         3.8. xcap_server (str)
         3.9. passive_mode(int)
         3.9. passive_mode(int)
+        3.10. xcapauth_userdel_reason(str)
 
 
    4. Functions
    4. Functions
 
 
@@ -135,6 +138,7 @@ Chapter 1. Admin Guide
    3.7. integrated_xcap_server (int)
    3.7. integrated_xcap_server (int)
    3.8. xcap_server (str)
    3.8. xcap_server (str)
    3.9. passive_mode(int)
    3.9. passive_mode(int)
+   3.10. xcapauth_userdel_reason(str)
 
 
 3.1. db_url(str)
 3.1. db_url(str)
 
 
@@ -260,6 +264,26 @@ modparam("presence_xml", "xcap_server", "xcap_server.ag.org")
 modparam("presence_xml", "passive_mode", 1)
 modparam("presence_xml", "passive_mode", 1)
 ...
 ...
 
 
+3.10. xcapauth_userdel_reason(str)
+
+   This parameter represents the reason that will be included in the
+   Subscription-State header of the Notify when a rule is no longer found
+   in the XCAP pres-auth document for a user that was previously allowed.
+   The Subscription state in this case switches to "terminated". Because
+   it is not clear which reason is most appropriate in this case from the
+   ones defined by the RFC 3265, this parameter offers the possibility for
+   the admin to decide which one he wishes to use.
+
+   Default value: “probation” . Since probation also accepts a retry-after
+   parameter to specify after at least how may seconds the client should
+   reattempt to resubscribe, you can include this in the parameter also.
+
+   Example 1.10. Set xcapauth_userdel_reason parameter
+...
+modparam("presence_xml", "xcapauth_userdel_reason", "probation;retry-after=30")
+modparam("presence_xml", "xcapauth_userdel_reason", "rejected")
+...
+
 4. Functions
 4. Functions
 
 
    4.1. pres_check_basic(presentity_uri, status)
    4.1. pres_check_basic(presentity_uri, status)
@@ -276,7 +300,7 @@ modparam("presence_xml", "passive_mode", 1)
      * 1 - if a match is found.
      * 1 - if a match is found.
      * -1 - if a match is not found.
      * -1 - if a match is not found.
 
 
-   Example 1.10. pres_check_basic usage
+   Example 1.11. pres_check_basic usage
 ...
 ...
     if (pres_check_basic("$ru", "open")) {
     if (pres_check_basic("$ru", "open")) {
         ...
         ...
@@ -300,7 +324,7 @@ modparam("presence_xml", "passive_mode", 1)
      * -1 - if a match is not found.
      * -1 - if a match is not found.
      * -2 - if /presence/person or /presence/person/activity do not exist.
      * -2 - if /presence/person or /presence/person/activity do not exist.
 
 
-   Example 1.11. pres_check_activities usage
+   Example 1.12. pres_check_activities usage
 ...
 ...
     if (pres_check_basic("$ru", "open")) {
     if (pres_check_basic("$ru", "open")) {
         pres_check_activities("$ru", "unknown");
         pres_check_activities("$ru", "unknown");

+ 29 - 0
modules_k/presence_xml/doc/presence_xml_admin.xml

@@ -285,11 +285,40 @@ modparam("presence_xml", "xcap_server", "xcap_server.ag.org")
 ...
 ...
 modparam("presence_xml", "passive_mode", 1)
 modparam("presence_xml", "passive_mode", 1)
 ...
 ...
+</programlisting>
+		</example>
+	</section>
+
+	<section>
+		<title><varname>xcapauth_userdel_reason</varname>(str)</title>
+		<para>
+		This parameter represents the reason that will be included in the
+		Subscription-State header of the Notify when a rule is no longer found
+		in the XCAP pres-auth document for a user that was previously allowed.
+		The Subscription state in this case switches to "terminated". Because
+		it is not clear which reason is most appropriate in this case from
+		the ones defined by the RFC 3265, this parameter offers the possibility
+		for the admin to decide which one he wishes to use.
+		</para>
+		<para>
+			<emphasis>Default value: <quote>probation</quote> </emphasis> . Since 
+			probation also accepts a retry-after parameter to specify after at
+			least how may seconds the client should reattempt to resubscribe,
+			you can include this in the parameter also.
+		</para>
+		<example>
+		<title>Set <varname>xcapauth_userdel_reason</varname> parameter</title>
+		<programlisting format="linespecific">
+...
+modparam("presence_xml", "xcapauth_userdel_reason", "probation;retry-after=30")
+modparam("presence_xml", "xcapauth_userdel_reason", "rejected")
+...
 </programlisting>
 </programlisting>
 		</example>
 		</example>
 	</section>
 	</section>
 </section>
 </section>
 
 
+
 <section>
 <section>
 	<title>Functions</title>
 	<title>Functions</title>
 	<section>
 	<section>

+ 4 - 0
modules_k/presence_xml/presence_xml.c

@@ -94,6 +94,7 @@ int disable_presence = 0;
 int disable_winfo    = 0;
 int disable_winfo    = 0;
 int disable_bla      = 1;
 int disable_bla      = 1;
 int passive_mode     = 0;
 int passive_mode     = 0;
+str xcapauth_userdel_reason = str_init("probation");
 
 
 /** SL API structure */
 /** SL API structure */
 sl_api_t slb;
 sl_api_t slb;
@@ -126,6 +127,7 @@ static param_export_t params[]={
 	{ "disable_winfo",		INT_PARAM, &disable_winfo },
 	{ "disable_winfo",		INT_PARAM, &disable_winfo },
 	{ "disable_bla",		INT_PARAM, &disable_bla },
 	{ "disable_bla",		INT_PARAM, &disable_bla },
 	{ "passive_mode",		INT_PARAM, &passive_mode },
 	{ "passive_mode",		INT_PARAM, &passive_mode },
+	{ "xcapauth_userdel_reason", STR_PARAM, &xcapauth_userdel_reason.s},
 	{ 0, 0, 0}
 	{ 0, 0, 0}
 };
 };
 
 
@@ -168,6 +170,8 @@ static int mod_init(void)
 		return -1;
 		return -1;
 	}
 	}
 
 
+	xcapauth_userdel_reason.len = strlen(xcapauth_userdel_reason.s);
+
 	db_url.len = db_url.s ? strlen(db_url.s) : 0;
 	db_url.len = db_url.s ? strlen(db_url.s) : 0;
 	LM_DBG("db_url=%s/%d/%p\n",ZSW(db_url.s),db_url.len, db_url.s);
 	LM_DBG("db_url=%s/%d/%p\n",ZSW(db_url.s),db_url.len, db_url.s);
 	xcap_table.len = xcap_table.s ? strlen(xcap_table.s) : 0;
 	xcap_table.len = xcap_table.s ? strlen(xcap_table.s) : 0;

+ 32 - 23
modules_k/presence_xml/xcap_auth.c

@@ -47,6 +47,8 @@
 #include "xcap_auth.h"
 #include "xcap_auth.h"
 #include "pidf.h"
 #include "pidf.h"
 
 
+extern str xcapauth_userdel_reason;
+
 int http_get_rules_doc(str user, str domain, str* rules_doc);
 int http_get_rules_doc(str user, str domain, str* rules_doc);
 
 
 int pres_watcher_allowed(subs_t* subs)
 int pres_watcher_allowed(subs_t* subs)
@@ -55,7 +57,8 @@ int pres_watcher_allowed(subs_t* subs)
 	xmlNodePtr node= NULL,  actions_node = NULL;
 	xmlNodePtr node= NULL,  actions_node = NULL;
 	xmlNodePtr sub_handling_node = NULL;
 	xmlNodePtr sub_handling_node = NULL;
 	char* sub_handling = NULL;
 	char* sub_handling = NULL;
-	
+	int ret = 0;
+
 	/* if force_active set status to active*/
 	/* if force_active set status to active*/
 	if(force_active)
 	if(force_active)
 	{
 	{
@@ -64,12 +67,12 @@ int pres_watcher_allowed(subs_t* subs)
 		subs->reason.len= 0;
 		subs->reason.len= 0;
 		return 0;
 		return 0;
 	}
 	}
-	subs->status= PENDING_STATUS;
-	subs->reason.s= NULL;
-	subs->reason.len= 0;
 
 
 	if(subs->auth_rules_doc== NULL)
 	if(subs->auth_rules_doc== NULL)
 	{
 	{
+		subs->status= PENDING_STATUS;
+		subs->reason.s= NULL;
+		subs->reason.len= 0;
 		return 0;
 		return 0;
 	}
 	}
 
 
@@ -84,27 +87,35 @@ int pres_watcher_allowed(subs_t* subs)
 	node= get_rule_node(subs, xcap_tree);
 	node= get_rule_node(subs, xcap_tree);
 	if(node== NULL)
 	if(node== NULL)
 	{
 	{
-		xmlFreeDoc(xcap_tree);
-		return 0;
+		/* if no rule node was found and the previous state was active -> set the
+		 * state to terminated with reason xcapauth_userdel_reason (default "probation") */
+		if(subs->status != PENDING_STATUS)
+		{
+			subs->status= TERMINATED_STATUS;
+			subs->reason= xcapauth_userdel_reason;
+		}
+		goto done;
 	}
 	}
 
 
-	/* process actions */	
+	subs->status= PENDING_STATUS;
+	subs->reason.s= NULL;
+	subs->reason.len= 0;
+
+	/* process actions */
 	actions_node = xmlNodeGetChildByName(node, "actions");
 	actions_node = xmlNodeGetChildByName(node, "actions");
 	if(actions_node == NULL)
 	if(actions_node == NULL)
-	{	
+	{
 		LM_DBG("actions_node NULL\n");
 		LM_DBG("actions_node NULL\n");
-		xmlFreeDoc(xcap_tree);
-		return 0;
+		goto done;
 	}
 	}
 	LM_DBG("actions_node->name= %s\n",
 	LM_DBG("actions_node->name= %s\n",
 			actions_node->name);
 			actions_node->name);
 			
 			
 	sub_handling_node = xmlNodeGetChildByName(actions_node, "sub-handling");
 	sub_handling_node = xmlNodeGetChildByName(actions_node, "sub-handling");
 	if(sub_handling_node== NULL)
 	if(sub_handling_node== NULL)
-	{	
+	{
 		LM_DBG("sub_handling_node NULL\n");
 		LM_DBG("sub_handling_node NULL\n");
-		xmlFreeDoc(xcap_tree);
-		return 0;
+		goto done;
 	}
 	}
 	sub_handling = (char*)xmlNodeGetContent(sub_handling_node);
 	sub_handling = (char*)xmlNodeGetContent(sub_handling_node);
 		LM_DBG("sub_handling_node->name= %s\n",
 		LM_DBG("sub_handling_node->name= %s\n",
@@ -115,8 +126,8 @@ int pres_watcher_allowed(subs_t* subs)
 	if(sub_handling== NULL)
 	if(sub_handling== NULL)
 	{
 	{
 		LM_ERR("Couldn't get sub-handling content\n");
 		LM_ERR("Couldn't get sub-handling content\n");
-		xmlFreeDoc(xcap_tree);
-		return -1;
+		ret = -1;
+		goto done;
 	}
 	}
 	if( strncmp((char*)sub_handling, "block",5 )==0)
 	if( strncmp((char*)sub_handling, "block",5 )==0)
 	{	
 	{	
@@ -140,21 +151,19 @@ int pres_watcher_allowed(subs_t* subs)
 	if( strncmp((char*)sub_handling , "allow",5 )==0)
 	if( strncmp((char*)sub_handling , "allow",5 )==0)
 	{
 	{
 		subs->status = ACTIVE_STATUS;
 		subs->status = ACTIVE_STATUS;
-		subs->reason.s = NULL;
 	}
 	}
 	else
 	else
 	{
 	{
 		LM_ERR("unknown subscription handling action\n");
 		LM_ERR("unknown subscription handling action\n");
-		xmlFree(sub_handling);
-		xmlFreeDoc(xcap_tree);
-		return -1;
+		ret = -1;
 	}
 	}
 
 
-	xmlFree(sub_handling);
+done:
+	if(sub_handling)
+		xmlFree(sub_handling);
 	xmlFreeDoc(xcap_tree);
 	xmlFreeDoc(xcap_tree);
-	return 0;
-
-}	
+	return ret;
+}
 
 
 xmlNodePtr get_rule_node(subs_t* subs, xmlDocPtr xcap_tree )
 xmlNodePtr get_rule_node(subs_t* subs, xmlDocPtr xcap_tree )
 {
 {

+ 3 - 0
modules_k/pv/pv.c

@@ -132,6 +132,9 @@ static pv_export_t mod_pvs[] = {
 	{{"cl", (sizeof("cl")-1)}, /* */
 	{{"cl", (sizeof("cl")-1)}, /* */
 		PVT_OTHER, pv_get_content_length, 0,
 		PVT_OTHER, pv_get_content_length, 0,
 		0, 0, 0, 0},
 		0, 0, 0, 0},
+	{{"cnt", sizeof("cnt")-1},
+		PVT_OTHER, pv_get_cnt, 0,
+		pv_parse_cnt_name, 0, 0, 0 },
 	{{"cs", (sizeof("cs")-1)}, /* */
 	{{"cs", (sizeof("cs")-1)}, /* */
 		PVT_OTHER, pv_get_cseq, 0,
 		PVT_OTHER, pv_get_cseq, 0,
 		0, 0, 0, 0},
 		0, 0, 0, 0},

+ 60 - 0
modules_k/pv/pv_core.c

@@ -1593,6 +1593,34 @@ int pv_get_server_id(struct sip_msg *msg, pv_param_t *param,
 	return pv_get_sintval(msg, param, res, server_id);
 	return pv_get_sintval(msg, param, res, server_id);
 }
 }
 
 
+int pv_get_cnt(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res)
+{
+	int_str avp_name;
+	unsigned short avp_type = 0;
+	avp_search_state_t state;
+	pv_spec_t *pv=NULL;
+	unsigned int n = 0;
+	avp_t *avp;
+
+	pv = (pv_spec_t*)param->pvn.u.dname;
+	if(pv==NULL)
+		return pv_get_null(msg, param, res);
+
+	if(pv_get_avp_name(0, &pv->pvp, &avp_name, &avp_type)!=0)
+	{
+		LM_ERR("invalid AVP definition\n");
+		return pv_get_null(msg, param, res);
+	}
+	avp=search_first_avp(avp_type, avp_name, NULL, &state);
+	while(avp) {
+		n++;
+		avp=search_next_avp(&state, NULL); 
+	}
+
+	return pv_get_uintval(msg, param, res, n);
+}
+
 
 
 /********* end PV get functions *********/
 /********* end PV get functions *********/
 
 
@@ -2404,3 +2432,35 @@ error:
 	return -1;
 	return -1;
 }
 }
 
 
+int pv_parse_cnt_name(pv_spec_p sp, str *in)
+{
+	pv_spec_t *pv=NULL;
+
+	if(in->s==NULL || in->len<=0)
+		return -1;
+
+	pv = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
+	if(pv==NULL)
+		return -1;
+
+	memset(pv, 0, sizeof(pv_spec_t));
+
+	if(pv_parse_spec(in, pv)==NULL)
+		goto error;
+
+	if(pv->type!=PVT_AVP)
+	{
+		LM_ERR("expected avp name instead of [%.*s]\n", in->len, in->s);
+		goto error;
+	}
+
+	sp->pvp.pvn.u.dname = (void*)pv;
+	sp->pvp.pvn.type = PV_NAME_PVAR;
+	return 0;
+
+error:
+	LM_ERR("invalid pv name [%.*s]\n", in->len, in->s);
+	if(pv!=NULL)
+		pkg_free(pv);
+	return -1;
+}

+ 6 - 0
modules_k/pv/pv_core.h

@@ -201,6 +201,10 @@ int pv_get_version(struct sip_msg *msg, pv_param_t *param,
 
 
 int pv_get_server_id(struct sip_msg *msg, pv_param_t *param,
 int pv_get_server_id(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res);
 		pv_value_t *res);
+
+int pv_get_cnt(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res);
+
 /********* end PV get functions *********/
 /********* end PV get functions *********/
 
 
 /********* start PV set functions *********/
 /********* start PV set functions *********/
@@ -270,5 +274,7 @@ int pv_parse_scriptvar_name(pv_spec_p sp, str *in);
 
 
 int pv_parse_hdr_name(pv_spec_p sp, str *in);
 int pv_parse_hdr_name(pv_spec_p sp, str *in);
 
 
+int pv_parse_cnt_name(pv_spec_p sp, str *in);
+
 #endif
 #endif
 
 

+ 12 - 1
pkg/kamailio/deb/debian/control

@@ -10,7 +10,7 @@ Package: kamailio
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Conflicts: kamailio-regex-modules, kamailio-dbg
 Conflicts: kamailio-regex-modules, kamailio-dbg
-Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules, kamailio-mono-modules
+Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules, kamailio-mono-modules, kamailio-dbg
 Description: very fast and configurable SIP proxy
 Description: very fast and configurable SIP proxy
  Kamailio is a very fast and flexible SIP (RFC3261)
  Kamailio is a very fast and flexible SIP (RFC3261)
  proxy server. Written entirely in C, Kamailio can handle thousands calls
  proxy server. Written entirely in C, Kamailio can handle thousands calls
@@ -29,6 +29,17 @@ Description: very fast and configurable SIP proxy
  and support binaries.
  and support binaries.
 
 
 
 
+Package: kamailio-dbg
+Architecture: any
+Depends: ${shlibs:Depends}, kamailio (= ${binary:Version})
+Description: Debugging symbols for Kamailio SIP proxy
+ Kamailio is a very fast and flexible SIP (RFC3261)
+ proxy server. Written entirely in C, Kamailio can handle thousands calls
+ per second even on low-budget hardware.
+ .
+ This package provides gdb debugging symbols  for Kamailio
+
+
 Package: kamailio-mysql-modules
 Package: kamailio-mysql-modules
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, kamailio (= ${binary:Version}), mysql-client
 Depends: ${shlibs:Depends}, kamailio (= ${binary:Version}), mysql-client

+ 2 - 2
pkg/kamailio/deb/debian/kamailio.init

@@ -2,8 +2,8 @@
 #
 #
 ### BEGIN INIT INFO
 ### BEGIN INIT INFO
 # Provides:          kamailio
 # Provides:          kamailio
-# Required-Start:    $syslog $network $local_fs $time
-# Required-Stop:     $syslog $network $local_fs
+# Required-Start:    $syslog $network $local_fs $remote_fs $time
+# Required-Stop:     $syslog $network $local_fs $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Default-Stop:      0 1 6
 # Should-Start:      postgresql mysql radius
 # Should-Start:      postgresql mysql radius

+ 2 - 3
pkg/kamailio/deb/debian/rules

@@ -16,8 +16,7 @@
 # This is the debhelper compatibility version to use.
 # This is the debhelper compatibility version to use.
 # export DH_COMPAT=4
 # export DH_COMPAT=4
 #  -- already set in compat
 #  -- already set in compat
-#  force no striping (always include debug symbols for now)
-export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) nostrip"
+export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) debug"
 
 
 # modules not in the "main" kamailio package
 # modules not in the "main" kamailio package
 EXCLUDED_MODULES= 
 EXCLUDED_MODULES= 
@@ -193,7 +192,7 @@ binary-common:
 #	dh_undocumented
 #	dh_undocumented
 	dh_installchangelogs ChangeLog 
 	dh_installchangelogs ChangeLog 
 	dh_link
 	dh_link
-	dh_strip
+	dh_strip --dbg-package=kamailio-dbg
 	dh_compress 
 	dh_compress 
 	dh_fixperms
 	dh_fixperms
 	dh_makeshlibs
 	dh_makeshlibs

+ 10 - 1
pkg/kamailio/deb/lenny/control

@@ -10,7 +10,7 @@ Package: kamailio
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Conflicts: kamailio-regex-modules, kamailio-dbg
 Conflicts: kamailio-regex-modules, kamailio-dbg
-Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules
+Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules, kamailio-dbg
 Description: very fast and configurable SIP proxy
 Description: very fast and configurable SIP proxy
  Kamailio is a very fast and flexible SIP (RFC3261)
  Kamailio is a very fast and flexible SIP (RFC3261)
  proxy server. Written entirely in C, Kamailio can handle thousands calls
  proxy server. Written entirely in C, Kamailio can handle thousands calls
@@ -28,6 +28,15 @@ Description: very fast and configurable SIP proxy
  This package contains the main Kamailio binary along with the principal modules
  This package contains the main Kamailio binary along with the principal modules
  and support binaries.
  and support binaries.
 
 
+Package: kamailio-dbg
+Architecture: any
+Depends: ${shlibs:Depends}, kamailio (= ${binary:Version})
+Description: Debugging symbols for Kamailio SIP proxy
+ Kamailio is a very fast and flexible SIP (RFC3261)
+ proxy server. Written entirely in C, Kamailio can handle thousands calls
+ per second even on low-budget hardware.
+ .
+ This package provides gdb debugging symbols  for Kamailio
 
 
 Package: kamailio-mysql-modules
 Package: kamailio-mysql-modules
 Architecture: any
 Architecture: any

+ 2 - 2
pkg/kamailio/deb/lenny/kamailio.init

@@ -2,8 +2,8 @@
 #
 #
 ### BEGIN INIT INFO
 ### BEGIN INIT INFO
 # Provides:          kamailio
 # Provides:          kamailio
-# Required-Start:    $syslog $network $local_fs $time
-# Required-Stop:     $syslog $network $local_fs
+# Required-Start:    $syslog $network $local_fs $remote_fs $time
+# Required-Stop:     $syslog $network $local_fs $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Default-Stop:      0 1 6
 # Should-Start:      postgresql mysql radius
 # Should-Start:      postgresql mysql radius

+ 2 - 3
pkg/kamailio/deb/lenny/rules

@@ -16,8 +16,7 @@
 # This is the debhelper compatibility version to use.
 # This is the debhelper compatibility version to use.
 # export DH_COMPAT=4
 # export DH_COMPAT=4
 #  -- already set in compat
 #  -- already set in compat
-#  force no striping (always include debug symbols for now)
-export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) nostrip"
+export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) debug"
 
 
 # modules not in the "main" kamailio package
 # modules not in the "main" kamailio package
 EXCLUDED_MODULES= geoip
 EXCLUDED_MODULES= geoip
@@ -193,7 +192,7 @@ binary-common:
 #	dh_undocumented
 #	dh_undocumented
 	dh_installchangelogs ChangeLog 
 	dh_installchangelogs ChangeLog 
 	dh_link
 	dh_link
-	dh_strip
+	dh_strip --dbg-package=kamailio-dbg
 	dh_compress 
 	dh_compress 
 	dh_fixperms
 	dh_fixperms
 	dh_makeshlibs
 	dh_makeshlibs

+ 12 - 1
pkg/kamailio/deb/lucid/control

@@ -10,7 +10,7 @@ Package: kamailio
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Conflicts: kamailio-regex-modules, kamailio-dbg
 Conflicts: kamailio-regex-modules, kamailio-dbg
-Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules
+Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules, kamailio-dbg
 Description: very fast and configurable SIP proxy
 Description: very fast and configurable SIP proxy
  Kamailio is a very fast and flexible SIP (RFC3261)
  Kamailio is a very fast and flexible SIP (RFC3261)
  proxy server. Written entirely in C, Kamailio can handle thousands calls
  proxy server. Written entirely in C, Kamailio can handle thousands calls
@@ -29,6 +29,17 @@ Description: very fast and configurable SIP proxy
  and support binaries.
  and support binaries.
 
 
 
 
+Package: kamailio-dbg
+Architecture: any
+Depends: ${shlibs:Depends}, kamailio (= ${binary:Version})
+Description: Debugging symbols for Kamailio SIP proxy
+ Kamailio is a very fast and flexible SIP (RFC3261)
+ proxy server. Written entirely in C, Kamailio can handle thousands calls
+ per second even on low-budget hardware.
+ .
+ This package provides gdb debugging symbols for Kamailio
+
+
 Package: kamailio-mysql-modules
 Package: kamailio-mysql-modules
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, kamailio (= ${binary:Version}), mysql-client
 Depends: ${shlibs:Depends}, kamailio (= ${binary:Version}), mysql-client

+ 2 - 2
pkg/kamailio/deb/lucid/kamailio.init

@@ -2,8 +2,8 @@
 #
 #
 ### BEGIN INIT INFO
 ### BEGIN INIT INFO
 # Provides:          kamailio
 # Provides:          kamailio
-# Required-Start:    $syslog $network $local_fs $time
-# Required-Stop:     $syslog $network $local_fs
+# Required-Start:    $syslog $network $local_fs $remote_fs $time
+# Required-Stop:     $syslog $network $local_fs $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Default-Stop:      0 1 6
 # Should-Start:      postgresql mysql radius
 # Should-Start:      postgresql mysql radius

+ 2 - 3
pkg/kamailio/deb/lucid/rules

@@ -16,8 +16,7 @@
 # This is the debhelper compatibility version to use.
 # This is the debhelper compatibility version to use.
 # export DH_COMPAT=4
 # export DH_COMPAT=4
 #  -- already set in compat
 #  -- already set in compat
-#  force no striping (always include debug symbols for now)
-export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) nostrip"
+export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) debug"
 
 
 # modules not in the "main" kamailio package
 # modules not in the "main" kamailio package
 EXCLUDED_MODULES= 
 EXCLUDED_MODULES= 
@@ -193,7 +192,7 @@ binary-common:
 #	dh_undocumented
 #	dh_undocumented
 	dh_installchangelogs ChangeLog 
 	dh_installchangelogs ChangeLog 
 	dh_link
 	dh_link
-	dh_strip
+	dh_strip --dbg-package=kamailio-dbg
 	dh_compress 
 	dh_compress 
 	dh_fixperms
 	dh_fixperms
 	dh_makeshlibs
 	dh_makeshlibs

+ 12 - 1
pkg/kamailio/deb/precise/control

@@ -10,7 +10,7 @@ Package: kamailio
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Conflicts: kamailio-regex-modules, kamailio-dbg
 Conflicts: kamailio-regex-modules, kamailio-dbg
-Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules, kamailio-mono-modules
+Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules, kamailio-mono-modules, kamailio-dbg
 Description: very fast and configurable SIP proxy
 Description: very fast and configurable SIP proxy
  Kamailio is a very fast and flexible SIP (RFC3261)
  Kamailio is a very fast and flexible SIP (RFC3261)
  proxy server. Written entirely in C, Kamailio can handle thousands calls
  proxy server. Written entirely in C, Kamailio can handle thousands calls
@@ -29,6 +29,17 @@ Description: very fast and configurable SIP proxy
  and support binaries.
  and support binaries.
 
 
 
 
+Package: kamailio-dbg
+Architecture: any
+Depends: ${shlibs:Depends}, kamailio (= ${binary:Version})
+Description: Debugging symbols for Kamailio SIP proxy
+ Kamailio is a very fast and flexible SIP (RFC3261)
+ proxy server. Written entirely in C, Kamailio can handle thousands calls
+ per second even on low-budget hardware.
+ .
+ This package provides gdb debugging symbols for Kamailio
+
+
 Package: kamailio-mysql-modules
 Package: kamailio-mysql-modules
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, kamailio (= ${binary:Version}), mysql-client
 Depends: ${shlibs:Depends}, kamailio (= ${binary:Version}), mysql-client

+ 2 - 2
pkg/kamailio/deb/precise/kamailio.init

@@ -2,8 +2,8 @@
 #
 #
 ### BEGIN INIT INFO
 ### BEGIN INIT INFO
 # Provides:          kamailio
 # Provides:          kamailio
-# Required-Start:    $syslog $network $local_fs $time
-# Required-Stop:     $syslog $network $local_fs
+# Required-Start:    $syslog $network $local_fs $remote_fs $time
+# Required-Stop:     $syslog $network $local_fs $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Default-Stop:      0 1 6
 # Should-Start:      postgresql mysql radius
 # Should-Start:      postgresql mysql radius

+ 2 - 3
pkg/kamailio/deb/precise/rules

@@ -16,8 +16,7 @@
 # This is the debhelper compatibility version to use.
 # This is the debhelper compatibility version to use.
 # export DH_COMPAT=4
 # export DH_COMPAT=4
 #  -- already set in compat
 #  -- already set in compat
-#  force no striping (always include debug symbols for now)
-export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) nostrip"
+export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) debug"
 
 
 # modules not in the "main" kamailio package
 # modules not in the "main" kamailio package
 EXCLUDED_MODULES= mi_xmlrpc
 EXCLUDED_MODULES= mi_xmlrpc
@@ -193,7 +192,7 @@ binary-common:
 #	dh_undocumented
 #	dh_undocumented
 	dh_installchangelogs ChangeLog 
 	dh_installchangelogs ChangeLog 
 	dh_link
 	dh_link
-	dh_strip
+	dh_strip --dbg-package=kamailio-dbg
 	dh_compress 
 	dh_compress 
 	dh_fixperms
 	dh_fixperms
 	dh_makeshlibs
 	dh_makeshlibs

+ 12 - 1
pkg/kamailio/deb/squeeze/control

@@ -10,7 +10,7 @@ Package: kamailio
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Conflicts: kamailio-regex-modules, kamailio-dbg
 Conflicts: kamailio-regex-modules, kamailio-dbg
-Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules
+Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules, kamailio-dbg
 Description: very fast and configurable SIP proxy
 Description: very fast and configurable SIP proxy
  Kamailio is a very fast and flexible SIP (RFC3261)
  Kamailio is a very fast and flexible SIP (RFC3261)
  proxy server. Written entirely in C, Kamailio can handle thousands calls
  proxy server. Written entirely in C, Kamailio can handle thousands calls
@@ -29,6 +29,17 @@ Description: very fast and configurable SIP proxy
  and support binaries.
  and support binaries.
 
 
 
 
+Package: kamailio-dbg
+Architecture: any
+Depends: ${shlibs:Depends}, kamailio (= ${binary:Version})
+Description: Debugging symbols for Kamailio SIP proxy
+ Kamailio is a very fast and flexible SIP (RFC3261)
+ proxy server. Written entirely in C, Kamailio can handle thousands calls
+ per second even on low-budget hardware.
+ .
+ This package provides gdb debugging symbols  for Kamailio
+
+
 Package: kamailio-mysql-modules
 Package: kamailio-mysql-modules
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, kamailio (= ${binary:Version}), mysql-client
 Depends: ${shlibs:Depends}, kamailio (= ${binary:Version}), mysql-client

+ 2 - 2
pkg/kamailio/deb/squeeze/kamailio.init

@@ -2,8 +2,8 @@
 #
 #
 ### BEGIN INIT INFO
 ### BEGIN INIT INFO
 # Provides:          kamailio
 # Provides:          kamailio
-# Required-Start:    $syslog $network $local_fs $time
-# Required-Stop:     $syslog $network $local_fs
+# Required-Start:    $syslog $network $local_fs $remote_fs $time
+# Required-Stop:     $syslog $network $local_fs $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Default-Stop:      0 1 6
 # Should-Start:      postgresql mysql radius
 # Should-Start:      postgresql mysql radius

+ 2 - 3
pkg/kamailio/deb/squeeze/rules

@@ -16,8 +16,7 @@
 # This is the debhelper compatibility version to use.
 # This is the debhelper compatibility version to use.
 # export DH_COMPAT=4
 # export DH_COMPAT=4
 #  -- already set in compat
 #  -- already set in compat
-#  force no striping (always include debug symbols for now)
-export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) nostrip"
+export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) debug"
 
 
 # modules not in the "main" kamailio package
 # modules not in the "main" kamailio package
 EXCLUDED_MODULES= purple
 EXCLUDED_MODULES= purple
@@ -193,7 +192,7 @@ binary-common:
 #	dh_undocumented
 #	dh_undocumented
 	dh_installchangelogs ChangeLog 
 	dh_installchangelogs ChangeLog 
 	dh_link
 	dh_link
-	dh_strip
+	dh_strip --dbg-package=kamailio-dbg
 	dh_compress 
 	dh_compress 
 	dh_fixperms
 	dh_fixperms
 	dh_makeshlibs
 	dh_makeshlibs

+ 12 - 1
pkg/kamailio/deb/wheezy/control

@@ -10,7 +10,7 @@ Package: kamailio
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
 Conflicts: kamailio-regex-modules, kamailio-dbg
 Conflicts: kamailio-regex-modules, kamailio-dbg
-Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules, kamailio-mono-modules
+Suggests: kamailio-mysql-modules, kamailio-postgres-modules, kamailio-unixodbc-modules, kamailio-tls-modules, kamailio-cpl-modules, kamailio-radius-modules, kamailio-presence-modules, kamailio-xml-modules, kamailio-perl-modules, kamailio-snmpstats-modules, kamailio-xmpp-modules, kamailio-carrierroute-modules, kamailio-berkeley-modules, kamailio-ldap-modules, kamailio-lua-modules, kamailio-python-modules, kamailio-mono-modules, kamailio-dbg
 Description: very fast and configurable SIP proxy
 Description: very fast and configurable SIP proxy
  Kamailio is a very fast and flexible SIP (RFC3261)
  Kamailio is a very fast and flexible SIP (RFC3261)
  proxy server. Written entirely in C, Kamailio can handle thousands calls
  proxy server. Written entirely in C, Kamailio can handle thousands calls
@@ -29,6 +29,17 @@ Description: very fast and configurable SIP proxy
  and support binaries.
  and support binaries.
 
 
 
 
+Package: kamailio-dbg
+Architecture: any
+Depends: ${shlibs:Depends}, kamailio (= ${binary:Version})
+Description: Debugging symbols for Kamailio SIP proxy
+ Kamailio is a very fast and flexible SIP (RFC3261)
+ proxy server. Written entirely in C, Kamailio can handle thousands calls
+ per second even on low-budget hardware.
+ .
+ This package provides gdb debugging symbols  for Kamailio
+
+
 Package: kamailio-mysql-modules
 Package: kamailio-mysql-modules
 Architecture: any
 Architecture: any
 Depends: ${shlibs:Depends}, kamailio (= ${binary:Version}), mysql-client
 Depends: ${shlibs:Depends}, kamailio (= ${binary:Version}), mysql-client

+ 2 - 2
pkg/kamailio/deb/wheezy/kamailio.init

@@ -2,8 +2,8 @@
 #
 #
 ### BEGIN INIT INFO
 ### BEGIN INIT INFO
 # Provides:          kamailio
 # Provides:          kamailio
-# Required-Start:    $syslog $network $local_fs $time
-# Required-Stop:     $syslog $network $local_fs
+# Required-Start:    $syslog $network $local_fs $remote_fs $time
+# Required-Stop:     $syslog $network $local_fs $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Default-Stop:      0 1 6
 # Should-Start:      postgresql mysql radius
 # Should-Start:      postgresql mysql radius

+ 2 - 3
pkg/kamailio/deb/wheezy/rules

@@ -16,8 +16,7 @@
 # This is the debhelper compatibility version to use.
 # This is the debhelper compatibility version to use.
 # export DH_COMPAT=4
 # export DH_COMPAT=4
 #  -- already set in compat
 #  -- already set in compat
-#  force no striping (always include debug symbols for now)
-export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) nostrip"
+export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) debug"
 
 
 # modules not in the "main" kamailio package
 # modules not in the "main" kamailio package
 EXCLUDED_MODULES= 
 EXCLUDED_MODULES= 
@@ -193,7 +192,7 @@ binary-common:
 #	dh_undocumented
 #	dh_undocumented
 	dh_installchangelogs ChangeLog 
 	dh_installchangelogs ChangeLog 
 	dh_link
 	dh_link
-	dh_strip
+	dh_strip --dbg-package=kamailio-dbg
 	dh_compress 
 	dh_compress 
 	dh_fixperms
 	dh_fixperms
 	dh_makeshlibs
 	dh_makeshlibs

+ 1 - 1
pkg/kamailio/fedora/16/kamailio.appl

@@ -25,7 +25,7 @@ packages:
   - mod_perl			# kamailio-perl
   - mod_perl			# kamailio-perl
   - mono-core			# kamailio-mono
   - mono-core			# kamailio-mono
   - mysql-libs			# kamailio-mysql
   - mysql-libs			# kamailio-mysql
-  - net-snmp-agent-libs		# kamailio-snmpstats
+  - net-snmp-libs		# kamailio-snmpstats
   - openldap			# kamailio-ldap
   - openldap			# kamailio-ldap
   - openssl			# kamailio-tls
   - openssl			# kamailio-tls
   - pcre			# kamailio-regex, kamailio-dialplan, kamailio-lcr
   - pcre			# kamailio-regex, kamailio-dialplan, kamailio-lcr

+ 16 - 14
pkg/kamailio/fedora/16/kamailio.spec

@@ -1,7 +1,6 @@
 %define name    kamailio
 %define name    kamailio
 %define ver     3.4.0
 %define ver     3.4.0
-%define rel     dev0%{dist}
-%define _sharedir %{_prefix}/share
+%define rel     dev1%{dist}
 
 
 
 
 
 
@@ -692,10 +691,10 @@ fi
 %{_mandir}/man5/*
 %{_mandir}/man5/*
 %{_mandir}/man8/*
 %{_mandir}/man8/*
 
 
-%dir %{_sharedir}/kamailio
-%dir %{_sharedir}/kamailio/dbtext
-%dir %{_sharedir}/kamailio/dbtext/kamailio
-%{_sharedir}/kamailio/dbtext/kamailio/*
+%dir %{_datadir}/kamailio
+%dir %{_datadir}/kamailio/dbtext
+%dir %{_datadir}/kamailio/dbtext/kamailio
+%{_datadir}/kamailio/dbtext/kamailio/*
 
 
 
 
 %files mysql
 %files mysql
@@ -704,8 +703,8 @@ fi
 %{_libdir}/kamailio/modules/db_mysql.so
 %{_libdir}/kamailio/modules/db_mysql.so
 %{_libdir}/kamailio/kamctl/kamctl.mysql
 %{_libdir}/kamailio/kamctl/kamctl.mysql
 %{_libdir}/kamailio/kamctl/kamdbctl.mysql
 %{_libdir}/kamailio/kamctl/kamdbctl.mysql
-%dir %{_sharedir}/kamailio/mysql
-%{_sharedir}/kamailio/mysql/*
+%dir %{_datadir}/kamailio/mysql
+%{_datadir}/kamailio/mysql/*
 
 
 
 
 %files postgresql
 %files postgresql
@@ -714,8 +713,8 @@ fi
 %{_libdir}/kamailio/modules/db_postgres.so
 %{_libdir}/kamailio/modules/db_postgres.so
 %{_libdir}/kamailio/kamctl/kamctl.pgsql
 %{_libdir}/kamailio/kamctl/kamctl.pgsql
 %{_libdir}/kamailio/kamctl/kamdbctl.pgsql
 %{_libdir}/kamailio/kamctl/kamdbctl.pgsql
-%dir %{_sharedir}/kamailio/postgres
-%{_sharedir}/kamailio/postgres/*
+%dir %{_datadir}/kamailio/postgres
+%{_datadir}/kamailio/postgres/*
 
 
 
 
 %files unixODBC
 %files unixODBC
@@ -731,8 +730,8 @@ fi
 %{_libdir}/kamailio/modules/db_berkeley.so
 %{_libdir}/kamailio/modules/db_berkeley.so
 %{_libdir}/kamailio/kamctl/kamctl.db_berkeley
 %{_libdir}/kamailio/kamctl/kamctl.db_berkeley
 %{_libdir}/kamailio/kamctl/kamdbctl.db_berkeley
 %{_libdir}/kamailio/kamctl/kamdbctl.db_berkeley
-%dir %{_sharedir}/kamailio/db_berkeley
-%{_sharedir}/kamailio/db_berkeley/*
+%dir %{_datadir}/kamailio/db_berkeley
+%{_datadir}/kamailio/db_berkeley/*
 
 
 
 
 %files sqlite
 %files sqlite
@@ -741,8 +740,8 @@ fi
 %{_libdir}/kamailio/modules_k/db_sqlite.so
 %{_libdir}/kamailio/modules_k/db_sqlite.so
 %{_libdir}/kamailio/kamctl/kamctl.sqlite
 %{_libdir}/kamailio/kamctl/kamctl.sqlite
 %{_libdir}/kamailio/kamctl/kamdbctl.sqlite
 %{_libdir}/kamailio/kamctl/kamdbctl.sqlite
-%dir %{_sharedir}/kamailio/db_sqlite
-%{_sharedir}/kamailio/db_sqlite/*
+%dir %{_datadir}/kamailio/db_sqlite
+%{_datadir}/kamailio/db_sqlite/*
 
 
 
 
 %files utils
 %files utils
@@ -957,6 +956,9 @@ fi
 
 
 
 
 %changelog
 %changelog
+* Sat Jun 30 2012 Peter Dunkley <[email protected]>
+  - Updated rel to dev1
+  - Removed %_sharedir and replaced with standard macro %_datadir
 * Sat Jun 23 2012 Peter Dunkley <[email protected]>
 * Sat Jun 23 2012 Peter Dunkley <[email protected]>
   - Added websocket module
   - Added websocket module
 * Mon Jun 11 2012 Peter Dunkley <[email protected]>
 * Mon Jun 11 2012 Peter Dunkley <[email protected]>

+ 44 - 0
pkg/kamailio/fedora/17/kamailio-build.appl

@@ -0,0 +1,44 @@
+name: "kamailio-build-#OS_NAME#-#OS_VERSION#-#BASE_ARCH#"
+summary: "#OS_NAME# #OS_VERSION# for building Kamailio #BASE_ARCH# RPMs"
+os:
+  name: fedora
+  version: 17
+  password: kamailio
+hardware:
+  memory: 1024
+  partitions:
+    "/":
+      size: 4
+packages:
+  - @core
+  - bison			# kamailio
+  - db4-devel			# kamailio-bdb
+  - expat-devel			# kamailio-xmpp
+  - flex			# kamailio
+  - GeoIP-devel			# kamailio-GeoIP
+  - gcc				# kamailio
+  - glib-devel			# kamailio-purple
+  - hiredis-devel		# kamailio-redis
+  - json-c-devel		# kamailio-json
+  - libconfuse-devel		# kamailio-carrierroute
+  - libcurl-devel		# kamailio-utils, kamailio-presence
+  - libevent-devel		# kamailio-json
+  - libpurple-devel		# kamailio-purple
+  - libxml2-devel		# kamailio-utils, kamailio-cpl, kamailio-presence, kamailio-purple, kamailio-xmlrpc, kamailio-xmlops
+  - lua-devel			# kamailio-lua
+  - make			# kamailio
+  - mod_perl-devel		# kamailio-perl
+  - mono-devel			# kamailio-mono
+  - mysql-devel			# kamailio-mysql
+  - net-snmp-devel		# kamailio-snmpstats
+  - openldap-devel		# kamailio-ldap
+  - openssl-devel		# kamailio-tls
+  - pcre-devel			# kamailio-regex, kamailio-dialplan, kamailio-lcr
+  - postgresql-devel		# kamailio-postgresql
+  - python-devel		# kamailio-python
+  - radiusclient-ng-devel	# kamailio-radius
+  - redhat-rpm-config		# kamailio-debuginfo
+  - rpm-build
+  - sqlite-devel		# kamailio-sqlite
+  - unixODBC-devel		# kamailio-unixODBC
+  - zlib-devel			# kamailio-mysql

+ 39 - 0
pkg/kamailio/fedora/17/kamailio.appl

@@ -0,0 +1,39 @@
+name: "kamailio-#OS_NAME#-#OS_VERSION#-#BASE_ARCH#"
+summary: "#OS_NAME# #OS_VERSION# for installing Kamailio #BASE_ARCH# RPMs"
+os:
+  name: fedora
+  version: 17
+  password: kamailio
+hardware:
+  memory: 1024
+  partitions:
+    "/":
+      size: 2
+packages:
+  - @core
+  - db4				# kamailio-bdb
+  - expat			# kamailio-xmpp
+  - GeoIP			# kamailio-GeoIP
+  - glib			# kamailio-purple
+  - hiredis			# kamailio-redis
+  - json-c			# kamailio-json
+  - libconfuse			# kamailio-carrierroute
+  - libcurl			# kamailio-utils, kamailio-presence
+  - libevent			# kamailio-json
+  - libpurple			# kamailio-purple
+  - libxml2			# kamailio-utils, kamailio-cpl, kamailio-presence, kamailio-purple, kamailio-xmlrpc, kamailio-xmlops
+  - mod_perl			# kamailio-perl
+  - mono-core			# kamailio-mono
+  - mysql-libs			# kamailio-mysql
+  - net-snmp-libs		# kamailio-snmpstats
+  - openldap			# kamailio-ldap
+  - openssl			# kamailio-tls
+  - pcre			# kamailio-regex, kamailio-dialplan, kamailio-lcr
+  - perl-Authen-SASL		# kamailio-perl
+  - perl-LDAP			# kamailio-perl
+  - postgresql-libs		# kamailio-postgresql
+  - python			# kamailio-python
+  - radiusclient-ng		# kamailio-radius
+  - sqlite			# kamailio-sqlite
+  - unixODBC			# kamailio-unixODBC
+  - zlib			# kamailio-mysql

+ 2 - 2
usr_avp.h

@@ -115,13 +115,13 @@ typedef struct avp_ident {
 /*
 /*
  * AVP search state
  * AVP search state
  */
  */
-struct search_state {
+typedef struct search_state {
 	avp_flags_t flags;  /* Type of search and additional flags */
 	avp_flags_t flags;  /* Type of search and additional flags */
 	avp_id_t id;
 	avp_id_t id;
 	avp_name_t name;
 	avp_name_t name;
 	avp_t* avp;            /* Current AVP */
 	avp_t* avp;            /* Current AVP */
 //	regex_t* search_re;    /* Compiled regular expression */
 //	regex_t* search_re;    /* Compiled regular expression */
-};
+} avp_search_state_t;
 
 
 /* avp aliases structs*/
 /* avp aliases structs*/
 typedef struct avp_spec {
 typedef struct avp_spec {