diff --git a/debian/changelog b/debian/changelog index d651389cd..971b22b7a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +ngcp-kamailio (4.0.3-3) unstable; urgency=low + + [ Victor Seva ] + * [93233e1] Add patches from upstream for app_lua sr.xavp.get function + * [bd57b58] remove unused patch + + -- Victor Seva Tue, 17 Sep 2013 16:41:05 +0200 + ngcp-kamailio (4.0.3-2) unstable; urgency=low [ Victor Seva ] diff --git a/debian/patches/series b/debian/patches/series index 1e170e858..d95af0bd2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -8,6 +8,8 @@ upstream/core-xavp-Added-helper-function-to-get-a-list-of-key.patch upstream/app_lua-Added-sr.xavp.get_keys-function.patch upstream/app_lua-Added-sr.xavp.get-function-in-order-to-get-a.patch upstream/0001-core-do-not-repeat-key-names-on-xavp_get_list_key_na.patch +upstream/modules-app_lua-fix-sr.xavp.get.-Get-all-the-values-.patch +upstream/modules-app_lua-added-param-to-sr.xavp.get-to-choose.patch upstream/debug/0002-core-updated-dprint-api-to-enable-support-for-debug-.patch upstream/debug/0003-debugger-option-to-set-debug-level-per-module.patch upstream/debug/core-use-pointer-to-pv_spec_t-on-lvalue-union.-Use-p.patch diff --git a/debian/patches/upstream/modules-app_lua-added-param-to-sr.xavp.get-to-choose.patch b/debian/patches/upstream/modules-app_lua-added-param-to-sr.xavp.get-to-choose.patch new file mode 100644 index 000000000..40f7d372c --- /dev/null +++ b/debian/patches/upstream/modules-app_lua-added-param-to-sr.xavp.get-to-choose.patch @@ -0,0 +1,137 @@ +From 8cd7a48479594052b6b6e70d48946e8963e1625d Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Tue, 9 Jul 2013 17:50:06 +0200 +Subject: [PATCH] modules/app_lua: added param to sr.xavp.get to choose + between all the values (default) or just the first ones. + +--- + modules/app_lua/app_lua_sr.c | 88 ++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 81 insertions(+), 7 deletions(-) + +diff --git a/modules/app_lua/app_lua_sr.c b/modules/app_lua/app_lua_sr.c +index 4075ef8..c5229f4 100644 +--- a/modules/app_lua/app_lua_sr.c ++++ b/modules/app_lua/app_lua_sr.c +@@ -1237,6 +1237,57 @@ static int lua_sr_push_xavp_table(lua_State *L, sr_xavp_t *xavp) { + return 1; + } + ++ /** ++ * creates and push a table to the lua stack with ++ * only the firsts elements of the xavp ++ */ ++static int lua_sr_push_xavp_table_simple(lua_State *L, sr_xavp_t *xavp) { ++ lua_Number i = 1; ++ sr_xavp_t *avp = NULL; ++ ++ if(xavp->val.type!=SR_XTYPE_XAVP){ ++ LM_ERR("%s not xavp?\n", xavp->name.s); ++ return 0; ++ } ++ avp = xavp->val.v.xavp; ++ ++ lua_newtable(L); ++ while(avp!=NULL){ ++ switch(avp->val.type) { ++ case SR_XTYPE_NULL: ++ lua_pushnil(L); ++ lua_setfield(L, -2, avp->name.s); ++ break; ++ case SR_XTYPE_INT: ++ i = avp->val.v.i; ++ lua_pushnumber(L, i); ++ lua_setfield(L, -2, avp->name.s); ++ break; ++ case SR_XTYPE_STR: ++ lua_pushlstring(L, avp->val.v.s.s, avp->val.v.s.len); ++ lua_setfield(L, -2, avp->name.s); ++ break; ++ case SR_XTYPE_TIME: ++ case SR_XTYPE_LONG: ++ case SR_XTYPE_LLONG: ++ case SR_XTYPE_DATA: ++ lua_pushnil(L); ++ lua_setfield(L, -2, avp->name.s); ++ LM_WARN("XAVP type:%d value not supported\n", avp->val.type); ++ break; ++ case SR_XTYPE_XAVP: ++ if(!lua_sr_push_xavp_table(L,avp->val.v.xavp)){ ++ LM_ERR("xavp:%.*s subtable error. Nil value added\n", avp->name.len, avp->name.s); ++ lua_pushnil(L); ++ } ++ lua_setfield(L, -2, avp->name.s); ++ break; ++ } ++ avp = avp->next; ++ } ++ return 1; ++} ++ + /** + * puts a table with content of a xavp + */ +@@ -1246,23 +1297,38 @@ static int lua_sr_xavp_get(lua_State *L) + int indx = 0; + sr_lua_env_t *env_L; + sr_xavp_t *avp; ++ int num_param = 0; ++ int param = -1; ++ int simple_flag = 0; + + env_L = sr_lua_env_get(); +- +- if(lua_gettop(L)<2) ++ num_param = lua_gettop(L); ++ if(num_param<2 && num_param>3) + { +- LM_ERR("to few parameters [%d]\n",lua_gettop(L)); ++ LM_ERR("wrong number of parameters [%d]\n", num_param); + return 0; + } + +- if(!lua_isnumber(L, -1)) ++ if(num_param==3) ++ { ++ if(!lua_isnumber(L, param)) ++ { ++ LM_ERR("invalid int parameter\n"); ++ return 0; ++ } ++ simple_flag = lua_tointeger(L, param); ++ param = param - 1; ++ } ++ ++ if(!lua_isnumber(L, param)) + { + LM_ERR("invalid int parameter\n"); + return 0; + } +- indx = lua_tointeger(L, -1); ++ indx = lua_tointeger(L, param); ++ param = param - 1; + +- xavp_name.s = (char*)lua_tostring(L, -2); ++ xavp_name.s = (char*)lua_tostring(L, param); + if(xavp_name.s==NULL || env_L->msg==NULL) + return 0; + xavp_name.len = strlen(xavp_name.s); +@@ -1273,7 +1339,15 @@ static int lua_sr_xavp_get(lua_State *L) + lua_pushnil(L); + return 1; + } +- lua_sr_push_xavp_table(L, avp); ++ ++ if (simple_flag != 0) ++ { ++ lua_sr_push_xavp_table_simple(L, avp); ++ } ++ else ++ { ++ lua_sr_push_xavp_table(L, avp); ++ } + return 1; + } + +-- +1.7.10.4 + diff --git a/debian/patches/upstream/modules-app_lua-fix-sr.xavp.get.-Get-all-the-values-.patch b/debian/patches/upstream/modules-app_lua-fix-sr.xavp.get.-Get-all-the-values-.patch new file mode 100644 index 000000000..64c17ff4c --- /dev/null +++ b/debian/patches/upstream/modules-app_lua-fix-sr.xavp.get.-Get-all-the-values-.patch @@ -0,0 +1,122 @@ +From 4a79fcdd9965c6c3195601baeb82d489d970aa12 Mon Sep 17 00:00:00 2001 +From: Victor Seva +Date: Tue, 9 Jul 2013 15:55:35 +0200 +Subject: [PATCH] modules/app_lua: fix sr.xavp.get. Get all the values not + only the first one. + +--- + modules/app_lua/app_lua_sr.c | 65 ++++++++++++++++++++++++++++++++---------- + 1 file changed, 50 insertions(+), 15 deletions(-) + +diff --git a/modules/app_lua/app_lua_sr.c b/modules/app_lua/app_lua_sr.c +index 93b89b8..4075ef8 100644 +--- a/modules/app_lua/app_lua_sr.c ++++ b/modules/app_lua/app_lua_sr.c +@@ -1151,42 +1151,40 @@ static int lua_sr_push_str_list_table(lua_State *L, struct str_list *list) { + return 1; + } + ++static int lua_sr_push_xavp_table(lua_State *L, sr_xavp_t *xavp); ++ + /** +- * creates and push a table to the lua stack with +- * the elements of the xavp ++ * creates and push a table for the key name in xavp + */ +-static int lua_sr_push_xavp_table(lua_State *L, sr_xavp_t *xavp) { ++static void lua_sr_push_xavp_name_table(lua_State *L, sr_xavp_t *xavp, str name) { + lua_Number i = 1; +- sr_xavp_t *avp = NULL; ++ lua_Number elem = 1; ++ sr_xavp_t *avp = xavp; + +- if(xavp->val.type!=SR_XTYPE_XAVP){ +- LM_ERR("%s not xavp?\n", xavp->name.s); +- return 0; ++ while(avp!=NULL&&!STR_EQ(avp->name,name)) ++ { ++ avp = avp->next; + } +- avp = xavp->val.v.xavp; +- + lua_newtable(L); ++ + while(avp!=NULL){ ++ lua_pushnumber(L, elem); + switch(avp->val.type) { + case SR_XTYPE_NULL: + lua_pushnil(L); +- lua_setfield(L, -2, avp->name.s); + break; + case SR_XTYPE_INT: + i = avp->val.v.i; + lua_pushnumber(L, i); +- lua_setfield(L, -2, avp->name.s); + break; + case SR_XTYPE_STR: + lua_pushlstring(L, avp->val.v.s.s, avp->val.v.s.len); +- lua_setfield(L, -2, avp->name.s); + break; + case SR_XTYPE_TIME: + case SR_XTYPE_LONG: + case SR_XTYPE_LLONG: + case SR_XTYPE_DATA: + lua_pushnil(L); +- lua_setfield(L, -2, avp->name.s); + LM_WARN("XAVP type:%d value not supported\n", avp->val.type); + break; + case SR_XTYPE_XAVP: +@@ -1194,11 +1192,48 @@ static int lua_sr_push_xavp_table(lua_State *L, sr_xavp_t *xavp) { + LM_ERR("xavp:%.*s subtable error. Nil value added\n", avp->name.len, avp->name.s); + lua_pushnil(L); + } +- lua_setfield(L, -2, avp->name.s); ++ break; ++ default: ++ LM_ERR("xavp:%.*s unknown type: %d. Nil value added\n", ++ avp->name.len, avp->name.s, avp->val.type); ++ lua_pushnil(L); + break; + } +- avp = avp->next; ++ lua_rawset(L, -3); ++ elem = elem + 1; ++ avp = xavp_get_next(avp); ++ } ++ lua_setfield(L, -2, name.s); ++} ++ ++/** ++ * creates and push a table to the lua stack with ++ * the elements of the xavp ++ */ ++static int lua_sr_push_xavp_table(lua_State *L, sr_xavp_t *xavp) { ++ sr_xavp_t *avp = NULL; ++ struct str_list *keys; ++ struct str_list *k; ++ ++ if(xavp->val.type!=SR_XTYPE_XAVP){ ++ LM_ERR("%s not xavp?\n", xavp->name.s); ++ return 0; + } ++ avp = xavp->val.v.xavp; ++ keys = xavp_get_list_key_names(xavp); ++ ++ lua_newtable(L); ++ if(keys!=NULL) ++ { ++ do ++ { ++ lua_sr_push_xavp_name_table(L, avp, keys->s); ++ k = keys; ++ keys = keys->next; ++ pkg_free(k); ++ }while(keys!=NULL); ++ } ++ + return 1; + } + +-- +1.7.10.4 +