Hi Benoit,
Branches are a hop-by-hop concept; that is, branch #1 is from calling UAC to the proxy, and branch #2 (and #N) is from the proxy to any upstream destinations. So, looking backward from the proxy toward the originating caller, there is no distinction between replying “on a branch” vs. just “replying”; they are one and the same.
The reason sending replies in branch_route is disallowed is because the intended purpose of branch_route is quite narrow: to make alterations to the SIP request which are scoped only to one branch and reverted on subsequent branches.
On the other hand, the problem you raise can be viewed in more general terms: given replication between two or more registrars, know to know if the registrant is “local”? Looking at the socket of the resolved contact is indeed a valid approach, but there are others.
My favourite approach is to use the Path header. While the primary use case of Path is when a proxy forwards a registration upstream to another registrar, Kamailio can also use it to determine whether a registrant is local:
https://kamailio.org/docs/modules/5.6.x/modules/registrar.html#registrar.p.p...
https://kamailio.org/docs/modules/5.6.x/modules/registrar.html#registrar.p.p...
Or in other words, if you do a lookup() and find that the next hop (i.e. $du) is == myself (assuming path_check_local == 0), you can presume that the current registrar is the “home registrar” for the device.
In the case of TCP and TLS (“reliable” / “streaming” transports, specifically), you can also preemptively test if the connection already exists using tcp_get_conid() from the `tcpops` module:
https://kamailio.org/docs/modules/5.6.x/modules/tcpops.html#tcpops.f.tcp_get...
That is, you can do a lookup(), then test whether a TCP connection exists to the recipient:
if(($nh(P) eq ’tcp' || $nh(P) eq ’tls') && !tcp_get_conid("$nh(d):$nh(p)", "$var(tcp_conid)”)) { send_reply(“410”, “Gone”); exit; }
However, this will not work for UDP for obvious reasons.
Hope it helps!
— Alex
On May 4, 2023, at 6:17 AM, Benoit Panizzon benoit.panizzon@imp.ch wrote:
Hello
Is there a possibility to send a reply from within a branch route?
Experimental case (yes, I know it's a non working set-up, but I just wonder if that would be possible).
Two registrar nodes, location information shared between the two.
CPE registers via TLS, therefore the existing connection shall be used towards the CPE and that only exists on one of the registrars.
So in the Branch Route I would like to do something like:
$var(socket) = $(ulc(aor=>socket)[$T_branch_idx]);
if ($var(socket) == 0) { send_reply("503","no local socket"); }
This would cause the core routing instance to select the next registrar from the dispatcher list which hopefully holds the active socket.
But none of the 'send_reply' variants seem to be allowed within a branch route.
Or is there a better solution?
Mit freundlichen Grüssen
-Benoît Panizzon-
I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: