<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<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 class="moz-txt-link-freetext" href="https://opensips.org/html/docs/modules/3.2.x/registrar.html#func_is_registered">https://opensips.org/html/docs/modules/3.2.x/registrar.html#func_is_registered</a><br>
<br>
Regards,<br>
</font>
<pre class="moz-signature" cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a class="moz-txt-link-freetext" href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a>
OpenSIPS eBootcamp
<a class="moz-txt-link-freetext" href="https://www.opensips.org/Training/Bootcamp">https://www.opensips.org/Training/Bootcamp</a></pre>
<div class="moz-cite-prefix">On 2/10/22 9:04 PM, Alberto wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CANoA6_J=P7kLVrSVqtN7sAcCgVnSXM7ZT_mSbUz5Jtfi5_ZZAg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<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 class="moz-txt-link-freetext" href="file:$cfg_line$C(xx)">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 class="moz-txt-link-freetext" href="file:$cfg_line$C(xx)">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 class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</body>
</html>