Module: kamailio
Branch: master
Commit: 9f9fd6ff153fe72aa4bb07f81aa4fbcf67cd9491
URL:
https://github.com/kamailio/kamailio/commit/9f9fd6ff153fe72aa4bb07f81aa4fbc…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-05-11T16:42:19+02:00
pv: kemi function to get $shvinc(name) value
---
Modified: src/modules/pv/pv.c
Modified: src/modules/pv/pv_shv.c
Modified: src/modules/pv/pv_shv.h
---
Diff:
https://github.com/kamailio/kamailio/commit/9f9fd6ff153fe72aa4bb07f81aa4fbc…
Patch:
https://github.com/kamailio/kamailio/commit/9f9fd6ff153fe72aa4bb07f81aa4fbc…
---
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index db832d7419..237ed8c7f5 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -2872,6 +2872,11 @@ static sr_kemi_t sr_kemi_pvx_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("pvx"), str_init("shvinc_get"),
+ SR_KEMIP_XVAL, ki_shvinc_get,
+ { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ str_init("pvx"), str_init("pv_var_to_xavp"),
SR_KEMIP_INT, ki_var_to_xavp,
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
diff --git a/src/modules/pv/pv_shv.c b/src/modules/pv/pv_shv.c
index 392c4d823d..f3469ccf55 100644
--- a/src/modules/pv/pv_shv.c
+++ b/src/modules/pv/pv_shv.c
@@ -796,4 +796,34 @@ sr_kemi_xval_t* ki_shv_get(sip_msg_t *msg, str *vname)
}
}
+/**
+ *
+ */
+sr_kemi_xval_t* ki_shvinc_get(sip_msg_t *msg, str *vname)
+{
+ sh_var_t *shv = NULL;
+
+ memset(&_sr_kemi_shv_xval, 0, sizeof(sr_kemi_xval_t));
+
+ shv = get_shvar_by_name(vname);
+ if(shv==NULL) {
+ LM_WARN("$shv(%.*s) is not defined - return value 0\n",
+ vname->len, vname->s);
+ _sr_kemi_shv_xval.vtype = SR_KEMIP_INT;
+ _sr_kemi_shv_xval.v.n = 0;
+ return &_sr_kemi_shv_xval;
+ }
+
+ lock_shvar(shv);
+ if(shv->v.flags&VAR_VAL_STR) {
+ _sr_kemi_shv_xval.v.n = 0;
+ } else {
+ shv->v.value.n++;
+ _sr_kemi_shv_xval.v.n = shv->v.value.n;
+ }
+ unlock_shvar(shv);
+ _sr_kemi_shv_xval.vtype = SR_KEMIP_INT;
+ return &_sr_kemi_shv_xval;
+}
+
/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
diff --git a/src/modules/pv/pv_shv.h b/src/modules/pv/pv_shv.h
index 65a4d1afc9..50311f5787 100644
--- a/src/modules/pv/pv_shv.h
+++ b/src/modules/pv/pv_shv.h
@@ -71,6 +71,7 @@ void rpc_shv_set(rpc_t* rpc, void* c);
int ki_shv_seti(sip_msg_t *msg, str *vname, int ival);
int ki_shv_sets(sip_msg_t *msg, str *vname, str *sval);
sr_kemi_xval_t* ki_shv_get(sip_msg_t *msg, str *vname);
+sr_kemi_xval_t* ki_shvinc_get(sip_msg_t *msg, str *vname);
#endif