mirror of https://github.com/sipwise/kamailio.git
Change-Id: I21163f128b0648131309fdd5d303d788eb1a5a47changes/46/5646/1
parent
02caa1f63d
commit
20120d45e1
@ -1,31 +0,0 @@
|
||||
From 160a9ae1f9bbd3451911a3a19f271142f8f6c98d Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Tue, 7 Jul 2015 13:04:00 +0200
|
||||
Subject: [PATCH] dmq_usrloc: update get_all_ucontacts API request
|
||||
|
||||
Fixes: #236
|
||||
(cherry picked from commit 733fd5daf74963b152a2964f9eea1a6fff91858a)
|
||||
---
|
||||
modules/dmq_usrloc/usrloc_sync.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/modules/dmq_usrloc/usrloc_sync.c
|
||||
+++ b/modules/dmq_usrloc/usrloc_sync.c
|
||||
@@ -152,7 +152,7 @@
|
||||
goto done;
|
||||
}
|
||||
|
||||
- rval = dmq_ul.get_all_ucontacts(buf, len, 0, 0, 1);
|
||||
+ rval = dmq_ul.get_all_ucontacts(buf, len, 0, 0, 1, 0);
|
||||
if (rval<0) {
|
||||
LM_ERR("failed to fetch contacts\n");
|
||||
goto done;
|
||||
@@ -166,7 +166,7 @@
|
||||
LM_ERR("out of pkg memory\n");
|
||||
goto done;
|
||||
}
|
||||
- rval = dmq_ul.get_all_ucontacts(buf, len, 0, 0, 1);
|
||||
+ rval = dmq_ul.get_all_ucontacts(buf, len, 0, 0, 1, 0);
|
||||
if (rval != 0) {
|
||||
pkg_free(buf);
|
||||
goto done;
|
@ -1,144 +0,0 @@
|
||||
From 039231a3b61c00fe36e868417144daa9f04936ba Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Sat, 4 Jul 2015 08:08:08 +0200
|
||||
Subject: [PATCH] usrloc: support filter by server_id at get_all_ucontacts
|
||||
|
||||
---
|
||||
modules/usrloc/dlist.c | 33 +++++++++++++++++++++++++--------
|
||||
modules/usrloc/dlist.h | 3 ++-
|
||||
modules/usrloc/usrloc.h | 4 +++-
|
||||
3 files changed, 30 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/modules/usrloc/dlist.c b/modules/usrloc/dlist.c
|
||||
index 1a95cc6..1081aad 100644
|
||||
--- a/modules/usrloc/dlist.c
|
||||
+++ b/modules/usrloc/dlist.c
|
||||
@@ -85,10 +85,12 @@ static inline int find_dlist(str* _n, dlist_t** _d)
|
||||
* \param flags contact flags
|
||||
* \param part_idx part index
|
||||
* \param part_max maximal part
|
||||
+ * \param GAU options
|
||||
* \return 0 on success, positive if buffer size was not sufficient, negative on failure
|
||||
*/
|
||||
static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
|
||||
- unsigned int part_idx, unsigned int part_max)
|
||||
+ unsigned int part_idx, unsigned int part_max,
|
||||
+ int options)
|
||||
{
|
||||
struct socket_info *sock;
|
||||
unsigned int dbflags;
|
||||
@@ -108,9 +110,9 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
|
||||
int i;
|
||||
void *cp;
|
||||
int shortage, needed;
|
||||
- db_key_t keys1[3]; /* where */
|
||||
- db_val_t vals1[3];
|
||||
- db_op_t ops1[3];
|
||||
+ db_key_t keys1[4]; /* where */
|
||||
+ db_val_t vals1[4];
|
||||
+ db_op_t ops1[4];
|
||||
db_key_t keys2[6]; /* select */
|
||||
int n[2] = {2,6}; /* number of dynamic values used on key1/key2 */
|
||||
|
||||
@@ -160,6 +162,14 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
|
||||
vals1[n[0]].val.int_val = 1;
|
||||
n[0]++;
|
||||
}
|
||||
+ if(options&GAU_OPT_SERVER_ID) {
|
||||
+ keys1[n[0]] = &srv_id_col;
|
||||
+ ops1[n[0]] = OP_EQ;
|
||||
+ vals1[n[0]].type = DB1_INT;
|
||||
+ vals1[n[0]].nul = 0;
|
||||
+ vals1[n[0]].val.int_val = server_id;
|
||||
+ n[0]++;
|
||||
+ }
|
||||
|
||||
/* TODO: use part_idx and part_max on keys1 */
|
||||
|
||||
@@ -323,10 +333,12 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
|
||||
* \param flags contact flags
|
||||
* \param part_idx part index
|
||||
* \param part_max maximal part
|
||||
+ * \param GAU options
|
||||
* \return 0 on success, positive if buffer size was not sufficient, negative on failure
|
||||
*/
|
||||
static inline int get_all_mem_ucontacts(void *buf, int len, unsigned int flags,
|
||||
- unsigned int part_idx, unsigned int part_max)
|
||||
+ unsigned int part_idx, unsigned int part_max,
|
||||
+ int options)
|
||||
{
|
||||
dlist_t *p;
|
||||
urecord_t *r;
|
||||
@@ -370,6 +382,9 @@ static inline int get_all_mem_ucontacts(void *buf, int len, unsigned int flags,
|
||||
if ((c->cflags & flags) != flags)
|
||||
continue;
|
||||
|
||||
+ if(options&GAU_OPT_SERVER_ID && server_id!=c->server_id)
|
||||
+ continue;
|
||||
+
|
||||
if(ul_keepalive_timeout>0 && c->last_keepalive>0)
|
||||
{
|
||||
if(c->sock!=NULL && c->sock->proto==PROTO_UDP)
|
||||
@@ -468,15 +483,17 @@ static inline int get_all_mem_ucontacts(void *buf, int len, unsigned int flags,
|
||||
* \param flags contact flags
|
||||
* \param part_idx part index
|
||||
* \param part_max maximal part
|
||||
+ * \param GAU options
|
||||
* \return 0 on success, positive if buffer size was not sufficient, negative on failure
|
||||
*/
|
||||
int get_all_ucontacts(void *buf, int len, unsigned int flags,
|
||||
- unsigned int part_idx, unsigned int part_max)
|
||||
+ unsigned int part_idx, unsigned int part_max,
|
||||
+ int options)
|
||||
{
|
||||
if (db_mode==DB_ONLY)
|
||||
- return get_all_db_ucontacts( buf, len, flags, part_idx, part_max);
|
||||
+ return get_all_db_ucontacts( buf, len, flags, part_idx, part_max, options);
|
||||
else
|
||||
- return get_all_mem_ucontacts( buf, len, flags, part_idx, part_max);
|
||||
+ return get_all_mem_ucontacts( buf, len, flags, part_idx, part_max, options);
|
||||
}
|
||||
|
||||
|
||||
diff --git a/modules/usrloc/dlist.h b/modules/usrloc/dlist.h
|
||||
index 9b8b84c..a210996 100644
|
||||
--- a/modules/usrloc/dlist.h
|
||||
+++ b/modules/usrloc/dlist.h
|
||||
@@ -109,10 +109,11 @@ int synchronize_all_udomains(int istart, int istep);
|
||||
* \param flags contact flags
|
||||
* \param part_idx part index
|
||||
* \param part_max maximal part
|
||||
+ * \param GAU options
|
||||
* \return 0 on success, positive if buffer size was not sufficient, negative on failure
|
||||
*/
|
||||
int get_all_ucontacts(void *buf, int len, unsigned int flags,
|
||||
- unsigned int part_idx, unsigned int part_max);
|
||||
+ unsigned int part_idx, unsigned int part_max, int options);
|
||||
|
||||
|
||||
/*!
|
||||
diff --git a/modules/usrloc/usrloc.h b/modules/usrloc/usrloc.h
|
||||
index 5688e8c..4425a06 100644
|
||||
--- a/modules/usrloc/usrloc.h
|
||||
+++ b/modules/usrloc/usrloc.h
|
||||
@@ -40,6 +40,8 @@
|
||||
#define DB_ONLY 3
|
||||
#define DB_READONLY 4
|
||||
|
||||
+#define GAU_OPT_SERVER_ID (1<<0) /* filter query by server_id */
|
||||
+
|
||||
/*forward declaration necessary for udomain*/
|
||||
|
||||
struct udomain;
|
||||
@@ -181,7 +183,7 @@ typedef void (*unlock_udomain_t)(struct udomain* _d, str *_aor);
|
||||
typedef int (*register_udomain_t)(const char* _n, struct udomain** _d);
|
||||
|
||||
typedef int (*get_all_ucontacts_t) (void* buf, int len, unsigned int flags,
|
||||
- unsigned int part_idx, unsigned int part_max);
|
||||
+ unsigned int part_idx, unsigned int part_max, int options);
|
||||
|
||||
typedef int (*get_udomain_t)(const char* _n, udomain_t** _d);
|
||||
|
||||
--
|
||||
2.1.4
|
||||
|
@ -1,92 +0,0 @@
|
||||
From aedd970a97fef3e00c9e490e458f6f9af19df4d2 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Sat, 4 Jul 2015 09:43:41 +0200
|
||||
Subject: [PATCH] usrloc: add module option to support preload using server_id
|
||||
as filter
|
||||
|
||||
---
|
||||
modules/usrloc/udomain.c | 26 ++++++++++++++++++++++----
|
||||
modules/usrloc/ul_mod.c | 4 +++-
|
||||
modules/usrloc/ul_mod.h | 2 ++
|
||||
3 files changed, 27 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/modules/usrloc/udomain.c
|
||||
+++ b/modules/usrloc/udomain.c
|
||||
@@ -379,6 +379,9 @@
|
||||
db_row_t *row;
|
||||
db_key_t columns[21];
|
||||
db1_res_t* res = NULL;
|
||||
+ db_key_t keys[1]; /* where */
|
||||
+ db_val_t vals[1];
|
||||
+ db_op_t ops[1];
|
||||
str user, contact;
|
||||
char* domain;
|
||||
int i;
|
||||
@@ -418,9 +421,21 @@
|
||||
LM_NOTICE("load start time [%d]\n", (int)time(NULL));
|
||||
#endif
|
||||
|
||||
+ if (ul_db_srvid) {
|
||||
+ LM_NOTICE("filtered by server_id[%d]\n", server_id);
|
||||
+ keys[0] = &srv_id_col;
|
||||
+ ops[0] = OP_EQ;
|
||||
+ vals[0].type = DB1_INT;
|
||||
+ vals[0].nul = 0;
|
||||
+ vals[0].val.int_val = server_id;
|
||||
+ }
|
||||
+
|
||||
if (DB_CAPABILITY(ul_dbf, DB_CAP_FETCH)) {
|
||||
- if (ul_dbf.query(_c, 0, 0, 0, columns, 0, (use_domain)?(21):(20), 0,
|
||||
- 0) < 0) {
|
||||
+ if (ul_dbf.query(_c, (ul_db_srvid)?(keys):(0),
|
||||
+ (ul_db_srvid)?(ops):(0), (ul_db_srvid)?(vals):(0),
|
||||
+ columns, (ul_db_srvid)?(1):(0),
|
||||
+ (use_domain)?(21):(20), 0, 0) < 0)
|
||||
+ {
|
||||
LM_ERR("db_query (1) failed\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -429,8 +444,11 @@
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
- if (ul_dbf.query(_c, 0, 0, 0, columns, 0, (use_domain)?(21):(20), 0,
|
||||
- &res) < 0) {
|
||||
+ if (ul_dbf.query(_c, (ul_db_srvid)?(keys):(0),
|
||||
+ (ul_db_srvid)?(ops):(0), (ul_db_srvid)?(vals):(0),
|
||||
+ columns, (ul_db_srvid)?(1):(0),
|
||||
+ (use_domain)?(21):(20), 0, &res) < 0)
|
||||
+ {
|
||||
LM_ERR("db_query failed\n");
|
||||
return -1;
|
||||
}
|
||||
--- a/modules/usrloc/ul_mod.c
|
||||
+++ b/modules/usrloc/ul_mod.c
|
||||
@@ -177,6 +177,8 @@
|
||||
db1_con_t* ul_dbh_ro = 0; /* Read-Only Database connection handle */
|
||||
db_func_t ul_dbf_ro;
|
||||
|
||||
+/* filter on load by server id */
|
||||
+unsigned int ul_db_srvid = 0;
|
||||
|
||||
/*! \brief
|
||||
* Exported functions
|
||||
@@ -233,6 +235,7 @@
|
||||
{"expires_type", PARAM_INT, &ul_expires_type},
|
||||
{"db_raw_fetch_type", PARAM_INT, &ul_db_raw_fetch_type},
|
||||
{"db_insert_null", PARAM_INT, &ul_db_insert_null},
|
||||
+ {"server_id_filter", PARAM_INT, &ul_db_srvid},
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
--- a/modules/usrloc/ul_mod.h
|
||||
+++ b/modules/usrloc/ul_mod.h
|
||||
@@ -87,6 +87,8 @@
|
||||
extern int handle_lost_tcp;
|
||||
extern int close_expired_tcp;
|
||||
|
||||
+/* filter on load by server id */
|
||||
+extern unsigned int ul_db_srvid;
|
||||
|
||||
/*! nat branch flag */
|
||||
extern unsigned int nat_bflag;
|
@ -1,63 +0,0 @@
|
||||
From 894796f6f1fa2d2778ace5c56f58d204ea06efc2 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Thu, 2 Apr 2015 16:27:23 +0200
|
||||
Subject: [PATCH] nathelper: support filter contacts by server_id
|
||||
|
||||
---
|
||||
modules/nathelper/nathelper.c | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/modules/nathelper/nathelper.c b/modules/nathelper/nathelper.c
|
||||
index f6791db..5f20a5f 100644
|
||||
--- a/modules/nathelper/nathelper.c
|
||||
+++ b/modules/nathelper/nathelper.c
|
||||
@@ -358,7 +358,8 @@ static unsigned int raw_ip = 0;
|
||||
static unsigned short raw_port = 0;
|
||||
static int nh_keepalive_timeout = 0;
|
||||
static request_method_t sipping_method_id = 0;
|
||||
-
|
||||
+/* filter contacts by server_id */
|
||||
+static int nh_filter_srvid = 0;
|
||||
|
||||
/*0-> disabled, 1 ->enabled*/
|
||||
unsigned int *natping_state=0;
|
||||
@@ -426,6 +427,7 @@ static param_export_t params[] = {
|
||||
{"keepalive_timeout", INT_PARAM, &nh_keepalive_timeout },
|
||||
{"udpping_from_path", INT_PARAM, &udpping_from_path },
|
||||
{"append_sdp_oldmediaip", INT_PARAM, &sdp_oldmediaip },
|
||||
+ {"filter_server_id", INT_PARAM, &nh_filter_srvid },
|
||||
|
||||
{0, 0, 0}
|
||||
};
|
||||
@@ -2067,6 +2069,7 @@ nh_timer(unsigned int ticks, void *timer_idx)
|
||||
char *path_ip_str = NULL;
|
||||
unsigned int path_ip = 0;
|
||||
unsigned short path_port = 0;
|
||||
+ int options = 0;
|
||||
|
||||
if((*natping_state) == 0)
|
||||
goto done;
|
||||
@@ -2079,9 +2082,10 @@ nh_timer(unsigned int ticks, void *timer_idx)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
+ if(nh_filter_srvid) options |= GAU_OPT_SERVER_ID;
|
||||
rval = ul.get_all_ucontacts(buf, cblen, (ping_nated_only?ul.nat_flag:0),
|
||||
((unsigned int)(unsigned long)timer_idx)*natping_interval+iteration,
|
||||
- natping_processes*natping_interval);
|
||||
+ natping_processes*natping_interval, options);
|
||||
if (rval<0) {
|
||||
LM_ERR("failed to fetch contacts\n");
|
||||
goto done;
|
||||
@@ -2097,7 +2101,7 @@ nh_timer(unsigned int ticks, void *timer_idx)
|
||||
}
|
||||
rval = ul.get_all_ucontacts(buf,cblen,(ping_nated_only?ul.nat_flag:0),
|
||||
((unsigned int)(unsigned long)timer_idx)*natping_interval+iteration,
|
||||
- natping_processes*natping_interval);
|
||||
+ natping_processes*natping_interval, options);
|
||||
if (rval != 0) {
|
||||
pkg_free(buf);
|
||||
goto done;
|
||||
--
|
||||
2.1.4
|
||||
|
@ -1,20 +0,0 @@
|
||||
From a1c218575281a3cee606e7e536e16a4f38017f08 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Thu, 10 Mar 2016 17:00:56 +0100
|
||||
Subject: [PATCH] db_mysql: change log level from WARN to DBG for ping checks
|
||||
|
||||
---
|
||||
modules/db_mysql/km_dbase.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/modules/db_mysql/km_dbase.c
|
||||
+++ b/modules/db_mysql/km_dbase.c
|
||||
@@ -81,7 +81,7 @@
|
||||
t = time(0);
|
||||
if ((t - CON_TIMESTAMP(_h)) > my_ping_interval) {
|
||||
if (mysql_ping(CON_CONNECTION(_h))) {
|
||||
- LM_WARN("driver error on ping: %s\n", mysql_error(CON_CONNECTION(_h)));
|
||||
+ LM_DBG("driver error on ping: %s\n", mysql_error(CON_CONNECTION(_h)));
|
||||
counter_inc(mysql_cnts_h.driver_err);
|
||||
}
|
||||
}
|
@ -1,902 +0,0 @@
|
||||
From dead28aa11df089e1110a531297d67a4dd583972 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Sat, 20 Jun 2015 13:37:04 +0200
|
||||
Subject: [PATCH] modules/debugger: move json related from debugger_api.c to
|
||||
debugger_json.c|h
|
||||
|
||||
---
|
||||
modules/debugger/debugger_api.c | 389 +----------------------------------
|
||||
modules/debugger/debugger_api.h | 2 +-
|
||||
modules/debugger/debugger_json.c | 423 +++++++++++++++++++++++++++++++++++++++
|
||||
modules/debugger/debugger_json.h | 32 +++
|
||||
modules/debugger/debugger_mod.c | 1 +
|
||||
5 files changed, 462 insertions(+), 385 deletions(-)
|
||||
create mode 100644 modules/debugger/debugger_json.c
|
||||
create mode 100644 modules/debugger/debugger_json.h
|
||||
|
||||
--- a/modules/debugger/debugger_api.c
|
||||
+++ b/modules/debugger/debugger_api.c
|
||||
@@ -27,20 +27,14 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../../dprint.h"
|
||||
-#include "../../ut.h"
|
||||
-#include "../../pt.h"
|
||||
#include "../../events.h"
|
||||
-#include "../../pvar.h"
|
||||
-#include "../../rpc.h"
|
||||
-#include "../../rpc_lookup.h"
|
||||
-#include "../../route_struct.h"
|
||||
-#include "../../mem/shm_mem.h"
|
||||
#include "../../locking.h"
|
||||
#include "../../lvalue.h"
|
||||
-#include "../../hashes.h"
|
||||
-#include "../../lib/srutils/srjson.h"
|
||||
-#include "../../xavp.h"
|
||||
-#include "../pv/pv_xavp.h"
|
||||
+#include "../../pt.h"
|
||||
+#include "../../route_struct.h"
|
||||
+#include "../../rpc.h"
|
||||
+#include "../../rpc_lookup.h"
|
||||
+#include "../../ut.h"
|
||||
|
||||
#include "debugger_act.h"
|
||||
#include "debugger_api.h"
|
||||
@@ -1432,376 +1426,3 @@
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
-
|
||||
-int _dbg_get_array_avp_vals(struct sip_msg *msg,
|
||||
- pv_param_t *param, srjson_doc_t *jdoc, srjson_t **jobj,
|
||||
- str *item_name)
|
||||
-{
|
||||
- struct usr_avp *avp;
|
||||
- unsigned short name_type;
|
||||
- int_str avp_name;
|
||||
- int_str avp_value;
|
||||
- struct search_state state;
|
||||
- srjson_t *jobjt;
|
||||
- memset(&state, 0, sizeof(struct search_state));
|
||||
-
|
||||
- if(pv_get_avp_name(msg, param, &avp_name, &name_type)!=0)
|
||||
- {
|
||||
- LM_ERR("invalid name\n");
|
||||
- return -1;
|
||||
- }
|
||||
- *jobj = srjson_CreateArray(jdoc);
|
||||
- if(*jobj==NULL)
|
||||
- {
|
||||
- LM_ERR("cannot create json object\n");
|
||||
- return -1;
|
||||
- }
|
||||
- if ((avp=search_first_avp(name_type, avp_name, &avp_value, &state))==0)
|
||||
- {
|
||||
- goto ok;
|
||||
- }
|
||||
- do
|
||||
- {
|
||||
- if(avp->flags & AVP_VAL_STR)
|
||||
- {
|
||||
- jobjt = srjson_CreateStr(jdoc, avp_value.s.s, avp_value.s.len);
|
||||
- if(jobjt==NULL)
|
||||
- {
|
||||
- LM_ERR("cannot create json object\n");
|
||||
- return -1;
|
||||
- }
|
||||
- } else {
|
||||
- jobjt = srjson_CreateNumber(jdoc, avp_value.n);
|
||||
- if(jobjt==NULL)
|
||||
- {
|
||||
- LM_ERR("cannot create json object\n");
|
||||
- return -1;
|
||||
- }
|
||||
- }
|
||||
- srjson_AddItemToArray(jdoc, *jobj, jobjt);
|
||||
- } while ((avp=search_next_avp(&state, &avp_value))!=0);
|
||||
-ok:
|
||||
- item_name->s = avp_name.s.s;
|
||||
- item_name->len = avp_name.s.len;
|
||||
- return 0;
|
||||
-}
|
||||
-#define DBG_XAVP_DUMP_SIZE 32
|
||||
-static str* _dbg_xavp_dump[DBG_XAVP_DUMP_SIZE];
|
||||
-int _dbg_xavp_dump_lookup(pv_param_t *param)
|
||||
-{
|
||||
- unsigned int i = 0;
|
||||
- pv_xavp_name_t *xname;
|
||||
-
|
||||
- if(param==NULL)
|
||||
- return -1;
|
||||
-
|
||||
- xname = (pv_xavp_name_t*)param->pvn.u.dname;
|
||||
-
|
||||
- while(_dbg_xavp_dump[i]!=NULL&&i<DBG_XAVP_DUMP_SIZE)
|
||||
- {
|
||||
- if(_dbg_xavp_dump[i]->len==xname->name.len)
|
||||
- {
|
||||
- if(strncmp(_dbg_xavp_dump[i]->s, xname->name.s, xname->name.len)==0)
|
||||
- return 1; /* already dump before */
|
||||
- }
|
||||
- i++;
|
||||
- }
|
||||
- if(i==DBG_XAVP_DUMP_SIZE)
|
||||
- {
|
||||
- LM_WARN("full _dbg_xavp_dump cache array\n");
|
||||
- return 0; /* end cache names */
|
||||
- }
|
||||
- _dbg_xavp_dump[i] = &xname->name;
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-void _dbg_get_obj_xavp_val(sr_xavp_t *avp, srjson_doc_t *jdoc, srjson_t **jobj)
|
||||
-{
|
||||
- static char _pv_xavp_buf[128];
|
||||
- int result = 0;
|
||||
-
|
||||
- switch(avp->val.type) {
|
||||
- case SR_XTYPE_NULL:
|
||||
- *jobj = srjson_CreateNull(jdoc);
|
||||
- break;
|
||||
- case SR_XTYPE_INT:
|
||||
- *jobj = srjson_CreateNumber(jdoc, avp->val.v.i);
|
||||
- break;
|
||||
- case SR_XTYPE_STR:
|
||||
- *jobj = srjson_CreateStr(jdoc, avp->val.v.s.s, avp->val.v.s.len);
|
||||
- break;
|
||||
- case SR_XTYPE_TIME:
|
||||
- result = snprintf(_pv_xavp_buf, 128, "%lu", (long unsigned)avp->val.v.t);
|
||||
- break;
|
||||
- case SR_XTYPE_LONG:
|
||||
- result = snprintf(_pv_xavp_buf, 128, "%ld", (long unsigned)avp->val.v.l);
|
||||
- break;
|
||||
- case SR_XTYPE_LLONG:
|
||||
- result = snprintf(_pv_xavp_buf, 128, "%lld", avp->val.v.ll);
|
||||
- break;
|
||||
- case SR_XTYPE_XAVP:
|
||||
- result = snprintf(_pv_xavp_buf, 128, "<<xavp:%p>>", avp->val.v.xavp);
|
||||
- break;
|
||||
- case SR_XTYPE_DATA:
|
||||
- result = snprintf(_pv_xavp_buf, 128, "<<data:%p>>", avp->val.v.data);
|
||||
- break;
|
||||
- default:
|
||||
- LM_WARN("unknown data type\n");
|
||||
- *jobj = srjson_CreateNull(jdoc);
|
||||
- }
|
||||
- if(result<0)
|
||||
- {
|
||||
- LM_ERR("cannot convert to str\n");
|
||||
- *jobj = srjson_CreateNull(jdoc);
|
||||
- }
|
||||
- else if(*jobj==NULL)
|
||||
- {
|
||||
- *jobj = srjson_CreateStr(jdoc, _pv_xavp_buf, 128);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-int _dbg_get_obj_avp_vals(str name, sr_xavp_t *xavp, srjson_doc_t *jdoc, srjson_t **jobj)
|
||||
-{
|
||||
- sr_xavp_t *avp = NULL;
|
||||
- srjson_t *jobjt = NULL;
|
||||
-
|
||||
- *jobj = srjson_CreateArray(jdoc);
|
||||
- if(*jobj==NULL)
|
||||
- {
|
||||
- LM_ERR("cannot create json object\n");
|
||||
- return -1;
|
||||
- }
|
||||
- avp = xavp;
|
||||
- while(avp!=NULL&&!STR_EQ(avp->name,name))
|
||||
- {
|
||||
- avp = avp->next;
|
||||
- }
|
||||
- while(avp!=NULL)
|
||||
- {
|
||||
- _dbg_get_obj_xavp_val(avp, jdoc, &jobjt);
|
||||
- srjson_AddItemToArray(jdoc, *jobj, jobjt);
|
||||
- jobjt = NULL;
|
||||
- avp = xavp_get_next(avp);
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-int _dbg_get_obj_xavp_vals(struct sip_msg *msg,
|
||||
- pv_param_t *param, srjson_doc_t *jdoc, srjson_t **jobjr,
|
||||
- str *item_name)
|
||||
-{
|
||||
- pv_xavp_name_t *xname = (pv_xavp_name_t*)param->pvn.u.dname;
|
||||
- sr_xavp_t *xavp = NULL;
|
||||
- sr_xavp_t *avp = NULL;
|
||||
- srjson_t *jobj = NULL;
|
||||
- srjson_t *jobjt = NULL;
|
||||
- struct str_list *keys;
|
||||
- struct str_list *k;
|
||||
-
|
||||
- *jobjr = srjson_CreateArray(jdoc);
|
||||
- if(*jobjr==NULL)
|
||||
- {
|
||||
- LM_ERR("cannot create json object\n");
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- item_name->s = xname->name.s;
|
||||
- item_name->len = xname->name.len;
|
||||
- xavp = xavp_get_by_index(&xname->name, 0, NULL);
|
||||
- if(xavp==NULL)
|
||||
- {
|
||||
- return 0; /* empty */
|
||||
- }
|
||||
-
|
||||
- do
|
||||
- {
|
||||
- if(xavp->val.type==SR_XTYPE_XAVP)
|
||||
- {
|
||||
- avp = xavp->val.v.xavp;
|
||||
- jobj = srjson_CreateObject(jdoc);
|
||||
- if(jobj==NULL)
|
||||
- {
|
||||
- LM_ERR("cannot create json object\n");
|
||||
- return -1;
|
||||
- }
|
||||
- keys = xavp_get_list_key_names(xavp);
|
||||
- if(keys!=NULL)
|
||||
- {
|
||||
- do
|
||||
- {
|
||||
- _dbg_get_obj_avp_vals(keys->s, avp, jdoc, &jobjt);
|
||||
- srjson_AddStrItemToObject(jdoc, jobj, keys->s.s,
|
||||
- keys->s.len, jobjt);
|
||||
- k = keys;
|
||||
- keys = keys->next;
|
||||
- pkg_free(k);
|
||||
- jobjt = NULL;
|
||||
- }while(keys!=NULL);
|
||||
- }
|
||||
- }
|
||||
- if(jobj!=NULL)
|
||||
- {
|
||||
- srjson_AddItemToArray(jdoc, *jobjr, jobj);
|
||||
- jobj = NULL;
|
||||
- }
|
||||
- }while((xavp = xavp_get_next(xavp))!=0);
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-int dbg_dump_json(struct sip_msg* msg, unsigned int mask, int level)
|
||||
-{
|
||||
- int i;
|
||||
- pv_value_t value;
|
||||
- pv_cache_t **_pv_cache = pv_cache_get_table();
|
||||
- pv_cache_t *el = NULL;
|
||||
- srjson_doc_t jdoc;
|
||||
- srjson_t *jobj = NULL;
|
||||
- char *output = NULL;
|
||||
- str item_name = STR_NULL;
|
||||
- static char iname[128];
|
||||
- int result = -1;
|
||||
-
|
||||
- if(_pv_cache==NULL)
|
||||
- {
|
||||
- LM_ERR("cannot access pv_cache\n");
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- memset(_dbg_xavp_dump, 0, sizeof(str*)*DBG_XAVP_DUMP_SIZE);
|
||||
- srjson_InitDoc(&jdoc, NULL);
|
||||
- if(jdoc.root==NULL)
|
||||
- {
|
||||
- jdoc.root = srjson_CreateObject(&jdoc);
|
||||
- if(jdoc.root==NULL)
|
||||
- {
|
||||
- LM_ERR("cannot create json root\n");
|
||||
- goto error;
|
||||
- }
|
||||
- }
|
||||
- for(i=0;i<PV_CACHE_SIZE;i++)
|
||||
- {
|
||||
- el = _pv_cache[i];
|
||||
- while(el)
|
||||
- {
|
||||
- if(!(el->spec.type==PVT_AVP||
|
||||
- el->spec.type==PVT_SCRIPTVAR||
|
||||
- el->spec.type==PVT_XAVP||
|
||||
- el->spec.type==PVT_OTHER)||
|
||||
- !((el->spec.type==PVT_AVP&&mask&DBG_DP_AVP)||
|
||||
- (el->spec.type==PVT_XAVP&&mask&DBG_DP_XAVP)||
|
||||
- (el->spec.type==PVT_SCRIPTVAR&&mask&DBG_DP_SCRIPTVAR)||
|
||||
- (el->spec.type==PVT_OTHER&&mask&DBG_DP_OTHER))||
|
||||
- (el->spec.trans!=NULL))
|
||||
- {
|
||||
- el = el->next;
|
||||
- continue;
|
||||
- }
|
||||
- jobj = NULL;
|
||||
- item_name.len = 0;
|
||||
- item_name.s = 0;
|
||||
- iname[0] = '\0';
|
||||
- if(el->spec.type==PVT_AVP)
|
||||
- {
|
||||
- if(el->spec.pvp.pvi.type==PV_IDX_ALL||
|
||||
- (el->spec.pvp.pvi.type==PV_IDX_INT&&el->spec.pvp.pvi.u.ival!=0))
|
||||
- {
|
||||
- el = el->next;
|
||||
- continue;
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- if(_dbg_get_array_avp_vals(msg, &el->spec.pvp, &jdoc, &jobj, &item_name)!=0)
|
||||
- {
|
||||
- LM_WARN("can't get value[%.*s]\n", el->pvname.len, el->pvname.s);
|
||||
- el = el->next;
|
||||
- continue;
|
||||
- }
|
||||
- if(srjson_GetArraySize(&jdoc, jobj)==0 && !(mask&DBG_DP_NULL))
|
||||
- {
|
||||
- el = el->next;
|
||||
- continue;
|
||||
- }
|
||||
- snprintf(iname, 128, "$avp(%.*s)", item_name.len, item_name.s);
|
||||
- }
|
||||
- }
|
||||
- else if(el->spec.type==PVT_XAVP)
|
||||
- {
|
||||
- if(_dbg_xavp_dump_lookup(&el->spec.pvp)!=0)
|
||||
- {
|
||||
- el = el->next;
|
||||
- continue;
|
||||
- }
|
||||
- if(_dbg_get_obj_xavp_vals(msg, &el->spec.pvp, &jdoc, &jobj, &item_name)!=0)
|
||||
- {
|
||||
- LM_WARN("can't get value[%.*s]\n", el->pvname.len, el->pvname.s);
|
||||
- el = el->next;
|
||||
- continue;
|
||||
- }
|
||||
- if(srjson_GetArraySize(&jdoc, jobj)==0 && !(mask&DBG_DP_NULL))
|
||||
- {
|
||||
- el = el->next;
|
||||
- continue;
|
||||
- }
|
||||
- snprintf(iname, 128, "$xavp(%.*s)", item_name.len, item_name.s);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- if(pv_get_spec_value(msg, &el->spec, &value)!=0)
|
||||
- {
|
||||
- LM_WARN("can't get value[%.*s]\n", el->pvname.len, el->pvname.s);
|
||||
- el = el->next;
|
||||
- continue;
|
||||
- }
|
||||
- if(value.flags&(PV_VAL_NULL|PV_VAL_EMPTY|PV_VAL_NONE))
|
||||
- {
|
||||
- if(mask&DBG_DP_NULL)
|
||||
- {
|
||||
- jobj = srjson_CreateNull(&jdoc);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- el = el->next;
|
||||
- continue;
|
||||
- }
|
||||
- }else if(value.flags&(PV_VAL_INT)){
|
||||
- jobj = srjson_CreateNumber(&jdoc, value.ri);
|
||||
- }else if(value.flags&(PV_VAL_STR)){
|
||||
- jobj = srjson_CreateStr(&jdoc, value.rs.s, value.rs.len);
|
||||
- }else {
|
||||
- LM_WARN("el->pvname[%.*s] value[%d] unhandled\n", el->pvname.len, el->pvname.s,
|
||||
- value.flags);
|
||||
- el = el->next;
|
||||
- continue;
|
||||
- }
|
||||
- if(jobj==NULL)
|
||||
- {
|
||||
- LM_ERR("el->pvname[%.*s] empty json object\n", el->pvname.len,
|
||||
- el->pvname.s);
|
||||
- goto error;
|
||||
- }
|
||||
- snprintf(iname, 128, "%.*s", el->pvname.len, el->pvname.s);
|
||||
- }
|
||||
- if(jobj!=NULL)
|
||||
- {
|
||||
- srjson_AddItemToObject(&jdoc, jdoc.root, iname, jobj);
|
||||
- }
|
||||
- el = el->next;
|
||||
- }
|
||||
- }
|
||||
- output = srjson_PrintUnformatted(&jdoc, jdoc.root);
|
||||
- if(output==NULL)
|
||||
- {
|
||||
- LM_ERR("cannot print json doc\n");
|
||||
- goto error;
|
||||
- }
|
||||
- LOG(level, "%s\n", output);
|
||||
- result = 0;
|
||||
-
|
||||
-error:
|
||||
- if(output!=NULL) jdoc.free_fn(output);
|
||||
- srjson_DestroyDoc(&jdoc);
|
||||
-
|
||||
- return result;
|
||||
-}
|
||||
--- a/modules/debugger/debugger_api.h
|
||||
+++ b/modules/debugger/debugger_api.h
|
||||
@@ -56,6 +56,6 @@
|
||||
#define DBG_DP_XAVP 8
|
||||
#define DBG_DP_OTHER 16
|
||||
#define DBG_DP_ALL 31
|
||||
-int dbg_dump_json(struct sip_msg* msg, unsigned int mask, int level);
|
||||
+
|
||||
#endif
|
||||
|
||||
--- /dev/null
|
||||
+++ b/modules/debugger/debugger_json.c
|
||||
@@ -0,0 +1,423 @@
|
||||
+/**
|
||||
+ *
|
||||
+ * Copyright (C) 2013-2015 Victor Seva (sipwise.com)
|
||||
+ *
|
||||
+ * This file is part of Kamailio, a free SIP server.
|
||||
+ *
|
||||
+ * This file is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2 of the License, or
|
||||
+ * (at your option) any later version
|
||||
+ *
|
||||
+ * This file is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with this program; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
+ *
|
||||
+ */
|
||||
+#include <stdio.h>
|
||||
+
|
||||
+#include "../../pvar.h"
|
||||
+#include "../../mem/shm_mem.h"
|
||||
+#include "../../xavp.h"
|
||||
+#include "../pv/pv_xavp.h"
|
||||
+
|
||||
+#include "debugger_api.h"
|
||||
+#include "debugger_json.h"
|
||||
+
|
||||
+int _dbg_get_array_avp_vals(struct sip_msg *msg,
|
||||
+ pv_param_t *param, srjson_doc_t *jdoc, srjson_t **jobj,
|
||||
+ str *item_name)
|
||||
+{
|
||||
+ struct usr_avp *avp;
|
||||
+ unsigned short name_type;
|
||||
+ int_str avp_name;
|
||||
+ int_str avp_value;
|
||||
+ struct search_state state;
|
||||
+ srjson_t *jobjt;
|
||||
+ memset(&state, 0, sizeof(struct search_state));
|
||||
+
|
||||
+ if(pv_get_avp_name(msg, param, &avp_name, &name_type)!=0)
|
||||
+ {
|
||||
+ LM_ERR("invalid name\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ *jobj = srjson_CreateArray(jdoc);
|
||||
+ if(*jobj==NULL)
|
||||
+ {
|
||||
+ LM_ERR("cannot create json object\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if ((avp=search_first_avp(name_type, avp_name, &avp_value, &state))==0)
|
||||
+ {
|
||||
+ goto ok;
|
||||
+ }
|
||||
+ do
|
||||
+ {
|
||||
+ if(avp->flags & AVP_VAL_STR)
|
||||
+ {
|
||||
+ jobjt = srjson_CreateStr(jdoc, avp_value.s.s, avp_value.s.len);
|
||||
+ if(jobjt==NULL)
|
||||
+ {
|
||||
+ LM_ERR("cannot create json object\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ jobjt = srjson_CreateNumber(jdoc, avp_value.n);
|
||||
+ if(jobjt==NULL)
|
||||
+ {
|
||||
+ LM_ERR("cannot create json object\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+ srjson_AddItemToArray(jdoc, *jobj, jobjt);
|
||||
+ } while ((avp=search_next_avp(&state, &avp_value))!=0);
|
||||
+ok:
|
||||
+ item_name->s = avp_name.s.s;
|
||||
+ item_name->len = avp_name.s.len;
|
||||
+ return 0;
|
||||
+}
|
||||
+#define DBG_XAVP_DUMP_SIZE 32
|
||||
+static str* _dbg_xavp_dump[DBG_XAVP_DUMP_SIZE];
|
||||
+int _dbg_xavp_dump_lookup(pv_param_t *param)
|
||||
+{
|
||||
+ unsigned int i = 0;
|
||||
+ pv_xavp_name_t *xname;
|
||||
+
|
||||
+ if(param==NULL)
|
||||
+ return -1;
|
||||
+
|
||||
+ xname = (pv_xavp_name_t*)param->pvn.u.dname;
|
||||
+
|
||||
+ while(_dbg_xavp_dump[i]!=NULL&&i<DBG_XAVP_DUMP_SIZE)
|
||||
+ {
|
||||
+ if(_dbg_xavp_dump[i]->len==xname->name.len)
|
||||
+ {
|
||||
+ if(strncmp(_dbg_xavp_dump[i]->s, xname->name.s, xname->name.len)==0)
|
||||
+ return 1; /* already dump before */
|
||||
+ }
|
||||
+ i++;
|
||||
+ }
|
||||
+ if(i==DBG_XAVP_DUMP_SIZE)
|
||||
+ {
|
||||
+ LM_WARN("full _dbg_xavp_dump cache array\n");
|
||||
+ return 0; /* end cache names */
|
||||
+ }
|
||||
+ _dbg_xavp_dump[i] = &xname->name;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+void _dbg_get_obj_xavp_val(sr_xavp_t *avp, srjson_doc_t *jdoc, srjson_t **jobj)
|
||||
+{
|
||||
+ static char _pv_xavp_buf[128];
|
||||
+ int result = 0;
|
||||
+
|
||||
+ switch(avp->val.type) {
|
||||
+ case SR_XTYPE_NULL:
|
||||
+ *jobj = srjson_CreateNull(jdoc);
|
||||
+ break;
|
||||
+ case SR_XTYPE_INT:
|
||||
+ *jobj = srjson_CreateNumber(jdoc, avp->val.v.i);
|
||||
+ break;
|
||||
+ case SR_XTYPE_STR:
|
||||
+ *jobj = srjson_CreateStr(jdoc, avp->val.v.s.s, avp->val.v.s.len);
|
||||
+ break;
|
||||
+ case SR_XTYPE_TIME:
|
||||
+ result = snprintf(_pv_xavp_buf, 128, "%lu", (long unsigned)avp->val.v.t);
|
||||
+ break;
|
||||
+ case SR_XTYPE_LONG:
|
||||
+ result = snprintf(_pv_xavp_buf, 128, "%ld", (long unsigned)avp->val.v.l);
|
||||
+ break;
|
||||
+ case SR_XTYPE_LLONG:
|
||||
+ result = snprintf(_pv_xavp_buf, 128, "%lld", avp->val.v.ll);
|
||||
+ break;
|
||||
+ case SR_XTYPE_XAVP:
|
||||
+ result = snprintf(_pv_xavp_buf, 128, "<<xavp:%p>>", avp->val.v.xavp);
|
||||
+ break;
|
||||
+ case SR_XTYPE_DATA:
|
||||
+ result = snprintf(_pv_xavp_buf, 128, "<<data:%p>>", avp->val.v.data);
|
||||
+ break;
|
||||
+ default:
|
||||
+ LM_WARN("unknown data type\n");
|
||||
+ *jobj = srjson_CreateNull(jdoc);
|
||||
+ }
|
||||
+ if(result<0)
|
||||
+ {
|
||||
+ LM_ERR("cannot convert to str\n");
|
||||
+ *jobj = srjson_CreateNull(jdoc);
|
||||
+ }
|
||||
+ else if(*jobj==NULL)
|
||||
+ {
|
||||
+ *jobj = srjson_CreateStr(jdoc, _pv_xavp_buf, 128);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int _dbg_get_obj_avp_vals(str name, sr_xavp_t *xavp, srjson_doc_t *jdoc, srjson_t **jobj)
|
||||
+{
|
||||
+ sr_xavp_t *avp = NULL;
|
||||
+ srjson_t *jobjt = NULL;
|
||||
+
|
||||
+ *jobj = srjson_CreateArray(jdoc);
|
||||
+ if(*jobj==NULL)
|
||||
+ {
|
||||
+ LM_ERR("cannot create json object\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ avp = xavp;
|
||||
+ while(avp!=NULL&&!STR_EQ(avp->name,name))
|
||||
+ {
|
||||
+ avp = avp->next;
|
||||
+ }
|
||||
+ while(avp!=NULL)
|
||||
+ {
|
||||
+ _dbg_get_obj_xavp_val(avp, jdoc, &jobjt);
|
||||
+ srjson_AddItemToArray(jdoc, *jobj, jobjt);
|
||||
+ jobjt = NULL;
|
||||
+ avp = xavp_get_next(avp);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int _dbg_get_obj_xavp_vals(struct sip_msg *msg,
|
||||
+ pv_param_t *param, srjson_doc_t *jdoc, srjson_t **jobjr,
|
||||
+ str *item_name)
|
||||
+{
|
||||
+ pv_xavp_name_t *xname = (pv_xavp_name_t*)param->pvn.u.dname;
|
||||
+ sr_xavp_t *xavp = NULL;
|
||||
+ sr_xavp_t *avp = NULL;
|
||||
+ srjson_t *jobj = NULL;
|
||||
+ srjson_t *jobjt = NULL;
|
||||
+ struct str_list *keys;
|
||||
+ struct str_list *k;
|
||||
+
|
||||
+ *jobjr = srjson_CreateArray(jdoc);
|
||||
+ if(*jobjr==NULL)
|
||||
+ {
|
||||
+ LM_ERR("cannot create json object\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ item_name->s = xname->name.s;
|
||||
+ item_name->len = xname->name.len;
|
||||
+ xavp = xavp_get_by_index(&xname->name, 0, NULL);
|
||||
+ if(xavp==NULL)
|
||||
+ {
|
||||
+ return 0; /* empty */
|
||||
+ }
|
||||
+
|
||||
+ do
|
||||
+ {
|
||||
+ if(xavp->val.type==SR_XTYPE_XAVP)
|
||||
+ {
|
||||
+ avp = xavp->val.v.xavp;
|
||||
+ jobj = srjson_CreateObject(jdoc);
|
||||
+ if(jobj==NULL)
|
||||
+ {
|
||||
+ LM_ERR("cannot create json object\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ keys = xavp_get_list_key_names(xavp);
|
||||
+ if(keys!=NULL)
|
||||
+ {
|
||||
+ do
|
||||
+ {
|
||||
+ _dbg_get_obj_avp_vals(keys->s, avp, jdoc, &jobjt);
|
||||
+ srjson_AddStrItemToObject(jdoc, jobj, keys->s.s,
|
||||
+ keys->s.len, jobjt);
|
||||
+ k = keys;
|
||||
+ keys = keys->next;
|
||||
+ pkg_free(k);
|
||||
+ jobjt = NULL;
|
||||
+ }while(keys!=NULL);
|
||||
+ }
|
||||
+ }
|
||||
+ if(jobj!=NULL)
|
||||
+ {
|
||||
+ srjson_AddItemToArray(jdoc, *jobjr, jobj);
|
||||
+ jobj = NULL;
|
||||
+ }
|
||||
+ }while((xavp = xavp_get_next(xavp))!=0);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int dbg_get_json(struct sip_msg* msg, unsigned int mask, srjson_doc_t *jdoc,
|
||||
+ srjson_t *head)
|
||||
+{
|
||||
+ int i;
|
||||
+ pv_value_t value;
|
||||
+ pv_cache_t **_pv_cache = pv_cache_get_table();
|
||||
+ pv_cache_t *el = NULL;
|
||||
+ srjson_t *jobj = NULL;
|
||||
+ str item_name = STR_NULL;
|
||||
+ static char iname[128];
|
||||
+
|
||||
+ if(_pv_cache==NULL)
|
||||
+ {
|
||||
+ LM_ERR("cannot access pv_cache\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if(jdoc==NULL){
|
||||
+ LM_ERR("jdoc is null\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if(head==NULL){
|
||||
+ LM_ERR("head is null\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ memset(_dbg_xavp_dump, 0, sizeof(str*)*DBG_XAVP_DUMP_SIZE);
|
||||
+ for(i=0;i<PV_CACHE_SIZE;i++)
|
||||
+ {
|
||||
+ el = _pv_cache[i];
|
||||
+ while(el)
|
||||
+ {
|
||||
+ if(!(el->spec.type==PVT_AVP||
|
||||
+ el->spec.type==PVT_SCRIPTVAR||
|
||||
+ el->spec.type==PVT_XAVP||
|
||||
+ el->spec.type==PVT_OTHER)||
|
||||
+ !((el->spec.type==PVT_AVP&&mask&DBG_DP_AVP)||
|
||||
+ (el->spec.type==PVT_XAVP&&mask&DBG_DP_XAVP)||
|
||||
+ (el->spec.type==PVT_SCRIPTVAR&&mask&DBG_DP_SCRIPTVAR)||
|
||||
+ (el->spec.type==PVT_OTHER&&mask&DBG_DP_OTHER))||
|
||||
+ (el->spec.trans!=NULL))
|
||||
+ {
|
||||
+ el = el->next;
|
||||
+ continue;
|
||||
+ }
|
||||
+ jobj = NULL;
|
||||
+ item_name.len = 0;
|
||||
+ item_name.s = 0;
|
||||
+ iname[0] = '\0';
|
||||
+ if(el->spec.type==PVT_AVP)
|
||||
+ {
|
||||
+ if(el->spec.pvp.pvi.type==PV_IDX_ALL||
|
||||
+ (el->spec.pvp.pvi.type==PV_IDX_INT&&el->spec.pvp.pvi.u.ival!=0))
|
||||
+ {
|
||||
+ el = el->next;
|
||||
+ continue;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ if(_dbg_get_array_avp_vals(msg, &el->spec.pvp, jdoc, &jobj, &item_name)!=0)
|
||||
+ {
|
||||
+ LM_WARN("can't get value[%.*s]\n", el->pvname.len, el->pvname.s);
|
||||
+ el = el->next;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if(srjson_GetArraySize(jdoc, jobj)==0 && !(mask&DBG_DP_NULL))
|
||||
+ {
|
||||
+ el = el->next;
|
||||
+ continue;
|
||||
+ }
|
||||
+ snprintf(iname, 128, "$avp(%.*s)", item_name.len, item_name.s);
|
||||
+ }
|
||||
+ }
|
||||
+ else if(el->spec.type==PVT_XAVP)
|
||||
+ {
|
||||
+ if(_dbg_xavp_dump_lookup(&el->spec.pvp)!=0)
|
||||
+ {
|
||||
+ el = el->next;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if(_dbg_get_obj_xavp_vals(msg, &el->spec.pvp, jdoc, &jobj, &item_name)!=0)
|
||||
+ {
|
||||
+ LM_WARN("can't get value[%.*s]\n", el->pvname.len, el->pvname.s);
|
||||
+ el = el->next;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if(srjson_GetArraySize(jdoc, jobj)==0 && !(mask&DBG_DP_NULL))
|
||||
+ {
|
||||
+ el = el->next;
|
||||
+ continue;
|
||||
+ }
|
||||
+ snprintf(iname, 128, "$xavp(%.*s)", item_name.len, item_name.s);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ if(pv_get_spec_value(msg, &el->spec, &value)!=0)
|
||||
+ {
|
||||
+ LM_WARN("can't get value[%.*s]\n", el->pvname.len, el->pvname.s);
|
||||
+ el = el->next;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if(value.flags&(PV_VAL_NULL|PV_VAL_EMPTY|PV_VAL_NONE))
|
||||
+ {
|
||||
+ if(mask&DBG_DP_NULL)
|
||||
+ {
|
||||
+ jobj = srjson_CreateNull(jdoc);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ el = el->next;
|
||||
+ continue;
|
||||
+ }
|
||||
+ }else if(value.flags&(PV_VAL_INT)){
|
||||
+ jobj = srjson_CreateNumber(jdoc, value.ri);
|
||||
+ }else if(value.flags&(PV_VAL_STR)){
|
||||
+ jobj = srjson_CreateStr(jdoc, value.rs.s, value.rs.len);
|
||||
+ }else {
|
||||
+ LM_WARN("el->pvname[%.*s] value[%d] unhandled\n", el->pvname.len, el->pvname.s,
|
||||
+ value.flags);
|
||||
+ el = el->next;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if(jobj==NULL)
|
||||
+ {
|
||||
+ LM_ERR("el->pvname[%.*s] empty json object\n", el->pvname.len,
|
||||
+ el->pvname.s);
|
||||
+ goto error;
|
||||
+ }
|
||||
+ snprintf(iname, 128, "%.*s", el->pvname.len, el->pvname.s);
|
||||
+ }
|
||||
+ if(jobj!=NULL)
|
||||
+ {
|
||||
+ srjson_AddItemToObject(jdoc, head, iname, jobj);
|
||||
+ }
|
||||
+ el = el->next;
|
||||
+ }
|
||||
+ }
|
||||
+ return 0;
|
||||
+
|
||||
+error:
|
||||
+ srjson_Delete(jdoc, head);
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+int dbg_dump_json(struct sip_msg* msg, unsigned int mask, int level)
|
||||
+{
|
||||
+ char *output = NULL;
|
||||
+ srjson_doc_t jdoc;
|
||||
+
|
||||
+ srjson_InitDoc(&jdoc, NULL);
|
||||
+ if(jdoc.root==NULL)
|
||||
+ {
|
||||
+ jdoc.root = srjson_CreateObject(&jdoc);
|
||||
+ if(jdoc.root==NULL)
|
||||
+ {
|
||||
+ LM_ERR("cannot create json root\n");
|
||||
+ goto error;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if(dbg_get_json(msg, mask, &jdoc, jdoc.root)<0) goto error;
|
||||
+ output = srjson_PrintUnformatted(&jdoc, jdoc.root);
|
||||
+ if(output==NULL)
|
||||
+ {
|
||||
+ LM_ERR("cannot print json doc\n");
|
||||
+ srjson_DestroyDoc(&jdoc);
|
||||
+ }
|
||||
+ LOG(level, "%s\n", output);
|
||||
+ jdoc.free_fn(output);
|
||||
+ srjson_DestroyDoc(&jdoc);
|
||||
+ return 0;
|
||||
+
|
||||
+error:
|
||||
+ srjson_DestroyDoc(&jdoc);
|
||||
+ return -1;
|
||||
+}
|
||||
--- /dev/null
|
||||
+++ b/modules/debugger/debugger_json.h
|
||||
@@ -0,0 +1,32 @@
|
||||
+/**
|
||||
+ *
|
||||
+ * Copyright (C) 2013-2015 Victor Seva (sipwise.com)
|
||||
+ *
|
||||
+ * This file is part of Kamailio, a free SIP server.
|
||||
+ *
|
||||
+ * This file is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2 of the License, or
|
||||
+ * (at your option) any later version
|
||||
+ *
|
||||
+ * This file is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with this program; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#ifndef _DEBUGGER_JSON_H
|
||||
+#define _DEBUGGER_JSON_H
|
||||
+
|
||||
+#include "../../lib/srutils/srjson.h"
|
||||
+#include "../../route_struct.h"
|
||||
+
|
||||
+int dbg_get_json(struct sip_msg* msg, unsigned int mask, srjson_doc_t *jdoc,
|
||||
+ srjson_t *head);
|
||||
+int dbg_dump_json(struct sip_msg* msg, unsigned int mask, int level);
|
||||
+#endif
|
||||
--- a/modules/debugger/debugger_mod.c
|
||||
+++ b/modules/debugger/debugger_mod.c
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "debugger_api.h"
|
||||
#include "debugger_config.h"
|
||||
+#include "debugger_json.h"
|
||||
|
||||
MODULE_VERSION
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +0,0 @@
|
||||
--- a/Makefile.groups
|
||||
+++ b/Makefile.groups
|
||||
@@ -20,7 +20,8 @@
|
||||
# - extra used modules, with no extra dependency
|
||||
mod_list_extra=avp auth_diameter call_control dmq domainpolicy msrp pdb \
|
||||
qos sca seas sms sst timer tmrec uac_redirect xhttp \
|
||||
- xhttp_rpc xprint jsonrpc-s nosip dmq_usrloc statsd rtjson
|
||||
+ xhttp_rpc xprint jsonrpc-s nosip dmq_usrloc statsd \
|
||||
+ rtjson cfgt
|
||||
|
||||
# - common modules depending on database
|
||||
mod_list_db=acc alias_db auth_db avpops cfg_db db_text db_flatstore \
|
@ -1,162 +0,0 @@
|
||||
From 7976aff5b9d49cd3d418b4668c02d5036297c646 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Thu, 17 Sep 2015 18:07:43 +0200
|
||||
Subject: [PATCH] registar: add contact and recieved values to xavp_rcd
|
||||
|
||||
set xavp_rcd at registered() too
|
||||
---
|
||||
modules/registrar/doc/registrar_admin.xml | 26 ++++++++++--
|
||||
modules/registrar/lookup.c | 69 ++++++++++++++++++++++---------
|
||||
2 files changed, 72 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/modules/registrar/doc/registrar_admin.xml b/modules/registrar/doc/registrar_admin.xml
|
||||
index f1c7063..8a9479d 100644
|
||||
--- a/modules/registrar/doc/registrar_admin.xml
|
||||
+++ b/modules/registrar/doc/registrar_admin.xml
|
||||
@@ -739,7 +739,7 @@ modparam("registrar", "xavp_cfg", "reg")
|
||||
<para>
|
||||
Defines the name of XAVP class to store details from the
|
||||
location records. The values are stored as inner XAVPs, like
|
||||
- $xavp(class=>attribute). Valid inner XAVP names:
|
||||
+ $xavp(class[0]=>attribute). Valid inner XAVP names:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
@@ -748,11 +748,31 @@ modparam("registrar", "xavp_cfg", "reg")
|
||||
id.
|
||||
</para>
|
||||
</listitem>
|
||||
+ <listitem>
|
||||
+ <para>
|
||||
+ <emphasis>contact</emphasis> - the record's contact value.
|
||||
+ </para>
|
||||
+ </listitem>
|
||||
+ <listitem>
|
||||
+ <para>
|
||||
+ <emphasis>received</emphasis> - the record's received value.
|
||||
+ </para>
|
||||
+ </listitem>
|
||||
</itemizedlist>
|
||||
<para>
|
||||
- For example. if this parameter is set to 'ulrcd', then the ruid
|
||||
- for contact records are set in $xavp(ulrcd=>ruid).
|
||||
+ For example. if this parameter is set to 'ulrcd', then values are set in:
|
||||
</para>
|
||||
+ <itemizedlist>
|
||||
+ <listitem>
|
||||
+ <para><emphasis>$xavp(ulrcd[0]=>ruid)</emphasis></para>
|
||||
+ </listitem>
|
||||
+ <listitem>
|
||||
+ <para><emphasis>$xavp(ulrcd[0]=>contact)</emphasis></para>
|
||||
+ </listitem>
|
||||
+ <listitem>
|
||||
+ <para><emphasis>$xavp(ulrcd[0]=>received)</emphasis></para>
|
||||
+ </listitem>
|
||||
+ </itemizedlist>
|
||||
<para>
|
||||
<emphasis>
|
||||
Default value is NULL (disabled).
|
||||
diff --git a/modules/registrar/lookup.c b/modules/registrar/lookup.c
|
||||
index 6fb170b..b8cf92a 100644
|
||||
--- a/modules/registrar/lookup.c
|
||||
+++ b/modules/registrar/lookup.c
|
||||
@@ -93,6 +93,52 @@ int lookup_to_dset(struct sip_msg* _m, udomain_t* _d, str* _uri) {
|
||||
}
|
||||
|
||||
/*! \brief
|
||||
+ * add xavp with details of the record (ruid, ...)
|
||||
+ */
|
||||
+int xavp_rcd_helper(ucontact_t* ptr) {
|
||||
+ sr_xavp_t *xavp=NULL;
|
||||
+ sr_xavp_t *list=NULL;
|
||||
+ str xname_ruid = {"ruid", 4};
|
||||
+ str xname_received = { "received", 8};
|
||||
+ str xname_contact = { "contact", 7};
|
||||
+ sr_xval_t xval;
|
||||
+
|
||||
+ if(ptr==NULL) return -1;
|
||||
+
|
||||
+ if(reg_xavp_rcd.s!=NULL)
|
||||
+ {
|
||||
+ list = xavp_get(®_xavp_rcd, NULL);
|
||||
+ xavp = list;
|
||||
+ memset(&xval, 0, sizeof(sr_xval_t));
|
||||
+ xval.type = SR_XTYPE_STR;
|
||||
+ xval.v.s = ptr->ruid;
|
||||
+ xavp_add_value(&xname_ruid, &xval, &xavp);
|
||||
+
|
||||
+ if(ptr->received.len > 0)
|
||||
+ {
|
||||
+ memset(&xval, 0, sizeof(sr_xval_t));
|
||||
+ xval.type = SR_XTYPE_STR;
|
||||
+ xval.v.s = ptr->received;
|
||||
+ xavp_add_value(&xname_received, &xval, &xavp);
|
||||
+ }
|
||||
+
|
||||
+ memset(&xval, 0, sizeof(sr_xval_t));
|
||||
+ xval.type = SR_XTYPE_STR;
|
||||
+ xval.v.s = ptr->c;
|
||||
+ xavp_add_value(&xname_contact, &xval, &xavp);
|
||||
+
|
||||
+ if(list==NULL)
|
||||
+ {
|
||||
+ /* no reg_xavp_rcd xavp in root list - add it */
|
||||
+ xval.type = SR_XTYPE_XAVP;
|
||||
+ xval.v.xavp = xavp;
|
||||
+ xavp_add_value(®_xavp_rcd, &xval, NULL);
|
||||
+ }
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/*! \brief
|
||||
* Lookup contact in the database and rewrite Request-URI
|
||||
* or not according to _mode value:
|
||||
* 0: rewrite
|
||||
@@ -115,9 +161,6 @@ int lookup_helper(struct sip_msg* _m, udomain_t* _d, str* _uri, int _mode)
|
||||
str inst = {0};
|
||||
unsigned int ahash = 0;
|
||||
sr_xavp_t *xavp=NULL;
|
||||
- sr_xavp_t *list=NULL;
|
||||
- str xname = {"ruid", 4};
|
||||
- sr_xval_t xval;
|
||||
sip_uri_t path_uri;
|
||||
str path_str;
|
||||
|
||||
@@ -238,23 +281,7 @@ int lookup_helper(struct sip_msg* _m, udomain_t* _d, str* _uri, int _mode)
|
||||
/* reset next hop address */
|
||||
reset_dst_uri(_m);
|
||||
|
||||
- /* add xavp with details of the record (ruid, ...) */
|
||||
- if(reg_xavp_rcd.s!=NULL)
|
||||
- {
|
||||
- list = xavp_get(®_xavp_rcd, NULL);
|
||||
- xavp = list;
|
||||
- memset(&xval, 0, sizeof(sr_xval_t));
|
||||
- xval.type = SR_XTYPE_STR;
|
||||
- xval.v.s = ptr->ruid;
|
||||
- xavp_add_value(&xname, &xval, &xavp);
|
||||
- if(list==NULL)
|
||||
- {
|
||||
- /* no reg_xavp_rcd xavp in root list - add it */
|
||||
- xval.type = SR_XTYPE_XAVP;
|
||||
- xval.v.xavp = xavp;
|
||||
- xavp_add_value(®_xavp_rcd, &xval, NULL);
|
||||
- }
|
||||
- }
|
||||
+ xavp_rcd_helper(ptr);
|
||||
|
||||
/* If a Path is present, use first path-uri in favour of
|
||||
* received-uri because in that case the last hop towards the uac
|
||||
@@ -713,6 +740,8 @@ int registered4(struct sip_msg* _m, udomain_t* _d, str* _uri, int match_flag, in
|
||||
memcmp(match_contact.s, ptr->c.s, match_contact.len)))
|
||||
continue;
|
||||
|
||||
+ xavp_rcd_helper(ptr);
|
||||
+
|
||||
if(ptr->xavp!=NULL && match_action_flag == 1) {
|
||||
sr_xavp_t *xavp = xavp_clone_level_nodata(ptr->xavp);
|
||||
if(xavp_add(xavp, NULL)<0) {
|
||||
--
|
||||
2.5.1
|
||||
|
@ -1,40 +0,0 @@
|
||||
From 11bcc8066ce856cabfc95949b65712d891976194 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Mon, 29 Jun 2015 10:23:12 +0200
|
||||
Subject: [PATCH] core: clean previous routename in order to get the correct
|
||||
default_routename
|
||||
|
||||
fix c44685cbcefb8f6ecfa6f11369699906db832c39
|
||||
---
|
||||
cfg.y | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/cfg.y b/cfg.y
|
||||
index 85e69a6..154cb44 100644
|
||||
--- a/cfg.y
|
||||
+++ b/cfg.y
|
||||
@@ -1778,8 +1778,8 @@ route_name: NUMBER {
|
||||
;
|
||||
|
||||
|
||||
-route_main: ROUTE { ; }
|
||||
- | ROUTE_REQUEST { ; }
|
||||
+route_main: ROUTE { routename=NULL; }
|
||||
+ | ROUTE_REQUEST { routename=NULL; }
|
||||
;
|
||||
|
||||
route_stm:
|
||||
@@ -1845,8 +1845,8 @@ failure_route_stm:
|
||||
;
|
||||
|
||||
|
||||
-route_reply_main: ROUTE_ONREPLY { ; }
|
||||
- | ROUTE_REPLY { ; }
|
||||
+route_reply_main: ROUTE_ONREPLY { routename=NULL; }
|
||||
+ | ROUTE_REPLY { routename=NULL; }
|
||||
;
|
||||
|
||||
|
||||
--
|
||||
2.1.4
|
||||
|
@ -1,56 +0,0 @@
|
||||
From fed41e7bd30a1c4cd925b7f0c73d8aaa44722955 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Tue, 25 Aug 2015 15:43:29 +0200
|
||||
Subject: [PATCH] core: fix routename for event_route
|
||||
|
||||
---
|
||||
cfg.lex | 17 +++++++++--------
|
||||
1 file changed, 9 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/cfg.lex b/cfg.lex
|
||||
index 95edfdb..147f597 100644
|
||||
--- a/cfg.lex
|
||||
+++ b/cfg.lex
|
||||
@@ -605,23 +605,23 @@ IMPORTFILE "import_file"
|
||||
<INITIAL>{ISAVPFLAGSET} { count(); yylval.strval=yytext; return ISAVPFLAGSET; }
|
||||
<INITIAL>{AVPFLAGS_DECL} { count(); yylval.strval=yytext; return AVPFLAGS_DECL; }
|
||||
<INITIAL>{MSGLEN} { count(); yylval.strval=yytext; return MSGLEN; }
|
||||
-<INITIAL>{ROUTE} { count(); default_routename="DEFAULT_ROUTE";
|
||||
+<INITIAL>{ROUTE} { count(); routename=NULL; default_routename="DEFAULT_ROUTE";
|
||||
yylval.strval=yytext; return ROUTE; }
|
||||
-<INITIAL>{ROUTE_REQUEST} { count(); default_routename="DEFAULT_ROUTE";
|
||||
+<INITIAL>{ROUTE_REQUEST} { count(); routename=NULL; default_routename="DEFAULT_ROUTE";
|
||||
yylval.strval=yytext; return ROUTE_REQUEST; }
|
||||
-<INITIAL>{ROUTE_ONREPLY} { count(); default_routename="DEFAULT_ONREPLY";
|
||||
+<INITIAL>{ROUTE_ONREPLY} { count(); routename=NULL; default_routename="DEFAULT_ONREPLY";
|
||||
yylval.strval=yytext;
|
||||
return ROUTE_ONREPLY; }
|
||||
-<INITIAL>{ROUTE_REPLY} { count(); default_routename="DEFAULT_ONREPLY";
|
||||
+<INITIAL>{ROUTE_REPLY} { count(); routename=NULL; default_routename="DEFAULT_ONREPLY";
|
||||
yylval.strval=yytext; return ROUTE_REPLY; }
|
||||
-<INITIAL>{ROUTE_FAILURE} { count(); default_routename="DEFAULT_FAILURE";
|
||||
+<INITIAL>{ROUTE_FAILURE} { count(); routename=NULL; default_routename="DEFAULT_FAILURE";
|
||||
yylval.strval=yytext;
|
||||
return ROUTE_FAILURE; }
|
||||
-<INITIAL>{ROUTE_BRANCH} { count(); default_routename="DEFAULT_BRANCH";
|
||||
+<INITIAL>{ROUTE_BRANCH} { count(); routename=NULL; default_routename="DEFAULT_BRANCH";
|
||||
yylval.strval=yytext; return ROUTE_BRANCH; }
|
||||
-<INITIAL>{ROUTE_SEND} { count(); default_routename="DEFAULT_SEND";
|
||||
+<INITIAL>{ROUTE_SEND} { count(); routename=NULL; default_routename="DEFAULT_SEND";
|
||||
yylval.strval=yytext; return ROUTE_SEND; }
|
||||
-<INITIAL>{ROUTE_EVENT} { count(); default_routename="DEFAULT_EVENT";
|
||||
+<INITIAL>{ROUTE_EVENT} { count(); routename=NULL; default_routename="DEFAULT_EVENT";
|
||||
yylval.strval=yytext;
|
||||
state=EVRT_NAME_S; BEGIN(EVRTNAME);
|
||||
return ROUTE_EVENT; }
|
||||
@@ -630,6 +630,7 @@ IMPORTFILE "import_file"
|
||||
<EVRTNAME>{EVENT_RT_NAME} { count();
|
||||
addstr(&s_buf, yytext, yyleng);
|
||||
yylval.strval=s_buf.s;
|
||||
+ routename=s_buf.s;
|
||||
memset(&s_buf, 0, sizeof(s_buf));
|
||||
return EVENT_RT_NAME; }
|
||||
<EVRTNAME>{RBRACK} { count();
|
||||
--
|
||||
2.5.0
|
||||
|
@ -1,49 +0,0 @@
|
||||
From 821d1d9f300a2d73d18a6dd95b8ad44a7d8794e8 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Wed, 26 Aug 2015 10:56:32 +0200
|
||||
Subject: [PATCH] core: partial revert from 546e624a859 wrong clear or
|
||||
routename
|
||||
|
||||
---
|
||||
cfg.lex | 16 ++++++++--------
|
||||
1 file changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/cfg.lex b/cfg.lex
|
||||
index 147f597..ef8c881 100644
|
||||
--- a/cfg.lex
|
||||
+++ b/cfg.lex
|
||||
@@ -605,23 +605,23 @@ IMPORTFILE "import_file"
|
||||
<INITIAL>{ISAVPFLAGSET} { count(); yylval.strval=yytext; return ISAVPFLAGSET; }
|
||||
<INITIAL>{AVPFLAGS_DECL} { count(); yylval.strval=yytext; return AVPFLAGS_DECL; }
|
||||
<INITIAL>{MSGLEN} { count(); yylval.strval=yytext; return MSGLEN; }
|
||||
-<INITIAL>{ROUTE} { count(); routename=NULL; default_routename="DEFAULT_ROUTE";
|
||||
+<INITIAL>{ROUTE} { count(); default_routename="DEFAULT_ROUTE";
|
||||
yylval.strval=yytext; return ROUTE; }
|
||||
-<INITIAL>{ROUTE_REQUEST} { count(); routename=NULL; default_routename="DEFAULT_ROUTE";
|
||||
+<INITIAL>{ROUTE_REQUEST} { count(); default_routename="DEFAULT_ROUTE";
|
||||
yylval.strval=yytext; return ROUTE_REQUEST; }
|
||||
-<INITIAL>{ROUTE_ONREPLY} { count(); routename=NULL; default_routename="DEFAULT_ONREPLY";
|
||||
+<INITIAL>{ROUTE_ONREPLY} { count(); default_routename="DEFAULT_ONREPLY";
|
||||
yylval.strval=yytext;
|
||||
return ROUTE_ONREPLY; }
|
||||
-<INITIAL>{ROUTE_REPLY} { count(); routename=NULL; default_routename="DEFAULT_ONREPLY";
|
||||
+<INITIAL>{ROUTE_REPLY} { count(); default_routename="DEFAULT_ONREPLY";
|
||||
yylval.strval=yytext; return ROUTE_REPLY; }
|
||||
-<INITIAL>{ROUTE_FAILURE} { count(); routename=NULL; default_routename="DEFAULT_FAILURE";
|
||||
+<INITIAL>{ROUTE_FAILURE} { count(); default_routename="DEFAULT_FAILURE";
|
||||
yylval.strval=yytext;
|
||||
return ROUTE_FAILURE; }
|
||||
-<INITIAL>{ROUTE_BRANCH} { count(); routename=NULL; default_routename="DEFAULT_BRANCH";
|
||||
+<INITIAL>{ROUTE_BRANCH} { count(); default_routename="DEFAULT_BRANCH";
|
||||
yylval.strval=yytext; return ROUTE_BRANCH; }
|
||||
-<INITIAL>{ROUTE_SEND} { count(); routename=NULL; default_routename="DEFAULT_SEND";
|
||||
+<INITIAL>{ROUTE_SEND} { count(); default_routename="DEFAULT_SEND";
|
||||
yylval.strval=yytext; return ROUTE_SEND; }
|
||||
-<INITIAL>{ROUTE_EVENT} { count(); routename=NULL; default_routename="DEFAULT_EVENT";
|
||||
+<INITIAL>{ROUTE_EVENT} { count(); default_routename="DEFAULT_EVENT";
|
||||
yylval.strval=yytext;
|
||||
state=EVRT_NAME_S; BEGIN(EVRTNAME);
|
||||
return ROUTE_EVENT; }
|
||||
--
|
||||
2.5.0
|
||||
|
@ -1,61 +0,0 @@
|
||||
From f3aa7bd4ffc489fcb7cb8a9c2f5da5569dfd9b28 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Mon, 5 Oct 2015 13:42:43 +0200
|
||||
Subject: [PATCH] acc: add acc_prepare_always parameter
|
||||
|
||||
This will force the preparation of the request no matter
|
||||
if the flags are set at the moment of the transaction
|
||||
creation
|
||||
---
|
||||
modules/acc/acc_logic.c | 2 +-
|
||||
modules/acc/acc_mod.c | 2 ++
|
||||
modules/acc/acc_mod.h | 1 +
|
||||
3 files changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/modules/acc/acc_logic.c b/modules/acc/acc_logic.c
|
||||
index 16a97e5..0d453a7 100644
|
||||
--- a/modules/acc/acc_logic.c
|
||||
+++ b/modules/acc/acc_logic.c
|
||||
@@ -102,7 +102,7 @@ struct acc_enviroment acc_env;
|
||||
(((_rq)->REQ_METHOD==METHOD_CANCEL) && report_cancels==0)
|
||||
|
||||
#define is_acc_prepare_on(_rq) \
|
||||
- (is_acc_flag_set(_rq,acc_prepare_flag))
|
||||
+ (acc_prepare_always || is_acc_flag_set(_rq,acc_prepare_flag))
|
||||
|
||||
static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps );
|
||||
|
||||
diff --git a/modules/acc/acc_mod.c b/modules/acc/acc_mod.c
|
||||
index 91b47d0..d412dbf 100644
|
||||
--- a/modules/acc/acc_mod.c
|
||||
+++ b/modules/acc/acc_mod.c
|
||||
@@ -108,6 +108,7 @@ static char *failed_filter_str = 0; /* by default, do not filter logging of
|
||||
unsigned short failed_filter[MAX_FAILED_FILTER_COUNT + 1];
|
||||
static char* leg_info_str = 0; /*!< multi call-leg support */
|
||||
struct acc_extra *leg_info = 0;
|
||||
+int acc_prepare_always = 0; /* prepare the request always for later acc */
|
||||
int acc_prepare_flag = -1; /*!< should the request be prepared for later acc */
|
||||
char *acc_time_format = "%Y-%m-%d %H:%M:%S";
|
||||
int reason_from_hf = 0; /*!< assign reason from reason hf if present */
|
||||
@@ -262,6 +263,7 @@ static param_export_t params[] = {
|
||||
{"multi_leg_info", PARAM_STRING, &leg_info_str },
|
||||
{"detect_direction", INT_PARAM, &detect_direction },
|
||||
{"acc_prepare_flag", INT_PARAM, &acc_prepare_flag },
|
||||
+ {"acc_prepare_always", INT_PARAM, &acc_prepare_always },
|
||||
{"reason_from_hf", INT_PARAM, &reason_from_hf },
|
||||
/* syslog specific */
|
||||
{"log_flag", INT_PARAM, &log_flag },
|
||||
diff --git a/modules/acc/acc_mod.h b/modules/acc/acc_mod.h
|
||||
index c746ffb..055ac61 100644
|
||||
--- a/modules/acc/acc_mod.h
|
||||
+++ b/modules/acc/acc_mod.h
|
||||
@@ -103,5 +103,6 @@ extern int acc_time_mode;
|
||||
extern str acc_time_attr;
|
||||
extern str acc_time_exten;
|
||||
|
||||
+extern int acc_prepare_always;
|
||||
|
||||
#endif
|
||||
--
|
||||
2.5.3
|
||||
|
@ -1,52 +0,0 @@
|
||||
From a48d6a1ed8950ba96d5e85769bba59bfbe469cfa Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Wed, 9 Sep 2015 10:30:27 +0200
|
||||
Subject: [PATCH] core: add fixup_pvar_pvar_pvar()
|
||||
|
||||
---
|
||||
mod_fix.c | 14 ++++++++++++++
|
||||
mod_fix.h | 3 +++
|
||||
2 files changed, 17 insertions(+)
|
||||
|
||||
diff --git a/mod_fix.c b/mod_fix.c
|
||||
index 46505f4..8951f2a 100644
|
||||
--- a/mod_fix.c
|
||||
+++ b/mod_fix.c
|
||||
@@ -319,6 +319,20 @@ int fixup_free_pvar_pvar(void** param, int param_no)
|
||||
}
|
||||
|
||||
|
||||
+int fixup_pvar_pvar_pvar(void** param, int param_no)
|
||||
+{
|
||||
+ if (param_no > 3)
|
||||
+ return E_UNSPEC;
|
||||
+ return fixup_pvar_all(param, param_no);
|
||||
+}
|
||||
+
|
||||
+int fixup_free_pvar_pvar_pvar(void** param, int param_no)
|
||||
+{
|
||||
+ if (param_no > 3)
|
||||
+ return E_UNSPEC;
|
||||
+ return fixup_free_pvar_all(param, param_no);
|
||||
+}
|
||||
+
|
||||
|
||||
int fixup_pvar_null(void** param, int param_no)
|
||||
{
|
||||
diff --git a/mod_fix.h b/mod_fix.h
|
||||
index e02aa6d..13c766a 100644
|
||||
--- a/mod_fix.h
|
||||
+++ b/mod_fix.h
|
||||
@@ -103,6 +103,9 @@ int fixup_free_pvar_none(void** param, int param_no);
|
||||
int fixup_pvar_pvar(void **param, int param_no);
|
||||
int fixup_free_pvar_pvar(void** param, int param_no);
|
||||
|
||||
+int fixup_pvar_pvar_pvar(void **param, int param_no);
|
||||
+int fixup_free_pvar_pvar_pvar(void** param, int param_no);
|
||||
+
|
||||
int fixup_pvar_str(void** param, int param_no);
|
||||
int fixup_free_pvar_str(void** param, int param_no);
|
||||
|
||||
--
|
||||
2.5.1
|
||||
|
@ -1,78 +0,0 @@
|
||||
From 691e007e535e384e3dc27f98c81cf247be14ba15 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Tue, 25 Jun 2013 14:09:06 +0200
|
||||
Subject: [PATCH] modules/debugger: trace msg out
|
||||
|
||||
---
|
||||
modules/debugger/debugger_api.c | 16 ++++++++++++++++
|
||||
modules/debugger/debugger_api.h | 2 ++
|
||||
modules/debugger/debugger_mod.c | 3 +++
|
||||
3 files changed, 21 insertions(+)
|
||||
|
||||
--- a/modules/debugger/debugger_api.c
|
||||
+++ b/modules/debugger/debugger_api.c
|
||||
@@ -174,6 +174,8 @@
|
||||
*/
|
||||
char *_dbg_cfgtrace_prefix = "*** cfgtrace:";
|
||||
|
||||
+int _dbg_outtrace = 0;
|
||||
+
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -520,6 +522,20 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int dbg_cfg_dump(void *data)
|
||||
+{
|
||||
+ str *buf = (str *) data;
|
||||
+ if(buf==NULL) return 0;
|
||||
+ LM_DBG("msg out:{%.*s}\n", buf->len, buf->s);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+void dbg_enable_outtrace(void)
|
||||
+{
|
||||
+ if(_dbg_outtrace==1)
|
||||
+ sr_event_register_cb(SREV_NET_DATA_OUT, dbg_cfg_dump);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
*
|
||||
*/
|
||||
--- a/modules/debugger/debugger_api.h
|
||||
+++ b/modules/debugger/debugger_api.h
|
||||
@@ -57,5 +57,6 @@
|
||||
#define DBG_DP_OTHER 16
|
||||
#define DBG_DP_ALL 31
|
||||
int dbg_dump_json(struct sip_msg* msg, unsigned int mask, int level);
|
||||
+void dbg_enable_outtrace(void);
|
||||
#endif
|
||||
|
||||
--- a/modules/debugger/debugger_mod.c
|
||||
+++ b/modules/debugger/debugger_mod.c
|
||||
@@ -61,6 +61,7 @@
|
||||
extern char *_dbg_cfgtrace_lname;
|
||||
extern int _dbg_step_usleep;
|
||||
extern int _dbg_step_loops;
|
||||
+extern int _dbg_outtrace;
|
||||
extern int _dbg_reset_msgid;
|
||||
|
||||
static char * _dbg_cfgtrace_facility_str = 0;
|
||||
@@ -88,6 +89,7 @@
|
||||
{"log_assign", INT_PARAM, &_dbg_log_assign},
|
||||
{"step_usleep", INT_PARAM, &_dbg_step_usleep},
|
||||
{"step_loops", INT_PARAM, &_dbg_step_loops},
|
||||
+ {"trace_out_msg", INT_PARAM, &_dbg_outtrace},
|
||||
{"mod_hash_size", INT_PARAM, &default_dbg_cfg.mod_hash_size},
|
||||
{"mod_level_mode", INT_PARAM, &default_dbg_cfg.mod_level_mode},
|
||||
{"mod_level", PARAM_STRING|USE_FUNC_PARAM, (void*)dbg_mod_level_param},
|
||||
@@ -180,6 +182,7 @@
|
||||
if (rank==PROC_INIT) {
|
||||
dbg_enable_mod_levels();
|
||||
dbg_enable_log_assign();
|
||||
+ dbg_enable_outtrace();
|
||||
return dbg_init_pid_list();
|
||||
}
|
||||
return dbg_init_mypid();
|
@ -1,225 +0,0 @@
|
||||
From 0c25a564ae178e46747bc31e9a289a1602a537e3 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Sat, 29 Aug 2015 09:07:27 +0200
|
||||
Subject: [PATCH] pv: pv_var_to_xavp
|
||||
|
||||
---
|
||||
modules/pv/doc/pv_admin.xml | 31 +++++++++++++++++++++++
|
||||
modules/pv/pv.c | 17 +++++++++++++
|
||||
modules/pv/pv_svar.c | 4 +++
|
||||
modules/pv/pv_svar.h | 1 +
|
||||
modules/pv/pv_xavp.c | 61 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
modules/pv/pv_xavp.h | 5 +++-
|
||||
6 files changed, 118 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/modules/pv/doc/pv_admin.xml b/modules/pv/doc/pv_admin.xml
|
||||
index f215e41..bed862d 100644
|
||||
--- a/modules/pv/doc/pv_admin.xml
|
||||
+++ b/modules/pv/doc/pv_admin.xml
|
||||
@@ -395,6 +395,37 @@ pv_xavp_print();
|
||||
</programlisting>
|
||||
</example>
|
||||
</section>
|
||||
+ <section id="pv.f.pv_var_to_xavp">
|
||||
+ <title>
|
||||
+ <function moreinfo="none">pv_var_to_xavp(varname, xname)</function>
|
||||
+ </title>
|
||||
+ <para>
|
||||
+ Copy script variables values to a xavp.
|
||||
+ </para>
|
||||
+ <para>
|
||||
+ First parameter can be '*' in order to copy all script variables. Second parameter is the name of the destination xavp. If xavp already exists it will be reset first.
|
||||
+ </para>
|
||||
+ <para>
|
||||
+ Function can be used from ANY_ROUTE.
|
||||
+ </para>
|
||||
+ <example>
|
||||
+ <title><function>pv_var_to_xavp()</function> usage</title>
|
||||
+ <programlisting format="linespecific">
|
||||
+...
|
||||
+$var("temp") = 3;
|
||||
+$var("foo") = "foo indeed";
|
||||
+pv_var_to_xavp("temp", "ok");
|
||||
+...
|
||||
+$xavp("ok[0]=>temp") now is 3
|
||||
+...
|
||||
+pv_var_to_xavp("*", "ok");
|
||||
+...
|
||||
+$xavp("ok[0]=>temp") now is 3
|
||||
+$xavp("ok[0]=>foo") now is "foo indeed"
|
||||
+...
|
||||
+ </programlisting>
|
||||
+ </example>
|
||||
+ </section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
diff --git a/modules/pv/pv.c b/modules/pv/pv.c
|
||||
index 1145f86..5e141c1 100644
|
||||
--- a/modules/pv/pv.c
|
||||
+++ b/modules/pv/pv.c
|
||||
@@ -494,6 +494,7 @@ static int w_xavp_params_explode(sip_msg_t *msg, char *pparams, char *pxname);
|
||||
static int w_sbranch_set_ruri(sip_msg_t *msg, char p1, char *p2);
|
||||
static int w_sbranch_append(sip_msg_t *msg, char p1, char *p2);
|
||||
static int w_sbranch_reset(sip_msg_t *msg, char p1, char *p2);
|
||||
+static int w_var_to_xavp(sip_msg_t *msg, char *p1, char *p2);
|
||||
|
||||
static int pv_init_rpc(void);
|
||||
|
||||
@@ -505,6 +506,8 @@ static cmd_export_t cmds[]={
|
||||
#ifdef WITH_XAVP
|
||||
{"pv_xavp_print", (cmd_function)pv_xavp_print, 0, 0, 0,
|
||||
ANY_ROUTE },
|
||||
+ {"pv_var_to_xavp", (cmd_function)w_var_to_xavp, 2, 0, 0,
|
||||
+ ANY_ROUTE },
|
||||
#endif
|
||||
{"is_int", (cmd_function)is_int, 1, fixup_pvar_null, fixup_free_pvar_null,
|
||||
ANY_ROUTE},
|
||||
@@ -693,6 +696,20 @@ static int is_int(struct sip_msg* msg, char* pvar, char* s2)
|
||||
return -1;
|
||||
}
|
||||
|
||||
+static int w_var_to_xavp(sip_msg_t *msg, char *s1, char *s2)
|
||||
+{
|
||||
+ str xname, varname;
|
||||
+
|
||||
+ if(s1 == NULL || s2 == NULL) {
|
||||
+ LM_ERR("wrong parameters\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ varname.len = strlen(s1); varname.s = s1;
|
||||
+ xname.s = s2; xname.len = strlen(s2);
|
||||
+ return pv_var_to_xavp(&varname, &xname);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
*
|
||||
*/
|
||||
diff --git a/modules/pv/pv_svar.c b/modules/pv/pv_svar.c
|
||||
index 2e50643..3b4c710 100644
|
||||
--- a/modules/pv/pv_svar.c
|
||||
+++ b/modules/pv/pv_svar.c
|
||||
@@ -186,6 +186,10 @@ script_var_t* get_varnull_by_name(str *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+script_var_t* get_var_all(void) {
|
||||
+ return script_vars;
|
||||
+}
|
||||
+
|
||||
void reset_vars(void)
|
||||
{
|
||||
script_var_t *it;
|
||||
diff --git a/modules/pv/pv_svar.h b/modules/pv/pv_svar.h
|
||||
index 6c503a5..c955e06 100644
|
||||
--- a/modules/pv/pv_svar.h
|
||||
+++ b/modules/pv/pv_svar.h
|
||||
@@ -51,6 +51,7 @@ script_var_t* add_var(str *name, int vtype);
|
||||
script_var_t* set_var_value(script_var_t *var, int_str *value, int flags);
|
||||
script_var_t* get_var_by_name(str *name);
|
||||
script_var_t* get_varnull_by_name(str *name);
|
||||
+script_var_t* get_var_all(void);
|
||||
|
||||
void reset_vars(void);
|
||||
void destroy_vars(void);
|
||||
diff --git a/modules/pv/pv_xavp.c b/modules/pv/pv_xavp.c
|
||||
index 53fd99a..0db1977 100644
|
||||
--- a/modules/pv/pv_xavp.c
|
||||
+++ b/modules/pv/pv_xavp.c
|
||||
@@ -613,4 +613,65 @@ int xavp_params_explode(str *params, str *xname)
|
||||
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+int pv_var_to_xavp(str *varname, str *xname)
|
||||
+{
|
||||
+ script_var_t *it;
|
||||
+ sr_xavp_t *xavp = NULL;
|
||||
+ sr_xval_t xval;
|
||||
+
|
||||
+ LM_DBG("xname:%.*s varname:%.*s\n", xname->len, xname->s,
|
||||
+ varname->len, varname->s);
|
||||
+
|
||||
+ // clean xavp
|
||||
+ xavp_rm_by_name(xname, 1, NULL);
|
||||
+
|
||||
+ if(varname->len==1 && varname->s[0] == '*') {
|
||||
+ for(it=get_var_all(); it; it=it->next) {
|
||||
+ memset(&xval, 0, sizeof(sr_xval_t));
|
||||
+ if(it->v.flags&VAR_VAL_INT)
|
||||
+ {
|
||||
+ xval.type = SR_XTYPE_INT;
|
||||
+ xval.v.i = it->v.value.n;
|
||||
+ } else {
|
||||
+ if(it->v.value.s.len==0) continue;
|
||||
+ xval.type = SR_XTYPE_STR;
|
||||
+ xval.v.s.s = it->v.value.s.s;
|
||||
+ xval.v.s.len = it->v.value.s.len;
|
||||
+ }
|
||||
+ xavp = xavp_add_xavp_value(xname, &it->name, &xval, NULL);
|
||||
+ if(xavp==NULL) {
|
||||
+ LM_ERR("can't copy [%.*s]\n", it->name.len, it->name.s);
|
||||
+ goto error;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ it = get_var_by_name(varname);
|
||||
+ if(it==NULL) {
|
||||
+ LM_ERR("script var [%.*s] not found\n", varname->len, varname->s);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ memset(&xval, 0, sizeof(sr_xval_t));
|
||||
+ if(it->v.flags&VAR_VAL_INT)
|
||||
+ {
|
||||
+ xval.type = SR_XTYPE_INT;
|
||||
+ xval.v.i = it->v.value.n;
|
||||
+ } else {
|
||||
+ xval.type = SR_XTYPE_STR;
|
||||
+ xval.v.s.s = it->v.value.s.s;
|
||||
+ xval.v.s.len = it->v.value.s.len;
|
||||
+ }
|
||||
+ xavp = xavp_add_xavp_value(xname, &it->name, &xval, NULL);
|
||||
+ if(xavp==NULL) {
|
||||
+ LM_ERR("can't copy [%.*s]\n", it->name.len, it->name.s);
|
||||
+ goto error;
|
||||
+ }
|
||||
+ }
|
||||
+ return 1;
|
||||
+
|
||||
+error:
|
||||
+ xavp_rm_by_name(xname, 1, NULL);
|
||||
+ return -1;
|
||||
+}
|
||||
#endif
|
||||
diff --git a/modules/pv/pv_xavp.h b/modules/pv/pv_xavp.h
|
||||
index 3c8238e..97d2bec 100644
|
||||
--- a/modules/pv/pv_xavp.h
|
||||
+++ b/modules/pv/pv_xavp.h
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
- * Copyright (C) 2009 Daniel-Constantin Mierla (asipto.com)
|
||||
+ * Copyright (C) 2009 Daniel-Constantin Mierla (asipto.com)
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifdef WITH_XAVP
|
||||
|
||||
#include "../../pvar.h"
|
||||
+#include "pv_svar.h"
|
||||
|
||||
int pv_get_xavp(struct sip_msg *msg, pv_param_t *param,
|
||||
pv_value_t *res);
|
||||
@@ -31,5 +32,7 @@ int pv_xavp_print(struct sip_msg* msg, char* s1, char *s2);
|
||||
|
||||
int xavp_params_explode(str *params, str *xname);
|
||||
|
||||
+int pv_var_to_xavp(str *varname, str *xname);
|
||||
+
|
||||
#endif
|
||||
#endif
|
||||
--
|
||||
2.5.0
|
||||
|
@ -1,170 +0,0 @@
|
||||
From dad1f24bee3f33c9902e487853be6f13b274aa93 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Mon, 7 Sep 2015 15:02:42 +0200
|
||||
Subject: [PATCH] pv: pv_xavp_to_var()
|
||||
|
||||
---
|
||||
modules/pv/doc/pv_admin.xml | 24 +++++++++++++++++++
|
||||
modules/pv/pv.c | 16 +++++++++++++
|
||||
modules/pv/pv_xavp.c | 58 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
modules/pv/pv_xavp.h | 1 +
|
||||
4 files changed, 99 insertions(+)
|
||||
|
||||
diff --git a/modules/pv/doc/pv_admin.xml b/modules/pv/doc/pv_admin.xml
|
||||
index bed862d..4cbd6b80 100644
|
||||
--- a/modules/pv/doc/pv_admin.xml
|
||||
+++ b/modules/pv/doc/pv_admin.xml
|
||||
@@ -426,6 +426,30 @@ $xavp("ok[0]=>foo") now is "foo indeed"
|
||||
</programlisting>
|
||||
</example>
|
||||
</section>
|
||||
+ <section id="pv.f.pv_xavp_to_var">
|
||||
+ <title>
|
||||
+ <function moreinfo="none">pv_xavp_to_var(xname)</function>
|
||||
+ </title>
|
||||
+ <para>
|
||||
+ Copy xavp values to vars. Reverse of pv_var_to_xavp().
|
||||
+ </para>
|
||||
+ <para>
|
||||
+ Function can be used from ANY_ROUTE.
|
||||
+ </para>
|
||||
+ <example>
|
||||
+ <title><function>pv_xavp_to_var()</function> usage</title>
|
||||
+ <programlisting format="linespecific">
|
||||
+...
|
||||
+$xavp("bar=>temp") = 3;
|
||||
+$xavp("bar[0]=>foo") = "foo indeed";
|
||||
+pv_xavp_to_var("bar");
|
||||
+...
|
||||
+$var("temp") now is 3
|
||||
+$var("foo") now is "foo indeed"
|
||||
+...
|
||||
+ </programlisting>
|
||||
+ </example>
|
||||
+ </section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
diff --git a/modules/pv/pv.c b/modules/pv/pv.c
|
||||
index 5e141c1..4ed9171 100644
|
||||
--- a/modules/pv/pv.c
|
||||
+++ b/modules/pv/pv.c
|
||||
@@ -495,6 +495,7 @@ static int w_sbranch_set_ruri(sip_msg_t *msg, char p1, char *p2);
|
||||
static int w_sbranch_append(sip_msg_t *msg, char p1, char *p2);
|
||||
static int w_sbranch_reset(sip_msg_t *msg, char p1, char *p2);
|
||||
static int w_var_to_xavp(sip_msg_t *msg, char *p1, char *p2);
|
||||
+static int w_xavp_to_var(sip_msg_t *msg, char *p1);
|
||||
|
||||
static int pv_init_rpc(void);
|
||||
|
||||
@@ -508,6 +509,8 @@ static cmd_export_t cmds[]={
|
||||
ANY_ROUTE },
|
||||
{"pv_var_to_xavp", (cmd_function)w_var_to_xavp, 2, 0, 0,
|
||||
ANY_ROUTE },
|
||||
+ {"pv_xavp_to_var", (cmd_function)w_xavp_to_var, 1, 0, 0,
|
||||
+ ANY_ROUTE },
|
||||
#endif
|
||||
{"is_int", (cmd_function)is_int, 1, fixup_pvar_null, fixup_free_pvar_null,
|
||||
ANY_ROUTE},
|
||||
@@ -710,6 +713,19 @@ static int w_var_to_xavp(sip_msg_t *msg, char *s1, char *s2)
|
||||
return pv_var_to_xavp(&varname, &xname);
|
||||
}
|
||||
|
||||
+static int w_xavp_to_var(sip_msg_t *msg, char *s1)
|
||||
+{
|
||||
+ str xname;
|
||||
+
|
||||
+ if(s1 == NULL) {
|
||||
+ LM_ERR("wrong parameters\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ xname.s = s1; xname.len = strlen(s1);
|
||||
+ return pv_xavp_to_var(&xname);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
*
|
||||
*/
|
||||
diff --git a/modules/pv/pv_xavp.c b/modules/pv/pv_xavp.c
|
||||
index 0db1977..8c11426 100644
|
||||
--- a/modules/pv/pv_xavp.c
|
||||
+++ b/modules/pv/pv_xavp.c
|
||||
@@ -674,4 +674,62 @@ error:
|
||||
xavp_rm_by_name(xname, 1, NULL);
|
||||
return -1;
|
||||
}
|
||||
+
|
||||
+int pv_xavp_to_var_helper(sr_xavp_t *avp) {
|
||||
+ script_var_t *it;
|
||||
+ int_str value;
|
||||
+ int flags = 0;
|
||||
+
|
||||
+ it = add_var(&avp->name, VAR_TYPE_ZERO);
|
||||
+ if(!it) return -1;
|
||||
+ if(avp->val.type==SR_XTYPE_STR){
|
||||
+ flags |= VAR_VAL_STR;
|
||||
+ value.s.len = avp->val.v.s.len;
|
||||
+ value.s.s = avp->val.v.s.s;
|
||||
+ LM_DBG("var:[%.*s] STR:[%.*s]\n", avp->name.len, avp->name.s,
|
||||
+ value.s.len, value.s.s);
|
||||
+ }
|
||||
+ else if(avp->val.type==SR_XTYPE_INT) {
|
||||
+ flags |= VAR_VAL_INT;
|
||||
+ value.n = avp->val.v.i;
|
||||
+ LM_DBG("var:[%.*s] INT:[%d]\n", avp->name.len, avp->name.s,
|
||||
+ value.n);
|
||||
+ } else {
|
||||
+ LM_ERR("avp type not STR nor INT\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ set_var_value(it, &value, flags);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int pv_xavp_to_var(str *xname) {
|
||||
+ sr_xavp_t *xavp;
|
||||
+ sr_xavp_t *avp;
|
||||
+
|
||||
+ LM_DBG("xname:%.*s\n", xname->len, xname->s);
|
||||
+
|
||||
+ xavp = xavp_get_by_index(xname, 0, NULL);
|
||||
+ if(!xavp) {
|
||||
+ LM_ERR("xavp [%.*s] not found\n", xname->len, xname->s);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if(xavp->val.type!=SR_XTYPE_XAVP){
|
||||
+ LM_ERR("%.*s not xavp type?\n", xname->len, xname->s);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ avp = xavp->val.v.xavp;
|
||||
+ if (avp)
|
||||
+ {
|
||||
+ if(pv_xavp_to_var_helper(avp)<0) return -1;
|
||||
+ avp = avp->next;
|
||||
+ }
|
||||
+
|
||||
+ while(avp)
|
||||
+ {
|
||||
+ if(pv_xavp_to_var_helper(avp)<0) return -1;
|
||||
+ avp = avp->next;
|
||||
+ }
|
||||
+ return 1;
|
||||
+}
|
||||
#endif
|
||||
diff --git a/modules/pv/pv_xavp.h b/modules/pv/pv_xavp.h
|
||||
index 97d2bec..f9ed6fc 100644
|
||||
--- a/modules/pv/pv_xavp.h
|
||||
+++ b/modules/pv/pv_xavp.h
|
||||
@@ -33,6 +33,7 @@ int pv_xavp_print(struct sip_msg* msg, char* s1, char *s2);
|
||||
int xavp_params_explode(str *params, str *xname);
|
||||
|
||||
int pv_var_to_xavp(str *varname, str *xname);
|
||||
+int pv_xavp_to_var(str *xname);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
--
|
||||
2.5.1
|
||||
|
Loading…
Reference in new issue