[Kamailio-Devel] cfgutils api

Elena-Ramona Modroiu ramona at rosdev.ro
Tue Aug 26 17:02:48 CEST 2008


Juha Heinanen wrote:
> Elena-Ramona Modroiu writes:
>
>  > you can simply give NULL value as parameter.
>
> ramona,
>
> that worked fine.  now i have in mod_init of shv_test module:
>
>     /* Shared variable test */
>     name.s = "$shv(enum_domains)";
>     name.len = strlen(name.s);
>     if (pv_parse_spec(&name, &spec) == NULL) {
> 	LM_ERR("invalid shared variable specification\n");
> 	return -1;
>     }
>     memset(&value, 0, sizeof(pv_value_t));
>     value.rs.s = "e164.arpa.";
>     value.rs.len = strlen(value.rs.s);
>     value.flags = PV_VAL_STR;
>     spec.setf(NULL, &spec.pvp, EQ_T, &value);
>
> and shared variable $shv(enum_domains) gets correctly assigned value
> "e164.arpa.", if and only if i have:
>
> loadmodule "cfgutils.so"
> loadmodule "shv_test.so"
> ...
> modparam("cfgutils", "shvset", "enum_domains=s:foo")
>
> that is, i create shared variable ""enum_domains" by cfgutils module.
>
> however, if i don't define the above cfgutils shvset module parameter, i
> get error message:
>
> Aug 26 17:09:18 localhost /usr/sbin/kamailio[22934]: ERROR:core:pv_parse_spec: error searching pvar "shv" 
> Aug 26 17:09:18 localhost /usr/sbin/kamailio[22934]: ERROR:core:pv_parse_spec: wrong char [e/101] in [$shv(enum_domains)] at [5 (5)] 
> Aug 26 17:09:18 localhost /usr/sbin/kamailio[22934]: ERROR:shv_test:mod_init: invalid shared variable specification 
> Aug 26 17:09:18 localhost /usr/sbin/kamailio[22934]: ERROR:core:init_mod: failed to initialize module shv_test
>   
shv variables are registered when config is parsed or via modparam. Are 
you using the $shv(enum_domains) anywhere in config file?

If not, the workaround is to set a value via modparam. For the future I 
will see what can be done to have such variables even they are not used 
in the config file.

Regards,
Ramona

> my next question is, how can i create a new shared variable in shv_test
> module without a need to do that by cfgutils module?  i have searched
> core/pvar.h, but have not found a pv create function.
>
> -- juha
>
>
>   




More information about the Devel mailing list