Hi,
I'm trying to pass a variable back to the Kamailio script from the Kamailio
module. Let's say that my module is called "random" and it exports the
function:
static int do_this(struct sip_msg *msg, char* _information);
- I pass some "_param1" and "_param2" parameters to this function
from
Kamailio script:
(Kamailio script code)
loadmodule "random.so"
modparam("random", "_param1", "www.host.com")
modparam("random", "_param2", 8877)
- "_information" is the content I get back from the function.
Reading _param1 and _param2 from the function of the module is
pretty straight forward. In order to write the "_information" variable
and being able to read from Kamailio script :
(Module code)
// this is inside do_this() function
// "content" has the value of the information that I would like to pass back
from the function.
pv_spec_t* dst;
pv_value_t val;
val.rs.s = content;
val.rs.len = strlen(content);
val.flags = PV_VAL_STR;
dst = (pv_spec_t *) _information;
dst->setf(msg, &dst->pvp, (int)EQ_T, &val);
From Kamailio script I can do:
(Kamailio script
code)
xlog("L_INFO","Calling do_this()\n");
$var(result) = do_this("$var(response)");
xlog("L_INFO","Returning do_this(). result=$var(result).
uri=$var(response)\n");
And works fine.
Now, I was wondering If I can have the _information parameter as this :
(Kamailio script code)
loadmodule "random.so"
modparam("random", "_param1", "www.host.com")
modparam("random", "_param2", 8877)
modparam("random", "_information", $(response))
Changing the interface of the function as:
static int do_this(struct sip_msg *msg);
Calling from the kamailio script as this:
(Kamailio script code)
xlog("L_INFO","Calling do_this()\n");
$var(result) = do_this();
xlog("L_INFO","Returning do_this(). result=$var(result).
uri=$var(response)\n");
But it doesn't work.
Anyone is welcome to provide insight.
Thanks,
Luis