Преглед изворни кода

Merge remote-tracking branch 'refs/remotes/kamailio/master'

Kevin Scott Adams пре 9 година
родитељ
комит
1e1c1ed02b
54 измењених фајлова са 732 додато и 1227 уклоњено
  1. 2 2
      Makefile.defs
  2. 4 1
      data_lump_rpl.c
  3. 5 5
      examples/scscf/kamailio.cfg
  4. 6 1
      md5.c
  5. 12 7
      md5.h
  6. 2 1
      modules/acc/diam_message.h
  7. 2 2
      modules/app_lua/app_lua_exp.c
  8. 2 2
      modules/auth_diameter/diameter_msg.h
  9. 2 1
      modules/cdp/diameter.h
  10. 65 3
      modules/dialog/dlg_cseq.c
  11. 3 0
      modules/dialog/dlg_cseq.h
  12. 9 2
      modules/dialog/dlg_handlers.c
  13. 1 1
      modules/dialog/dlg_var.c
  14. 1 5
      modules/http_async_client/http_async_client_mod.c
  15. 1 1
      modules/ims_dialog/dlg_db_handler.h
  16. 0 48
      modules/nsq/http.h
  17. 0 91
      modules/nsq/nsq.h
  18. 1 1
      modules/nsq/nsq_mod.c
  19. 0 173
      modules/nsq/reader.c
  20. 0 728
      modules/nsq/utlist.h
  21. 18 1
      modules/outbound/Makefile
  22. 12 12
      modules/permissions/hash.c
  23. 2 2
      modules/permissions/permissions.c
  24. 11 45
      modules/pike/pike_rpc.c
  25. 0 1
      modules/pike/pike_top.c
  26. 2 0
      modules/pike/pike_top.h
  27. 9 2
      modules/presence/hash.c
  28. 1 1
      modules/presence/notify.c
  29. 290 7
      modules/presence/presentity.c
  30. 16 8
      modules/sdpops/README
  31. 3 2
      modules/sdpops/api.h
  32. 12 2
      modules/sdpops/doc/sdpops_admin.xml
  33. 57 25
      modules/sdpops/sdpops_mod.c
  34. 10 4
      modules/sipcapture/sipcapture.c
  35. 1 1
      modules/siptrace/siptrace.c
  36. 2 3
      modules/topos/tps_storage.c
  37. 28 6
      modules/uri_db/README
  38. 25 0
      modules/uri_db/checks.c
  39. 6 0
      modules/uri_db/checks.h
  40. 32 0
      modules/uri_db/doc/uri_db_admin.xml
  41. 3 0
      modules/uri_db/uri_db.c
  42. 3 2
      modules/xmpp/sha.c
  43. 1 0
      parser/hf.c
  44. 17 21
      parser/parse_disposition.c
  45. 6 0
      pkg/kamailio/deb/debian/changelog
  46. 6 0
      pkg/kamailio/deb/jessie/changelog
  47. 6 0
      pkg/kamailio/deb/precise/changelog
  48. 6 0
      pkg/kamailio/deb/sid/changelog
  49. 6 0
      pkg/kamailio/deb/squeeze/changelog
  50. 6 0
      pkg/kamailio/deb/stretch/changelog
  51. 6 0
      pkg/kamailio/deb/trusty/changelog
  52. 6 0
      pkg/kamailio/deb/wheezy/changelog
  53. 5 7
      tcp_read.c
  54. 0 0
      utils/kamctl/mysql/ims_dialog-create.sql

+ 2 - 2
Makefile.defs

@@ -97,7 +97,7 @@ INSTALL_FLAVOUR=$(FLAVOUR)
 VERSION = 5
 VERSION = 5
 PATCHLEVEL = 0
 PATCHLEVEL = 0
 SUBLEVEL =  0
 SUBLEVEL =  0
-EXTRAVERSION = -dev5
+EXTRAVERSION = -dev6
 
 
 # memory manager switcher
 # memory manager switcher
 # 0 - f_malloc (fast malloc)
 # 0 - f_malloc (fast malloc)
@@ -1832,7 +1832,7 @@ ifeq ($(CC_NAME), suncc)
 endif
 endif
 	OLD_SOLARIS= $(shell echo "$(OSREL)" | \
 	OLD_SOLARIS= $(shell echo "$(OSREL)" | \
 				sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
 				sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
-	LIBS+= -L$(LOCALBASE)/lib -lxnet -lsocket -lnsl
+	LIBS+= -L$(LOCALBASE)/lib -lxnet -lsocket -lnsl -lmd5
 ifeq	($(OLD_SOLARIS), yes)
 ifeq	($(OLD_SOLARIS), yes)
 		LIBS+=-lposix4
 		LIBS+=-lposix4
 else
 else

+ 4 - 1
data_lump_rpl.c

@@ -102,9 +102,12 @@ void free_lump_rpl(struct lump_rpl* lump)
 {
 {
 	if (lump) {
 	if (lump) {
 		if (!((lump->flags)&LUMP_RPL_NOFREE) && ((lump->flags)&LUMP_RPL_NODUP)
 		if (!((lump->flags)&LUMP_RPL_NOFREE) && ((lump->flags)&LUMP_RPL_NODUP)
-		&& lump->text.s)
+		&& lump->text.s) {
 			pkg_free(lump->text.s);
 			pkg_free(lump->text.s);
+			lump->text.s = 0;
+		}
 		pkg_free(lump);
 		pkg_free(lump);
+		lump = 0;
 	}
 	}
 }
 }
 
 

+ 5 - 5
examples/scscf/kamailio.cfg

@@ -737,7 +737,7 @@ route[REG_MAR_REPLY]
                      send_reply("500", "MAR failed");
                      send_reply("500", "MAR failed");
                      break;
                      break;
              default:
              default:
-                     xlog("L_ERR", "Unknown return code from MAR, value is [$avp(s:uaa_return_code)]\n");
+                     xlog("L_ERR", "Unknown return code from MAR, value is [$avp(s:maa_return_code)]\n");
                      send_reply("500", "Unknown response code from MAR");
                      send_reply("500", "Unknown response code from MAR");
                      break;
                      break;
      }
      }
@@ -761,7 +761,7 @@ route[PRE_REG_SAR_REPLY]
                     xlog("L_ERR", "SAR error - error response sent from module\n");
                     xlog("L_ERR", "SAR error - error response sent from module\n");
                     break;
                     break;
             default:
             default:
-                    xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:uaa_return_code)]\n");
+                    xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:saa_return_code)]\n");
                     break;
                     break;
     }
     }
     exit;
     exit;
@@ -783,7 +783,7 @@ route[REG_SAR_REPLY]
                     xlog("L_ERR", "SAR error - error response sent from module\n");
                     xlog("L_ERR", "SAR error - error response sent from module\n");
                     break;
                     break;
             default:
             default:
-                    xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:uaa_return_code)]\n");
+                    xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:saa_return_code)]\n");
                     break;
                     break;
     }
     }
     exit;
     exit;
@@ -869,7 +869,7 @@ route[FINAL_ORIG]
 
 
 route[CHARGING_CCR_ORIG_REPLY]
 route[CHARGING_CCR_ORIG_REPLY]
 {
 {
-        xlog("L_DBG","saa_return code is $avp(s:cca_return_code)\n");
+        xlog("L_DBG","cca_return code is $avp(s:cca_return_code)\n");
 
 
         switch ($avp(s:cca_return_code)){
         switch ($avp(s:cca_return_code)){
             case 1: #success
             case 1: #success
@@ -1039,7 +1039,7 @@ route[FINAL_TERM] {
 
 
 route[CHARGING_CCR_TERM_REPLY]
 route[CHARGING_CCR_TERM_REPLY]
 {
 {
-        xlog("L_DBG","saa_return code is $avp(s:cca_return_code)\n");
+        xlog("L_DBG","cca_return code is $avp(s:cca_return_code)\n");
 
 
         switch ($avp(s:cca_return_code)){
         switch ($avp(s:cca_return_code)){
             case 1: #success
             case 1: #success

+ 6 - 1
md5.c

@@ -20,8 +20,11 @@
 #include <sys/types.h>
 #include <sys/types.h>
 #include <string.h>
 #include <string.h>
 
 
+#include "endianness.h"
 #include "md5.h"
 #include "md5.h"
 
 
+#ifndef __OS_solaris
+
 #define PUT_64BIT_LE(cp, value) do {					\
 #define PUT_64BIT_LE(cp, value) do {					\
 	(cp)[7] = (value) >> 56;					\
 	(cp)[7] = (value) >> 56;					\
 	(cp)[6] = (value) >> 48;					\
 	(cp)[6] = (value) >> 48;					\
@@ -157,7 +160,7 @@ MD5Transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LENGTH])
 {
 {
 	u_int32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4];
 	u_int32_t a, b, c, d, in[MD5_BLOCK_LENGTH / 4];
 
 
-#ifndef WORDS_BIGENDIAN
+#ifndef __IS_BIG_ENDIAN
 	memcpy(in, block, sizeof(in));
 	memcpy(in, block, sizeof(in));
 #else
 #else
 	for (a = 0; a < MD5_BLOCK_LENGTH / 4; a++) {
 	for (a = 0; a < MD5_BLOCK_LENGTH / 4; a++) {
@@ -247,3 +250,5 @@ MD5Transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LENGTH])
 	state[2] += c;
 	state[2] += c;
 	state[3] += d;
 	state[3] += d;
 }
 }
+
+#endif /* __OS_solaris */

+ 12 - 7
md5.h

@@ -15,6 +15,8 @@
 #ifndef _MD5_H_
 #ifndef _MD5_H_
 #define _MD5_H_
 #define _MD5_H_
 
 
+#ifndef __OS_solaris
+
 #define	MD5_BLOCK_LENGTH		64
 #define	MD5_BLOCK_LENGTH		64
 #define	MD5_DIGEST_LENGTH		16
 #define	MD5_DIGEST_LENGTH		16
 #define	MD5_DIGEST_STRING_LENGTH	(MD5_DIGEST_LENGTH * 2 + 1)
 #define	MD5_DIGEST_STRING_LENGTH	(MD5_DIGEST_LENGTH * 2 + 1)
@@ -22,13 +24,6 @@
 /* Probably not the proper place, but will do for Debian: */
 /* Probably not the proper place, but will do for Debian: */
 #include <sys/types.h>
 #include <sys/types.h>
 
 
-/* fix types for Sun Solaris */
-#if defined(__SVR4) || defined(__sun)
-    typedef uint8_t u_int8_t;
-    typedef uint32_t u_int32_t;
-    typedef uint64_t u_int64_t;
-#endif
-
 typedef struct MD5Context {
 typedef struct MD5Context {
 	u_int32_t state[4];			/* state */
 	u_int32_t state[4];			/* state */
 	u_int64_t count;			/* number of bits, mod 2^64 */
 	u_int64_t count;			/* number of bits, mod 2^64 */
@@ -49,4 +44,14 @@ static inline void MD5Final(char buf[MD5_DIGEST_LENGTH], MD5_CTX *ctx) {
 	U_MD5Final((unsigned char *)buf, ctx);
 	U_MD5Final((unsigned char *)buf, ctx);
 }
 }
 
 
+#else /* __OS_solaris */
+#include <md5.h>
+
+#define U_MD5Update(ctx, input, len) \
+	MD5Update(ctx, input, len)
+#define U_MD5Final(digest, ctx) \
+	MD5Final(digest, ctx)
+
+#endif /* __OS_solaris */
+
 #endif /* _MD5_H_ */
 #endif /* _MD5_H_ */

+ 2 - 1
modules/acc/diam_message.h

@@ -38,6 +38,7 @@
 
 
 #include "../../str.h"
 #include "../../str.h"
 #include "../../mem/mem.h"
 #include "../../mem/mem.h"
+#include "../../endianness.h"
 
 
 #define ad_malloc	pkg_malloc
 #define ad_malloc	pkg_malloc
 #define ad_free		pkg_free
 #define ad_free		pkg_free
@@ -68,7 +69,7 @@
 
 
 /* message codes
 /* message codes
  */
  */
-#ifndef WORDS_BIGENDIAN
+#ifndef __IS_BIG_ENDIAN
 	#define AS_MSG_CODE      0x12010000
 	#define AS_MSG_CODE      0x12010000
 	#define AC_MSG_CODE      0x0f010000
 	#define AC_MSG_CODE      0x0f010000
 	#define CE_MSG_CODE      0x01010000
 	#define CE_MSG_CODE      0x01010000

+ 2 - 2
modules/app_lua/app_lua_exp.c

@@ -2220,7 +2220,7 @@ static int lua_sr_sdpops_remove_codecs_by_id(lua_State *L)
 	codecs.s = (char*)lua_tostring(L, -1);
 	codecs.s = (char*)lua_tostring(L, -1);
 	codecs.len = strlen(codecs.s);
 	codecs.len = strlen(codecs.s);
 
 
-	ret = _lua_sdpopsb.sdp_remove_codecs_by_id(env_L->msg, &codecs);
+	ret = _lua_sdpopsb.sdp_remove_codecs_by_id(env_L->msg, &codecs, NULL);
 
 
 	return app_lua_return_int(L, ret);
 	return app_lua_return_int(L, ret);
 }
 }
@@ -2257,7 +2257,7 @@ static int lua_sr_sdpops_remove_codecs_by_name(lua_State *L)
 	codecs.s = (char*)lua_tostring(L, -1);
 	codecs.s = (char*)lua_tostring(L, -1);
 	codecs.len = strlen(codecs.s);
 	codecs.len = strlen(codecs.s);
 
 
-	ret = _lua_sdpopsb.sdp_remove_codecs_by_name(env_L->msg, &codecs);
+	ret = _lua_sdpopsb.sdp_remove_codecs_by_name(env_L->msg, &codecs, NULL);
 
 
 	return app_lua_return_int(L, ret);
 	return app_lua_return_int(L, ret);
 }
 }

+ 2 - 2
modules/auth_diameter/diameter_msg.h

@@ -29,6 +29,7 @@
 
 
 #include "../../str.h"
 #include "../../str.h"
 #include "../../mem/mem.h"
 #include "../../mem/mem.h"
+#include "../../endianness.h"
 
 
 #define ad_malloc	pkg_malloc
 #define ad_malloc	pkg_malloc
 #define ad_free		pkg_free
 #define ad_free		pkg_free
@@ -59,7 +60,7 @@
 
 
 /* message codes
 /* message codes
  */
  */
-#ifndef WORDS_BIGENDIAN
+#ifndef __IS_BIG_ENDIAN
 	#define AS_MSG_CODE      0x12010000
 	#define AS_MSG_CODE      0x12010000
 	#define AC_MSG_CODE      0x0f010000
 	#define AC_MSG_CODE      0x0f010000
 	#define CE_MSG_CODE      0x01010000
 	#define CE_MSG_CODE      0x01010000
@@ -69,7 +70,6 @@
 	#define ST_MSG_CODE      0x13010000
 	#define ST_MSG_CODE      0x13010000
 	#define MASK_MSG_CODE    0xffffff00
 	#define MASK_MSG_CODE    0xffffff00
 #else
 #else
-	#error BIG endian detected!!
 	#define AS_MSG_CODE      0x00000112
 	#define AS_MSG_CODE      0x00000112
 	#define AC_MSG_CODE      0x0000010f
 	#define AC_MSG_CODE      0x0000010f
 	#define CE_MSG_CODE      0x00000101
 	#define CE_MSG_CODE      0x00000101

+ 2 - 1
modules/cdp/diameter.h

@@ -47,6 +47,7 @@
 
 
 #include "utils.h"
 #include "utils.h"
 #include <ctype.h>
 #include <ctype.h>
+#include "../../endianness.h"
 
 
 #include "diameter_code_result.h"
 #include "diameter_code_result.h"
 #include "diameter_code_avp.h"
 #include "diameter_code_avp.h"
@@ -104,7 +105,7 @@
 	AVP_VENDOR_ID_SIZE*(((_flags_)&AAA_AVP_FLAG_VENDOR_SPECIFIC)!=0) )
 	AVP_VENDOR_ID_SIZE*(((_flags_)&AAA_AVP_FLAG_VENDOR_SPECIFIC)!=0) )
 
 
 /* mesage codes */
 /* mesage codes */
-#ifndef WORDS_BIGENDIAN
+#ifndef __IS_BIG_ENDIAN
 	#define AS_MSG_CODE      0x12010000
 	#define AS_MSG_CODE      0x12010000
 	#define AC_MSG_CODE      0x0f010000
 	#define AC_MSG_CODE      0x0f010000
 	#define CE_MSG_CODE      0x01010000
 	#define CE_MSG_CODE      0x01010000

+ 65 - 3
modules/dialog/dlg_cseq.c

@@ -186,6 +186,61 @@ error:
 	return -1;
 	return -1;
 }
 }
 
 
+
+/**
+ *
+ */
+int dlg_cseq_refresh(sip_msg_t *msg, dlg_cell_t *dlg,
+		unsigned int direction)
+{
+	str nval;
+	str *pval;
+
+	if(dlg_cseq_prepare_msg(msg)!=0) {
+		goto error;
+	}
+	if(msg->first_line.type==SIP_REPLY) {
+		/* nothing to do for outgoing replies */
+		goto done;
+	}
+
+	LM_DBG("initiating cseq refresh\n");
+
+	/* supported only for downstrem direction */
+	if(direction != DLG_DIR_DOWNSTREAM) {
+		LM_DBG("request not going downstream (%u)\n", direction);
+		goto done;
+	}
+
+	/* take the increment value from dialog */
+	if(!((dlg->iflags&DLG_IFLAG_CSEQ_DIFF)==DLG_IFLAG_CSEQ_DIFF)) {
+		LM_DBG("no cseq refresh required\n");
+		goto done;
+	}
+
+	/* get dialog variable holding cseq diff */
+	pval = get_dlg_variable(dlg, &_dlg_cseq_diff_var_name);
+	if(pval==NULL || pval->s==NULL || pval->len<=0) {
+		LM_DBG("dialog marked with cseq diff but no variable set yet\n");
+		goto done;
+	}
+
+	nval = *pval;
+	trim(&nval);
+
+	LM_DBG("adding cseq refresh header value: %.*s\n", nval.len, nval.s);
+	parse_headers(msg, HDR_EOH_F, 0);
+	sr_hdr_add_zs(msg, "P-K-CSeq-Refresh", &nval);
+
+done:
+	if(dlg!=NULL) dlg_release(dlg);
+	return 0;
+
+error:
+	if(dlg!=NULL) dlg_release(dlg);
+	return -1;
+}
+
 /**
 /**
  *
  *
  */
  */
@@ -319,15 +374,22 @@ int dlg_cseq_msg_sent(void *data)
 		parse_headers(&msg, HDR_EOH_F, 0);
 		parse_headers(&msg, HDR_EOH_F, 0);
 		hfk = sr_hdr_get_z(&msg, "P-K-Auth-CSeq");
 		hfk = sr_hdr_get_z(&msg, "P-K-Auth-CSeq");
 		if(hfk!=NULL) {
 		if(hfk!=NULL) {
-			LM_DBG("uac auth request - cseq inc needed\n");
+			LM_DBG("new cseq inc requested\n");
 			nval = hfk->body;
 			nval = hfk->body;
 			trim(&nval);
 			trim(&nval);
 		} else {
 		} else {
-			LM_DBG("uac auth request - cseq inc not needed\n");
-			goto done;
+			LM_DBG("new cseq inc not requested\n");
 		}
 		}
 	}
 	}
 
 
+	if(nval.len<=0) {
+		hfk = sr_hdr_get_z(&msg, "P-K-CSeq-Refresh");
+		if(hfk!=NULL) {
+			LM_DBG("cseq refresh requested\n");
+			nval = hfk->body;
+			trim(&nval);
+		}
+	}
 	if(nval.len<=0) {
 	if(nval.len<=0) {
 		goto done;
 		goto done;
 	}
 	}

+ 3 - 0
modules/dialog/dlg_cseq.h

@@ -32,9 +32,12 @@
 #define _DLG_CSEQ_H_
 #define _DLG_CSEQ_H_
 
 
 #include "../../parser/msg_parser.h"
 #include "../../parser/msg_parser.h"
+#include "dlg_hash.h"
 
 
 int dlg_register_cseq_callbacks(void);
 int dlg_register_cseq_callbacks(void);
 
 
 int dlg_cseq_update(sip_msg_t *msg);
 int dlg_cseq_update(sip_msg_t *msg);
+int dlg_cseq_refresh(sip_msg_t *msg, dlg_cell_t *dlg,
+		unsigned int direction);
 
 
 #endif
 #endif

+ 9 - 2
modules/dialog/dlg_handlers.c

@@ -48,6 +48,7 @@
 #include "dlg_hash.h"
 #include "dlg_hash.h"
 #include "dlg_timer.h"
 #include "dlg_timer.h"
 #include "dlg_cb.h"
 #include "dlg_cb.h"
+#include "dlg_cseq.h"
 #include "dlg_handlers.h"
 #include "dlg_handlers.h"
 #include "dlg_req_within.h"
 #include "dlg_req_within.h"
 #include "dlg_db_handler.h"
 #include "dlg_db_handler.h"
@@ -1158,7 +1159,7 @@ dlg_cell_t *dlg_get_msg_dialog(sip_msg_t *msg)
 
 
 /*!
 /*!
  * \brief Function that is registered as RR callback for dialog tracking
  * \brief Function that is registered as RR callback for dialog tracking
- * 
+ *
  * Function that is registered as RR callback for dialog tracking. It
  * Function that is registered as RR callback for dialog tracking. It
  * sets the appropriate events after the SIP method and run the state
  * sets the appropriate events after the SIP method and run the state
  * machine to update the dialog state. It updates then the saved
  * machine to update the dialog state. It updates then the saved
@@ -1250,7 +1251,7 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
 	}
 	}
 
 
 	if (dlg==0) {
 	if (dlg==0) {
-		if (pre_match_parse( req, &callid, &ftag, &ttag, 1)<0)
+		if (pre_match_parse(req, &callid, &ftag, &ttag, 1)<0)
 			return;
 			return;
 		/* TODO - try to use the RR dir detection to speed up here the
 		/* TODO - try to use the RR dir detection to speed up here the
 		 * search -bogdan */
 		 * search -bogdan */
@@ -1267,6 +1268,12 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
     _dlg_ctx.iuid.h_entry = dlg->h_entry;
     _dlg_ctx.iuid.h_entry = dlg->h_entry;
     _dlg_ctx.iuid.h_id = dlg->h_id;
     _dlg_ctx.iuid.h_id = dlg->h_id;
 
 
+	if(dlg->iflags & DLG_IFLAG_CSEQ_DIFF) {
+		if(dlg_cseq_refresh(req, dlg, dir)<0) {
+			LM_ERR("failed to refresh cseq update\n");
+		}
+	}
+
 	if (req->first_line.u.request.method_value != METHOD_ACK) {
 	if (req->first_line.u.request.method_value != METHOD_ACK) {
 		iuid = dlg_get_iuid_shm_clone(dlg);
 		iuid = dlg_get_iuid_shm_clone(dlg);
 		if(iuid!=NULL)
 		if(iuid!=NULL)

+ 1 - 1
modules/dialog/dlg_var.c

@@ -186,7 +186,7 @@ int set_dlg_variable_unsafe(struct dlg_cell *dlg, str *key, str *val)
 				/* replace the current it with var and free the it */
 				/* replace the current it with var and free the it */
 				var->next = it->next;
 				var->next = it->next;
 				/* Take the previous vflags: */
 				/* Take the previous vflags: */
-				var->vflags = it->vflags & DLG_FLAG_CHANGED;
+				var->vflags = it->vflags | DLG_FLAG_CHANGED;
 				if (it_prev) it_prev->next = var;
 				if (it_prev) it_prev->next = var;
 				else *var_list = var;				  
 				else *var_list = var;				  
 			}
 			}

+ 1 - 5
modules/http_async_client/http_async_client_mod.c

@@ -487,11 +487,7 @@ static int w_http_async_post(sip_msg_t *msg, char *query, char* post, char* rt)
 		return -1;
 		return -1;
 	}
 	}
 
 
-	if(async_send_query(msg, &sdata, &post_data, act)<0)
-		return -1;
-
-	/* force exit in config */
-	return 0;
+	return async_send_query(msg, &sdata, &post_data, act);
 }
 }
 
 
 #define _IVALUE_ERROR(NAME) LM_ERR("invalid parameter '" #NAME "' (must be a number)\n")
 #define _IVALUE_ERROR(NAME) LM_ERR("invalid parameter '" #NAME "' (must be a number)\n")

+ 1 - 1
modules/ims_dialog/dlg_db_handler.h

@@ -72,7 +72,7 @@
 #define VARS_KEY_COL				"dialog_key"
 #define VARS_KEY_COL				"dialog_key"
 #define VARS_VALUE_COL				"dialog_value"
 #define VARS_VALUE_COL				"dialog_value"
 #define DIALOG_VARS_TABLE_NAME		"dialog_vars"
 #define DIALOG_VARS_TABLE_NAME		"dialog_vars"
-#define DLG_VARS_TABLE_VERSION		1
+#define DLG_VARS_TABLE_VERSION		7
 #define DIALOG_VARS_TABLE_COL_NO 	4
 #define DIALOG_VARS_TABLE_COL_NO 	4
 
 
 /*every minute the dialogs' information will be refreshed*/
 /*every minute the dialogs' information will be refreshed*/

+ 0 - 48
modules/nsq/http.h

@@ -1,48 +0,0 @@
-#ifndef __http_h
-#define __http_h
-
-#include <ev.h>
-#include <curl/curl.h>
-
-struct HttpClient {
-    CURLM *multi;
-    struct ev_loop *loop;
-    struct ev_timer timer_event;
-    int still_running;
-};
-
-struct HttpResponse {
-    int status_code;
-    struct Buffer *data;
-};
-
-struct HttpRequest {
-    CURL *easy;
-    char *url;
-    struct HttpClient *httpc;
-    char error[CURL_ERROR_SIZE];
-    struct Buffer *data;
-    void (*callback)(struct HttpRequest *req, struct HttpResponse *resp, void *arg);
-    void *cb_arg;
-};
-
-struct HttpSocket {
-    curl_socket_t sockfd;
-    CURL *easy;
-    int action;
-    long timeout;
-    struct ev_io ev;
-    int evset;
-    struct HttpClient *httpc;
-};
-
-struct HttpClient *new_http_client(struct ev_loop *loop);
-void free_http_client(struct HttpClient *httpc);
-struct HttpRequest *new_http_request(const char *url,
-    void (*callback)(struct HttpRequest *req, struct HttpResponse *resp, void *arg), void *cb_arg, char *data);
-void free_http_request(struct HttpRequest *req);
-struct HttpResponse *new_http_response(int status_code, void *data);
-void free_http_response(struct HttpResponse *resp);
-int http_client_get(struct HttpClient *httpc, struct HttpRequest *req);
-
-#endif

+ 0 - 91
modules/nsq/nsq.h

@@ -1,91 +0,0 @@
-#ifndef __nsq_h
-#define __nsq_h
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <time.h>
-#include <ev.h>
-#include <evbuffsock.h>
-
-#include "utlist.h"
-
-typedef enum {NSQ_FRAME_TYPE_RESPONSE, NSQ_FRAME_TYPE_ERROR, NSQ_FRAME_TYPE_MESSAGE} frame_type;
-struct NSQDConnection;
-struct NSQMessage;
-
-struct NSQReader {
-    char *topic;
-    char *channel;
-    void *ctx; //context for call back
-    int max_in_flight;
-    struct NSQDConnection *conns;
-    struct NSQLookupdEndpoint *lookupd;
-    struct ev_timer lookupd_poll_timer;
-    struct ev_loop *loop;
-    void *httpc;
-    void (*connect_callback)(struct NSQReader *rdr, struct NSQDConnection *conn);
-    void (*close_callback)(struct NSQReader *rdr, struct NSQDConnection *conn);
-    void (*msg_callback)(struct NSQReader *rdr, struct NSQDConnection *conn, struct NSQMessage *msg, void *ctx);
-};
-
-struct NSQReader *new_nsq_reader(struct ev_loop *loop, const char *topic, const char *channel, void *ctx,
-    void (*connect_callback)(struct NSQReader *rdr, struct NSQDConnection *conn),
-    void (*close_callback)(struct NSQReader *rdr, struct NSQDConnection *conn),
-    void (*msg_callback)(struct NSQReader *rdr, struct NSQDConnection *conn, struct NSQMessage *msg, void *ctx));
-void free_nsq_reader(struct NSQReader *rdr);
-int nsq_reader_connect_to_nsqd(struct NSQReader *rdr, const char *address, int port);
-int nsq_reader_add_nsqlookupd_endpoint(struct NSQReader *rdr, const char *address, int port);
-void nsq_reader_set_loop(struct NSQReader *rdr, struct ev_loop *loop);
-void nsq_run(struct ev_loop *loop);
-
-struct NSQDConnection {
-    struct BufferedSocket *bs;
-    struct Buffer *command_buf;
-    uint32_t current_msg_size;
-    uint32_t current_frame_type;
-    char *current_data;
-    struct ev_loop *loop;
-    void (*connect_callback)(struct NSQDConnection *conn, void *arg);
-    void (*close_callback)(struct NSQDConnection *conn, void *arg);
-    void (*msg_callback)(struct NSQDConnection *conn, struct NSQMessage *msg, void *arg);
-    void *arg;
-    struct NSQDConnection *next;
-};
-
-struct NSQDConnection *new_nsqd_connection(struct ev_loop *loop, const char *address, int port,
-    void (*connect_callback)(struct NSQDConnection *conn, void *arg),
-    void (*close_callback)(struct NSQDConnection *conn, void *arg),
-    void (*msg_callback)(struct NSQDConnection *conn, struct NSQMessage *msg, void *arg),
-    void *arg);
-void free_nsqd_connection(struct NSQDConnection *conn);
-int nsqd_connection_connect(struct NSQDConnection *conn);
-void nsqd_connection_disconnect(struct NSQDConnection *conn);
-
-void nsq_subscribe(struct Buffer *buf, const char *topic, const char *channel);
-void nsq_ready(struct Buffer *buf, int count);
-void nsq_finish(struct Buffer *buf, const char *id);
-void nsq_requeue(struct Buffer *buf, const char *id, int timeout_ms);
-void nsq_nop(struct Buffer *buf);
-
-struct NSQMessage {
-    int64_t timestamp;
-    uint16_t attempts;
-    char id[16+1];
-    size_t body_length;
-    char *body;
-};
-
-struct NSQMessage *nsq_decode_message(const char *data, size_t data_length);
-void free_nsq_message(struct NSQMessage *msg);
-
-struct NSQLookupdEndpoint {
-    char *address;
-    int port;
-    struct NSQLookupdEndpoint *next;
-};
-
-struct NSQLookupdEndpoint *new_nsqlookupd_endpoint(const char *address, int port);
-void free_nsqlookupd_endpoint(struct NSQLookupdEndpoint *nsqlookupd_endpoint);
-
-#endif

+ 1 - 1
modules/nsq/nsq_mod.c

@@ -273,7 +273,7 @@ int nsq_consumer_worker_proc(int cmd_pipe, char *topic, char *channel)
 
 
 	LM_DBG("NSQ Worker connecting to NSQ Topic [%s] and NSQ Channel [%s]\n", topic, channel);
 	LM_DBG("NSQ Worker connecting to NSQ Topic [%s] and NSQ Channel [%s]\n", topic, channel);
 	// setup the reader
 	// setup the reader
-	rdr = new_nsq_reader(loop, topic, channel, (void *)ctx, NULL, NULL, nsq_message_handler);
+	rdr = new_nsq_reader(loop, topic, channel, (void *)ctx, NULL, NULL, NULL, nsq_message_handler);
 
 
 	if (consumer_use_nsqd == 0) {
 	if (consumer_use_nsqd == 0) {
 		snprintf(address, 128, "%.*s", nsq_lookupd_address.len, nsq_lookupd_address.s);
 		snprintf(address, 128, "%.*s", nsq_lookupd_address.len, nsq_lookupd_address.s);

+ 0 - 173
modules/nsq/reader.c

@@ -1,173 +0,0 @@
-#include "nsq.h"
-#include "utlist.h"
-#include "http.h"
-#include "../../dprint.h"
-#include "../../rand/kam_rand.h"
-
-extern int nsq_max_in_flight;
-
-static void nsq_reader_connect_cb(struct NSQDConnection *conn, void *arg)
-{
-    struct NSQReader *rdr = (struct NSQReader *)arg;
-
-    if (rdr->connect_callback) {
-        rdr->connect_callback(rdr, conn);
-    }
-
-    // subscribe
-    buffer_reset(conn->command_buf);
-    nsq_subscribe(conn->command_buf, rdr->topic, rdr->channel);
-    buffered_socket_write_buffer(conn->bs, conn->command_buf);
-
-    // send initial RDY
-    buffer_reset(conn->command_buf);
-    nsq_ready(conn->command_buf, rdr->max_in_flight);
-    buffered_socket_write_buffer(conn->bs, conn->command_buf);
-}
-
-static void nsq_reader_msg_cb(struct NSQDConnection *conn, struct NSQMessage *msg, void *arg)
-{
-    struct NSQReader *rdr = (struct NSQReader *)arg;
-
-	//LM_ERR("nsq_reader_msg_cb()!\n");
-    if (rdr->msg_callback) {
-        msg->id[sizeof(msg->id)-1] = '\0';
-        rdr->msg_callback(rdr, conn, msg, rdr->ctx);
-    }
-}
-
-static void nsq_reader_close_cb(struct NSQDConnection *conn, void *arg)
-{
-    struct NSQReader *rdr = (struct NSQReader *)arg;
-
-	//LM_ERR("nsq_reader_close_cb()!\n");
-
-    if (rdr->close_callback) {
-        rdr->close_callback(rdr, conn);
-    }
-
-    LL_DELETE(rdr->conns, conn);
-
-    free_nsqd_connection(conn);
-}
-
-void nsq_lookupd_request_cb(struct HttpRequest *req, struct HttpResponse *resp, void *arg);
-
-static void nsq_reader_lookupd_poll_cb(EV_P_ struct ev_timer *w, int revents)
-{
-    struct NSQReader *rdr = (struct NSQReader *)w->data;
-    struct NSQLookupdEndpoint *nsqlookupd_endpoint;
-    struct HttpRequest *req;
-    int i, idx, count = 0;
-    char buf[256];
-
-	//LM_ERR("nsq_reader_lookupd_poll_cb()!\n");
-
-    LL_FOREACH(rdr->lookupd, nsqlookupd_endpoint) {
-        count++;
-    }
-    if (count == 0)
-	idx = 0;
-    else
-	idx = kam_rand() % count;
-
-
-    i = 0;
-    LL_FOREACH(rdr->lookupd, nsqlookupd_endpoint) {
-        if (i++ == idx) {
-            sprintf(buf, "http://%s:%d/lookup?topic=%s", nsqlookupd_endpoint->address,
-                nsqlookupd_endpoint->port, rdr->topic);
-			//LM_ERR("buf %s\n", buf);
-            req = new_http_request(buf, nsq_lookupd_request_cb, rdr, NULL);
-            http_client_get((struct HttpClient *)rdr->httpc, req);
-            break;
-        }
-    }
-
-    ev_timer_again(rdr->loop, &rdr->lookupd_poll_timer);
-}
-
-struct NSQReader* new_nsq_reader(struct ev_loop *loop, const char *topic, const char *channel, void *ctx,
-    void (*connect_callback)(struct NSQReader *rdr, struct NSQDConnection *conn),
-    void (*close_callback)(struct NSQReader *rdr, struct NSQDConnection *conn),
-    void (*msg_callback)(struct NSQReader *rdr, struct NSQDConnection *conn, struct NSQMessage *msg, void *ctx))
-{
-    struct NSQReader *rdr;
-
-    rdr = (struct NSQReader *)malloc(sizeof(struct NSQReader));
-    rdr->topic = strdup(topic);
-    rdr->channel = strdup(channel);
-    rdr->max_in_flight = nsq_max_in_flight;
-    rdr->connect_callback = connect_callback;
-    rdr->close_callback = close_callback;
-    rdr->msg_callback = msg_callback;
-    rdr->ctx = ctx;
-    rdr->conns = NULL;
-    rdr->lookupd = NULL;
-    rdr->loop = loop;
-
-    rdr->httpc = new_http_client(rdr->loop);
-
-	//LM_ERR("new_nsq_reader(), nsq_max_in_flight = %d!\n", nsq_max_in_flight);
-
-    // TODO: configurable interval
-    ev_timer_init(&rdr->lookupd_poll_timer, nsq_reader_lookupd_poll_cb, 0., 5.);
-    rdr->lookupd_poll_timer.data = rdr;
-    ev_timer_again(rdr->loop, &rdr->lookupd_poll_timer);
-
-    return rdr;
-}
-
-void free_nsq_reader(struct NSQReader *rdr)
-{
-    struct NSQDConnection *conn;
-    struct NSQLookupdEndpoint *nsqlookupd_endpoint;
-
-	//LM_ERR("free_nsq_reader()!\n");
-
-    if (rdr) {
-        // TODO: this should probably trigger disconnections and then keep
-        // trying to clean up until everything upstream is finished
-        LL_FOREACH(rdr->conns, conn) {
-            nsqd_connection_disconnect(conn);
-        }
-        LL_FOREACH(rdr->lookupd, nsqlookupd_endpoint) {
-            free_nsqlookupd_endpoint(nsqlookupd_endpoint);
-        }
-        free(rdr->topic);
-        free(rdr->channel);
-        free(rdr);
-    }
-}
-
-int nsq_reader_add_nsqlookupd_endpoint(struct NSQReader *rdr, const char *address, int port)
-{
-    struct NSQLookupdEndpoint *nsqlookupd_endpoint;
-
-	//LM_ERR("nsq_reader_add_nsqlookupd_endpoint(address = %s, port = %d)!\n", address, port);
-    nsqlookupd_endpoint = new_nsqlookupd_endpoint(address, port);
-    LL_APPEND(rdr->lookupd, nsqlookupd_endpoint);
-
-    return 1;
-}
-
-int nsq_reader_connect_to_nsqd(struct NSQReader *rdr, const char *address, int port)
-{
-    struct NSQDConnection *conn;
-    int rc;
-
-	//LM_ERR("nsq_reader_connect_to_nsqd()!\n");
-    conn = new_nsqd_connection(rdr->loop, address, port, nsq_reader_connect_cb, nsq_reader_close_cb, nsq_reader_msg_cb, rdr);
-    rc = nsqd_connection_connect(conn);
-    if (rc > 0) {
-        LL_APPEND(rdr->conns, conn);
-    }
-    return rc;
-}
-
-void nsq_run(struct ev_loop *loop)
-{
-	//LM_ERR("nsq_run()!\n");
-    kam_srand(time(NULL));
-    ev_loop(loop, 0);
-}

+ 0 - 728
modules/nsq/utlist.h

@@ -1,728 +0,0 @@
-/*
-Copyright (c) 2007-2013, Troy D. Hanson   http://troydhanson.github.com/uthash/
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef UTLIST_H
-#define UTLIST_H
-
-#define UTLIST_VERSION 1.9.8
-
-#include <assert.h>
-
-/* 
- * This file contains macros to manipulate singly and doubly-linked lists.
- *
- * 1. LL_ macros:  singly-linked lists.
- * 2. DL_ macros:  doubly-linked lists.
- * 3. CDL_ macros: circular doubly-linked lists.
- *
- * To use singly-linked lists, your structure must have a "next" pointer.
- * To use doubly-linked lists, your structure must "prev" and "next" pointers.
- * Either way, the pointer to the head of the list must be initialized to NULL.
- * 
- * ----------------.EXAMPLE -------------------------
- * struct item {
- *      int id;
- *      struct item *prev, *next;
- * }
- *
- * struct item *list = NULL:
- *
- * int main() {
- *      struct item *item;
- *      ... allocate and populate item ...
- *      DL_APPEND(list, item);
- * }
- * --------------------------------------------------
- *
- * For doubly-linked lists, the append and delete macros are O(1)
- * For singly-linked lists, append and delete are O(n) but prepend is O(1)
- * The sort macro is O(n log(n)) for all types of single/double/circular lists.
- */
-
-/* These macros use decltype or the earlier __typeof GNU extension.
-   As decltype is only available in newer compilers (VS2010 or gcc 4.3+
-   when compiling c++ code), this code uses whatever method is needed
-   or, for VS2008 where neither is available, uses casting workarounds. */
-#ifdef _MSC_VER            /* MS compiler */
-#if _MSC_VER >= 1600 && defined(__cplusplus)  /* VS2010 or newer in C++ mode */
-#define LDECLTYPE(x) decltype(x)
-#else                     /* VS2008 or older (or VS2010 in C mode) */
-#define NO_DECLTYPE
-#define LDECLTYPE(x) char*
-#endif
-#else                      /* GNU, Sun and other compilers */
-#define LDECLTYPE(x) __typeof(x)
-#endif
-
-/* for VS2008 we use some workarounds to get around the lack of decltype,
- * namely, we always reassign our tmp variable to the list head if we need
- * to dereference its prev/next pointers, and save/restore the real head.*/
-#ifdef NO_DECLTYPE
-#define _SV(elt,list) _tmp = (char*)(list); {char **_alias = (char**)&(list); *_alias = (elt); }
-#define _NEXT(elt,list,next) ((char*)((list)->next))
-#define _NEXTASGN(elt,list,to,next) { char **_alias = (char**)&((list)->next); *_alias=(char*)(to); }
-/* #define _PREV(elt,list,prev) ((char*)((list)->prev)) */
-#define _PREVASGN(elt,list,to,prev) { char **_alias = (char**)&((list)->prev); *_alias=(char*)(to); }
-#define _RS(list) { char **_alias = (char**)&(list); *_alias=_tmp; }
-#define _CASTASGN(a,b) { char **_alias = (char**)&(a); *_alias=(char*)(b); }
-#else 
-#define _SV(elt,list)
-#define _NEXT(elt,list,next) ((elt)->next)
-#define _NEXTASGN(elt,list,to,next) ((elt)->next)=(to)
-/* #define _PREV(elt,list,prev) ((elt)->prev) */
-#define _PREVASGN(elt,list,to,prev) ((elt)->prev)=(to)
-#define _RS(list)
-#define _CASTASGN(a,b) (a)=(b)
-#endif
-
-/******************************************************************************
- * The sort macro is an adaptation of Simon Tatham's O(n log(n)) mergesort    *
- * Unwieldy variable names used here to avoid shadowing passed-in variables.  *
- *****************************************************************************/
-#define LL_SORT(list, cmp)                                                                     \
-    LL_SORT2(list, cmp, next)
-
-#define LL_SORT2(list, cmp, next)                                                              \
-do {                                                                                           \
-  LDECLTYPE(list) _ls_p;                                                                       \
-  LDECLTYPE(list) _ls_q;                                                                       \
-  LDECLTYPE(list) _ls_e;                                                                       \
-  LDECLTYPE(list) _ls_tail;                                                                    \
-  int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping;                       \
-  if (list) {                                                                                  \
-    _ls_insize = 1;                                                                            \
-    _ls_looping = 1;                                                                           \
-    while (_ls_looping) {                                                                      \
-      _CASTASGN(_ls_p,list);                                                                   \
-      list = NULL;                                                                             \
-      _ls_tail = NULL;                                                                         \
-      _ls_nmerges = 0;                                                                         \
-      while (_ls_p) {                                                                          \
-        _ls_nmerges++;                                                                         \
-        _ls_q = _ls_p;                                                                         \
-        _ls_psize = 0;                                                                         \
-        for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
-          _ls_psize++;                                                                         \
-          _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list,next); _RS(list);                          \
-          if (!_ls_q) break;                                                                   \
-        }                                                                                      \
-        _ls_qsize = _ls_insize;                                                                \
-        while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
-          if (_ls_psize == 0) {                                                                \
-            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
-          } else if (_ls_qsize == 0 || !_ls_q) {                                               \
-            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
-          } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
-            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
-          } else {                                                                             \
-            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
-          }                                                                                    \
-          if (_ls_tail) {                                                                      \
-            _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list);                \
-          } else {                                                                             \
-            _CASTASGN(list,_ls_e);                                                             \
-          }                                                                                    \
-          _ls_tail = _ls_e;                                                                    \
-        }                                                                                      \
-        _ls_p = _ls_q;                                                                         \
-      }                                                                                        \
-      if (_ls_tail) {                                                                          \
-        _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL,next); _RS(list);                     \
-      }                                                                                        \
-      if (_ls_nmerges <= 1) {                                                                  \
-        _ls_looping=0;                                                                         \
-      }                                                                                        \
-      _ls_insize *= 2;                                                                         \
-    }                                                                                          \
-  }                                                                                            \
-} while (0)
-
-
-#define DL_SORT(list, cmp)                                                                     \
-    DL_SORT2(list, cmp, prev, next)
-
-#define DL_SORT2(list, cmp, prev, next)                                                        \
-do {                                                                                           \
-  LDECLTYPE(list) _ls_p;                                                                       \
-  LDECLTYPE(list) _ls_q;                                                                       \
-  LDECLTYPE(list) _ls_e;                                                                       \
-  LDECLTYPE(list) _ls_tail;                                                                    \
-  int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping;                       \
-  if (list) {                                                                                  \
-    _ls_insize = 1;                                                                            \
-    _ls_looping = 1;                                                                           \
-    while (_ls_looping) {                                                                      \
-      _CASTASGN(_ls_p,list);                                                                   \
-      list = NULL;                                                                             \
-      _ls_tail = NULL;                                                                         \
-      _ls_nmerges = 0;                                                                         \
-      while (_ls_p) {                                                                          \
-        _ls_nmerges++;                                                                         \
-        _ls_q = _ls_p;                                                                         \
-        _ls_psize = 0;                                                                         \
-        for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
-          _ls_psize++;                                                                         \
-          _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list,next); _RS(list);                          \
-          if (!_ls_q) break;                                                                   \
-        }                                                                                      \
-        _ls_qsize = _ls_insize;                                                                \
-        while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
-          if (_ls_psize == 0) {                                                                \
-            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
-          } else if (_ls_qsize == 0 || !_ls_q) {                                               \
-            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
-          } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
-            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
-          } else {                                                                             \
-            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
-          }                                                                                    \
-          if (_ls_tail) {                                                                      \
-            _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list);                \
-          } else {                                                                             \
-            _CASTASGN(list,_ls_e);                                                             \
-          }                                                                                    \
-          _SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail,prev); _RS(list);                     \
-          _ls_tail = _ls_e;                                                                    \
-        }                                                                                      \
-        _ls_p = _ls_q;                                                                         \
-      }                                                                                        \
-      _CASTASGN(list->prev, _ls_tail);                                                         \
-      _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL,next); _RS(list);                       \
-      if (_ls_nmerges <= 1) {                                                                  \
-        _ls_looping=0;                                                                         \
-      }                                                                                        \
-      _ls_insize *= 2;                                                                         \
-    }                                                                                          \
-  }                                                                                            \
-} while (0)
-
-#define CDL_SORT(list, cmp)                                                                    \
-    CDL_SORT2(list, cmp, prev, next)
-
-#define CDL_SORT2(list, cmp, prev, next)                                                       \
-do {                                                                                           \
-  LDECLTYPE(list) _ls_p;                                                                       \
-  LDECLTYPE(list) _ls_q;                                                                       \
-  LDECLTYPE(list) _ls_e;                                                                       \
-  LDECLTYPE(list) _ls_tail;                                                                    \
-  LDECLTYPE(list) _ls_oldhead;                                                                 \
-  LDECLTYPE(list) _tmp;                                                                        \
-  int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping;                       \
-  if (list) {                                                                                  \
-    _ls_insize = 1;                                                                            \
-    _ls_looping = 1;                                                                           \
-    while (_ls_looping) {                                                                      \
-      _CASTASGN(_ls_p,list);                                                                   \
-      _CASTASGN(_ls_oldhead,list);                                                             \
-      list = NULL;                                                                             \
-      _ls_tail = NULL;                                                                         \
-      _ls_nmerges = 0;                                                                         \
-      while (_ls_p) {                                                                          \
-        _ls_nmerges++;                                                                         \
-        _ls_q = _ls_p;                                                                         \
-        _ls_psize = 0;                                                                         \
-        for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) {                                         \
-          _ls_psize++;                                                                         \
-          _SV(_ls_q,list);                                                                     \
-          if (_NEXT(_ls_q,list,next) == _ls_oldhead) {                                         \
-            _ls_q = NULL;                                                                      \
-          } else {                                                                             \
-            _ls_q = _NEXT(_ls_q,list,next);                                                    \
-          }                                                                                    \
-          _RS(list);                                                                           \
-          if (!_ls_q) break;                                                                   \
-        }                                                                                      \
-        _ls_qsize = _ls_insize;                                                                \
-        while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) {                                    \
-          if (_ls_psize == 0) {                                                                \
-            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
-            if (_ls_q == _ls_oldhead) { _ls_q = NULL; }                                        \
-          } else if (_ls_qsize == 0 || !_ls_q) {                                               \
-            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
-            if (_ls_p == _ls_oldhead) { _ls_p = NULL; }                                        \
-          } else if (cmp(_ls_p,_ls_q) <= 0) {                                                  \
-            _ls_e = _ls_p; _SV(_ls_p,list); _ls_p =                                            \
-              _NEXT(_ls_p,list,next); _RS(list); _ls_psize--;                                  \
-            if (_ls_p == _ls_oldhead) { _ls_p = NULL; }                                        \
-          } else {                                                                             \
-            _ls_e = _ls_q; _SV(_ls_q,list); _ls_q =                                            \
-              _NEXT(_ls_q,list,next); _RS(list); _ls_qsize--;                                  \
-            if (_ls_q == _ls_oldhead) { _ls_q = NULL; }                                        \
-          }                                                                                    \
-          if (_ls_tail) {                                                                      \
-            _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e,next); _RS(list);                \
-          } else {                                                                             \
-            _CASTASGN(list,_ls_e);                                                             \
-          }                                                                                    \
-          _SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail,prev); _RS(list);                     \
-          _ls_tail = _ls_e;                                                                    \
-        }                                                                                      \
-        _ls_p = _ls_q;                                                                         \
-      }                                                                                        \
-      _CASTASGN(list->prev,_ls_tail);                                                          \
-      _CASTASGN(_tmp,list);                                                                    \
-      _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_tmp,next); _RS(list);                       \
-      if (_ls_nmerges <= 1) {                                                                  \
-        _ls_looping=0;                                                                         \
-      }                                                                                        \
-      _ls_insize *= 2;                                                                         \
-    }                                                                                          \
-  }                                                                                            \
-} while (0)
-
-/******************************************************************************
- * singly linked list macros (non-circular)                                   *
- *****************************************************************************/
-#define LL_PREPEND(head,add)                                                                   \
-    LL_PREPEND2(head,add,next)
-
-#define LL_PREPEND2(head,add,next)                                                             \
-do {                                                                                           \
-  (add)->next = head;                                                                          \
-  head = add;                                                                                  \
-} while (0)
-
-#define LL_CONCAT(head1,head2)                                                                 \
-    LL_CONCAT2(head1,head2,next)
-
-#define LL_CONCAT2(head1,head2,next)                                                           \
-do {                                                                                           \
-  LDECLTYPE(head1) _tmp;                                                                       \
-  if (head1) {                                                                                 \
-    _tmp = head1;                                                                              \
-    while (_tmp->next) { _tmp = _tmp->next; }                                                  \
-    _tmp->next=(head2);                                                                        \
-  } else {                                                                                     \
-    (head1)=(head2);                                                                           \
-  }                                                                                            \
-} while (0)
-
-#define LL_APPEND(head,add)                                                                    \
-    LL_APPEND2(head,add,next)
-
-#define LL_APPEND2(head,add,next)                                                              \
-do {                                                                                           \
-  LDECLTYPE(head) _tmp;                                                                        \
-  (add)->next=NULL;                                                                            \
-  if (head) {                                                                                  \
-    _tmp = head;                                                                               \
-    while (_tmp->next) { _tmp = _tmp->next; }                                                  \
-    _tmp->next=(add);                                                                          \
-  } else {                                                                                     \
-    (head)=(add);                                                                              \
-  }                                                                                            \
-} while (0)
-
-#define LL_DELETE(head,del)                                                                    \
-    LL_DELETE2(head,del,next)
-
-#define LL_DELETE2(head,del,next)                                                              \
-do {                                                                                           \
-  LDECLTYPE(head) _tmp;                                                                        \
-  if ((head) == (del)) {                                                                       \
-    (head)=(head)->next;                                                                       \
-  } else {                                                                                     \
-    _tmp = head;                                                                               \
-    while (_tmp->next && (_tmp->next != (del))) {                                              \
-      _tmp = _tmp->next;                                                                       \
-    }                                                                                          \
-    if (_tmp->next) {                                                                          \
-      _tmp->next = ((del)->next);                                                              \
-    }                                                                                          \
-  }                                                                                            \
-} while (0)
-
-/* Here are VS2008 replacements for LL_APPEND and LL_DELETE */
-#define LL_APPEND_VS2008(head,add)                                                             \
-    LL_APPEND2_VS2008(head,add,next)
-
-#define LL_APPEND2_VS2008(head,add,next)                                                       \
-do {                                                                                           \
-  if (head) {                                                                                  \
-    (add)->next = head;     /* use add->next as a temp variable */                             \
-    while ((add)->next->next) { (add)->next = (add)->next->next; }                             \
-    (add)->next->next=(add);                                                                   \
-  } else {                                                                                     \
-    (head)=(add);                                                                              \
-  }                                                                                            \
-  (add)->next=NULL;                                                                            \
-} while (0)
-
-#define LL_DELETE_VS2008(head,del)                                                             \
-    LL_DELETE2_VS2008(head,del,next)
-
-#define LL_DELETE2_VS2008(head,del,next)                                                       \
-do {                                                                                           \
-  if ((head) == (del)) {                                                                       \
-    (head)=(head)->next;                                                                       \
-  } else {                                                                                     \
-    char *_tmp = (char*)(head);                                                                \
-    while ((head)->next && ((head)->next != (del))) {                                          \
-      head = (head)->next;                                                                     \
-    }                                                                                          \
-    if ((head)->next) {                                                                        \
-      (head)->next = ((del)->next);                                                            \
-    }                                                                                          \
-    {                                                                                          \
-      char **_head_alias = (char**)&(head);                                                    \
-      *_head_alias = _tmp;                                                                     \
-    }                                                                                          \
-  }                                                                                            \
-} while (0)
-#ifdef NO_DECLTYPE
-#undef LL_APPEND
-#define LL_APPEND LL_APPEND_VS2008
-#undef LL_DELETE
-#define LL_DELETE LL_DELETE_VS2008
-#undef LL_DELETE2
-#define LL_DELETE2_VS2008
-#undef LL_APPEND2
-#define LL_APPEND2 LL_APPEND2_VS2008
-#undef LL_CONCAT /* no LL_CONCAT_VS2008 */
-#undef DL_CONCAT /* no DL_CONCAT_VS2008 */
-#endif
-/* end VS2008 replacements */
-
-#define LL_FOREACH(head,el)                                                                    \
-    LL_FOREACH2(head,el,next)
-
-#define LL_FOREACH2(head,el,next)                                                              \
-    for(el=head;el;el=(el)->next)
-
-#define LL_FOREACH_SAFE(head,el,tmp)                                                           \
-    LL_FOREACH_SAFE2(head,el,tmp,next)
-
-#define LL_FOREACH_SAFE2(head,el,tmp,next)                                                     \
-  for((el)=(head);(el) && (tmp = (el)->next, 1); (el) = tmp)
-
-#define LL_SEARCH_SCALAR(head,out,field,val)                                                   \
-    LL_SEARCH_SCALAR2(head,out,field,val,next)
-
-#define LL_SEARCH_SCALAR2(head,out,field,val,next)                                             \
-do {                                                                                           \
-    LL_FOREACH2(head,out,next) {                                                               \
-      if ((out)->field == (val)) break;                                                        \
-    }                                                                                          \
-} while(0) 
-
-#define LL_SEARCH(head,out,elt,cmp)                                                            \
-    LL_SEARCH2(head,out,elt,cmp,next)
-
-#define LL_SEARCH2(head,out,elt,cmp,next)                                                      \
-do {                                                                                           \
-    LL_FOREACH2(head,out,next) {                                                               \
-      if ((cmp(out,elt))==0) break;                                                            \
-    }                                                                                          \
-} while(0) 
-
-#define LL_REPLACE_ELEM(head, el, add)                                                         \
-do {                                                                                           \
- LDECLTYPE(head) _tmp;                                                                         \
- assert(head != NULL);                                                                         \
- assert(el != NULL);                                                                           \
- assert(add != NULL);                                                                          \
- (add)->next = (el)->next;                                                                     \
- if ((head) == (el)) {                                                                         \
-  (head) = (add);                                                                              \
- } else {                                                                                      \
-  _tmp = head;                                                                                 \
-  while (_tmp->next && (_tmp->next != (el))) {                                                 \
-   _tmp = _tmp->next;                                                                          \
-  }                                                                                            \
-  if (_tmp->next) {                                                                            \
-    _tmp->next = (add);                                                                        \
-  }                                                                                            \
- }                                                                                             \
-} while (0)
-
-#define LL_PREPEND_ELEM(head, el, add)                                                         \
-do {                                                                                           \
- LDECLTYPE(head) _tmp;                                                                         \
- assert(head != NULL);                                                                         \
- assert(el != NULL);                                                                           \
- assert(add != NULL);                                                                          \
- (add)->next = (el);                                                                           \
- if ((head) == (el)) {                                                                         \
-  (head) = (add);                                                                              \
- } else {                                                                                      \
-  _tmp = head;                                                                                 \
-  while (_tmp->next && (_tmp->next != (el))) {                                                 \
-   _tmp = _tmp->next;                                                                          \
-  }                                                                                            \
-  if (_tmp->next) {                                                                            \
-    _tmp->next = (add);                                                                        \
-  }                                                                                            \
- }                                                                                             \
-} while (0)                                                                                    \
-
-
-/******************************************************************************
- * doubly linked list macros (non-circular)                                   *
- *****************************************************************************/
-#define DL_PREPEND(head,add)                                                                   \
-    DL_PREPEND2(head,add,prev,next)
-
-#define DL_PREPEND2(head,add,prev,next)                                                        \
-do {                                                                                           \
- (add)->next = head;                                                                           \
- if (head) {                                                                                   \
-   (add)->prev = (head)->prev;                                                                 \
-   (head)->prev = (add);                                                                       \
- } else {                                                                                      \
-   (add)->prev = (add);                                                                        \
- }                                                                                             \
- (head) = (add);                                                                               \
-} while (0)
-
-#define DL_APPEND(head,add)                                                                    \
-    DL_APPEND2(head,add,prev,next)
-
-#define DL_APPEND2(head,add,prev,next)                                                         \
-do {                                                                                           \
-  if (head) {                                                                                  \
-      (add)->prev = (head)->prev;                                                              \
-      (head)->prev->next = (add);                                                              \
-      (head)->prev = (add);                                                                    \
-      (add)->next = NULL;                                                                      \
-  } else {                                                                                     \
-      (head)=(add);                                                                            \
-      (head)->prev = (head);                                                                   \
-      (head)->next = NULL;                                                                     \
-  }                                                                                            \
-} while (0) 
-
-#define DL_CONCAT(head1,head2)                                                                 \
-    DL_CONCAT2(head1,head2,prev,next)
-
-#define DL_CONCAT2(head1,head2,prev,next)                                                      \
-do {                                                                                           \
-  LDECLTYPE(head1) _tmp;                                                                       \
-  if (head2) {                                                                                 \
-    if (head1) {                                                                               \
-        _tmp = (head2)->prev;                                                                  \
-        (head2)->prev = (head1)->prev;                                                         \
-        (head1)->prev->next = (head2);                                                         \
-        (head1)->prev = _tmp;                                                                  \
-    } else {                                                                                   \
-        (head1)=(head2);                                                                       \
-    }                                                                                          \
-  }                                                                                            \
-} while (0) 
-
-#define DL_DELETE(head,del)                                                                    \
-    DL_DELETE2(head,del,prev,next)
-
-#define DL_DELETE2(head,del,prev,next)                                                         \
-do {                                                                                           \
-  assert((del)->prev != NULL);                                                                 \
-  if ((del)->prev == (del)) {                                                                  \
-      (head)=NULL;                                                                             \
-  } else if ((del)==(head)) {                                                                  \
-      (del)->next->prev = (del)->prev;                                                         \
-      (head) = (del)->next;                                                                    \
-  } else {                                                                                     \
-      (del)->prev->next = (del)->next;                                                         \
-      if ((del)->next) {                                                                       \
-          (del)->next->prev = (del)->prev;                                                     \
-      } else {                                                                                 \
-          (head)->prev = (del)->prev;                                                          \
-      }                                                                                        \
-  }                                                                                            \
-} while (0) 
-
-
-#define DL_FOREACH(head,el)                                                                    \
-    DL_FOREACH2(head,el,next)
-
-#define DL_FOREACH2(head,el,next)                                                              \
-    for(el=head;el;el=(el)->next)
-
-/* this version is safe for deleting the elements during iteration */
-#define DL_FOREACH_SAFE(head,el,tmp)                                                           \
-    DL_FOREACH_SAFE2(head,el,tmp,next)
-
-#define DL_FOREACH_SAFE2(head,el,tmp,next)                                                     \
-  for((el)=(head);(el) && (tmp = (el)->next, 1); (el) = tmp)
-
-/* these are identical to their singly-linked list counterparts */
-#define DL_SEARCH_SCALAR LL_SEARCH_SCALAR
-#define DL_SEARCH LL_SEARCH
-#define DL_SEARCH_SCALAR2 LL_SEARCH_SCALAR2
-#define DL_SEARCH2 LL_SEARCH2
-
-#define DL_REPLACE_ELEM(head, el, add)                                                         \
-do {                                                                                           \
- assert(head != NULL);                                                                         \
- assert(el != NULL);                                                                           \
- assert(add != NULL);                                                                          \
- if ((head) == (el)) {                                                                         \
-  (head) = (add);                                                                              \
-  (add)->next = (el)->next;                                                                    \
-  if ((el)->next == NULL) {                                                                    \
-   (add)->prev = (add);                                                                        \
-  } else {                                                                                     \
-   (add)->prev = (el)->prev;                                                                   \
-   (add)->next->prev = (add);                                                                  \
-  }                                                                                            \
- } else {                                                                                      \
-  (add)->next = (el)->next;                                                                    \
-  (add)->prev = (el)->prev;                                                                    \
-  (add)->prev->next = (add);                                                                   \
-  if ((el)->next == NULL) {                                                                    \
-   (head)->prev = (add);                                                                       \
-  } else {                                                                                     \
-   (add)->next->prev = (add);                                                                  \
-  }                                                                                            \
- }                                                                                             \
-} while (0)
-
-#define DL_PREPEND_ELEM(head, el, add)                                                         \
-do {                                                                                           \
- assert(head != NULL);                                                                         \
- assert(el != NULL);                                                                           \
- assert(add != NULL);                                                                          \
- (add)->next = (el);                                                                           \
- (add)->prev = (el)->prev;                                                                     \
- (el)->prev = (add);                                                                           \
- if ((head) == (el)) {                                                                         \
-  (head) = (add);                                                                              \
- } else {                                                                                      \
-  (add)->prev->next = (add);                                                                   \
- }                                                                                             \
-} while (0)                                                                                    \
-
-
-/******************************************************************************
- * circular doubly linked list macros                                         *
- *****************************************************************************/
-#define CDL_PREPEND(head,add)                                                                  \
-    CDL_PREPEND2(head,add,prev,next)
-
-#define CDL_PREPEND2(head,add,prev,next)                                                       \
-do {                                                                                           \
- if (head) {                                                                                   \
-   (add)->prev = (head)->prev;                                                                 \
-   (add)->next = (head);                                                                       \
-   (head)->prev = (add);                                                                       \
-   (add)->prev->next = (add);                                                                  \
- } else {                                                                                      \
-   (add)->prev = (add);                                                                        \
-   (add)->next = (add);                                                                        \
- }                                                                                             \
-(head)=(add);                                                                                  \
-} while (0)
-
-#define CDL_DELETE(head,del)                                                                   \
-    CDL_DELETE2(head,del,prev,next)
-
-#define CDL_DELETE2(head,del,prev,next)                                                        \
-do {                                                                                           \
-  if ( ((head)==(del)) && ((head)->next == (head))) {                                          \
-      (head) = 0L;                                                                             \
-  } else {                                                                                     \
-     (del)->next->prev = (del)->prev;                                                          \
-     (del)->prev->next = (del)->next;                                                          \
-     if ((del) == (head)) (head)=(del)->next;                                                  \
-  }                                                                                            \
-} while (0) 
-
-#define CDL_FOREACH(head,el)                                                                   \
-    CDL_FOREACH2(head,el,next)
-
-#define CDL_FOREACH2(head,el,next)                                                             \
-    for(el=head;el;el=((el)->next==head ? 0L : (el)->next)) 
-
-#define CDL_FOREACH_SAFE(head,el,tmp1,tmp2)                                                    \
-    CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next)
-
-#define CDL_FOREACH_SAFE2(head,el,tmp1,tmp2,prev,next)                                         \
-  for((el)=(head), ((tmp1)=(head)?((head)->prev):NULL);                                        \
-      (el) && ((tmp2)=(el)->next, 1);                                                          \
-      ((el) = (((el)==(tmp1)) ? 0L : (tmp2))))
-
-#define CDL_SEARCH_SCALAR(head,out,field,val)                                                  \
-    CDL_SEARCH_SCALAR2(head,out,field,val,next)
-
-#define CDL_SEARCH_SCALAR2(head,out,field,val,next)                                            \
-do {                                                                                           \
-    CDL_FOREACH2(head,out,next) {                                                              \
-      if ((out)->field == (val)) break;                                                        \
-    }                                                                                          \
-} while(0) 
-
-#define CDL_SEARCH(head,out,elt,cmp)                                                           \
-    CDL_SEARCH2(head,out,elt,cmp,next)
-
-#define CDL_SEARCH2(head,out,elt,cmp,next)                                                     \
-do {                                                                                           \
-    CDL_FOREACH2(head,out,next) {                                                              \
-      if ((cmp(out,elt))==0) break;                                                            \
-    }                                                                                          \
-} while(0) 
-
-#define CDL_REPLACE_ELEM(head, el, add)                                                        \
-do {                                                                                           \
- assert(head != NULL);                                                                         \
- assert(el != NULL);                                                                           \
- assert(add != NULL);                                                                          \
- if ((el)->next == (el)) {                                                                     \
-  (add)->next = (add);                                                                         \
-  (add)->prev = (add);                                                                         \
-  (head) = (add);                                                                              \
- } else {                                                                                      \
-  (add)->next = (el)->next;                                                                    \
-  (add)->prev = (el)->prev;                                                                    \
-  (add)->next->prev = (add);                                                                   \
-  (add)->prev->next = (add);                                                                   \
-  if ((head) == (el)) {                                                                        \
-   (head) = (add);                                                                             \
-  }                                                                                            \
- }                                                                                             \
-} while (0)
-
-#define CDL_PREPEND_ELEM(head, el, add)                                                        \
-do {                                                                                           \
- assert(head != NULL);                                                                         \
- assert(el != NULL);                                                                           \
- assert(add != NULL);                                                                          \
- (add)->next = (el);                                                                           \
- (add)->prev = (el)->prev;                                                                     \
- (el)->prev = (add);                                                                           \
- (add)->prev->next = (add);                                                                    \
- if ((head) == (el)) {                                                                         \
-  (head) = (add);                                                                              \
- }                                                                                             \
-} while (0)                                                                                    \
-
-#endif /* UTLIST_H */
-

+ 18 - 1
modules/outbound/Makefile

@@ -1,4 +1,4 @@
-# 
+#
 # WARNING: do not run this directly, it should be run by the master Makefile
 # WARNING: do not run this directly, it should be run by the master Makefile
 
 
 include ../../Makefile.defs
 include ../../Makefile.defs
@@ -6,15 +6,32 @@ auto_gen=
 NAME=outbound.so
 NAME=outbound.so
 
 
 ifeq ($(CROSS_COMPILE),)
 ifeq ($(CROSS_COMPILE),)
+	BUILDER = $(shell which pkg-config)
+endif
+
+ifneq ($(BUILDER),)
 SSL_BUILDER=$(shell \
 SSL_BUILDER=$(shell \
 	if pkg-config --exists libssl; then \
 	if pkg-config --exists libssl; then \
 		echo 'pkg-config libssl'; \
 		echo 'pkg-config libssl'; \
 	fi)
 	fi)
+
+CRYPTO_BUILDER=$(shell \
+	if pkg-config --exists libcrypto; then \
+		echo 'pkg-config libcrypto'; \
+	fi)
 endif
 endif
 
 
+ifneq ($(BUILDER),)
+
 ifneq ($(SSL_BUILDER),)
 ifneq ($(SSL_BUILDER),)
 	DEFS += $(shell $(SSL_BUILDER) --cflags)
 	DEFS += $(shell $(SSL_BUILDER) --cflags)
 	LIBS += $(shell $(SSL_BUILDER) --libs)
 	LIBS += $(shell $(SSL_BUILDER) --libs)
+endif
+ifneq ($(CRYPTO_BUILDER),)
+	DEFS += $(shell $(CRYPTO_BUILDER) --cflags)
+	LIBS += $(shell $(CRYPTO_BUILDER) --libs)
+endif
+
 else
 else
 	DEFS += -I$(LOCALBASE)/ssl/include
 	DEFS += -I$(LOCALBASE)/ssl/include
 	LIBS += -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib \
 	LIBS += -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib \

+ 12 - 12
modules/permissions/hash.c

@@ -612,15 +612,15 @@ int addr_hash_table_rpc_print(struct addr_list** table, rpc_t* rpc, void* c)
 	struct addr_list *np;
 	struct addr_list *np;
 
 
 
 
-	if (rpc->add(c, "{", &th) < 0)
-	{
-		rpc->fault(c, 500, "Internal error creating rpc");
-		return -1;
-	}
-
 	for (i = 0; i < PERM_HASH_SIZE; i++) {
 	for (i = 0; i < PERM_HASH_SIZE; i++) {
 		np = table[i];
 		np = table[i];
 		while (np) {
 		while (np) {
+			if (rpc->add(c, "{", &th) < 0)
+			{
+				rpc->fault(c, 500, "Internal error creating rpc");
+				return -1;
+			}
+
 			if(rpc->struct_add(th, "dd{",
 			if(rpc->struct_add(th, "dd{",
 						"table", i,
 						"table", i,
 						"group", np->grp,
 						"group", np->grp,
@@ -847,13 +847,13 @@ int subnet_table_rpc_print(struct subnet* table, rpc_t* rpc, void* c)
 
 
 	count = table[PERM_MAX_SUBNETS].grp;
 	count = table[PERM_MAX_SUBNETS].grp;
 
 
-	if (rpc->add(c, "{", &th) < 0)
-	{
-		rpc->fault(c, 500, "Internal error creating rpc");
-		return -1;
-	}
-
 	for (i = 0; i < count; i++) {
 	for (i = 0; i < count; i++) {
+		if (rpc->add(c, "{", &th) < 0)
+		{
+			rpc->fault(c, 500, "Internal error creating rpc");
+			return -1;
+		}
+
 		if(rpc->struct_add(th, "dd{",
 		if(rpc->struct_add(th, "dd{",
 					"id", i,
 					"id", i,
 					"group", table[i].grp,
 					"group", table[i].grp,

+ 2 - 2
modules/permissions/permissions.c

@@ -1016,8 +1016,8 @@ rpc_export_t permissions_rpc[] = {
 	{"permissions.trustedReload", rpc_trusted_reload, rpc_trusted_reload_doc, 0},
 	{"permissions.trustedReload", rpc_trusted_reload, rpc_trusted_reload_doc, 0},
 	{"permissions.addressReload", rpc_address_reload, rpc_address_reload_doc, 0},
 	{"permissions.addressReload", rpc_address_reload, rpc_address_reload_doc, 0},
 	{"permissions.trustedDump", rpc_trusted_dump, rpc_trusted_dump_doc, 0},
 	{"permissions.trustedDump", rpc_trusted_dump, rpc_trusted_dump_doc, 0},
-	{"permissions.addressDump", rpc_address_dump, rpc_address_dump_doc, 0},
-	{"permissions.subnetDump", rpc_subnet_dump, rpc_subnet_dump_doc, 0},
+	{"permissions.addressDump", rpc_address_dump, rpc_address_dump_doc, RET_ARRAY},
+	{"permissions.subnetDump", rpc_subnet_dump, rpc_subnet_dump_doc, RET_ARRAY},
 	{"permissions.domainDump", rpc_domain_name_dump, rpc_domain_name_dump_doc, 0},
 	{"permissions.domainDump", rpc_domain_name_dump, rpc_domain_name_dump_doc, 0},
 	{"permissions.testUri", rpc_test_uri, rpc_test_uri_doc, 0},
 	{"permissions.testUri", rpc_test_uri, rpc_test_uri_doc, 0},
 	{0, 0, 0, 0}
 	{0, 0, 0, 0}

+ 11 - 45
modules/pike/pike_rpc.c

@@ -101,42 +101,15 @@ static void collect_data(int options)
 	}
 	}
 }
 }
 
 
-/* do not use static buffer with this function */
-static const char *concat_err = "ERROR while concatenating string";
-static char *concat(char *buff, size_t buffsize, const char *first, int second)
-{
-	int rv;
-	size_t size;
-
-	while ( (rv = snprintf(buff, buffsize, "%s%d", first, second)) >= buffsize ) {
-		size = rv > 128 ? rv : 128;
-		buff = (char *)realloc(buff, size);
-		if ( buff == 0 )
-			return (char*)concat_err;
-		buffsize = size;
-		DBG("pike:rpc:concat: new buffer size for %s: %d", first,
-				(int)buffsize);
-	}
-	return buff;
-}
-
 static void pike_top(rpc_t *rpc, void *c)
 static void pike_top(rpc_t *rpc, void *c)
 {
 {
 	int i;
 	int i;
 	void *handle;
 	void *handle;
+	void *list;
+	void *item;
 	struct TopListItem_t *top_list_root;
 	struct TopListItem_t *top_list_root;
 	struct TopListItem_t *ti = 0;
 	struct TopListItem_t *ti = 0;
-	char addr_buff[40];
-	char *ip_addr = 0;
-	char *leaf_hits_prev = 0;
-	char *leaf_hits_curr = 0;
-	char *expires = 0;
-	char *status = 0;
-	size_t ip_addr_size = 0;
-	size_t leaf_hits_prev_size = 0;
-	size_t leaf_hits_curr_size = 0;
-	size_t expires_size = 0;
-	size_t status_size = 0;
+	char addr_buff[PIKE_BUFF_SIZE*sizeof(char)];
 	char *stropts;
 	char *stropts;
 	int   options = 0;
 	int   options = 0;
 
 
@@ -170,7 +143,7 @@ static void pike_top(rpc_t *rpc, void *c)
 	DBG("pike_top: top_list_root = %p", top_list_root);
 	DBG("pike_top: top_list_root = %p", top_list_root);
 
 
 	rpc->add(c, "{", &handle);
 	rpc->add(c, "{", &handle);
-	rpc->struct_add(handle, "d", "max_hits", get_max_hits());
+	rpc->struct_add(handle, "d[", "max_hits", get_max_hits(), "list", &list);
 	i = 0; // it is passed as number of rows
 	i = 0; // it is passed as number of rows
 	if ( top_list_root == 0 ) {
 	if ( top_list_root == 0 ) {
 		DBG("pike_top: no data");
 		DBG("pike_top: no data");
@@ -181,24 +154,17 @@ static void pike_top(rpc_t *rpc, void *c)
 			DBG("pike:top: result[%d]: %s leaf_hits[%d,%d] hits[%d,%d] expires: %d status: 0x%02x",
 			DBG("pike:top: result[%d]: %s leaf_hits[%d,%d] hits[%d,%d] expires: %d status: 0x%02x",
 					i, addr_buff, ti->leaf_hits[0], ti->leaf_hits[1],
 					i, addr_buff, ti->leaf_hits[0], ti->leaf_hits[1],
 					ti->hits[0], ti->hits[1], ti->expires, ti->status);
 					ti->hits[0], ti->hits[1], ti->expires, ti->status);
-			rpc->struct_add(handle, "sddds",
-							concat(ip_addr, ip_addr_size, "ip_addr", i), addr_buff,
-							concat(leaf_hits_prev, leaf_hits_prev_size, "leaf_hits_prev", i), ti->leaf_hits[0],
-							concat(leaf_hits_curr, leaf_hits_curr_size, "leaf_hits_curr", i), ti->leaf_hits[1],
-							concat(expires, expires_size, "expires", i), ti->expires,
-							concat(status, status_size, "status", i), node_status_array[ti->status]);
+			rpc->array_add(list, "{", &item);
+			rpc->struct_add(item, "sddds",
+							"ip_addr", addr_buff,
+							"leaf_hits_prev", ti->leaf_hits[0],
+							"leaf_hits_curr", ti->leaf_hits[1],
+							"expires", ti->expires,
+							"status", node_status_array[ti->status]);
 		}
 		}
 	}
 	}
 	rpc->struct_add(handle, "d", "number_of_rows", i);
 	rpc->struct_add(handle, "d", "number_of_rows", i);
-	/* free buffers */
-	free(ip_addr);
-	free(leaf_hits_prev);
-	free(leaf_hits_curr);
-	free(expires);
-	free(status);
 	pike_top_list_clear();
 	pike_top_list_clear();
-
-	rpc->send(c);
 }
 }
 
 
 /* ----- exported data structure with methods ----- */
 /* ----- exported data structure with methods ----- */

+ 0 - 1
modules/pike/pike_top.c

@@ -33,7 +33,6 @@
 static struct TopListItem_t *top_list_root = 0;
 static struct TopListItem_t *top_list_root = 0;
 static struct TopListItem_t *top_list_iter = 0;
 static struct TopListItem_t *top_list_iter = 0;
 
 
-#define PIKE_BUFF_SIZE	128
 static char buff[PIKE_BUFF_SIZE];
 static char buff[PIKE_BUFF_SIZE];
 
 
 struct TopListItem_t *pike_top_get_root() { return top_list_root; }
 struct TopListItem_t *pike_top_get_root() { return top_list_root; }

+ 2 - 0
modules/pike/pike_top.h

@@ -24,6 +24,8 @@
 #include "ip_tree.h"
 #include "ip_tree.h"
 #include "../../ip_addr.h"
 #include "../../ip_addr.h"
 
 
+#define PIKE_BUFF_SIZE  128
+
 struct TopListItem_t {
 struct TopListItem_t {
 	int             addr_len;
 	int             addr_len;
 	unsigned char   ip_addr[45];	/*!< Make room for IPv6 */
 	unsigned char   ip_addr[45];	/*!< Make room for IPv6 */

+ 9 - 2
modules/presence/hash.c

@@ -101,6 +101,7 @@ void destroy_shtable(shtable_t htable, int hash_size)
 		lock_destroy(&htable[i].lock);
 		lock_destroy(&htable[i].lock);
 		free_subs_list(htable[i].entries->next, SHM_MEM_TYPE, 1);
 		free_subs_list(htable[i].entries->next, SHM_MEM_TYPE, 1);
 		shm_free(htable[i].entries);
 		shm_free(htable[i].entries);
+		htable[i].entries = NULL;
 	}
 	}
 	shm_free(htable);
 	shm_free(htable);
 	htable= NULL;
 	htable= NULL;
@@ -345,15 +346,21 @@ void free_subs_list(subs_t* s_array, int mem_type, int ic)
 		s_array= s_array->next;
 		s_array= s_array->next;
 		if(mem_type & PKG_MEM_TYPE)
 		if(mem_type & PKG_MEM_TYPE)
 		{
 		{
-			if(ic)
+			if(ic) {
 				pkg_free(s->contact.s);
 				pkg_free(s->contact.s);
+				s->contact.s = NULL;
+			}
 			pkg_free(s);
 			pkg_free(s);
+			s = NULL;
 		}
 		}
 		else
 		else
 		{
 		{
-			if(ic)
+			if(ic) {
 				shm_free(s->contact.s);
 				shm_free(s->contact.s);
+				s->contact.s = NULL;
+			}
 			shm_free(s);
 			shm_free(s);
+			s = NULL;
 		}
 		}
 	}
 	}
 	
 	

+ 1 - 1
modules/presence/notify.c

@@ -2127,7 +2127,7 @@ error:
 #define EXTRACT_STRING(strng, chars)\
 #define EXTRACT_STRING(strng, chars)\
 			do {\
 			do {\
 			strng.s = (char *) chars;\
 			strng.s = (char *) chars;\
-			strng.len = strlen(strng.s);\
+			strng.len = strng.s == NULL ? 0 : strlen(strng.s);\
 			} while(0);
 			} while(0);
 
 
 static int unset_watchers_updated_winfo(str *pres_uri)
 static int unset_watchers_updated_winfo(str *pres_uri)

+ 290 - 7
modules/presence/presentity.c

@@ -268,10 +268,14 @@ xmlNodePtr xmlNodeGetChildByName(xmlNodePtr node, const char *name)
 	return NULL;
 	return NULL;
 }
 }
 
 
-int check_if_dialog(str body, int *is_dialog)
+int check_if_dialog(str body, int *is_dialog, char **dialog_id)
 {
 {
 	xmlDocPtr doc;
 	xmlDocPtr doc;
 	xmlNodePtr node;
 	xmlNodePtr node;
+	char *tmp_dialog_id;
+
+	*dialog_id = NULL;
+	*is_dialog = 0;
 
 
 	doc = xmlParseMemory(body.s, body.len);
 	doc = xmlParseMemory(body.s, body.len);
 	if(doc== NULL)
 	if(doc== NULL)
@@ -283,15 +287,260 @@ int check_if_dialog(str body, int *is_dialog)
 	node = doc->children;
 	node = doc->children;
 	node = xmlNodeGetChildByName(node, "dialog");
 	node = xmlNodeGetChildByName(node, "dialog");
 
 
-	if(node == NULL)
-		*is_dialog = 0;
-	else
+	if(node != NULL)
+	{
 		*is_dialog = 1;
 		*is_dialog = 1;
+		tmp_dialog_id = (char *)xmlGetProp(node, (xmlChar *)"id");
+
+		if (tmp_dialog_id != NULL)
+		{
+			*dialog_id = strdup(tmp_dialog_id);
+			xmlFree(tmp_dialog_id);
+		}
+	}
 
 
 	xmlFreeDoc(doc);
 	xmlFreeDoc(doc);
 	return 0;
 	return 0;
 }
 }
 
 
+int parse_dialog_state_from_body(str body, int *is_dialog, char **state)
+{
+	xmlDocPtr doc;
+	xmlNodePtr node;
+	xmlNodePtr childNode;
+	char *tmp_state;
+
+	*state = NULL;
+	*is_dialog = 0;
+
+	doc = xmlParseMemory(body.s, body.len);
+	if(doc== NULL)
+	{
+		LM_ERR("failed to parse xml document\n");
+		return -1;
+	}
+
+	node = doc->children;
+	node = xmlNodeGetChildByName(node, "dialog");
+
+	if(node != NULL)
+	{
+		*is_dialog = 1;
+
+		childNode = xmlNodeGetChildByName(node, "state");
+		tmp_state = (char *)xmlNodeGetContent(childNode);
+
+		if (tmp_state != NULL)
+		{
+			*state = strdup(tmp_state);
+			xmlFree(tmp_state);
+		}
+	}
+
+	xmlFreeDoc(doc);
+	return 0;
+}
+
+int delete_presentity_if_dialog_id_exists(presentity_t* presentity, char* dialog_id) {
+	db_key_t query_cols[13], result_cols[6];
+	db_op_t  query_ops[13];
+	db_val_t query_vals[13];
+	int n_query_cols = 0;
+	int rez_body_col = 0, rez_etag_col = 0, n_result_cols= 0;
+	db1_res_t *result = NULL;
+	db_row_t *row = NULL;
+	db_val_t *row_vals = NULL;
+	char* db_dialog_id = NULL;
+	int db_is_dialog = 0;
+	str tmp_db_body, tmp_db_etag;
+	int i = 0;
+	presentity_t old_presentity;
+
+	query_cols[n_query_cols] = &str_domain_col;
+	query_ops[n_query_cols] = OP_EQ;
+	query_vals[n_query_cols].type = DB1_STR;
+	query_vals[n_query_cols].nul = 0;
+	query_vals[n_query_cols].val.str_val = presentity->domain;
+	n_query_cols++;
+
+	query_cols[n_query_cols] = &str_username_col;
+	query_ops[n_query_cols] = OP_EQ;
+	query_vals[n_query_cols].type = DB1_STR;
+	query_vals[n_query_cols].nul = 0;
+	query_vals[n_query_cols].val.str_val = presentity->user;
+	n_query_cols++;
+
+	query_cols[n_query_cols] = &str_event_col;
+	query_ops[n_query_cols] = OP_EQ;
+	query_vals[n_query_cols].type = DB1_STR;
+	query_vals[n_query_cols].nul = 0;
+	query_vals[n_query_cols].val.str_val = presentity->event->name;
+	n_query_cols++;
+
+	result_cols[rez_body_col=n_result_cols++] = &str_body_col;
+	result_cols[rez_etag_col=n_result_cols++] = &str_etag_col;
+
+	if (pa_dbf.use_table(pa_db, &presentity_table) < 0)
+	{
+		LM_ERR("unsuccessful sql use table\n");
+		return -1;
+	}
+
+	if (pa_dbf.query (pa_db, query_cols, query_ops, query_vals,
+	 result_cols, n_query_cols, n_result_cols, 0, &result) < 0)
+	{
+		LM_ERR("unsuccessful sql query\n");
+		return -2;
+	}
+
+	if(result == NULL)
+		return -3;
+
+	// No results from query definitely means no dialog exists
+	if (result->n <= 0)
+		return 0;
+
+	// Loop the rows returned from the DB
+	for (i=0; i < result->n; i++)
+	{
+		row = &result->rows[i];
+		row_vals = ROW_VALUES(row);
+		tmp_db_body.s = (char*)row_vals[rez_body_col].val.string_val;
+		tmp_db_body.len = strlen(tmp_db_body.s);
+
+		tmp_db_etag.s = (char*)row_vals[rez_etag_col].val.string_val;
+		tmp_db_etag.len = strlen(tmp_db_etag.s);
+
+		if (check_if_dialog(tmp_db_body, &db_is_dialog, &db_dialog_id) == 0)
+		{
+			// If ID from DB matches the one we supplied
+			if (db_dialog_id && !strcmp(db_dialog_id, dialog_id))
+			{
+				old_presentity.domain = presentity->domain;
+				old_presentity.user = presentity->user;
+				old_presentity.event = presentity->event;
+				old_presentity.etag = tmp_db_etag;
+
+				LM_WARN("Presentity already exists - deleting it\n");
+
+				delete_presentity(&old_presentity);
+
+				pa_dbf.free_result(pa_db, result);
+				result = NULL;
+				free(db_dialog_id);
+
+				return 1;
+			}
+
+			free(db_dialog_id);
+		}
+	}
+
+	pa_dbf.free_result(pa_db, result);
+	result = NULL;
+	return 0;
+}
+
+int get_dialog_state(presentity_t* presentity, char** state)
+{
+	db_key_t query_cols[13], result_cols[6];
+	db_op_t  query_ops[13];
+	db_val_t query_vals[13];
+	int n_query_cols = 0;
+	int rez_body_col = 0, n_result_cols= 0;
+	db1_res_t *result = NULL;
+	db_row_t *row = NULL;
+	db_val_t *row_vals = NULL;
+	int db_is_dialog = 0;
+	str tmp_db_body;
+	int i = 0, parse_state_result = 0;
+
+	*state = NULL;
+
+	query_cols[n_query_cols] = &str_domain_col;
+	query_ops[n_query_cols] = OP_EQ;
+	query_vals[n_query_cols].type = DB1_STR;
+	query_vals[n_query_cols].nul = 0;
+	query_vals[n_query_cols].val.str_val = presentity->domain;
+	n_query_cols++;
+
+	query_cols[n_query_cols] = &str_username_col;
+	query_ops[n_query_cols] = OP_EQ;
+	query_vals[n_query_cols].type = DB1_STR;
+	query_vals[n_query_cols].nul = 0;
+	query_vals[n_query_cols].val.str_val = presentity->user;
+	n_query_cols++;
+
+	query_cols[n_query_cols] = &str_event_col;
+	query_ops[n_query_cols] = OP_EQ;
+	query_vals[n_query_cols].type = DB1_STR;
+	query_vals[n_query_cols].nul = 0;
+	query_vals[n_query_cols].val.str_val = presentity->event->name;
+	n_query_cols++;
+
+	query_cols[n_query_cols] = &str_etag_col;
+	query_ops[n_query_cols] = OP_EQ;
+	query_vals[n_query_cols].type = DB1_STR;
+	query_vals[n_query_cols].nul = 0;
+	query_vals[n_query_cols].val.str_val = presentity->etag;
+	n_query_cols++;
+
+	result_cols[rez_body_col=n_result_cols++] = &str_body_col;
+
+	if (pa_dbf.use_table(pa_db, &presentity_table) < 0)
+	{
+		LM_ERR("unsuccessful sql use table\n");
+		return -1;
+	}
+
+	if (pa_dbf.query (pa_db, query_cols, query_ops, query_vals,
+	 result_cols, n_query_cols, n_result_cols, 0, &result) < 0)
+	{
+		LM_ERR("unsuccessful sql query\n");
+		return -2;
+	}
+
+	if(result == NULL)
+		return -3;
+
+	// No results from query definitely means no dialog exists
+	if (result->n <= 0)
+		return 0;
+
+	// Loop the rows returned from the DB
+	for (i=0; i < result->n; i++)
+	{
+		row = &result->rows[i];
+		row_vals = ROW_VALUES(row);
+		tmp_db_body.s = (char*)row_vals[rez_body_col].val.string_val;
+		tmp_db_body.len = strlen(tmp_db_body.s);
+
+		parse_state_result = parse_dialog_state_from_body(tmp_db_body, &db_is_dialog, state);
+
+		pa_dbf.free_result(pa_db, result);
+		result = NULL;
+
+		return parse_state_result;
+	}
+
+	pa_dbf.free_result(pa_db, result);
+	result = NULL;
+	return 0;
+}
+
+int is_dialog_terminated(presentity_t* presentity)
+{
+	char *state = NULL;
+	int rtn;
+
+	get_dialog_state(presentity, &state);
+
+	rtn = state && !strcasecmp(state, "terminated");
+
+	free(state);
+
+	return rtn;
+}
 
 
 int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 		int new_t, int* sent_reply, char* sphere)
 		int new_t, int* sent_reply, char* sphere)
@@ -316,6 +565,7 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 	int ret = -1;
 	int ret = -1;
 	int db_record_exists = 0;
 	int db_record_exists = 0;
 	int num_watchers = 0;
 	int num_watchers = 0;
+	char *old_dialog_id = NULL, *dialog_id = NULL;
 
 
 	if (sent_reply) *sent_reply= 0;
 	if (sent_reply) *sent_reply= 0;
 	if(pres_notifier_processes == 0 && presentity->event->req_auth)
 	if(pres_notifier_processes == 0 && presentity->event->req_auth)
@@ -435,6 +685,14 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 				}
 				}
 			}
 			}
 
 
+			check_if_dialog(*body, &is_dialog, &dialog_id);
+
+			if (delete_presentity_if_dialog_id_exists(presentity, dialog_id) < 0) {
+				goto error;
+			}
+
+			free(dialog_id);
+
 			LM_DBG("inserting %d cols into table\n",n_query_cols);
 			LM_DBG("inserting %d cols into table\n",n_query_cols);
 
 
 			if (pa_dbf.insert(pa_db, query_cols, query_vals, n_query_cols) < 0)
 			if (pa_dbf.insert(pa_db, query_cols, query_vals, n_query_cols) < 0)
@@ -529,16 +787,20 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 
 
 			old_body.s = (char*)row_vals[rez_body_col].val.string_val;
 			old_body.s = (char*)row_vals[rez_body_col].val.string_val;
 			old_body.len = strlen(old_body.s);
 			old_body.len = strlen(old_body.s);
-			if(check_if_dialog(*body, &is_dialog)< 0)
+			if(check_if_dialog(*body, &is_dialog, &dialog_id)< 0)
 			{
 			{
 				LM_ERR("failed to check if dialog stored\n");
 				LM_ERR("failed to check if dialog stored\n");
 				goto error;
 				goto error;
 			}
 			}
 
 
-			if(is_dialog== 1)  /* if the new body has a dialog - overwrite */
+			free(dialog_id);
+
+			if(is_dialog== 1) /* if the new body has a dialog - overwrite */
+			{
 				goto after_dialog_check;
 				goto after_dialog_check;
+			}
 
 
-			if(check_if_dialog(old_body, &is_dialog)< 0)
+			if(check_if_dialog(old_body, &is_dialog, &old_dialog_id)< 0)
 			{
 			{
 				LM_ERR("failed to check if dialog stored\n");
 				LM_ERR("failed to check if dialog stored\n");
 				goto error;
 				goto error;
@@ -547,6 +809,8 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 			if(is_dialog==0 ) /* if the old body has no dialog - overwrite */
 			if(is_dialog==0 ) /* if the old body has no dialog - overwrite */
 				goto after_dialog_check;
 				goto after_dialog_check;
 
 
+			free(old_dialog_id);
+
 			sender.s = (char*)row_vals[rez_sender_col].val.string_val;
 			sender.s = (char*)row_vals[rez_sender_col].val.string_val;
 			sender.len= strlen(sender.s);
 			sender.len= strlen(sender.s);
 
 
@@ -702,6 +966,25 @@ after_dialog_check:
 		else
 		else
 			cur_etag= presentity->etag;
 			cur_etag= presentity->etag;
 
 
+		if (is_dialog_terminated(presentity))
+		{
+			LM_WARN("Trying to update an already terminated state. Skipping update.\n");
+
+			/* send 200OK */
+			if (publ_send200ok(msg, presentity->expires, cur_etag)< 0)
+			{
+				LM_ERR("sending 200OK reply\n");
+				goto error;
+			}
+			if (sent_reply) *sent_reply= 1;
+
+			if(etag.s)
+				pkg_free(etag.s);
+			etag.s= NULL;
+
+			goto done;
+		}
+
 		update_keys[n_update_cols] = &str_expires_col;
 		update_keys[n_update_cols] = &str_expires_col;
 		update_vals[n_update_cols].type = DB1_INT;
 		update_vals[n_update_cols].type = DB1_INT;
 		update_vals[n_update_cols].nul = 0;
 		update_vals[n_update_cols].nul = 0;

+ 16 - 8
modules/sdpops/README

@@ -26,8 +26,8 @@ Daniel-Constantin Mierla
         3. Parameters
         3. Parameters
         4. Functions
         4. Functions
 
 
-              4.1. sdp_remove_codecs_by_id(list)
-              4.2. sdp_remove_codecs_by_name(list)
+              4.1. sdp_remove_codecs_by_id(list [, mtype])
+              4.2. sdp_remove_codecs_by_name(list [, mtype])
               4.3. sdp_remove_line_by_prefix(string)
               4.3. sdp_remove_line_by_prefix(string)
               4.4. sdp_keep_codecs_by_id(list [, mtype])
               4.4. sdp_keep_codecs_by_id(list [, mtype])
               4.5. sdp_keep_codecs_by_name(list [, mtype])
               4.5. sdp_keep_codecs_by_name(list [, mtype])
@@ -81,8 +81,8 @@ Chapter 1. Admin Guide
    3. Parameters
    3. Parameters
    4. Functions
    4. Functions
 
 
-        4.1. sdp_remove_codecs_by_id(list)
-        4.2. sdp_remove_codecs_by_name(list)
+        4.1. sdp_remove_codecs_by_id(list [, mtype])
+        4.2. sdp_remove_codecs_by_name(list [, mtype])
         4.3. sdp_remove_line_by_prefix(string)
         4.3. sdp_remove_line_by_prefix(string)
         4.4. sdp_keep_codecs_by_id(list [, mtype])
         4.4. sdp_keep_codecs_by_id(list [, mtype])
         4.5. sdp_keep_codecs_by_name(list [, mtype])
         4.5. sdp_keep_codecs_by_name(list [, mtype])
@@ -133,8 +133,8 @@ Chapter 1. Admin Guide
 
 
 4. Functions
 4. Functions
 
 
-   4.1. sdp_remove_codecs_by_id(list)
-   4.2. sdp_remove_codecs_by_name(list)
+   4.1. sdp_remove_codecs_by_id(list [, mtype])
+   4.2. sdp_remove_codecs_by_name(list [, mtype])
    4.3. sdp_remove_line_by_prefix(string)
    4.3. sdp_remove_line_by_prefix(string)
    4.4. sdp_keep_codecs_by_id(list [, mtype])
    4.4. sdp_keep_codecs_by_id(list [, mtype])
    4.5. sdp_keep_codecs_by_name(list [, mtype])
    4.5. sdp_keep_codecs_by_name(list [, mtype])
@@ -153,7 +153,7 @@ Chapter 1. Admin Guide
    4.18. sdp_with_ice()
    4.18. sdp_with_ice()
    4.19. sdp_get_line_startswith(avpvar, string)
    4.19. sdp_get_line_startswith(avpvar, string)
 
 
-4.1.  sdp_remove_codecs_by_id(list)
+4.1.  sdp_remove_codecs_by_id(list [, mtype])
 
 
    Remove the codecs provided in the parameter 'list' from all media
    Remove the codecs provided in the parameter 'list' from all media
    streams found in SDP payload. The parameter 'list' must be one item or
    streams found in SDP payload. The parameter 'list' must be one item or
@@ -168,15 +168,20 @@ Chapter 1. Admin Guide
 sdp_remove_codecs_by_id("0");
 sdp_remove_codecs_by_id("0");
 # remove PCMU, PCMA and GSM
 # remove PCMU, PCMA and GSM
 sdp_remove_codecs_by_id("0,8,3");
 sdp_remove_codecs_by_id("0,8,3");
+sdp_remove_codecs_by_id("17", "audio");
+sdp_remove_codecs_by_id("23", "video");
 ...
 ...
 
 
-4.2.  sdp_remove_codecs_by_name(list)
+4.2.  sdp_remove_codecs_by_name(list [, mtype])
 
 
    Remove the codecs provided in the parameter 'list' from all media
    Remove the codecs provided in the parameter 'list' from all media
    streams found in SDP payload. The parameter 'list' must be one item or
    streams found in SDP payload. The parameter 'list' must be one item or
    a comma separated list of codec names. The parameter can be a static
    a comma separated list of codec names. The parameter can be a static
    string or a variable holding the list of codec names.
    string or a variable holding the list of codec names.
 
 
+   Optional parameter mtype can be provided to apply the operations only
+   to the streams matching m=mtype.
+
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
    Example 1.2. sdp_remove_codecs_by_name usage
    Example 1.2. sdp_remove_codecs_by_name usage
@@ -192,6 +197,9 @@ sdp_remove_codecs_by_name("PCMU,PCMA,GSM");
    Remove all SDP attribute lines beginning with 'string' in all media
    Remove all SDP attribute lines beginning with 'string' in all media
    streams.
    streams.
 
 
+   Optional parameter mtype can be provided to apply the operations only
+   to the streams matching m=mtype.
+
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
    Example 1.3. sdp_remove_line_by_prefix usage
    Example 1.3. sdp_remove_line_by_prefix usage

+ 3 - 2
modules/sdpops/api.h

@@ -28,6 +28,7 @@ typedef int (*sdp_with_transport_t)(struct sip_msg*, str*, int);
 typedef int (*sdp_with_ice_t)(struct sip_msg*);
 typedef int (*sdp_with_ice_t)(struct sip_msg*);
 typedef int (*sdp_keep_media_t)(struct sip_msg*, str*, str*);
 typedef int (*sdp_keep_media_t)(struct sip_msg*, str*, str*);
 typedef int (*sdp_remove_media_t)(struct sip_msg*, str*);
 typedef int (*sdp_remove_media_t)(struct sip_msg*, str*);
+typedef int (*sdp_remove_media_type_t)(struct sip_msg*, str*, str*);
 
 
 typedef struct sdpops_binds {
 typedef struct sdpops_binds {
 	sdp_with_media_t     sdp_with_media;
 	sdp_with_media_t     sdp_with_media;
@@ -41,8 +42,8 @@ typedef struct sdpops_binds {
 	sdp_remove_media_t   sdp_remove_media;
 	sdp_remove_media_t   sdp_remove_media;
 	sdp_remove_media_t   sdp_remove_transport;
 	sdp_remove_media_t   sdp_remove_transport;
 	sdp_remove_media_t   sdp_remove_line_by_prefix;
 	sdp_remove_media_t   sdp_remove_line_by_prefix;
-	sdp_remove_media_t   sdp_remove_codecs_by_id;
-	sdp_remove_media_t   sdp_remove_codecs_by_name;
+	sdp_remove_media_type_t   sdp_remove_codecs_by_id;
+	sdp_remove_media_type_t   sdp_remove_codecs_by_name;
 } sdpops_api_t;
 } sdpops_api_t;
 
 
 typedef int (*bind_sdpops_f)(sdpops_api_t*);
 typedef int (*bind_sdpops_f)(sdpops_api_t*);

+ 12 - 2
modules/sdpops/doc/sdpops_admin.xml

@@ -68,7 +68,7 @@
 	<title>Functions</title>
 	<title>Functions</title>
 	<section id="sdpops.f.remove_codecs_by_id">
 	<section id="sdpops.f.remove_codecs_by_id">
 	    <title>
 	    <title>
-		<function moreinfo="none">sdp_remove_codecs_by_id(list)</function>
+		<function moreinfo="none">sdp_remove_codecs_by_id(list [, mtype])</function>
 	    </title>
 	    </title>
 	    <para>
 	    <para>
 			Remove the codecs provided in the parameter 'list' from all
 			Remove the codecs provided in the parameter 'list' from all
@@ -88,13 +88,15 @@
 sdp_remove_codecs_by_id("0");
 sdp_remove_codecs_by_id("0");
 # remove PCMU, PCMA and GSM
 # remove PCMU, PCMA and GSM
 sdp_remove_codecs_by_id("0,8,3");
 sdp_remove_codecs_by_id("0,8,3");
+sdp_remove_codecs_by_id("17", "audio");
+sdp_remove_codecs_by_id("23", "video");
 ...
 ...
 </programlisting>
 </programlisting>
 	    </example>
 	    </example>
 	</section>
 	</section>
 	<section id="sdpops.f.remove_codecs_by_name">
 	<section id="sdpops.f.remove_codecs_by_name">
 	    <title>
 	    <title>
-		<function moreinfo="none">sdp_remove_codecs_by_name(list)</function>
+		<function moreinfo="none">sdp_remove_codecs_by_name(list [, mtype])</function>
 	    </title>
 	    </title>
 	    <para>
 	    <para>
 			Remove the codecs provided in the parameter 'list' from all
 			Remove the codecs provided in the parameter 'list' from all
@@ -102,6 +104,10 @@ sdp_remove_codecs_by_id("0,8,3");
 			be one item or a comma separated list of codec names. The
 			be one item or a comma separated list of codec names. The
 			parameter can be a static string or a variable holding the
 			parameter can be a static string or a variable holding the
 			list of codec names.
 			list of codec names.
+	    </para>
+		<para>
+			Optional parameter mtype can be provided to apply the operations
+			only to the streams matching m=mtype.
 	    </para>
 	    </para>
 		<para>
 		<para>
 			This function can be used from ANY_ROUTE.
 			This function can be used from ANY_ROUTE.
@@ -126,6 +132,10 @@ sdp_remove_codecs_by_name("PCMU,PCMA,GSM");
 			Remove all SDP attribute lines beginning with 'string'
 			Remove all SDP attribute lines beginning with 'string'
 			in all media streams.
 			in all media streams.
 	</para>
 	</para>
+		<para>
+			Optional parameter mtype can be provided to apply the operations
+			only to the streams matching m=mtype.
+	    </para>
 	<para>
 	<para>
 			This function can be used from ANY_ROUTE.
 			This function can be used from ANY_ROUTE.
 	</para>
 	</para>

+ 57 - 25
modules/sdpops/sdpops_mod.c

@@ -43,10 +43,10 @@
 MODULE_VERSION
 MODULE_VERSION
 
 
 static int w_sdp_remove_line_by_prefix(sip_msg_t* msg, char* prefix, char* bar);
 static int w_sdp_remove_line_by_prefix(sip_msg_t* msg, char* prefix, char* bar);
-static int w_sdp_remove_codecs_by_id(sip_msg_t* msg, char* codecs, char *bar);
-static int w_sdp_remove_codecs_by_name(sip_msg_t* msg, char* codecs, char *bar);
-static int w_sdp_keep_codecs_by_id(sip_msg_t* msg, char* codecs, char *bar);
-static int w_sdp_keep_codecs_by_name(sip_msg_t* msg, char* codecs, char *bar);
+static int w_sdp_remove_codecs_by_id(sip_msg_t* msg, char* codecs, char *media);
+static int w_sdp_remove_codecs_by_name(sip_msg_t* msg, char* codecs, char *media);
+static int w_sdp_keep_codecs_by_id(sip_msg_t* msg, char* codecs, char *media);
+static int w_sdp_keep_codecs_by_name(sip_msg_t* msg, char* codecs, char *media);
 static int w_sdp_with_media(sip_msg_t* msg, char* media, char *bar);
 static int w_sdp_with_media(sip_msg_t* msg, char* media, char *bar);
 static int w_sdp_with_active_media(sip_msg_t* msg, char* media, char *bar);
 static int w_sdp_with_active_media(sip_msg_t* msg, char* media, char *bar);
 static int w_sdp_with_transport(sip_msg_t* msg, char* transport, char *bar);
 static int w_sdp_with_transport(sip_msg_t* msg, char* transport, char *bar);
@@ -75,8 +75,12 @@ static cmd_export_t cmds[] = {
 		1, fixup_spve_null,  0, ANY_ROUTE},
 		1, fixup_spve_null,  0, ANY_ROUTE},
 	{"sdp_remove_codecs_by_id",    (cmd_function)w_sdp_remove_codecs_by_id,
 	{"sdp_remove_codecs_by_id",    (cmd_function)w_sdp_remove_codecs_by_id,
 		1, fixup_spve_null,  0, ANY_ROUTE},
 		1, fixup_spve_null,  0, ANY_ROUTE},
+	{"sdp_remove_codecs_by_id",    (cmd_function)w_sdp_remove_codecs_by_id,
+		2, fixup_spve_spve,  0, ANY_ROUTE},
 	{"sdp_remove_codecs_by_name",  (cmd_function)w_sdp_remove_codecs_by_name,
 	{"sdp_remove_codecs_by_name",  (cmd_function)w_sdp_remove_codecs_by_name,
 		1, fixup_spve_null,  0, ANY_ROUTE},
 		1, fixup_spve_null,  0, ANY_ROUTE},
+	{"sdp_remove_codecs_by_name",    (cmd_function)w_sdp_remove_codecs_by_name,
+		2, fixup_spve_spve,  0, ANY_ROUTE},
 	{"sdp_keep_codecs_by_id",    (cmd_function)w_sdp_keep_codecs_by_id,
 	{"sdp_keep_codecs_by_id",    (cmd_function)w_sdp_keep_codecs_by_id,
 		1, fixup_spve_null,  0, ANY_ROUTE},
 		1, fixup_spve_null,  0, ANY_ROUTE},
 	{"sdp_keep_codecs_by_id",    (cmd_function)w_sdp_keep_codecs_by_id,
 	{"sdp_keep_codecs_by_id",    (cmd_function)w_sdp_keep_codecs_by_id,
@@ -317,7 +321,7 @@ int sdp_remove_str_codec_id(sip_msg_t* msg, str *allcodecs, str* rmcodec)
 /**
 /**
  *
  *
  */
  */
-int sdp_remove_codecs_by_id(sip_msg_t* msg, str* codecs)
+int sdp_remove_codecs_by_id(sip_msg_t* msg, str* codecs, str* media)
 {
 {
 	sdp_info_t *sdp = NULL;
 	sdp_info_t *sdp = NULL;
 	int sdp_session_num;
 	int sdp_session_num;
@@ -357,19 +361,26 @@ int sdp_remove_codecs_by_id(sip_msg_t* msg, str* codecs)
 			LM_DBG("stream %d of %d - payloads [%.*s]\n",
 			LM_DBG("stream %d of %d - payloads [%.*s]\n",
 					sdp_stream_num, sdp_session_num,
 					sdp_stream_num, sdp_session_num,
 					sdp_stream->payloads.len, sdp_stream->payloads.s);
 					sdp_stream->payloads.len, sdp_stream->payloads.s);
-			sdp_codecs = sdp_stream->payloads;
-			tmp_codecs = *codecs;
-			while(str_find_token(&tmp_codecs, &rm_codec, ',')==0
-					&& rm_codec.len>0)
+
+			if((media==NULL) || (media->len==0)
+					|| (media->len==sdp_stream->media.len
+						&& strncasecmp(sdp_stream->media.s, media->s,
+							media->len)==0))
 			{
 			{
-				tmp_codecs.len -=(int)(&rm_codec.s[rm_codec.len]-tmp_codecs.s);
-				tmp_codecs.s = rm_codec.s + rm_codec.len;
-
-				LM_DBG("codecs [%.*s] - remove [%.*s]\n",
-						sdp_codecs.len, sdp_codecs.s,
-						rm_codec.len, rm_codec.s);
-				sdp_remove_str_codec_id(msg, &sdp_codecs, &rm_codec);
-				sdp_remove_str_codec_id_attrs(msg, sdp_stream, &rm_codec);
+				sdp_codecs = sdp_stream->payloads;
+				tmp_codecs = *codecs;
+				while(str_find_token(&tmp_codecs, &rm_codec, ',')==0
+						&& rm_codec.len>0)
+				{
+					tmp_codecs.len -=(int)(&rm_codec.s[rm_codec.len]-tmp_codecs.s);
+					tmp_codecs.s = rm_codec.s + rm_codec.len;
+
+					LM_DBG("codecs [%.*s] - remove [%.*s]\n",
+							sdp_codecs.len, sdp_codecs.s,
+							rm_codec.len, rm_codec.s);
+					sdp_remove_str_codec_id(msg, &sdp_codecs, &rm_codec);
+					sdp_remove_str_codec_id_attrs(msg, sdp_stream, &rm_codec);
+				}
 			}
 			}
 			sdp_stream_num++;
 			sdp_stream_num++;
 		}
 		}
@@ -501,9 +512,10 @@ static int w_sdp_remove_line_by_prefix(sip_msg_t* msg, char* prefix, char* bar)
 /**
 /**
  *
  *
  */
  */
-static int w_sdp_remove_codecs_by_id(sip_msg_t* msg, char* codecs, char* bar)
+static int w_sdp_remove_codecs_by_id(sip_msg_t* msg, char* codecs, char* media)
 {
 {
 	str lcodecs = {0, 0};
 	str lcodecs = {0, 0};
+	str lmedia = {0, 0};
 
 
 	if(codecs==0)
 	if(codecs==0)
 	{
 	{
@@ -517,7 +529,16 @@ static int w_sdp_remove_codecs_by_id(sip_msg_t* msg, char* codecs, char* bar)
 		return -1;
 		return -1;
 	}
 	}
 
 
-	if(sdp_remove_codecs_by_id(msg, &lcodecs)<0)
+	if(media!=NULL)
+	{
+		if(fixup_get_svalue(msg, (gparam_p)media, &lmedia)!=0)
+		{
+			LM_ERR("unable to get the media type\n");
+			return -1;
+		}
+	}
+
+	if(sdp_remove_codecs_by_id(msg, &lcodecs, &lmedia)<0)
 		return -1;
 		return -1;
 	return 1;
 	return 1;
 }
 }
@@ -525,7 +546,7 @@ static int w_sdp_remove_codecs_by_id(sip_msg_t* msg, char* codecs, char* bar)
 /**
 /**
  *
  *
  */
  */
-int sdp_remove_codecs_by_name(sip_msg_t* msg, str* codecs)
+int sdp_remove_codecs_by_name(sip_msg_t* msg, str* codecs, str* media)
 {
 {
 	sdp_info_t *sdp = NULL;
 	sdp_info_t *sdp = NULL;
 	str idslist;
 	str idslist;
@@ -548,7 +569,7 @@ int sdp_remove_codecs_by_name(sip_msg_t* msg, str* codecs)
 	if(sdpops_build_ids_list(sdp, codecs, &idslist)<0)
 	if(sdpops_build_ids_list(sdp, codecs, &idslist)<0)
 		return -1;
 		return -1;
 
 
-	if(sdp_remove_codecs_by_id(msg, &idslist)<0)
+	if(sdp_remove_codecs_by_id(msg, &idslist, media)<0)
 		return -1;
 		return -1;
 
 
 	return 0;
 	return 0;
@@ -558,9 +579,10 @@ int sdp_remove_codecs_by_name(sip_msg_t* msg, str* codecs)
 /**
 /**
  *
  *
  */
  */
-static int w_sdp_remove_codecs_by_name(sip_msg_t* msg, char* codecs, char* bar)
+static int w_sdp_remove_codecs_by_name(sip_msg_t* msg, char* codecs, char* media)
 {
 {
 	str lcodecs = {0, 0};
 	str lcodecs = {0, 0};
+	str lmedia = {0, 0};
 
 
 	if(codecs==0)
 	if(codecs==0)
 	{
 	{
@@ -574,8 +596,18 @@ static int w_sdp_remove_codecs_by_name(sip_msg_t* msg, char* codecs, char* bar)
 		return -1;
 		return -1;
 	}
 	}
 
 
-	if(sdp_remove_codecs_by_name(msg, &lcodecs)<0)
+	if(media!=NULL)
+	{
+		if(fixup_get_svalue(msg, (gparam_p)media, &lmedia)!=0)
+		{
+			LM_ERR("unable to get the media type\n");
+			return -1;
+		}
+	}
+
+	if(sdp_remove_codecs_by_name(msg, &lcodecs, &lmedia)<0)
 		return -1;
 		return -1;
+
 	return 1;
 	return 1;
 }
 }
 
 
@@ -1806,12 +1838,12 @@ error:
 static sr_kemi_t sr_kemi_sdpops_exports[] = {
 static sr_kemi_t sr_kemi_sdpops_exports[] = {
 	{ str_init("sdpops"), str_init("remove_codecs_by_name"),
 	{ str_init("sdpops"), str_init("remove_codecs_by_name"),
 		SR_KEMIP_INT, sdp_remove_codecs_by_name,
 		SR_KEMIP_INT, sdp_remove_codecs_by_name,
-		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
 	},
 	{ str_init("sdpops"), str_init("remove_codecs_by_id"),
 	{ str_init("sdpops"), str_init("remove_codecs_by_id"),
 		SR_KEMIP_INT, sdp_remove_codecs_by_id,
 		SR_KEMIP_INT, sdp_remove_codecs_by_id,
-		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
 	},
 	{ str_init("sdpops"), str_init("keep_codecs_by_name"),
 	{ str_init("sdpops"), str_init("keep_codecs_by_name"),

+ 10 - 4
modules/sipcapture/sipcapture.c

@@ -1840,8 +1840,16 @@ static int sip_capture(struct sip_msg *msg, str *_table, _capture_mode_data_t *
 		sco.originator_port = 0;
 		sco.originator_port = 0;
 	}
 	}
 
 
+	/* X-RTP-Stat-Add */
+	if((tmphdr[3] = get_hdr_by_name(msg,"X-RTP-Stat-Add", 14)) != NULL) {
+		sco.rtp_stat =  tmphdr[3]->body;
+	}
+	/* X-RTP-Stat-T38 */
+	else if((tmphdr[3] = get_hdr_by_name(msg,"X-RTP-Stat-T38", 14)) != NULL) {
+		sco.rtp_stat =  tmphdr[3]->body;
+	}
 	/* X-RTP-Stat */
 	/* X-RTP-Stat */
-	if((tmphdr[3] = get_hdr_by_name(msg,"X-RTP-Stat", 10)) != NULL) {
+	else if((tmphdr[3] = get_hdr_by_name(msg,"X-RTP-Stat", 10)) != NULL) {
 		sco.rtp_stat =  tmphdr[3]->body;
 		sco.rtp_stat =  tmphdr[3]->body;
 	}
 	}
 	/* P-RTP-Stat */
 	/* P-RTP-Stat */
@@ -1860,10 +1868,8 @@ static int sip_capture(struct sip_msg *msg, str *_table, _capture_mode_data_t *
 	else if((tmphdr[3] = get_hdr_by_name(msg,"RTP-RxStat", 10)) != NULL) {
 	else if((tmphdr[3] = get_hdr_by_name(msg,"RTP-RxStat", 10)) != NULL) {
 		sco.rtp_stat =  tmphdr[3]->body;
 		sco.rtp_stat =  tmphdr[3]->body;
 	}
 	}
-
 	else { EMPTY_STR(sco.rtp_stat); }
 	else { EMPTY_STR(sco.rtp_stat); }
 
 
-
 	/* PROTO TYPE */
 	/* PROTO TYPE */
 	sco.proto = msg->rcv.proto;
 	sco.proto = msg->rcv.proto;
 
 
@@ -2662,7 +2668,7 @@ static int nosip_hep_msg(void *data)
 {
 {
         sip_msg_t* msg;
         sip_msg_t* msg;
         char *buf;
         char *buf;
-        unsigned int len = 0;
+        int len = 0;
         struct run_act_ctx ra_ctx;
         struct run_act_ctx ra_ctx;
         int ret = 0;
         int ret = 0;
 
 

+ 1 - 1
modules/siptrace/siptrace.c

@@ -1854,7 +1854,7 @@ static int pipport2su (char *pipport, union sockaddr_union *tmp_su, unsigned int
 	if(strncmp(pipport, "udp:",4) == 0) *proto = IPPROTO_UDP;
 	if(strncmp(pipport, "udp:",4) == 0) *proto = IPPROTO_UDP;
 	else if(strncmp(pipport, "tcp:",4) == 0) *proto = IPPROTO_TCP;
 	else if(strncmp(pipport, "tcp:",4) == 0) *proto = IPPROTO_TCP;
 	else if(strncmp(pipport, "tls:",4) == 0) *proto = IPPROTO_IDP; /* fake proto type */
 	else if(strncmp(pipport, "tls:",4) == 0) *proto = IPPROTO_IDP; /* fake proto type */
-	else if(strncmp(pipport, "ws:",3) == 0) *proto = IPPROTO_IDP; /* fake proto type */
+	else if(strncmp(pipport, "ws:",3) == 0) cutlen = 3, *proto = IPPROTO_IDP; /* fake proto type */
 	else if(strncmp(pipport, "wss:",4) == 0) *proto = IPPROTO_IDP; /* fake proto type */
 	else if(strncmp(pipport, "wss:",4) == 0) *proto = IPPROTO_IDP; /* fake proto type */
 #ifdef USE_SCTP
 #ifdef USE_SCTP
 	else if(strncmp(pipport, "sctp:",5) == 0) cutlen = 5, *proto = IPPROTO_SCTP;
 	else if(strncmp(pipport, "sctp:",5) == 0) cutlen = 5, *proto = IPPROTO_SCTP;

+ 2 - 3
modules/topos/tps_storage.c

@@ -298,9 +298,8 @@ int tps_storage_link_msg(sip_msg_t *msg, tps_data_t *td, int dir)
 
 
 	/* extract the contact address */
 	/* extract the contact address */
 	if(parse_headers(msg, HDR_CONTACT_F, 0)<0 || msg->contact==NULL) {
 	if(parse_headers(msg, HDR_CONTACT_F, 0)<0 || msg->contact==NULL) {
-		if(td->s_method_id == METHOD_MESSAGE
-				|| td->s_method_id == METHOD_OPTIONS) {
-			/* no contact required for MESSAGE - done */
+		if(td->s_method_id != METHOD_INVITE) {
+			/* no mandatory contact unless is INVITE - done */
 			return 0;
 			return 0;
 		}
 		}
 		LM_ERR("bad sip message or missing Contact hdr\n");
 		LM_ERR("bad sip message or missing Contact hdr\n");

+ 28 - 6
modules/uri_db/README

@@ -41,7 +41,8 @@ Bogdan-Andrei Iancu
 
 
               4.1. check_to()
               4.1. check_to()
               4.2. check_from()
               4.2. check_from()
-              4.3. does_uri_exist()
+              4.3. check_uri(uri)
+              4.4. does_uri_exist()
 
 
    List of Examples
    List of Examples
 
 
@@ -54,7 +55,8 @@ Bogdan-Andrei Iancu
    1.7. Set use_domain parameter
    1.7. Set use_domain parameter
    1.8. check_to usage
    1.8. check_to usage
    1.9. check_from usage
    1.9. check_from usage
-   1.10. does_uri_exist usage
+   1.10. check_uri usage
+   1.11. does_uri_exist usage
 
 
 Chapter 1. Admin Guide
 Chapter 1. Admin Guide
 
 
@@ -80,7 +82,8 @@ Chapter 1. Admin Guide
 
 
         4.1. check_to()
         4.1. check_to()
         4.2. check_from()
         4.2. check_from()
-        4.3. does_uri_exist()
+        4.3. check_uri(uri)
+        4.4. does_uri_exist()
 
 
 1. Overview
 1. Overview
 
 
@@ -204,7 +207,8 @@ modparam("uri_db", "use_domain", 1)
 
 
    4.1. check_to()
    4.1. check_to()
    4.2. check_from()
    4.2. check_from()
-   4.3. does_uri_exist()
+   4.3. check_uri(uri)
+   4.4. does_uri_exist()
 
 
 4.1.  check_to()
 4.1.  check_to()
 
 
@@ -234,7 +238,25 @@ if (check_from()) {
 };
 };
 ...
 ...
 
 
-4.3.  does_uri_exist()
+4.3.  check_uri(uri)
+
+   Check the username from the given uri against URI table (if
+   use_uri_table is set) or digest credentials (no DB backend required).
+
+   Description of parameters:
+     * uri Has to be a valid SIP URI, used to extract the username from.
+       The parameter can be a static or dynamic (with variables) string.
+
+   This function can be used from REQUEST_ROUTE.
+
+   Example 1.10. check_uri usage
+...
+if (check_uri("$var(uri)")) {
+        ...
+};
+...
+
+4.4.  does_uri_exist()
 
 
    Check if username in the request URI belongs to an existing user.
    Check if username in the request URI belongs to an existing user.
 
 
@@ -243,7 +265,7 @@ if (check_from()) {
 
 
    This function can be used from REQUEST_ROUTE.
    This function can be used from REQUEST_ROUTE.
 
 
-   Example 1.10. does_uri_exist usage
+   Example 1.11. does_uri_exist usage
 ...
 ...
 if (does_uri_exist()) {
 if (does_uri_exist()) {
         ...
         ...

+ 25 - 0
modules/uri_db/checks.c

@@ -29,6 +29,7 @@
 #include "../../parser/parse_uri.h"
 #include "../../parser/parse_uri.h"
 #include "../../ut.h"                   /* Handy utilities */
 #include "../../ut.h"                   /* Handy utilities */
 #include "../../lib/srdb1/db.h"                /* Database API */
 #include "../../lib/srdb1/db.h"                /* Database API */
+#include "../../mod_fix.h"
 #include "uri_db.h"
 #include "uri_db.h"
 #include "checks.h"
 #include "checks.h"
 
 
@@ -172,6 +173,30 @@ int check_from(struct sip_msg* _m, char* _s1, char* _s2)
 }
 }
 
 
 
 
+/*
+ *
+ */
+int check_uri(struct sip_msg* msg, char* uri, char* _s2)
+{
+    str suri;
+    struct sip_uri parsed_uri;
+
+    if (fixup_get_svalue(msg, (gparam_t*)uri, &suri) != 0)
+    {
+        ERR("cannot get uri value\n");
+        return -1;
+    }
+
+    if (parse_uri(suri.s, suri.len, &parsed_uri) != 0)
+    {
+        ERR("Error while parsing URI\n");
+        return -1;
+    }
+
+    return check_username(msg, &parsed_uri);
+}
+
+
 /*
 /*
  * Check if uri belongs to a local user
  * Check if uri belongs to a local user
  */
  */

+ 6 - 0
modules/uri_db/checks.h

@@ -42,6 +42,12 @@ int check_to(struct sip_msg* _msg, char* _str1, char* _str2);
 int check_from(struct sip_msg* _msg, char* _str1, char* _str2);
 int check_from(struct sip_msg* _msg, char* _str1, char* _str2);
 
 
 
 
+/*
+ *
+ */
+int check_uri(struct sip_msg* msg, char* uri, char* _s2);
+
+
 /*
 /*
  * Check if uri belongs to a local user, contributed by Juha Heinanen
  * Check if uri belongs to a local user, contributed by Juha Heinanen
  */
  */

+ 32 - 0
modules/uri_db/doc/uri_db_admin.xml

@@ -253,6 +253,38 @@ if (check_from()) {
 		</example>
 		</example>
 	</section>
 	</section>
 
 
+	<section id="uri_db.f.check_uri">
+		<title>
+			<function moreinfo="none">check_uri(uri)</function>
+		</title>
+		<para>
+			Check the username from the given uri against &uri; table (if use_uri_table is set) or
+			digest credentials (no DB backend required).
+		</para>
+        <para>Description of parameters:</para>
+        <itemizedlist>
+            <listitem>
+                <para><emphasis>uri</emphasis> Has to be a valid SIP URI,
+                    used to extract the username from. The parameter can be
+                    a static or dynamic (with variables) string.
+                </para>
+            </listitem>
+        </itemizedlist>
+		<para>
+			This function can be used from REQUEST_ROUTE.
+		</para>
+		<example>
+			<title><function>check_uri</function> usage</title>
+			<programlisting format="linespecific">
+...
+if (check_uri("$var(uri)")) {
+	...
+};
+...
+</programlisting>
+		</example>
+	</section>
+
 	<section id="uri_db.f.does_uri_exist">
 	<section id="uri_db.f.does_uri_exist">
 		<title>
 		<title>
 		<function moreinfo="none">does_uri_exist()</function>
 		<function moreinfo="none">does_uri_exist()</function>

+ 3 - 0
modules/uri_db/uri_db.c

@@ -30,6 +30,7 @@
 #include "../../ut.h"
 #include "../../ut.h"
 #include "../../error.h"
 #include "../../error.h"
 #include "../../mem/mem.h"
 #include "../../mem/mem.h"
+#include "../../mod_fix.h"
 #include "uri_db.h"
 #include "uri_db.h"
 #include "checks.h"
 #include "checks.h"
 
 
@@ -78,6 +79,8 @@ static cmd_export_t cmds[] = {
 		REQUEST_ROUTE},
 		REQUEST_ROUTE},
 	{"check_from",     (cmd_function)check_from,     0, 0, 0,
 	{"check_from",     (cmd_function)check_from,     0, 0, 0,
 		REQUEST_ROUTE},
 		REQUEST_ROUTE},
+	{"check_uri",      (cmd_function)check_uri,      1, fixup_spve_null, 0,
+        REQUEST_ROUTE},
 	{"does_uri_exist", (cmd_function)does_uri_exist, 0, 0, fixup_exist,
 	{"does_uri_exist", (cmd_function)does_uri_exist, 0, 0, fixup_exist,
 		REQUEST_ROUTE|LOCAL_ROUTE},
 		REQUEST_ROUTE|LOCAL_ROUTE},
 	{0, 0, 0, 0, 0, 0}
 	{0, 0, 0, 0, 0, 0}

+ 3 - 2
modules/xmpp/sha.c

@@ -49,6 +49,7 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <fcntl.h>
 #include <fcntl.h>
 #include <string.h>
 #include <string.h>
+#include "../../endianness.h"
 
 
 #ifndef MACOS
 #ifndef MACOS
 #  include <sys/stat.h>
 #  include <sys/stat.h>
@@ -104,7 +105,7 @@ sha_hash(int *data, int *hash)
 
 
   for (t=0; t<16; t++) 
   for (t=0; t<16; t++) 
     {
     {
-#ifndef WORDS_BIGENDIAN
+#ifndef __IS_BIG_ENDIAN
       W[t]=switch_endianness(data[t]);
       W[t]=switch_endianness(data[t]);
 #else 
 #else 
       W[t]=data[t];
       W[t]=data[t];
@@ -244,7 +245,7 @@ char *shahash(const char *str)
 				for (i=0; i<14; i++) 
 				for (i=0; i<14; i++) 
 					((int*)read_buffer)[i]=0;
 					((int*)read_buffer)[i]=0;
 			}      
 			}      
-#ifndef WORDS_BIGENDIAN
+#ifndef __IS_BIG_ENDIAN
 			for (i=0; i<8; i++) 
 			for (i=0; i<8; i++) 
 			{
 			{
 				read_buffer[56+i]=(char)(length>>(56-(i*8))) & 0xff;
 				read_buffer[56+i]=(char)(length>>(56-(i*8))) & 0xff;

+ 1 - 0
parser/hf.c

@@ -215,6 +215,7 @@ void free_hdr_field_lst(struct hdr_field* hf)
 		hf=hf->next;
 		hf=hf->next;
 		clean_hdr_field(foo);
 		clean_hdr_field(foo);
 		pkg_free(foo);
 		pkg_free(foo);
+		foo = 0;
 	}
 	}
 }
 }
 
 

+ 17 - 21
parser/parse_disposition.c

@@ -52,6 +52,11 @@ int parse_disposition( str *s, struct disposition *disp)
 	char *tmp;
 	char *tmp;
 	char *end;
 	char *end;
 
 
+	if(s==NULL || s->s==NULL || s->len<=0) {
+		LM_ERR("invalid parameters\n");
+		return -1;
+	}
+
 	state = saved_state = FIND_TYPE;
 	state = saved_state = FIND_TYPE;
 	end = s->s + s->len;
 	end = s->s + s->len;
 	disp_p = 0;
 	disp_p = 0;
@@ -114,8 +119,7 @@ int parse_disposition( str *s, struct disposition *disp)
 						state=F_CRLF;
 						state=F_CRLF;
 						break;
 						break;
 					default:
 					default:
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
-							"char [%c] in status %d: <<%.*s>> .\n",
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
 							*tmp,state, (int)(tmp-s->s), s->s);
 							*tmp,state, (int)(tmp-s->s), s->s);
 						goto error;
 						goto error;
 				}
 				}
@@ -143,15 +147,13 @@ int parse_disposition( str *s, struct disposition *disp)
 						state=F_CR;
 						state=F_CR;
 						break;
 						break;
 					default:
 					default:
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
-							"char [%c] in status %d: <<%.*s>> .\n",
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
 			case 0:
 			case 0:
-				LOG(L_ERR,"ERROR:parse_disposition: unexpected "
-					"char [%c] in status %d: <<%.*s>> .\n",
+				LM_ERR("nexpected char [%c] in status %d: <<%.*s>>.\n",
 					*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 					*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 				goto error;
 				goto error;
 				break;
 				break;
@@ -180,8 +182,7 @@ int parse_disposition( str *s, struct disposition *disp)
 						state = FIND_PARAM;
 						state = FIND_PARAM;
 						break;
 						break;
 					default:
 					default:
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
-							"char [%c] in status %d: <<%.*s>> .\n",
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 						goto error;
 						goto error;
 				}
 				}
@@ -202,8 +203,7 @@ int parse_disposition( str *s, struct disposition *disp)
 						state = FIND_VAL;
 						state = FIND_VAL;
 						break;
 						break;
 					default:
 					default:
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
-							"char [%c] in status %d: <<%.*s>> .\n",
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 						goto error;
 						goto error;
 				}
 				}
@@ -222,8 +222,7 @@ int parse_disposition( str *s, struct disposition *disp)
 						state = END_VAL;
 						state = END_VAL;
 						break;
 						break;
 					default:
 					default:
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
-							"char [%c] in status %d: <<%.*s>> .\n",
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 						goto error;
 						goto error;
 				}
 				}
@@ -241,8 +240,7 @@ int parse_disposition( str *s, struct disposition *disp)
 						state = SKIP_QUOTED_VAL;
 						state = SKIP_QUOTED_VAL;
 						break;
 						break;
 					default:
 					default:
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
-							"char [%c] in status %d: <<%.*s>> .\n",
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 						goto error;
 						goto error;
 				}
 				}
@@ -270,8 +268,7 @@ int parse_disposition( str *s, struct disposition *disp)
 					case QUOTED_VAL:
 					case QUOTED_VAL:
 						break;
 						break;
 					default:
 					default:
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
-							"char [%c] in status %d: <<%.*s>> .\n",
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
 						goto error;
 						goto error;
 				}
 				}
@@ -290,8 +287,7 @@ int parse_disposition( str *s, struct disposition *disp)
 						new_p=(struct disposition_param*)pkg_malloc
 						new_p=(struct disposition_param*)pkg_malloc
 							(sizeof(struct disposition_param));
 							(sizeof(struct disposition_param));
 						if (new_p==0) {
 						if (new_p==0) {
-							LOG(L_ERR,"ERROR:parse_disposition: no more "
-								"pkg mem\n");
+							LM_ERR("no more pkg mem\n");
 							goto error;
 							goto error;
 						}
 						}
 						memset(new_p,0,sizeof(struct disposition_param));
 						memset(new_p,0,sizeof(struct disposition_param));
@@ -331,7 +327,7 @@ int parse_disposition( str *s, struct disposition *disp)
 			disp_p->body.len = tmp - disp_p->body.s;
 			disp_p->body.len = tmp - disp_p->body.s;
 			break;
 			break;
 		default:
 		default:
-			LOG(L_ERR,"ERROR:parse_disposition: wrong final state (%d)\n",
+			LM_ERR("wrong final state (%d)\n",
 				state);
 				state);
 			goto error;
 			goto error;
 	}
 	}
@@ -375,7 +371,7 @@ int parse_content_disposition( struct sip_msg *msg )
 		if (parse_headers(msg, HDR_CONTENTDISPOSITION_F, 0)==-1)
 		if (parse_headers(msg, HDR_CONTENTDISPOSITION_F, 0)==-1)
 			goto error;
 			goto error;
 		if (msg->content_disposition==0) {
 		if (msg->content_disposition==0) {
-			DBG("DEBUG:parse_content_disposition: hdr not found\n");
+			DBG("hdr not found\n");
 			return 1;
 			return 1;
 		}
 		}
 	}
 	}
@@ -389,7 +385,7 @@ int parse_content_disposition( struct sip_msg *msg )
 	/* parse the body */
 	/* parse the body */
 	disp = (struct disposition*)pkg_malloc(sizeof(struct disposition));
 	disp = (struct disposition*)pkg_malloc(sizeof(struct disposition));
 	if (disp==0) {
 	if (disp==0) {
-		LOG(L_ERR,"ERROR:parse_content_disposition: no more pkg memory\n");
+		LM_ERR("no more pkg memory\n");
 		goto error;
 		goto error;
 	}
 	}
 	memset(disp,0,sizeof(struct disposition));
 	memset(disp,0,sizeof(struct disposition));

+ 6 - 0
pkg/kamailio/deb/debian/changelog

@@ -1,3 +1,9 @@
+kamailio (5.0.0~dev6) unstable; urgency=medium
+
+  * version set to 5.0.0-dev6
+
+ -- Victor Seva <[email protected]>  Mon, 29 Aug 2016 11:36:17 +0200
+
 kamailio (5.0.0~dev5) unstable; urgency=medium
 kamailio (5.0.0~dev5) unstable; urgency=medium
 
 
   * version set to 5.0.0-dev5
   * version set to 5.0.0-dev5

+ 6 - 0
pkg/kamailio/deb/jessie/changelog

@@ -1,3 +1,9 @@
+kamailio (5.0.0~dev6) unstable; urgency=medium
+
+  * version set to 5.0.0-dev6
+
+ -- Victor Seva <[email protected]>  Mon, 29 Aug 2016 11:36:17 +0200
+
 kamailio (5.0.0~dev5) unstable; urgency=medium
 kamailio (5.0.0~dev5) unstable; urgency=medium
 
 
   * version set to 5.0.0-dev5
   * version set to 5.0.0-dev5

+ 6 - 0
pkg/kamailio/deb/precise/changelog

@@ -1,3 +1,9 @@
+kamailio (5.0.0~dev6) unstable; urgency=medium
+
+  * version set to 5.0.0-dev6
+
+ -- Victor Seva <[email protected]>  Mon, 29 Aug 2016 11:36:17 +0200
+
 kamailio (5.0.0~dev5) unstable; urgency=medium
 kamailio (5.0.0~dev5) unstable; urgency=medium
 
 
   * version set to 5.0.0-dev5
   * version set to 5.0.0-dev5

+ 6 - 0
pkg/kamailio/deb/sid/changelog

@@ -1,3 +1,9 @@
+kamailio (5.0.0~dev6) unstable; urgency=medium
+
+  * version set to 5.0.0-dev6
+
+ -- Victor Seva <[email protected]>  Mon, 29 Aug 2016 11:36:17 +0200
+
 kamailio (5.0.0~dev5) unstable; urgency=medium
 kamailio (5.0.0~dev5) unstable; urgency=medium
 
 
   * version set to 5.0.0-dev5
   * version set to 5.0.0-dev5

+ 6 - 0
pkg/kamailio/deb/squeeze/changelog

@@ -1,3 +1,9 @@
+kamailio (5.0.0~dev6) unstable; urgency=medium
+
+  * version set to 5.0.0-dev6
+
+ -- Victor Seva <[email protected]>  Mon, 29 Aug 2016 11:36:17 +0200
+
 kamailio (5.0.0~dev5) unstable; urgency=medium
 kamailio (5.0.0~dev5) unstable; urgency=medium
 
 
   * version set to 5.0.0-dev5
   * version set to 5.0.0-dev5

+ 6 - 0
pkg/kamailio/deb/stretch/changelog

@@ -1,3 +1,9 @@
+kamailio (5.0.0~dev6) unstable; urgency=medium
+
+  * version set to 5.0.0-dev6
+
+ -- Victor Seva <[email protected]>  Mon, 29 Aug 2016 11:36:17 +0200
+
 kamailio (5.0.0~dev5) unstable; urgency=medium
 kamailio (5.0.0~dev5) unstable; urgency=medium
 
 
   * version set to 5.0.0-dev5
   * version set to 5.0.0-dev5

+ 6 - 0
pkg/kamailio/deb/trusty/changelog

@@ -1,3 +1,9 @@
+kamailio (5.0.0~dev6) unstable; urgency=medium
+
+  * version set to 5.0.0-dev6
+
+ -- Victor Seva <[email protected]>  Mon, 29 Aug 2016 11:36:17 +0200
+
 kamailio (5.0.0~dev5) unstable; urgency=medium
 kamailio (5.0.0~dev5) unstable; urgency=medium
 
 
   * version set to 5.0.0-dev5
   * version set to 5.0.0-dev5

+ 6 - 0
pkg/kamailio/deb/wheezy/changelog

@@ -1,3 +1,9 @@
+kamailio (5.0.0~dev6) unstable; urgency=medium
+
+  * version set to 5.0.0-dev6
+
+ -- Victor Seva <[email protected]>  Mon, 29 Aug 2016 11:36:17 +0200
+
 kamailio (5.0.0~dev5) unstable; urgency=medium
 kamailio (5.0.0~dev5) unstable; urgency=medium
 
 
   * version set to 5.0.0-dev5
   * version set to 5.0.0-dev5

+ 5 - 7
tcp_read.c

@@ -287,11 +287,10 @@ again:
 						}
 						}
 				}
 				}
 				LOG(cfg_get(core, core_cfg, corelog),
 				LOG(cfg_get(core, core_cfg, corelog),
-						"error reading: %s (%d) ([%s]:%u -> [%s]:%u)\n",
+						"error reading: %s (%d) ([%s]:%u ->",
 						strerror(errno), errno,
 						strerror(errno), errno,
-						ip_addr2a(&c->rcv.src_ip), c->rcv.src_port,
-						ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port);
-
+						ip_addr2a(&c->rcv.src_ip), c->rcv.src_port);
+				LOG(cfg_get(core, core_cfg, corelog),"-> [%s]:%u)\n", ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port);
 				if((errno == ECONNRESET || errno == ETIMEDOUT) && likely(c->rcv.proto_reserved1 != 0)){
 				if((errno == ECONNRESET || errno == ETIMEDOUT) && likely(c->rcv.proto_reserved1 != 0)){
 					tcp_make_closed_event(&c->rcv, c);
 					tcp_make_closed_event(&c->rcv, c);
 				}
 				}
@@ -305,9 +304,8 @@ again:
 			if (likely(c->rcv.proto_reserved1 != 0)){
 			if (likely(c->rcv.proto_reserved1 != 0)){
 				tcp_make_closed_event(&c->rcv, c);
 				tcp_make_closed_event(&c->rcv, c);
 			}
 			}
-			LM_DBG("EOF on %p, FD %d ([%s]:%u -> [%s]:%u)\n", c, fd,
-					ip_addr2a(&c->rcv.src_ip), c->rcv.src_port,
-					ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port);
+			LM_DBG("EOF on %p, FD %d ([%s]:%u ->", c, fd, ip_addr2a(&c->rcv.src_ip), c->rcv.src_port);
+			LM_DBG("-> [%s]:%u)\n", ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port);
 		}else{
 		}else{
 			if (unlikely(c->state==S_CONN_CONNECT || c->state==S_CONN_ACCEPT)){
 			if (unlikely(c->state==S_CONN_CONNECT || c->state==S_CONN_ACCEPT)){
 				TCP_STATS_ESTABLISHED(c->state);
 				TCP_STATS_ESTABLISHED(c->state);

+ 0 - 0
utils/kamctl/mysql/dialog_ng-create.sql → utils/kamctl/mysql/ims_dialog-create.sql