[OpenSIPS-Users] issues on CANCEL proxying

pierre cloury pierre.cloury at gmail.com
Thu Nov 7 16:17:55 UTC 2024


Hi,
I'm working on an emergency server which is basically a proxy for a SIP
INVITE, but which change request uri (example : from
urn:service:sos.ambulance to tel:EC00033434678952).
This part is working correctly, however i have a problem with SIP CANCEL
gestion. I just want to forward the CANCEL sip message, however I
understand that the request URI AND the via branch tag must be the same
than the INVITE sended by my opensips server. For exemple, it must have
"tel:EC00033434678952" and not "urn:service:sos.ambulance" in request URI.

Or the only way i found to do that is to cache the generated new request
URI during request route for INVITE, and the via branch tag on the sip
reply received by my opensips server (in the sip reply 100 trying... beurk).

It is ugly, and i'm sure there is a best method. I strongly suspect that it
is possible with tm module, and i tried statefull behaviour, but i did not
manage to do it without caching.

You can find below a simplified version of my current opensips.cfg :

route {
      if (is_method("INVITE")) {
            t_newtran();
            #determine new request URI, not important. Result is on
$avp(psap)
            $avp(psap) = "33434678789"
            #cache result with call-ID as key
            cache_store("local:psap_cache", "$hdr(Call-ID)",
"$avp(psap)",15);
            forward()
      }
      else if (is_method("CANCEL")){
            #extract from cach both value, modify via and then forward
            cache_fetch("local:psap_cache","$hdr(Call-ID)", $var(psap));
            cache_fetch("local:via_branch_cache","$hdr(Call-ID)",
$var(branch_via))

            $ru = "tel:" + $var(psap);
            insert_hf("Via: SIP/2.0/TCP 100.76.22.1:5062
;branch=$var(branch_via)\r\n");
            forward();

      }
}
onreply_route {

       #extract via branch tag on sip 100 trying answer after INVITE
       if ($(var(cseq_header){s.select,1, }) == "INVITE" and
$var(responde_code) == 100 ){
             $var(branch_via) = "z9..."
             #cache branch_via
             cache_store("local:via_branch_cache", "$hdr(Call-ID)",
"$var(branch_via)",15);
       }
}

Could you please provide the idea to unblock me and find a better method ?
Regards,
Pierre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20241107/adfb29aa/attachment.html>


More information about the Users mailing list