kamailio.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
List overview
Download
sr-dev
November 2022
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
sr-dev@lists.kamailio.org
11 participants
216 discussions
Start a n
N
ew thread
git: new commits in branch master
by Daniel-Constantin Mierla
- URL:
https://github.com/kamailio/kamailio/commit/8c4feb02e0e85771746b5c39af9fe65…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T08:48:18+01:00 ims_dialog: cast pv value to long - URL:
https://github.com/kamailio/kamailio/commit/00a8b6d765cdd8a1fc3b77416912f11…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T09:02:18+01:00 lib/srdb1: cast pv value to long - URL:
https://github.com/kamailio/kamailio/commit/d536fb24bc265358924887877ce4395…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T10:32:21+01:00 core: avp - number field set to long - URL:
https://github.com/kamailio/kamailio/commit/887903caa12a7cae785a8814ee9fa9a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:34+01:00 avp: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/132ffd7a48664c013aa3c095996e0c3…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:34+01:00 avpops: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/bbaafb0bc0b94a7b14c1ef17d731521…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:34+01:00 carrierroute: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/8cdcb9b28c22b40099df3bab3a402eb…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:34+01:00 cfgt: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/46214133bf64b8c89872b9937cda54c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:34+01:00 debugger: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/59fb187c7706f9e59cdb69079127b5c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:34+01:00 domain: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/34ec72e099eb51a81a32155fc7e50cb…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:34+01:00 domainpolicy: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/d2f1e39d153fb0b6b83085f980cb6d8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:34+01:00 group: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/ce0d289824b5dac742355340703e705…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:34+01:00 htable: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/179af99d46d176e07cfaff4057025b6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:34+01:00 matrix: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/25afad678b5753af6f3ad68fee44c7e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:35+01:00 mtree: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/6033dbf16a3f16292ef2dece95aba4e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:35+01:00 pv: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/39b71dcf637794ef95a1e218e9bb285…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:35+01:00 rtpengine: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/9911482bc6889107a1930239f4e2860…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:35+01:00 rtpproxy: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/6a5c4930976a9e2a6d52748524759f4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:35+01:00 sdpops: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/6a22d4168a1614cf84df690ac6b56c0…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:35+01:00 tls: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/5ff6404b4d5d63a3c0b573b485abfb1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:09:35+01:00 tm: updated for avp long value field - URL:
https://github.com/kamailio/kamailio/commit/7f258d97431a9a4bccf8155def52c9e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:28:32+01:00 sipcapture: debug message with header offset and address family - URL:
https://github.com/kamailio/kamailio/commit/d1db642736e9b573644f97a828dc7ac…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-21T11:30:35+01:00 core: avp - renamed structures to use num instead of int - type of number is long
2 years
1
0
0
0
git:master:cbcad7a1: core: updates to functions for cfg val int to long replacement
by Daniel-Constantin Mierla
Module: kamailio Branch: master Commit: cbcad7a16173c2c436aabb70f848bcde5eb839b2 URL:
https://github.com/kamailio/kamailio/commit/cbcad7a16173c2c436aabb70f848bcd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Committer: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-18T19:11:53+01:00 core: updates to functions for cfg val int to long replacement --- Modified: src/core/action.c Modified: src/core/route.c Modified: src/core/rvalue.c Modified: src/core/rvalue.h Modified: src/core/switch.c Modified: src/core/switch.h --- Diff:
https://github.com/kamailio/kamailio/commit/cbcad7a16173c2c436aabb70f848bcd…
Patch:
https://github.com/kamailio/kamailio/commit/cbcad7a16173c2c436aabb70f848bcd…
2 years
1
0
0
0
git:master:d02732ad: core: helper function to get mod param function in a string buffer
by Daniel-Constantin Mierla
Module: kamailio Branch: master Commit: d02732adef800b7a1107d106ac8e58730e256485 URL:
https://github.com/kamailio/kamailio/commit/d02732adef800b7a1107d106ac8e587…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Committer: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-17T14:40:07+01:00 core: helper function to get mod param function in a string buffer --- Modified: src/core/mod_fix.h Modified: src/core/sr_module.c Modified: src/core/sr_module.h --- Diff:
https://github.com/kamailio/kamailio/commit/d02732adef800b7a1107d106ac8e587…
Patch:
https://github.com/kamailio/kamailio/commit/d02732adef800b7a1107d106ac8e587…
--- diff --git a/src/core/mod_fix.h b/src/core/mod_fix.h index 8c2c766c1e..043b1e3546 100644 --- a/src/core/mod_fix.h +++ b/src/core/mod_fix.h @@ -62,6 +62,8 @@ int fixup_get_svalue(struct sip_msg* msg, gparam_p gp, str *val); */ #define fixup_get_svalue(msg, fp, sval) get_str_fparam(sval, msg, fp) +#define fixup_get_bufvalue(msg, fp, sval) get_strbuf_fparam(sval, msg, fp) + /** get an int value out of a fparam_t. * * Note: this macro/function is for kamailio compatibility diff --git a/src/core/sr_module.c b/src/core/sr_module.c index d869b8ae63..154ce27740 100644 --- a/src/core/sr_module.c +++ b/src/core/sr_module.c @@ -1727,6 +1727,92 @@ int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param) } +/** Get the function parameter value as string cpoied in the dst->s buffer. + * - dst->len has to provide size of dst->s buffer and it is updated to the + * size of the value + * @return 0 - Success + * -1 - Cannot get value + */ +int get_strbuf_fparam(str* dst, struct sip_msg* msg, fparam_t* param) +{ + int_str val; + int ret; + avp_t* avp; + pv_value_t pv_val; + str sv = STR_NULL; + + if(dst==NULL || dst->s==NULL || dst->len<=0) { + return -1; + } + + switch(param->type) { + case FPARAM_REGEX: + case FPARAM_UNSPEC: + case FPARAM_INT: + return -1; + case FPARAM_STRING: + sv.s = param->v.asciiz; + sv.len = strlen(param->v.asciiz); + break; + case FPARAM_STR: + sv = param->v.str; + break; + case FPARAM_AVP: + avp = search_first_avp(param->v.avp.flags, param->v.avp.name, + &val, 0); + if (unlikely(!avp)) { + LM_DBG("Could not find AVP from function parameter '%s'\n", + param->orig); + return -1; + } + if (likely(avp->flags & AVP_VAL_STR)) { + sv = val.s; + } else { + /* The caller does not know of what type the AVP will be so + * convert int AVPs into string here + */ + sv.s = int2str(val.n, &sv.len); + } + break; + case FPARAM_SELECT: + ret = run_select(&sv, param->v.select, msg); + if (unlikely(ret < 0 || ret > 0)) return -1; + break; + case FPARAM_PVS: + if (likely((pv_get_spec_value(msg, param->v.pvs, &pv_val)==0) && + ((pv_val.flags&(PV_VAL_NULL|PV_VAL_STR))==PV_VAL_STR))){ + sv=pv_val.rs; + }else{ + LM_ERR("Could not convert PV to str\n"); + return -1; + } + break; + case FPARAM_PVE: + if (unlikely(pv_printf(msg, param->v.pve, dst->s, &dst->len)!=0)){ + LM_ERR("Could not convert the PV-formated string to str\n"); + dst->len=0; + return -1; + }; + break; + } + if(param->type != FPARAM_PVE) { + if(sv.len>=dst->len-1) { + LM_ERR("not enough space in output buffer (size: %d need: %d)\n", + dst->len, sv.len); + return -1; + } + if(sv.len > 0) { + memcpy(dst->s, sv.s, sv.len); + dst->len = sv.len; + dst->s[dst->len] = '\0'; + } else { + dst->len = 0; + dst->s[dst->len] = '\0'; + } + } + return 0; +} + /** Get the function parameter value as integer. * @return 0 - Success * -1 - Cannot get value diff --git a/src/core/sr_module.h b/src/core/sr_module.h index 7235c2840a..ba6f54bd8d 100644 --- a/src/core/sr_module.h +++ b/src/core/sr_module.h @@ -489,6 +489,8 @@ int fixup_str_2(void** param, int param_no); */ int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param); +int get_strbuf_fparam(str* dst, struct sip_msg* msg, fparam_t* param); + /** * @brief Get the function parameter value as integer * @param dst string destination
2 years
1
0
0
0
git:master:1256392a: modules: readme files regenerated - jansson ... [skip ci]
by Kamailio Dev
Module: kamailio Branch: master Commit: 1256392ab12ec1ada491f2fc5212bb99ba6fc14c URL:
https://github.com/kamailio/kamailio/commit/1256392ab12ec1ada491f2fc5212bb9…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org> Committer: Kamailio Dev <kamailio.dev(a)kamailio.org> Date: 2022-11-17T13:46:55+01:00 modules: readme files regenerated - jansson ... [skip ci] --- Modified: src/modules/jansson/README --- Diff:
https://github.com/kamailio/kamailio/commit/1256392ab12ec1ada491f2fc5212bb9…
Patch:
https://github.com/kamailio/kamailio/commit/1256392ab12ec1ada491f2fc5212bb9…
2 years
1
0
0
0
git:master:d47d62f5: jansson: docs for jansson_pv_get() function
by Daniel-Constantin Mierla
Module: kamailio Branch: master Commit: d47d62f54c9115c765a1437ffc8c8e619e056f54 URL:
https://github.com/kamailio/kamailio/commit/d47d62f54c9115c765a1437ffc8c8e6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Committer: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-17T13:44:37+01:00 jansson: docs for jansson_pv_get() function --- Modified: src/modules/jansson/doc/jansson_admin.xml --- Diff:
https://github.com/kamailio/kamailio/commit/d47d62f54c9115c765a1437ffc8c8e6…
Patch:
https://github.com/kamailio/kamailio/commit/d47d62f54c9115c765a1437ffc8c8e6…
--- diff --git a/src/modules/jansson/doc/jansson_admin.xml b/src/modules/jansson/doc/jansson_admin.xml index b65fb70d8cd..969804c96b2 100644 --- a/src/modules/jansson/doc/jansson_admin.xml +++ b/src/modules/jansson/doc/jansson_admin.xml @@ -59,7 +59,8 @@ <function moreinfo="none">jansson_get(key/path, src, dst)</function> </title> <para> - Copy the value at the location 'path' from the json object 'src' and store it in pvar 'dst'. + Copy the value at the location 'path' from the json object 'src' and store it in pvar 'dst'. + The 'src' can be a static string or a dynamic string with variables. </para> <para> The path string supports dot delimited notation (e.g. foo.bar.baz), @@ -82,7 +83,29 @@ <title><function>jansson_get</function> usage</title> <programlisting format="linespecific"> ... -if(!jansson_get("inner.deep.list[3]", $var(myjson), "$var(n)")) { +if(!jansson_get("inner.deep.list[3]", "$var(myjson)", "$var(n)")) { + xlog("L_ERR", "Can't parse json data"); +} +xlog("L_INFO", "foo is $var(n)"); +... +jansson_get("test", "{\"test\":\"abc\",\"idx\":20}", "$var(n)") +... + </programlisting> + </example> + </section> + <section id="jansson.f.jansson_pv_get"> + <title> + <function moreinfo="none">jansson_pv_get(key/path, srcvar, dst)</function> + </title> + <para> + Similar to jansson_get(), but the 'srcvar' parameter can be only a + variable name. + </para> + <example> + <title><function>jansson_pv_get</function> usage</title> + <programlisting format="linespecific"> +... +if(!jansson_pv_get("inner.deep.list[3]", "$var(myjson)", "$var(n)")) { xlog("L_ERR", "Can't parse json data"); } xlog("L_INFO", "foo is $var(n)");
2 years
1
0
0
0
git:master:3ce5c42c: jansson: added jansson_pv_get(...)
by Daniel-Constantin Mierla
Module: kamailio Branch: master Commit: 3ce5c42c53dcf6f3f1da952d3b523876c7381913 URL:
https://github.com/kamailio/kamailio/commit/3ce5c42c53dcf6f3f1da952d3b52387…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Committer: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-17T13:38:05+01:00 jansson: added jansson_pv_get(...) - similar to jansson_geet(), but the input has to be a single variable name, not a dynamic string --- Modified: src/modules/jansson/jansson_funcs.c Modified: src/modules/jansson/jansson_funcs.h Modified: src/modules/jansson/jansson_mod.c --- Diff:
https://github.com/kamailio/kamailio/commit/3ce5c42c53dcf6f3f1da952d3b52387…
Patch:
https://github.com/kamailio/kamailio/commit/3ce5c42c53dcf6f3f1da952d3b52387…
--- diff --git a/src/modules/jansson/jansson_funcs.c b/src/modules/jansson/jansson_funcs.c index 857b6871f0c..0ff937ee7be 100644 --- a/src/modules/jansson/jansson_funcs.c +++ b/src/modules/jansson/jansson_funcs.c @@ -92,6 +92,29 @@ int janssonmod_get(struct sip_msg* msg, char* path_in, char* src_in, char* dst) return janssonmod_get_helper(msg, &path_s, &src_s, (pv_spec_t *)dst); } +int janssonmod_pv_get(struct sip_msg* msg, char* path_in, char* src_in, char* dst) +{ + str path_s; + pv_value_t val; + int ret; + + if((pv_get_spec_value(msg, (pv_spec_t*)src_in, &val) < 0) + || ((val.flags & PV_VAL_STR) == 0)) { + ERR("cannot get json string value\n"); + return -1; + } + if (fixup_get_svalue(msg, (gparam_p)path_in, &path_s) != 0) { + ERR("cannot get path string value\n"); + return -1; + } + + ret = janssonmod_get_helper(msg, &path_s, &val.rs, (pv_spec_t*)dst); + + pv_value_destroy(&val); + + return ret; +} + #define STR_EQ_STATIC(a,b) ((a.len == sizeof(b)-1) && (strncmp(a.s, b, sizeof(b)-1)==0)) int janssonmod_set(unsigned int append, struct sip_msg* msg, char* type_in, diff --git a/src/modules/jansson/jansson_funcs.h b/src/modules/jansson/jansson_funcs.h index aeaf0791b90..ce8e9d5b4a1 100644 --- a/src/modules/jansson/jansson_funcs.h +++ b/src/modules/jansson/jansson_funcs.h @@ -27,6 +27,8 @@ int janssonmod_get(struct sip_msg* msg, char* path_in, char* json_in, char* result); +int janssonmod_pv_get(struct sip_msg* msg, char* path_in, char* json_in, + char* result); int janssonmod_set(unsigned int append, struct sip_msg* msg, char* type_in, char* path_in, char* value_in, char* result); int janssonmod_array_size(struct sip_msg* msg, char* json_in, diff --git a/src/modules/jansson/jansson_mod.c b/src/modules/jansson/jansson_mod.c index 6a2fe6ead66..46cfda2fec4 100644 --- a/src/modules/jansson/jansson_mod.c +++ b/src/modules/jansson/jansson_mod.c @@ -36,6 +36,8 @@ MODULE_VERSION static int mod_init(void); static int fixup_get_params(void** param, int param_no); static int fixup_get_params_free(void** param, int param_no); +static int fixup_pv_get_params(void** param, int param_no); +static int fixup_pv_get_params_free(void** param, int param_no); static int fixup_set_params(void** param, int param_no); static int fixup_set_params_free(void** param, int param_no); static int fixup_xencode(void** param, int param_no); @@ -60,6 +62,8 @@ int janssonmod_get_field(struct sip_msg* msg, char* jansson_in, char* path_in, static cmd_export_t cmds[]={ {"jansson_get", (cmd_function)janssonmod_get, 3, fixup_get_params, fixup_get_params_free, ANY_ROUTE}, + {"jansson_pv_get", (cmd_function)janssonmod_pv_get, 3, + fixup_pv_get_params, fixup_pv_get_params_free, ANY_ROUTE}, {"jansson_array_size", (cmd_function)janssonmod_array_size, 3, fixup_get_params, fixup_get_params_free, ANY_ROUTE}, {"jansson_set", (cmd_function)janssonmod_set_replace, 4, @@ -121,6 +125,34 @@ static int fixup_get_params_free(void** param, int param_no) return -1; } +static int fixup_pv_get_params(void** param, int param_no) +{ + if (param_no == 1) { + return fixup_spve_null(param, 1); + } + + if (param_no == 2 || param_no == 3) { + return fixup_pvar_null(param, 1); + } + + ERR("invalid parameter number <%d>\n", param_no); + return -1; +} + +static int fixup_pv_get_params_free(void** param, int param_no) +{ + if (param_no == 1) { + return fixup_free_spve_null(param, 1); + } + + if (param_no == 2 || param_no == 3) { + return fixup_free_pvar_null(param, 1); + } + + ERR("invalid parameter number <%d>\n", param_no); + return -1; +} + static int fixup_set_params(void** param, int param_no) { if(param_no <= 3) { @@ -232,4 +264,4 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2) { sr_kemi_modules_add(sr_kemi_jansson_exports); return 0; -} \ No newline at end of file +}
2 years
1
0
0
0
git:master:a83e44b7: core: new global parameter return_mode
by Daniel-Constantin Mierla
Module: kamailio Branch: master Commit: a83e44b7a942afcf1770fa179cda8e530c74e28a URL:
https://github.com/kamailio/kamailio/commit/a83e44b7a942afcf1770fa179cda8e5…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com> Committer: Daniel-Constantin Mierla <miconda(a)gmail.com> Date: 2022-11-17T13:08:59+01:00 core: new global parameter return_mode - control the return code evaluation mode: - 0 (default) - evaluation is like so far (negative is false, positive is true) - 1 - propagate return value and evaluation has to be done with >0 or <0, otherwise value!=0 is evaluated to true no matter is negative or positive --- Modified: src/core/action.c Modified: src/core/cfg.lex Modified: src/core/cfg.y Modified: src/core/globals.h Modified: src/core/rvalue.c --- Diff:
https://github.com/kamailio/kamailio/commit/a83e44b7a942afcf1770fa179cda8e5…
Patch:
https://github.com/kamailio/kamailio/commit/a83e44b7a942afcf1770fa179cda8e5…
--- diff --git a/src/core/action.c b/src/core/action.c index 48b150dd70..b95c531e1d 100644 --- a/src/core/action.c +++ b/src/core/action.c @@ -1065,7 +1065,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg) h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return & break in expr*/ ret=1; /*default is continue */ - if (v>0) { + if ((ksr_return_mode==0 && v>0) || (ksr_return_mode!=0 && v!=0)) { if ((a->val[1].type==ACTIONS_ST)&&a->val[1].u.data){ ret=run_actions(h, (struct action*)a->val[1].u.data, msg); @@ -1363,12 +1363,13 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg) rve=(struct rval_expr*)a->val[0].u.data; ret=1; while(!(flags & (BREAK_R_F|RETURN_R_F|EXIT_R_F)) && - (rval_expr_eval_int(h, msg, &v, rve) == 0) && v){ + (rval_expr_eval_int(h, msg, &v, rve) == 0) && + ((ksr_return_mode==0 && v>0) || (ksr_return_mode!=0 && v!=0))) { if (cfg_get(core, core_cfg, max_while_loops) > 0) i++; if (unlikely(i > cfg_get(core, core_cfg, max_while_loops))){ - LM_ERR("runaway while (%d, %d): more then %d loops\n", + LM_ERR("runaway while (%d, %d): more then %d loops\n", rve->fpos.s_line, rve->fpos.s_col, cfg_get(core, core_cfg, max_while_loops)); ret=-1; diff --git a/src/core/cfg.lex b/src/core/cfg.lex index cc0afb8f22..d4379da3fc 100644 --- a/src/core/cfg.lex +++ b/src/core/cfg.lex @@ -147,6 +147,7 @@ FORWARD_SCTP forward_sctp DROP "drop" EXIT "exit" RETURN "return" +RETURN_MODE "return_mode" BREAK "break" LOG log ERROR error @@ -1049,6 +1050,7 @@ IMPORTFILE "import_file" <INITIAL>{CFGENGINE} { count(); yylval.strval=yytext; return CFGENGINE; } <INITIAL>{URI_HOST_EXTRA_CHARS} { yylval.strval=yytext; return URI_HOST_EXTRA_CHARS; } <INITIAL>{HDR_NAME_EXTRA_CHARS} { yylval.strval=yytext; return HDR_NAME_EXTRA_CHARS; } +<INITIAL>{RETURN_MODE} { count(); yylval.strval=yytext; return RETURN_MODE; } <INITIAL>{EQUAL} { count(); return EQUAL; } <INITIAL>{ADDEQ} { count(); return ADDEQ; } diff --git a/src/core/cfg.y b/src/core/cfg.y index 89eb5c210f..230be193dd 100644 --- a/src/core/cfg.y +++ b/src/core/cfg.y @@ -227,6 +227,7 @@ extern char *default_routename; %token EXIT %token DROP %token RETURN +%token RETURN_MODE %token BREAK %token LOG_TOK %token ERROR @@ -1900,6 +1901,8 @@ assign_stm: | WAIT_WORKER1_USLEEP EQUAL error { yyerror("number expected"); } | SERVER_ID EQUAL NUMBER { server_id=$3; } | SERVER_ID EQUAL error { yyerror("number expected"); } + | RETURN_MODE EQUAL NUMBER { ksr_return_mode=$3; } + | RETURN_MODE EQUAL error { yyerror("number expected"); } | KEMI DOT ONSEND_ROUTE_CALLBACK EQUAL STRING { kemi_onsend_route_callback.s = $5; kemi_onsend_route_callback.len = strlen($5); diff --git a/src/core/globals.h b/src/core/globals.h index 03eb1ef897..8d72807aee 100644 --- a/src/core/globals.h +++ b/src/core/globals.h @@ -219,6 +219,7 @@ extern str _ksr_xavp_via_params; extern str _ksr_xavp_via_fields; extern int ksr_sip_parser_mode; extern int ksr_cfg_print_mode; +extern int ksr_return_mode; extern int ksr_wait_worker1_mode; extern int ksr_wait_worker1_time; diff --git a/src/core/rvalue.c b/src/core/rvalue.c index 9e5268c888..4ab93f44f4 100644 --- a/src/core/rvalue.c +++ b/src/core/rvalue.c @@ -82,6 +82,9 @@ #define rv_unref(rv) ((--(rv)->refcnt)==0) +/* control return code evaluation mode */ +int ksr_return_mode = 0; + inline static void rval_force_clean(struct rvalue* rv) { if (rv->flags & RV_CNT_ALLOCED_F){ @@ -946,7 +949,11 @@ int rval_get_int(struct run_act_ctx* h, struct sip_msg* msg, break; case RV_ACTION_ST: if (rv->v.action) { - *i=(run_actions_safe(h, rv->v.action, msg)>0); + if(unlikely(ksr_return_mode==1)) { + *i=run_actions_safe(h, rv->v.action, msg); + } else { + *i=(run_actions_safe(h, rv->v.action, msg)>0); + } h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return & break in expr*/ } else
2 years
1
0
0
0
git:5.5:fdfb8c55: dialog: remove dialog variable debugging function, it might cause race conditions
by Henning Westerholt
Module: kamailio Branch: 5.5 Commit: fdfb8c5563bd327774802cb08b68b27faee2e840 URL:
https://github.com/kamailio/kamailio/commit/fdfb8c5563bd327774802cb08b68b27…
Author: Henning Westerholt <hw(a)gilawa.com> Committer: Henning Westerholt <hw(a)gilawa.com> Date: 2022-11-16T16:05:42Z dialog: remove dialog variable debugging function, it might cause race conditions --- Modified: src/modules/dialog/dlg_var.c --- Diff:
https://github.com/kamailio/kamailio/commit/fdfb8c5563bd327774802cb08b68b27…
Patch:
https://github.com/kamailio/kamailio/commit/fdfb8c5563bd327774802cb08b68b27…
--- diff --git a/src/modules/dialog/dlg_var.c b/src/modules/dialog/dlg_var.c index b2a373a5018..8fd261c4bf5 100644 --- a/src/modules/dialog/dlg_var.c +++ b/src/modules/dialog/dlg_var.c @@ -254,31 +254,6 @@ int pv_parse_dialog_var_name(pv_spec_p sp, str *in) return 0; } -/*! Internal debugging function: Prints the list of dialogs */ -void print_lists(struct dlg_cell *dlg) { - struct dlg_var *varlist; - varlist = _dlg_var_table; - LM_DBG("Internal var-list (%p):\n", varlist); - while (varlist) { - LM_DBG("%.*s=%.*s (flags %i)\n", - varlist->key.len, varlist->key.s, - varlist->value.len, varlist->value.s, - varlist->vflags); - varlist = varlist->next; - } - if (dlg) { - varlist = dlg->vars; - LM_DBG("Dialog var-list (%p):\n", varlist); - while (varlist) { - LM_DBG("%.*s=%.*s (flags %i)\n", - varlist->key.len, varlist->key.s, - varlist->value.len, varlist->value.s, - varlist->vflags); - varlist = varlist->next; - } - } -} - str * get_dlg_variable(struct dlg_cell *dlg, str *key) { str* var = NULL; @@ -317,8 +292,6 @@ int set_dlg_variable(struct dlg_cell *dlg, str *key, str *val) if ( dlg_db_mode==DB_MODE_REALTIME ) update_dialog_dbinfo(dlg); - print_lists(dlg); - return 0; done: @@ -366,8 +339,6 @@ int pv_get_dlg_variable(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) } } - print_lists(dlg); - /* unlock dialog */ if (dlg) { dlg_unlock(d_table, &(d_table->entries[dlg->h_entry])); @@ -440,8 +411,6 @@ int pv_set_dlg_variable(struct sip_msg* msg, pv_param_t *param, int op, pv_value } dlg_unlock(d_table, &(d_table->entries[dlg->h_entry])); } - print_lists(dlg); - dlg_release(dlg); return 0; error:
2 years
1
0
0
0
git:5.6:1e083043: dialog: remove dialog variable debugging function, it might cause race conditions
by Henning Westerholt
Module: kamailio Branch: 5.6 Commit: 1e0830433e46827ed9424a6d9cc01e95546c04f0 URL:
https://github.com/kamailio/kamailio/commit/1e0830433e46827ed9424a6d9cc01e9…
Author: Henning Westerholt <hw(a)gilawa.com> Committer: Henning Westerholt <hw(a)gilawa.com> Date: 2022-11-16T16:02:09Z dialog: remove dialog variable debugging function, it might cause race conditions --- Modified: src/modules/dialog/dlg_var.c --- Diff:
https://github.com/kamailio/kamailio/commit/1e0830433e46827ed9424a6d9cc01e9…
Patch:
https://github.com/kamailio/kamailio/commit/1e0830433e46827ed9424a6d9cc01e9…
--- diff --git a/src/modules/dialog/dlg_var.c b/src/modules/dialog/dlg_var.c index 473736b4373..883b99b630f 100644 --- a/src/modules/dialog/dlg_var.c +++ b/src/modules/dialog/dlg_var.c @@ -254,31 +254,6 @@ int pv_parse_dialog_var_name(pv_spec_p sp, str *in) return 0; } -/*! Internal debugging function: Prints the list of dialogs */ -void print_lists(struct dlg_cell *dlg) { - struct dlg_var *varlist; - varlist = _dlg_var_table; - LM_DBG("Internal var-list (%p):\n", varlist); - while (varlist) { - LM_DBG("%.*s=%.*s (flags %i)\n", - varlist->key.len, varlist->key.s, - varlist->value.len, varlist->value.s, - varlist->vflags); - varlist = varlist->next; - } - if (dlg) { - varlist = dlg->vars; - LM_DBG("Dialog var-list (%p):\n", varlist); - while (varlist) { - LM_DBG("%.*s=%.*s (flags %i)\n", - varlist->key.len, varlist->key.s, - varlist->value.len, varlist->value.s, - varlist->vflags); - varlist = varlist->next; - } - } -} - /** * return reference to the dlg variable value * - unsafe - use only when it is sure that the value is not updated @@ -449,8 +424,6 @@ int set_dlg_variable(struct dlg_cell *dlg, str *key, str *val) if ( dlg_db_mode==DB_MODE_REALTIME ) update_dialog_dbinfo(dlg); - print_lists(dlg); - return 0; done: @@ -510,8 +483,6 @@ int pv_get_dlg_variable(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) } } - print_lists(dlg); - /* unlock dialog */ if (dlg) { dlg_unlock(d_table, &(d_table->entries[dlg->h_entry])); @@ -584,8 +555,6 @@ int pv_set_dlg_variable(struct sip_msg* msg, pv_param_t *param, int op, pv_value } dlg_unlock(d_table, &(d_table->entries[dlg->h_entry])); } - print_lists(dlg); - dlg_release(dlg); return 0; error:
2 years
1
0
0
0
git:master:83b1ebb1: dialog: remove variable self-assignment that causes compilation warnings
by Henning Westerholt
Module: kamailio Branch: master Commit: 83b1ebb1ef7f6eb5a2fbc05f0da5a0e9a1109eca URL:
https://github.com/kamailio/kamailio/commit/83b1ebb1ef7f6eb5a2fbc05f0da5a0e…
Author: Henning Westerholt <hw(a)gilawa.com> Committer: Henning Westerholt <hw(a)gilawa.com> Date: 2022-11-16T15:51:21Z dialog: remove variable self-assignment that causes compilation warnings --- Modified: src/modules/dialog/dlg_req_within.c --- Diff:
https://github.com/kamailio/kamailio/commit/83b1ebb1ef7f6eb5a2fbc05f0da5a0e…
Patch:
https://github.com/kamailio/kamailio/commit/83b1ebb1ef7f6eb5a2fbc05f0da5a0e…
--- diff --git a/src/modules/dialog/dlg_req_within.c b/src/modules/dialog/dlg_req_within.c index c073988448..05305950b0 100644 --- a/src/modules/dialog/dlg_req_within.c +++ b/src/modules/dialog/dlg_req_within.c @@ -488,7 +488,6 @@ dlg_t * build_dlg_t_early(struct sip_msg *msg, struct dlg_cell * cell, branch_id, cell->t->nr_of_outgoings); goto error; } - msg = msg; } if (!msg->contact && (parse_headers(msg,HDR_CONTACT_F,0)<0
2 years
1
1
0
0
← Newer
1
...
16
17
18
19
20
21
22
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Results per page:
10
25
50
100
200