mirror of https://github.com/sipwise/kamailio.git
Change-Id: I08eaa477c5ec13f93383ae0a0cf575799fc3ba18changes/92/39292/11
parent
eaeb44fae2
commit
02ba8431d5
@ -0,0 +1,113 @@
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Mon, 13 Apr 2020 17:10:01 +0200
|
||||
Subject: [PATCH] app_lua: add support for ARRAY and DICT types
|
||||
|
||||
---
|
||||
src/modules/app_lua/app_lua_api.c | 87 +++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 87 insertions(+)
|
||||
|
||||
diff --git a/src/modules/app_lua/app_lua_api.c b/src/modules/app_lua/app_lua_api.c
|
||||
index f80de09..da3b4ee 100644
|
||||
--- a/src/modules/app_lua/app_lua_api.c
|
||||
+++ b/src/modules/app_lua/app_lua_api.c
|
||||
@@ -806,6 +806,85 @@ int sr_kemi_lua_return_int(lua_State* L, sr_kemi_t *ket, int rc)
|
||||
return app_lua_return_false(L);
|
||||
}
|
||||
|
||||
+void sr_kemi_lua_push_dict_item(lua_State *L, sr_kemi_dict_item_t *item);
|
||||
+
|
||||
+/**
|
||||
+ * creates and push a table to the lua stack with
|
||||
+ * the elements of the list
|
||||
+ */
|
||||
+void sr_kemi_lua_push_array(lua_State *L, sr_kemi_dict_item_t *item) {
|
||||
+ int i = 1;
|
||||
+ sr_kemi_dict_item_t *k;
|
||||
+ if(!item) {
|
||||
+ LM_CRIT("BUG: dict field empty\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ if (item->vtype == SR_KEMIP_ARRAY) {
|
||||
+ k = item->v.dict;
|
||||
+ } else {
|
||||
+ k = item;
|
||||
+ }
|
||||
+ if(k) {
|
||||
+ lua_newtable(L);
|
||||
+ }
|
||||
+ while(k){
|
||||
+ lua_pushnumber(L, i++);
|
||||
+ sr_kemi_lua_push_dict_item(L, k);
|
||||
+ lua_settable(L, -3);
|
||||
+ k = k->next;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void sr_kemi_lua_push_dict(lua_State *L, sr_kemi_dict_item_t *item) {
|
||||
+ sr_kemi_dict_item_t *k = item;
|
||||
+ if(!item) {
|
||||
+ LM_CRIT("BUG: dict field empty\n");
|
||||
+ return;
|
||||
+ }
|
||||
+ lua_newtable(L);
|
||||
+ while(k){
|
||||
+ sr_kemi_lua_push_dict_item(L, k->v.dict);
|
||||
+ lua_setfield(L, -2, k->name.s);
|
||||
+ k = k->next;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+sr_kemi_lua_push_dict_item(lua_State *L, sr_kemi_dict_item_t *item)
|
||||
+{
|
||||
+ switch(item->vtype) {
|
||||
+ case SR_KEMIP_NONE:
|
||||
+ LM_CRIT("BUG: vtype is NONE\n");
|
||||
+ lua_pushnil(L);
|
||||
+ break;
|
||||
+ case SR_KEMIP_INT:
|
||||
+ lua_pushinteger(L, item->v.n);
|
||||
+ break;
|
||||
+ case SR_KEMIP_STR:
|
||||
+ lua_pushlstring(L, item->v.s.s, item->v.s.len);
|
||||
+ break;
|
||||
+ case SR_KEMIP_BOOL:
|
||||
+ if(item->v.n!=SR_KEMI_FALSE) {
|
||||
+ lua_pushboolean(L, SRLUA_TRUE);
|
||||
+ } else {
|
||||
+ lua_pushboolean(L, SRLUA_FALSE);
|
||||
+ }
|
||||
+ break;
|
||||
+ case SR_KEMIP_NULL:
|
||||
+ lua_pushnil(L);
|
||||
+ break;
|
||||
+ case SR_KEMIP_ARRAY:
|
||||
+ sr_kemi_lua_push_array(L, item);
|
||||
+ break;
|
||||
+ case SR_KEMIP_DICT:
|
||||
+ sr_kemi_lua_push_dict(L, item);
|
||||
+ break;
|
||||
+ default:
|
||||
+ LM_DBG("unknown type:%d\n", item->vtype);
|
||||
+ /* unknown type - return false */
|
||||
+ lua_pushboolean(L, SRLUA_FALSE);
|
||||
+ }
|
||||
+}
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -835,6 +914,14 @@ int sr_kemi_lua_return_xval(lua_State* L, sr_kemi_t *ket, sr_kemi_xval_t *rx)
|
||||
case SR_KEMIP_NULL:
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
+ case SR_KEMIP_ARRAY:
|
||||
+ sr_kemi_lua_push_array(L, rx->v.dict);
|
||||
+ sr_kemi_xval_free(rx);
|
||||
+ return 1;
|
||||
+ case SR_KEMIP_DICT:
|
||||
+ sr_kemi_lua_push_dict_item(L, rx->v.dict);
|
||||
+ sr_kemi_xval_free(rx);
|
||||
+ return 1;
|
||||
default:
|
||||
/* unknown type - return false */
|
||||
lua_pushboolean(L, SRLUA_FALSE);
|
||||
@ -0,0 +1,93 @@
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Mon, 13 Apr 2020 17:08:50 +0200
|
||||
Subject: [PATCH] core: KEMI suport for ARRAY and DICT
|
||||
|
||||
---
|
||||
src/core/kemi.c | 28 ++++++++++++++++++++++++++++
|
||||
src/core/kemi.h | 17 ++++++++++++++++-
|
||||
2 files changed, 44 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/core/kemi.c b/src/core/kemi.c
|
||||
index 7a96254..1f22969 100644
|
||||
--- a/src/core/kemi.c
|
||||
+++ b/src/core/kemi.c
|
||||
@@ -2373,6 +2373,34 @@ static void sr_kemi_pv_push_valx (sr_kemi_xval_t *xval, int rmode, int vi, str *
|
||||
}
|
||||
}
|
||||
|
||||
+/**
|
||||
+ *
|
||||
+ */
|
||||
+void sr_kemi_dict_item_free(sr_kemi_dict_item_t *item)
|
||||
+{
|
||||
+ sr_kemi_dict_item_t *v;
|
||||
+
|
||||
+ while(item) {
|
||||
+ if (item->vtype == SR_KEMIP_ARRAY || item->vtype == SR_KEMIP_DICT) {
|
||||
+ sr_kemi_dict_item_free(item->v.dict);
|
||||
+ }
|
||||
+ v = item;
|
||||
+ item = item->next;
|
||||
+ pkg_free(v);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ *
|
||||
+ */
|
||||
+void sr_kemi_xval_free(sr_kemi_xval_t *xval)
|
||||
+{
|
||||
+ if(xval && (xval->vtype == SR_KEMIP_ARRAY || xval->vtype == SR_KEMIP_DICT))
|
||||
+ {
|
||||
+ sr_kemi_dict_item_free(xval->v.dict);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/**
|
||||
*
|
||||
*/
|
||||
diff --git a/src/core/kemi.h b/src/core/kemi.h
|
||||
index 7824ce2..85cd521 100644
|
||||
--- a/src/core/kemi.h
|
||||
+++ b/src/core/kemi.h
|
||||
@@ -32,6 +32,8 @@
|
||||
#define SR_KEMIP_BOOL (1<<2) /* type boolean (0/1) */
|
||||
#define SR_KEMIP_XVAL (1<<3) /* type extended value (integer, str*, ...) */
|
||||
#define SR_KEMIP_NULL (1<<4) /* type NULL */
|
||||
+#define SR_KEMIP_DICT (1<<5) /* type dictionary */
|
||||
+#define SR_KEMIP_ARRAY (1<<6) /* type array */
|
||||
|
||||
#define SR_KEMI_FALSE 0
|
||||
#define SR_KEMI_TRUE 1
|
||||
@@ -66,11 +68,24 @@ typedef union {
|
||||
str s;
|
||||
} sr_kemi_val_t;
|
||||
|
||||
+typedef struct sr_kemi_dict_item
|
||||
+{
|
||||
+ struct sr_kemi_dict_item *next;
|
||||
+ str name;
|
||||
+ int vtype;
|
||||
+ union {
|
||||
+ int n;
|
||||
+ str s;
|
||||
+ struct sr_kemi_dict_item *dict;
|
||||
+ } v;
|
||||
+} sr_kemi_dict_item_t;
|
||||
+
|
||||
typedef struct sr_kemi_xval {
|
||||
int vtype;
|
||||
union {
|
||||
int n;
|
||||
str s;
|
||||
+ sr_kemi_dict_item_t *dict;
|
||||
} v;
|
||||
} sr_kemi_xval_t;
|
||||
|
||||
@@ -208,5 +223,5 @@ sr_kemi_t* sr_kemi_exports_get_pv(void);
|
||||
#define SR_KEMI_XVAL_NULL_PRINT 1
|
||||
#define SR_KEMI_XVAL_NULL_EMPTY 2
|
||||
void sr_kemi_xval_null(sr_kemi_xval_t *xval, int rmode);
|
||||
-
|
||||
+void sr_kemi_xval_free(sr_kemi_xval_t *xval);
|
||||
#endif
|
||||
@ -0,0 +1,307 @@
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Mon, 13 Apr 2020 17:10:51 +0200
|
||||
Subject: [PATCH] pv: add KEMI functions pvx.xavp_get_keys and pvx.xavp_getd
|
||||
|
||||
---
|
||||
src/modules/pv/pv.c | 281 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 281 insertions(+)
|
||||
|
||||
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
|
||||
index 310acf5..54bf38d 100644
|
||||
--- a/src/modules/pv/pv.c
|
||||
+++ b/src/modules/pv/pv.c
|
||||
@@ -1225,6 +1225,272 @@ static sr_kemi_xval_t* ki_xavp_getw(sip_msg_t *msg, str *rname)
|
||||
return ki_xavp_get_mode(msg, rname, SR_KEMI_XVAL_NULL_PRINT);
|
||||
}
|
||||
|
||||
+sr_kemi_dict_item_t* ki_xavp_dict(sr_xavp_t *xavp);
|
||||
+/**
|
||||
+ * SR_KEMIP_ARRAY with values of xavp=>name
|
||||
+ */
|
||||
+sr_kemi_dict_item_t* ki_xavp_dict_name(sr_xavp_t *xavp, str name)
|
||||
+{
|
||||
+ sr_kemi_dict_item_t *ini = NULL;
|
||||
+ sr_kemi_dict_item_t *val;
|
||||
+ sr_kemi_dict_item_t *last = NULL;
|
||||
+ sr_xavp_t *avp = xavp;
|
||||
+
|
||||
+ ini = (sr_kemi_dict_item_t*)pkg_malloc(sizeof(sr_kemi_dict_item_t));
|
||||
+ if(ini==NULL) {
|
||||
+ PKG_MEM_ERROR;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ memset(ini, 0, sizeof(sr_kemi_xval_t));
|
||||
+ ini->vtype = SR_KEMIP_ARRAY;
|
||||
+ while(avp!=NULL&&!STR_EQ(avp->name,name))
|
||||
+ {
|
||||
+ avp = avp->next;
|
||||
+ }
|
||||
+
|
||||
+ while(avp!=NULL){
|
||||
+ switch(avp->val.type) {
|
||||
+ case SR_XTYPE_XAVP:
|
||||
+ break;
|
||||
+ default:
|
||||
+ val = (sr_kemi_dict_item_t*)pkg_malloc(sizeof(sr_kemi_dict_item_t));
|
||||
+ if(val==NULL) {
|
||||
+ PKG_MEM_ERROR;
|
||||
+ goto error;
|
||||
+ }
|
||||
+ memset(val, 0, sizeof(sr_kemi_xval_t));
|
||||
+ break;
|
||||
+ }
|
||||
+ switch(avp->val.type) {
|
||||
+ case SR_XTYPE_NULL:
|
||||
+ val->vtype = SR_KEMIP_NULL;
|
||||
+ break;
|
||||
+ case SR_XTYPE_INT:
|
||||
+ val->vtype = SR_KEMIP_INT;
|
||||
+ val->v.n = avp->val.v.i;
|
||||
+ break;
|
||||
+ case SR_XTYPE_STR:
|
||||
+ val->vtype = SR_KEMIP_STR;
|
||||
+ val->v.s.s = avp->val.v.s.s;
|
||||
+ val->v.s.len = avp->val.v.s.len;
|
||||
+ break;
|
||||
+ case SR_XTYPE_TIME:
|
||||
+ case SR_XTYPE_LONG:
|
||||
+ case SR_XTYPE_LLONG:
|
||||
+ case SR_XTYPE_DATA:
|
||||
+ val->vtype = SR_KEMIP_NULL;
|
||||
+ LM_WARN("XAVP type:%d value not supported\n", avp->val.type);
|
||||
+ break;
|
||||
+ case SR_XTYPE_XAVP:
|
||||
+ val = ki_xavp_dict(avp->val.v.xavp);
|
||||
+ break;
|
||||
+ default:
|
||||
+ val->vtype = SR_KEMIP_NULL;
|
||||
+ LM_ERR("xavp:%.*s unknown type: %d\n",
|
||||
+ avp->name.len, avp->name.s, avp->val.type);
|
||||
+ break;
|
||||
+ }
|
||||
+ if(last) {
|
||||
+ last->next = val;
|
||||
+ } else {
|
||||
+ ini->v.dict = val;
|
||||
+ last = val;
|
||||
+ }
|
||||
+ avp = xavp_get_next(avp);
|
||||
+ }
|
||||
+ return ini;
|
||||
+error:
|
||||
+ while(ini) {
|
||||
+ last = ini;
|
||||
+ ini = ini->next;
|
||||
+ pkg_free(last);
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * SR_KEMIP_DICT of xavp
|
||||
+ */
|
||||
+sr_kemi_dict_item_t* ki_xavp_dict(sr_xavp_t *xavp) {
|
||||
+ sr_xavp_t *avp = NULL;
|
||||
+ struct str_list *keys;
|
||||
+ struct str_list *k;
|
||||
+ sr_kemi_dict_item_t *val;
|
||||
+ sr_kemi_dict_item_t *ini = NULL;
|
||||
+ sr_kemi_dict_item_t *last = NULL;
|
||||
+
|
||||
+ if(xavp->val.type!=SR_XTYPE_XAVP) {
|
||||
+ LM_ERR("%s not xavp?\n", xavp->name.s);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ avp = xavp->val.v.xavp;
|
||||
+ if((keys = xavp_get_list_key_names(xavp)) != NULL) {
|
||||
+ do {
|
||||
+ val = (sr_kemi_dict_item_t*)pkg_malloc(sizeof(sr_kemi_dict_item_t));
|
||||
+ if(val==NULL) {
|
||||
+ PKG_MEM_ERROR;
|
||||
+ goto error;
|
||||
+ }
|
||||
+ memset(val, 0, sizeof(sr_kemi_xval_t));
|
||||
+ val->vtype = SR_KEMIP_DICT;
|
||||
+ val->name.s = keys->s.s;
|
||||
+ val->name.len = keys->s.len;
|
||||
+ val->v.dict = ki_xavp_dict_name(avp, keys->s);
|
||||
+ if(last) {
|
||||
+ last->next = val;
|
||||
+ } else {
|
||||
+ ini = val;
|
||||
+ last = ini;
|
||||
+ }
|
||||
+ k = keys;
|
||||
+ keys = keys->next;
|
||||
+ pkg_free(k);
|
||||
+ } while(keys!=NULL);
|
||||
+ }
|
||||
+ return ini;
|
||||
+error:
|
||||
+ while(keys!=NULL) {
|
||||
+ k = keys;
|
||||
+ keys = keys->next;
|
||||
+ pkg_free(k);
|
||||
+ }
|
||||
+ while(ini) {
|
||||
+ val = ini;
|
||||
+ ini = ini->next;
|
||||
+ pkg_free(val);
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ *
|
||||
+ */
|
||||
+static sr_kemi_xval_t*
|
||||
+ki_xavp_getd_helper(sip_msg_t *msg, str *rname, int *_indx)
|
||||
+{
|
||||
+ sr_xavp_t *xavp=NULL;
|
||||
+ int xavp_size = 0;
|
||||
+ int indx = 0;
|
||||
+ sr_kemi_dict_item_t *val;
|
||||
+ sr_kemi_dict_item_t *last = NULL;
|
||||
+
|
||||
+ memset(&_sr_kemi_pv_xval, 0, sizeof(sr_kemi_xval_t));
|
||||
+ if(_indx) {
|
||||
+ indx = *_indx;
|
||||
+ /* we're going to retrive just one */
|
||||
+ _sr_kemi_pv_xval.vtype = SR_KEMIP_DICT;
|
||||
+ } else {
|
||||
+ /* we're going to retrive all */
|
||||
+ _sr_kemi_pv_xval.vtype = SR_KEMIP_ARRAY;
|
||||
+ }
|
||||
+ xavp_size = xavp_count(rname, NULL);
|
||||
+ if(indx<0)
|
||||
+ {
|
||||
+ if((indx*-1)>xavp_size)
|
||||
+ {
|
||||
+ sr_kemi_xval_null(&_sr_kemi_pv_xval, SR_KEMI_XVAL_NULL_NONE);
|
||||
+ return &_sr_kemi_pv_xval;
|
||||
+ }
|
||||
+ indx = xavp_size + indx;
|
||||
+ }
|
||||
+
|
||||
+ xavp = xavp_get_by_index(rname, indx, NULL);
|
||||
+ if(xavp==NULL) {
|
||||
+ sr_kemi_xval_null(&_sr_kemi_pv_xval, SR_KEMI_XVAL_NULL_NONE);
|
||||
+ return &_sr_kemi_pv_xval;
|
||||
+ }
|
||||
+ do {
|
||||
+ val = ki_xavp_dict(xavp);
|
||||
+ if(last) {
|
||||
+ last->next = val;
|
||||
+ } else {
|
||||
+ _sr_kemi_pv_xval.v.dict = val;
|
||||
+ }
|
||||
+ if(val) last = val;
|
||||
+ if(_indx) {
|
||||
+ xavp = NULL;
|
||||
+ } else {
|
||||
+ indx = indx + 1;
|
||||
+ xavp = xavp_get_by_index(rname, indx, NULL);
|
||||
+ }
|
||||
+ } while(xavp!=NULL);
|
||||
+ return &_sr_kemi_pv_xval;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ *
|
||||
+ */
|
||||
+static sr_kemi_xval_t*
|
||||
+ki_xavp_getd(sip_msg_t *msg, str *rname)
|
||||
+{
|
||||
+ return ki_xavp_getd_helper(msg, rname, NULL);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ *
|
||||
+ */
|
||||
+static sr_kemi_xval_t*
|
||||
+ki_xavp_getd_p1(sip_msg_t *msg, str *rname, int indx)
|
||||
+{
|
||||
+ return ki_xavp_getd_helper(msg, rname, &indx);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ *
|
||||
+ */
|
||||
+static sr_kemi_xval_t*
|
||||
+ki_xavp_get_keys(sip_msg_t *msg, str *rname, int indx) {
|
||||
+ sr_xavp_t *xavp=NULL;
|
||||
+ struct str_list *keys, *k;
|
||||
+ sr_kemi_dict_item_t *val;
|
||||
+ sr_kemi_dict_item_t *last = NULL;
|
||||
+
|
||||
+ memset(&_sr_kemi_pv_xval, 0, sizeof(sr_kemi_xval_t));
|
||||
+
|
||||
+ xavp = xavp_get_by_index(rname, indx, NULL);
|
||||
+ if(xavp==NULL) {
|
||||
+ sr_kemi_xval_null(&_sr_kemi_pv_xval, SR_KEMI_XVAL_NULL_NONE);
|
||||
+ return &_sr_kemi_pv_xval;
|
||||
+ }
|
||||
+ keys = xavp_get_list_key_names(xavp);
|
||||
+ _sr_kemi_pv_xval.vtype = SR_KEMIP_ARRAY;
|
||||
+ while(keys!=NULL){
|
||||
+ k = keys;
|
||||
+ val = (sr_kemi_dict_item_t*)pkg_malloc(sizeof(sr_kemi_dict_item_t));
|
||||
+ if(val==NULL) {
|
||||
+ PKG_MEM_ERROR;
|
||||
+ goto error;
|
||||
+ }
|
||||
+ memset(val, 0, sizeof(sr_kemi_xval_t));
|
||||
+ val->vtype = SR_KEMIP_STR;
|
||||
+ val->v.s.len = k->s.len;
|
||||
+ val->v.s.s = k->s.s;
|
||||
+ keys = k->next;
|
||||
+ pkg_free(k);
|
||||
+ if(last) {
|
||||
+ last->next = val;
|
||||
+ } else {
|
||||
+ _sr_kemi_pv_xval.v.dict = val;
|
||||
+ }
|
||||
+ last = val;
|
||||
+ }
|
||||
+ return &_sr_kemi_pv_xval;
|
||||
+error:
|
||||
+ while(keys!=NULL) {
|
||||
+ k = keys;
|
||||
+ keys = keys->next;
|
||||
+ pkg_free(k);
|
||||
+ }
|
||||
+ last = _sr_kemi_pv_xval.v.dict;
|
||||
+ while(last) {
|
||||
+ val = last;
|
||||
+ last = last->next;
|
||||
+ pkg_free(val);
|
||||
+ }
|
||||
+ sr_kemi_xval_null(&_sr_kemi_pv_xval, SR_KEMI_XVAL_NULL_NONE);
|
||||
+ return &_sr_kemi_pv_xval;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -1696,6 +1962,21 @@ 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("xavp_getd"),
|
||||
+ SR_KEMIP_XVAL, ki_xavp_getd,
|
||||
+ { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
|
||||
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
|
||||
+ },
|
||||
+ { str_init("pvx"), str_init("xavp_getd_p1"),
|
||||
+ SR_KEMIP_XVAL, ki_xavp_getd_p1,
|
||||
+ { SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_NONE,
|
||||
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
|
||||
+ },
|
||||
+ { str_init("pvx"), str_init("xavp_get_keys"),
|
||||
+ SR_KEMIP_XVAL, ki_xavp_get_keys,
|
||||
+ { SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_NONE,
|
||||
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
|
||||
+ },
|
||||
{ str_init("pvx"), str_init("xavp_rm"),
|
||||
SR_KEMIP_INT, ki_xavp_rm,
|
||||
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
|
||||
@ -0,0 +1,60 @@
|
||||
From 916c775f8ccb079af11f370aa498b5932f3734d5 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Seva <linuxmaniac@torreviejawireless.org>
|
||||
Date: Tue, 21 Apr 2020 13:03:16 +0200
|
||||
Subject: [PATCH] pv: fixes for KEMI pvx.xavp_getd
|
||||
|
||||
---
|
||||
src/modules/pv/pv.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
|
||||
index 2574148c04..511a0e3b29 100644
|
||||
--- a/src/modules/pv/pv.c
|
||||
+++ b/src/modules/pv/pv.c
|
||||
@@ -1402,7 +1402,7 @@ sr_kemi_dict_item_t* ki_xavp_dict(sr_xavp_t *xavp);
|
||||
/**
|
||||
* SR_KEMIP_ARRAY with values of xavp=>name
|
||||
*/
|
||||
-sr_kemi_dict_item_t* ki_xavp_dict_name(sr_xavp_t *xavp, str name)
|
||||
+sr_kemi_dict_item_t* ki_xavp_dict_name(sr_xavp_t *xavp, str *name)
|
||||
{
|
||||
sr_kemi_dict_item_t *ini = NULL;
|
||||
sr_kemi_dict_item_t *val;
|
||||
@@ -1416,7 +1416,7 @@ sr_kemi_dict_item_t* ki_xavp_dict_name(sr_xavp_t *xavp, str name)
|
||||
}
|
||||
memset(ini, 0, sizeof(sr_kemi_xval_t));
|
||||
ini->vtype = SR_KEMIP_ARRAY;
|
||||
- while(avp!=NULL&&!STR_EQ(avp->name,name))
|
||||
+ while(avp!=NULL&&!STR_EQ(avp->name,*name))
|
||||
{
|
||||
avp = avp->next;
|
||||
}
|
||||
@@ -1467,8 +1467,8 @@ sr_kemi_dict_item_t* ki_xavp_dict_name(sr_xavp_t *xavp, str name)
|
||||
last->next = val;
|
||||
} else {
|
||||
ini->v.dict = val;
|
||||
- last = val;
|
||||
}
|
||||
+ last = val;
|
||||
avp = xavp_get_next(avp);
|
||||
}
|
||||
return ini;
|
||||
@@ -1509,13 +1509,13 @@ sr_kemi_dict_item_t* ki_xavp_dict(sr_xavp_t *xavp)
|
||||
val->vtype = SR_KEMIP_DICT;
|
||||
val->name.s = keys->s.s;
|
||||
val->name.len = keys->s.len;
|
||||
- val->v.dict = ki_xavp_dict_name(avp, keys->s);
|
||||
+ val->v.dict = ki_xavp_dict_name(avp, &keys->s);
|
||||
if(last) {
|
||||
last->next = val;
|
||||
} else {
|
||||
ini = val;
|
||||
- last = ini;
|
||||
}
|
||||
+ last = val;
|
||||
k = keys;
|
||||
keys = keys->next;
|
||||
pkg_free(k);
|
||||
--
|
||||
2.20.1
|
||||
|
||||
Loading…
Reference in new issue