[sr-dev] Kamailio variable -> Kamailio script.

Luis Martin Gil martingil.luis at gmail.com
Tue Oct 25 19:11:53 CEST 2011


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);



More information about the sr-dev mailing list