mirror of https://github.com/sipwise/kamailio.git
* refresh patches * remove patches already applied on 5.3.5 Change-Id: Ibf787ce7a4588c9e860dceff1589cc9888de9a6echanges/41/41141/1
parent
4f64f36925
commit
ac3631e7de
@ -1,192 +0,0 @@
|
|||||||
From 64fa29f28a96a57a592e5d267004a3ff08a140b5 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
|
||||||
Date: Thu, 11 Jun 2020 10:48:29 +0200
|
|
||||||
Subject: [PATCH] avpops: export functions to KEMI
|
|
||||||
|
|
||||||
* avp_check
|
|
||||||
* avp_copy
|
|
||||||
---
|
|
||||||
src/modules/avpops/avpops.c | 162 ++++++++++++++++++++++++++++++++++++
|
|
||||||
1 file changed, 162 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/src/modules/avpops/avpops.c b/src/modules/avpops/avpops.c
|
|
||||||
index 3d8f949b39..06f5f1f8fa 100644
|
|
||||||
--- a/src/modules/avpops/avpops.c
|
|
||||||
+++ b/src/modules/avpops/avpops.c
|
|
||||||
@@ -30,6 +30,7 @@
|
|
||||||
#include "../../core/mem/mem.h"
|
|
||||||
#include "../../core/parser/parse_hname2.h"
|
|
||||||
#include "../../core/sr_module.h"
|
|
||||||
+#include "../../core/kemi.h"
|
|
||||||
#include "../../core/str.h"
|
|
||||||
#include "../../core/dprint.h"
|
|
||||||
#include "../../core/error.h"
|
|
||||||
@@ -1122,3 +1123,164 @@ static int w_print_avps(struct sip_msg* msg, char* foo, char *bar)
|
|
||||||
return ops_print_avp();
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int ki_check_avps(struct sip_msg* msg, str* param, str *check)
|
|
||||||
+{
|
|
||||||
+ struct fis_param *fparam, *fcheck;
|
|
||||||
+ regex_t* re = NULL;
|
|
||||||
+ int res;
|
|
||||||
+
|
|
||||||
+ if((fparam = avpops_parse_pvar(param->s)) == NULL)
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("unable to get pseudo-variable in param 1\n");
|
|
||||||
+ return E_OUT_OF_MEM;
|
|
||||||
+ }
|
|
||||||
+ /* attr name is mandatory */
|
|
||||||
+ if (fparam->u.sval->type==PVT_NULL)
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("null pseudo-variable in param 1\n");
|
|
||||||
+ pkg_free(fparam);
|
|
||||||
+ return E_UNSPEC;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if((fcheck = avpops_parse_pvar(check->s)) == NULL)
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("failed to parse checked value \n");
|
|
||||||
+ pkg_free(fparam);
|
|
||||||
+ return E_UNSPEC;
|
|
||||||
+ }
|
|
||||||
+ /* if REGEXP op -> compile the expresion */
|
|
||||||
+ if(fcheck->ops&AVPOPS_OP_RE)
|
|
||||||
+ {
|
|
||||||
+ if( (fcheck->opd&AVPOPS_VAL_STR) != 0 )
|
|
||||||
+ {
|
|
||||||
+ if((re = (regex_t*) pkg_malloc(sizeof(regex_t))) == NULL)
|
|
||||||
+ {
|
|
||||||
+ PKG_MEM_ERROR;
|
|
||||||
+ pkg_free(fparam);
|
|
||||||
+ pkg_free(fcheck);
|
|
||||||
+ return E_OUT_OF_MEM;
|
|
||||||
+ }
|
|
||||||
+ LM_DBG("compiling regexp <%.*s>\n", fcheck->u.s.len, fcheck->u.s.s);
|
|
||||||
+ if (regcomp(re, fcheck->u.s.s,REG_EXTENDED|REG_ICASE|REG_NEWLINE))
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("bad re <%.*s>\n", fcheck->u.s.len, fcheck->u.s.s);
|
|
||||||
+ pkg_free(fparam);
|
|
||||||
+ pkg_free(re);
|
|
||||||
+ pkg_free(fcheck);
|
|
||||||
+ return E_BAD_RE;
|
|
||||||
+ }
|
|
||||||
+ fcheck->u.s.s = (char*)re;
|
|
||||||
+ }
|
|
||||||
+ } else if (fcheck->ops&AVPOPS_OP_FM) {
|
|
||||||
+ if (!( fcheck->opd&AVPOPS_VAL_PVAR ||
|
|
||||||
+ (!(fcheck->opd&AVPOPS_VAL_PVAR) && fcheck->opd&AVPOPS_VAL_STR) ) )
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("fast_match operation requires string value or "
|
|
||||||
+ "avp name/alias (%d/%d)\n", fcheck->opd, fcheck->ops);
|
|
||||||
+ pkg_free(fparam);
|
|
||||||
+ pkg_free(fcheck);
|
|
||||||
+ return E_UNSPEC;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ res = ops_check_avp(msg, fparam, fcheck);
|
|
||||||
+ pkg_free(fparam);
|
|
||||||
+ pkg_free(fcheck);
|
|
||||||
+ if(re) pkg_free(re);
|
|
||||||
+ return res;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int ki_copy_avps(struct sip_msg* msg, str *name1, str *name2)
|
|
||||||
+{
|
|
||||||
+ struct fis_param *fname1, *fname2;
|
|
||||||
+ char *p = NULL;
|
|
||||||
+ int res;
|
|
||||||
+
|
|
||||||
+ if((fname1 = avpops_parse_pvar(name1->s)) == NULL)
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("unable to get pseudo-variable in param 1\n");
|
|
||||||
+ return E_OUT_OF_MEM;
|
|
||||||
+ }
|
|
||||||
+ /* attr name is mandatory */
|
|
||||||
+ if (fname1->u.sval->type != PVT_AVP)
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("you must specify only AVP as parameter\n");
|
|
||||||
+ pkg_free(fname1);
|
|
||||||
+ return E_UNSPEC;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* avp / flags */
|
|
||||||
+ if ( (p=strchr(name2->s,'/')) != 0 )
|
|
||||||
+ *(p++) = 0;
|
|
||||||
+
|
|
||||||
+ if((fname2 = avpops_parse_pvar(name2->s)) == NULL)
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("unable to get pseudo-variable in param 2\n");
|
|
||||||
+ return E_OUT_OF_MEM;
|
|
||||||
+ }
|
|
||||||
+ /* attr name is mandatory */
|
|
||||||
+ if (fname2->u.sval->type != PVT_AVP)
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("you must specify only AVP as parameter\n");
|
|
||||||
+ pkg_free(fname1);
|
|
||||||
+ pkg_free(fname2);
|
|
||||||
+ return E_UNSPEC;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* flags */
|
|
||||||
+ for( ; p&&*p ; p++ )
|
|
||||||
+ {
|
|
||||||
+ switch (*p) {
|
|
||||||
+ case 'g':
|
|
||||||
+ case 'G':
|
|
||||||
+ fname2->ops|=AVPOPS_FLAG_ALL;
|
|
||||||
+ break;
|
|
||||||
+ case 'd':
|
|
||||||
+ case 'D':
|
|
||||||
+ fname2->ops|=AVPOPS_FLAG_DELETE;
|
|
||||||
+ break;
|
|
||||||
+ case 'n':
|
|
||||||
+ case 'N':
|
|
||||||
+ fname2->ops|=AVPOPS_FLAG_CASTN;
|
|
||||||
+ break;
|
|
||||||
+ case 's':
|
|
||||||
+ case 'S':
|
|
||||||
+ fname2->ops|=AVPOPS_FLAG_CASTS;
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ LM_ERR("bad flag <%c>\n",*p);
|
|
||||||
+ pkg_free(fname1);
|
|
||||||
+ pkg_free(fname2);
|
|
||||||
+ return E_UNSPEC;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ res = ops_copy_avp( msg, fname1, fname2);
|
|
||||||
+ pkg_free(fname1);
|
|
||||||
+ pkg_free(fname2);
|
|
||||||
+ return res;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+/* clang-format off */
|
|
||||||
+static sr_kemi_t sr_kemi_rtpengine_exports[] = {
|
|
||||||
+ { str_init("avpops"), str_init("avp_check"),
|
|
||||||
+ SR_KEMIP_INT, ki_check_avps,
|
|
||||||
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
|
|
||||||
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
|
|
||||||
+ },
|
|
||||||
+ { str_init("avpops"), str_init("avp_copy"),
|
|
||||||
+ SR_KEMIP_INT, ki_copy_avps,
|
|
||||||
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
|
|
||||||
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
|
|
||||||
+ },
|
|
||||||
+ { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
|
|
||||||
+};
|
|
||||||
+/* clang-format on */
|
|
||||||
+
|
|
||||||
+int mod_register(char *path, int *dlflags, void *p1, void *p2) {
|
|
||||||
+ sr_kemi_modules_add(sr_kemi_rtpengine_exports);
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
\ No newline at end of file
|
|
||||||
--
|
|
||||||
2.20.1
|
|
||||||
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
From: Victor Seva <vseva@sipwise.com>
|
|
||||||
Date: Wed, 22 Apr 2020 14:12:54 +0200
|
|
||||||
Subject: ndb_redis: fix return redis_cmd function
|
|
||||||
|
|
||||||
return error if command execution fails
|
|
||||||
---
|
|
||||||
src/modules/ndb_redis/redis_client.c | 15 +++++++++++++++
|
|
||||||
1 file changed, 15 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/src/modules/ndb_redis/redis_client.c b/src/modules/ndb_redis/redis_client.c
|
|
||||||
index a453180..acdc978 100644
|
|
||||||
--- a/src/modules/ndb_redis/redis_client.c
|
|
||||||
+++ b/src/modules/ndb_redis/redis_client.c
|
|
||||||
@@ -953,6 +953,14 @@ int redisc_exec(str *srv, str *res, str *cmd, ...)
|
|
||||||
goto error_exec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ LM_DBG("rpl->rplRedis->type:%d\n", rpl->rplRedis->type);
|
|
||||||
+ if(rpl->rplRedis->type == REDIS_REPLY_ERROR) {
|
|
||||||
+ LM_ERR("Redis error:%.*s\n",
|
|
||||||
+ (int)rpl->rplRedis->len, rpl->rplRedis->str);
|
|
||||||
+ goto error_exec;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (check_cluster_reply(rpl->rplRedis, &rsrv)) {
|
|
||||||
LM_DBG("rsrv->ctxRedis = %p\n", rsrv->ctxRedis);
|
|
||||||
if(rsrv->ctxRedis==NULL)
|
|
||||||
@@ -987,6 +995,13 @@ int redisc_exec(str *srv, str *res, str *cmd, ...)
|
|
||||||
goto error_exec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ LM_DBG("rpl->rplRedis->type:%d\n", rpl->rplRedis->type);
|
|
||||||
+ if(rpl->rplRedis->type == REDIS_REPLY_ERROR) {
|
|
||||||
+ LM_ERR("Redis error:%.*s\n",
|
|
||||||
+ (int)rpl->rplRedis->len, rpl->rplRedis->str);
|
|
||||||
+ goto error_exec;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
cmd->s[cmd->len] = c;
|
|
||||||
rsrv->disable.consecutive_errors = 0;
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,85 +0,0 @@
|
|||||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
|
||||||
Date: Tue, 9 Jun 2020 12:02:43 +0200
|
|
||||||
Subject: sqlops: export sql_pvquery to KEMI
|
|
||||||
|
|
||||||
---
|
|
||||||
src/modules/sqlops/sqlops.c | 59 +++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
1 file changed, 59 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/src/modules/sqlops/sqlops.c b/src/modules/sqlops/sqlops.c
|
|
||||||
index 3943b1b..8727551 100644
|
|
||||||
--- a/src/modules/sqlops/sqlops.c
|
|
||||||
+++ b/src/modules/sqlops/sqlops.c
|
|
||||||
@@ -492,6 +492,60 @@ static int ki_sqlops_query(sip_msg_t *msg, str *scon, str *squery, str *sres)
|
|
||||||
return sqlops_do_query(scon, squery, sres);
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int ki_sqlops_pvquery(sip_msg_t *msg, str *scon, str *squery, str *sres)
|
|
||||||
+{
|
|
||||||
+ pv_elem_t *query = NULL;
|
|
||||||
+ pvname_list_t *pv_res = NULL;
|
|
||||||
+ pvname_list_t *pvl = NULL;
|
|
||||||
+ sql_con_t *con = NULL;
|
|
||||||
+ int i, res;
|
|
||||||
+
|
|
||||||
+ if (scon == NULL || scon->s == NULL || scon->len<=0) {
|
|
||||||
+ LM_ERR("invalid connection name\n");
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ con = sql_get_connection(scon);
|
|
||||||
+ if(con==NULL) {
|
|
||||||
+ LM_ERR("invalid connection [%.*s]\n", scon->len, scon->s);
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if(pv_parse_format(squery, &query)<0)
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("invalid query string [%s]\n", squery->s);
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* parse result variables into list of pv_spec_t's */
|
|
||||||
+ pv_res = parse_pvname_list(sres, 0);
|
|
||||||
+ if(pv_res==NULL)
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("invalid result parameter [%s]\n", sres->s);
|
|
||||||
+ pv_elem_free_all(query);
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+ /* check if all result variables are writable */
|
|
||||||
+ pvl = pv_res;
|
|
||||||
+ i = 1;
|
|
||||||
+ while (pvl) {
|
|
||||||
+ if (pvl->sname.setf == NULL)
|
|
||||||
+ {
|
|
||||||
+ LM_ERR("result variable [%d] is read-only\n", i);
|
|
||||||
+ pv_elem_free_all(query);
|
|
||||||
+ free_pvname_list(pv_res);
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+ i++;
|
|
||||||
+ pvl = pvl->next;
|
|
||||||
+ }
|
|
||||||
+ res = sql_do_pvquery(msg, con, query, pv_res);
|
|
||||||
+
|
|
||||||
+ pv_elem_free_all(query);
|
|
||||||
+ free_pvname_list(pv_res);
|
|
||||||
+ return res;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int ki_sqlops_query_async(sip_msg_t *msg, str *scon, str *squery)
|
|
||||||
{
|
|
||||||
sql_con_t *con = NULL;
|
|
||||||
@@ -561,6 +615,11 @@ static sr_kemi_t sr_kemi_sqlops_exports[] = {
|
|
||||||
{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_INT,
|
|
||||||
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
|
|
||||||
},
|
|
||||||
+ { str_init("sqlops"), str_init("sql_pvquery"),
|
|
||||||
+ SR_KEMIP_INT, ki_sqlops_pvquery,
|
|
||||||
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
|
|
||||||
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
|
|
||||||
+ },
|
|
||||||
{ str_init("sqlops"), str_init("sql_xquery"),
|
|
||||||
SR_KEMIP_INT, sqlops_do_xquery,
|
|
||||||
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
|
|
||||||
Loading…
Reference in new issue