<div dir="ltr"><div>Thanks, I was trying to use the lookup function, overlooked completely is_registered.</div><div></div><div>Note to self: RTFM!!!<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 14 Feb 2022 at 07:10, Bogdan-Andrei Iancu <<a href="mailto:bogdan@opensips.org">bogdan@opensips.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<font face="monospace">Hi Alberto,<br>
<br>
I have to admit you lost me somewhere on the way with what you
want to do. But focusing on your final question "But when the uac
starts a call, how do I validate the uac was previously
registered?", the answer is
<a href="https://opensips.org/html/docs/modules/3.2.x/registrar.html#func_is_registered" target="_blank">https://opensips.org/html/docs/modules/3.2.x/registrar.html#func_is_registered</a><br>
<br>
Regards,<br>
</font>
<pre cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a href="https://www.opensips-solutions.com" target="_blank">https://www.opensips-solutions.com</a>
OpenSIPS eBootcamp
<a href="https://www.opensips.org/Training/Bootcamp" target="_blank">https://www.opensips.org/Training/Bootcamp</a></pre>
<div>On 2/10/22 9:04 PM, Alberto wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi,<br>
<br>
I followed pretty much the available tutorials for
mid_registrar, but I can't figure out something:<br>
<br>
I have:<br>
<br>
loadmodule "registrar.so"<br>
modparam("registrar", "attr_avp", "$avp(avp_json)")<br>
modparam("registrar", "max_contacts", 1)<br>
modparam("registrar", "tcp_persistent_flag",
"TCP_PERSIST_DURATION")<br>
<br>
loadmodule "mid_registrar.so"<br>
modparam("mid_registrar", "attr_avp", "$avp(avp_json)")<br>
modparam("mid_registrar", "max_contacts", 1)<br>
modparam("mid_registrar", "mode", 0)<br>
modparam("mid_registrar", "tcp_persistent_flag",
"TCP_PERSIST_REGISTRATIONS")<br>
<br>
and then:<br>
<br>
if (is_method("REGISTER")) {<br>
$json(x) := "{}";<br>
<br>
python_exec("fn_lookup_account", "$rd|$socket_in(proto)");<br>
<br>
$avp(avp_json) = $json_compact(x);<br>
mid_registrar_save("location");<br>
switch ($retcode) {<br>
case 1:<br>
$du = $json(x/remote_dest);<br>
$ru = $json(x/remote_uri);<br>
route(relay);<br>
break;<br>
case 2:<br>
xlog("L_INFO", "Absorb REGISTER!\n");<br>
break;<br>
default:<br>
xlog("L_INFO", "Failed to save registration!\n");<br>
break;<br>
}<br>
<br>
exit;<br>
} <br>
<br>
<br>
I do this because I want to store some configuration in the attr
column that I don't want to retrieve every call.<br>
<br>
However, the mid_registrar example then continues with
mid_registrar_lookup, and that works fine for calls originating
from the main registrar going to the uac.<br>
But when the uac starts a call, how do I validate the uac was
previously registered?<br>
<br>
I tried with this below, but lookup doesn't work in this
scenario.<br>
<br>
if (mid_registrar_lookup("location")) {<br>
$json(x) := $avp(avp_json);<br>
xlog("L_INFO", "$C(cs)$cfg_<a>file:$cfg_line$C(xx)</a> [$rm] Found
mid_registrar_lookup from $si:$sp to $ru\n");<br>
} else if (lookup("location")) {<br>
$json(x) := $avp(avp_json);<br>
xlog("L_INFO", "$C(cs)$cfg_<a>file:$cfg_line$C(xx)</a> [$rm] Found
lookup from $si:$sp to $ru\n");<br>
} else {<br>
t_reply(404, "Not Found");<br>
exit;<br>
} <br>
<br>
<br>
Thanks</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</div>
</blockquote></div>