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&#39;m trying to pass a variable back to the Kamail=
io script from the Kamailio module.=A0Let&#39;s say that my module is calle=
d &quot;random&quot; 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 &quot;_param1&quot; and &quot;_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 &quot;random.so&quot;</div><div>modparam(&quot;<meta http-e=
quiv=3D"content-type" content=3D"text/html; charset=3Dutf-8">random&quot;, =
&quot;_param1&quot;, &quot;<a href=3D"http://www.host.com">www.host.com</a>=
&quot;)</div>
<div>modparam(&quot;<meta http-equiv=3D"content-type" content=3D"text/html;=
 charset=3Dutf-8">random&quot;, &quot;<meta http-equiv=3D"content-type" con=
tent=3D"text/html; charset=3Dutf-8">_param2&quot;, 8877)</div></div><div><b=
r></div>
<div>- &quot;_information&quot; 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 &quot;_information&quot; 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>// &quot;content&quot; 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-&gt;setf(=
msg, &amp;dst-&gt;pvp, (int)EQ_T, &amp;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(&quot;L_INFO&quot;,&quot;Calling do_this()\n&quot;);</div><d=
iv>$var(result) =3D do_this(&quot;$var(response)&quot;);</div><div>xlog(&qu=
ot;L_INFO&quot;,&quot;Returning do_this(). result=3D$var(result). uri=3D$va=
r(response)\n&quot;);</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 &quot;random.so&quot;</div><=
div>modparam(&quot;random&quot;, &quot;_param1&quot;, &quot;<a href=3D"http=
://www.host.com">www.host.com</a>&quot;)</div>
<div>modparam(&quot;random&quot;, &quot;_param2&quot;, 8877)</div></div></d=
iv><div><meta http-equiv=3D"content-type" content=3D"text/html; charset=3Du=
tf-8">modparam(&quot;random&quot;, &quot;_information&quot;, $(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(&quot;L_INFO&quot;,&quot;Calling do_this()\n&quot;);</div><div>$var(re=
sult) =3D do_this();</div><div>xlog(&quot;L_INFO&quot;,&quot;Returning do_t=
his(). result=3D$var(result). uri=3D$var(response)\n&quot;);</div></div><di=
v>
<br></div><div>But it doesn&#39;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