No subject
Tue Aug 30 21:52:48 CEST 2011
(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
--20cf303b4337ce962a04b022a29b
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,<div><br></div><div>I'm trying to pass a variable back to the Kamail=
io script from the Kamailio module.=A0Let's say that my module is calle=
d "random" and it exports the function:</div><div>static int do_t=
his(struct sip_msg *msg, char* _information);</div>
<div><br></div><div>- I pass some "_param1" and "_param2&quo=
t; parameters to this function from Kamailio script:</div><div><div><meta h=
ttp-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8">(Kamailio=
script code)</div>
<div>loadmodule "random.so"</div><div>modparam("<meta http-e=
quiv=3D"content-type" content=3D"text/html; charset=3Dutf-8">random", =
"_param1", "<a href=3D"http://www.host.com">www.host.com</a>=
")</div>
<div>modparam("<meta http-equiv=3D"content-type" content=3D"text/html;=
charset=3Dutf-8">random", "<meta http-equiv=3D"content-type" con=
tent=3D"text/html; charset=3Dutf-8">_param2", 8877)</div></div><div><b=
r></div>
<div>- "_information" is the content I get back from the function=
.</div><div><br></div><div><br></div><div><br></div><div>Reading _param1 an=
d _param2 from the function of the module is pretty=A0straight=A0forward. I=
n order to write the "_information" variable and=A0being=A0able t=
o read from Kamailio script :</div>
<div><br></div><div><meta http-equiv=3D"content-type" content=3D"text/html;=
charset=3Dutf-8">(Module code)</div><blockquote class=3D"webkit-indent-blo=
ckquote" style=3D"margin: 0 0 0 40px; border: none; padding: 0px;"></blockq=
uote>// this is inside do_this() function<br>
<blockquote class=3D"webkit-indent-blockquote" style=3D"margin: 0 0 0 40px;=
border: none; padding: 0px;"></blockquote>// "content" has the v=
alue of the information that I would like to pass back from the function.<d=
iv>
<blockquote class=3D"webkit-indent-blockquote" style=3D"margin: 0 0 0 40px;=
border: none; padding: 0px;"></blockquote>pv_spec_t* dst;<br><blockquote c=
lass=3D"webkit-indent-blockquote" style=3D"margin: 0 0 0 40px; border: none=
; padding: 0px;">
</blockquote>pv_value_t val;<br><blockquote class=3D"webkit-indent-blockquo=
te" style=3D"margin: 0 0 0 40px; border: none; padding: 0px;"></blockquote>=
val.rs.s =3D content;<br><blockquote class=3D"webkit-indent-blockquote" sty=
le=3D"margin: 0 0 0 40px; border: none; padding: 0px;">
</blockquote>val.rs.len =3D strlen(content);<br><blockquote class=3D"webkit=
-indent-blockquote" style=3D"margin: 0 0 0 40px; border: none; padding: 0px=
;"></blockquote>val.flags =3D PV_VAL_STR;<br><blockquote class=3D"webkit-in=
dent-blockquote" style=3D"margin: 0 0 0 40px; border: none; padding: 0px;">
</blockquote>dst =3D (pv_spec_t *) _information;<br><div><div>dst->setf(=
msg, &dst->pvp, (int)EQ_T, &val);</div></div><div><br></div><div=
>From Kamailio script I can do:</div><div><meta http-equiv=3D"content-type"=
content=3D"text/html; charset=3Dutf-8"><meta http-equiv=3D"content-type" c=
ontent=3D"text/html; charset=3Dutf-8">(Kamailio script code)</div>
<div><div>xlog("L_INFO","Calling do_this()\n");</div><d=
iv>$var(result) =3D do_this("$var(response)");</div><div>xlog(&qu=
ot;L_INFO","Returning do_this(). result=3D$var(result). uri=3D$va=
r(response)\n");</div>
</div><div><br></div><div>And works fine.</div><div><br></div><div><br></di=
v><div>Now, I was wondering If I can have the _information parameter as thi=
s :</div><div><meta http-equiv=3D"content-type" content=3D"text/html; chars=
et=3Dutf-8"><div>
<meta http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8">(K=
amailio script code)</div><div><div>loadmodule "random.so"</div><=
div>modparam("random", "_param1", "<a href=3D"http=
://www.host.com">www.host.com</a>")</div>
<div>modparam("random", "_param2", 8877)</div></div></d=
iv><div><meta http-equiv=3D"content-type" content=3D"text/html; charset=3Du=
tf-8">modparam("random", "_information", $(response))</=
div>
<div><br></div><div>Changing the interface of the function as:</div><div><m=
eta http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8">stat=
ic int do_this(struct sip_msg *msg);</div><div><br></div></div><div>Calling=
from the kamailio script as this:</div>
<div><meta http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-=
8"><meta http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8"=
>(Kamailio script code)</div><div><meta http-equiv=3D"content-type" content=
=3D"text/html; charset=3Dutf-8"><div>
xlog("L_INFO","Calling do_this()\n");</div><div>$var(re=
sult) =3D do_this();</div><div>xlog("L_INFO","Returning do_t=
his(). result=3D$var(result). uri=3D$var(response)\n");</div></div><di=
v>
<br></div><div>But it doesn't work.</div><div><br></div><div><br></div>=
<div>Anyone is welcome to provide insight.</div><div><br></div><div>Thanks,=
</div><div>Luis</div>
--20cf303b4337ce962a04b022a29b--
More information about the sr-dev
mailing list