Module: kamailio Branch: master Commit: 2f3f38d552667e392dadf45aa92f73b9a5647029 URL: https://github.com/kamailio/kamailio/commit/2f3f38d552667e392dadf45aa92f73b9a5647029
Author: Daniel-Constantin Mierla <mico...@gmail.com> Committer: Daniel-Constantin Mierla <mico...@gmail.com> Date: 2025-07-28T15:06:38+02:00 core: rpc function to set integer modparam stored in shared memory - kamcli modparam.setn modname paramname ival --- Modified: src/core/core_cmd.c --- Diff: https://github.com/kamailio/kamailio/commit/2f3f38d552667e392dadf45aa92f73b9a5647029.diff Patch: https://github.com/kamailio/kamailio/commit/2f3f38d552667e392dadf45aa92f73b9a5647029.patch --- diff --git a/src/core/core_cmd.c b/src/core/core_cmd.c index 779d77bf847..f368850d420 100644 --- a/src/core/core_cmd.c +++ b/src/core/core_cmd.c @@ -1169,12 +1169,55 @@ static void rpc_modparam_getn(rpc_t *rpc, void *c) return; } +static const char *rpc_modparam_setn_doc[] = { + "Set the value of an integer parameter kept in shared memory.", 0}; + +static void rpc_modparam_setn(rpc_t *rpc, void *c) +{ + char *mname; + char *pname; + int oval; + int nval; + sr_module_t *mod = NULL; + void *pp = NULL; + modparam_t param_type = 0; + void *h = NULL; + + if(rpc->scan(c, "ssd", &mname, &pname, &nval) < 3) { + rpc->fault(c, 400, "Module, Parameter And Value Expected"); + return; + } + + mod = find_module_by_name(mname); + if(mod == NULL) { + rpc->fault(c, 404, "Module Not Found"); + return; + } + pp = find_param_export(mod, pname, PARAM_INT, ¶m_type); + if(pp == NULL) { + rpc->fault(c, 404, "Parameter Not Found"); + return; + } + if(!(param_type & PARAM_USE_SHM)) { + rpc->fault(c, 488, "Not Acceptable Here"); + return; + } + oval = *(*((int **)pp)); + *(*((int **)pp)) = nval; + + rpc->add(c, "{", &h); + rpc->struct_add(h, "sssdd", "module", mname, "param", pname, "shm", "yes", + "ovalue", oval, "value", nval); + return; +} + /* * RPC Methods exported by core for modparam operations */ /* clang-format off */ static rpc_export_t core_modparam_rpc_methods[] = { {"modparam.getn", rpc_modparam_getn, rpc_modparam_getn_doc, 0}, + {"modparam.setn", rpc_modparam_setn, rpc_modparam_setn_doc, 0}, {0, 0, 0, 0} }; _______________________________________________ Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org To unsubscribe send an email to sr-dev-le...@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!