[OpenSIPS-Users] Change SIP response code

Bogdan-Andrei Iancu bogdan at voice-system.ro
Thu Sep 24 12:33:21 CEST 2009


Hi Josip,

if you want to change a final negative reply, you can simply do it from 
failure_route ( as you discovered)  without any need of an onreply_route..

The only note to your script is that, in failure route you are (re) 
processing the initial request (see 
http://www.opensips.org/Resources/DocsCoreRoutes#toc3).
So, your search() will be over the INVITE and not the 500 you received.

In 1.6 you can solve this by using AVPs with classes (see 
http://www.opensips.org/Main/Ver160#toc4)

failure_route[1] {

        if (t_check_status("500")) {
                if (  $(<reply>hdr(Expire)) != NULL )  {
                        t_reply("480", "Temporarily Unavailable");
                        break;
                }
        }
}


Regards,
Bogdan


Josip Djuricic wrote:
> Yeap I think it should work great with opensips, will test it first thing
> in the morning, we are also having one old ser 0.9.6 machine and I need to
> do the same on this machine.
>
> With ser ofcourse I cant use: 
>      $var(s:reply_status) = $rs;...
> and all other things.
>
> I thought about this:
>
> failure_route[1] {
>
>         if (t_check_status("500")) {
>                 if (search("^Expire*")) {
>                         t_reply("480", "Temporarily Unavailable");
>                         break;
>                 }
>         }
> }
>
> but the problem is I am not sure how to search trough Status-Line to find
> "Expired". Does anyone know any other way to get reason phrase or the way
> to use search to search trough entire SIP message?
>
> I know this is off topic, but for now I cant move this machine from ser to
> opensips :( ...will be able to move it in few months but until then need to
> resolve this issue.
>
> Best regards,
>
> Josip
>
>
>
>
> On Wed, 23 Sep 2009 16:37:42 +0200, Mauro Davì <mauro.davi at acotel.com>
> wrote:
>   
>> Hi Josip,
>>
>> you can try with something like this:
>>
>> before to sent the INVITE
>>
>> route[0] {
>>
>> ....
>> ....
>> ....
>>
>> t_on_reply("1");
>> t_on_failure("1");
>> t_relay();
>> ....
>> ....
>> ....
>>
>> }
>>
>> in the on reply_route
>>
>> onreply_route[1] {
>>          # In the on_reply route I can store the reply status and reply 
>> reason values
>>         $var(s:reply_status) = $rs;
>>         $var(s:reply_reason) = $rr;
>> }
>>
>> failure_route[1] {
>>         if (t_was_cancelled()) {
>>                 exit();
>>         }
>>
>>         # Here I can check the status reply and reason reply values 
>> stored into the $var(s:reply_status) and $var(s:reply_reason)
>>         if 
>> (($var(s:reply_status)=="200")&&($var(s:reply_reason)=="Expired")){
>>            send_reply("480", "Temporarily Unavailable");
>>
>>            break;
>>
>>     }
>> }
>>
>> Regards,
>>    
>>     MD
>>
>>
>> Josip Djuricic ha scritto:
>>     
>>> So I guess this would not work?
>>>
>>>  
>>>
>>> if (t_check_status("500") && search("^Expired*")) {
>>>
>>>                 sl_send_reply("480", "Temporarily Unavailable");
>>>
>>>                 break;
>>>
>>> };
>>>
>>>  
>>>
>>> I should probably use it somewhere in onreply_route instead?
>>>
>>>  
>>>
>>> I am sorry I am still relatively new to opensips and ser
>>>
>>>  
>>>
>>> Josip
>>>
>>>  
>>>
>>> *From:* users-bounces at lists.opensips.org 
>>> [mailto:users-bounces at lists.opensips.org] *On Behalf Of *Mauro Davi
>>> *Sent:* Wednesday, September 23, 2009 12:48 PM
>>> *To:* OpenSIPS users mailling list
>>> *Subject:* Re: [OpenSIPS-Users] Change SIP response code
>>>
>>>  
>>>
>>> Hi Josip,
>>>
>>> I think that the below answer could be the solution:
>>>
>>> http://www.openser.org/pipermail/users/2006-January/002692.html
>>>
>>> Regards
>>>     MD
>>>
>>> Josip Djuricic ha scritto:
>>>
>>> Dear,
>>>
>>>  
>>>
>>> What would be the best way to change SIP response message from 5xx to 
>>> 4xx. The problem is we have client with a broken b2bua which sends SIP 
>>> 500 Expired after the user does not answer the phone, so I would like 
>>> to change it to SIP 480 Temporarily unavailable message before sending 
>>> it back.
>>>
>>>  
>>>
>>> if (search("^Expired*")) {
>>>
>>> sl_send_reply("480", "Temporarily Unavailable");
>>>
>>> break;
>>>
>>> };
>>>
>>>  
>>>
>>> I thought about something like that but that would match also the 
>>> initial invite that has Expired valule in it, so I would need to match 
>>> only SIP 500 message with string Expired in it.
>>>
>>>  
>>>
>>> Thank you
>>>
>>>  
>>>
>>> Josip
>>>
>>>  
>>> ------------------------------------------------------------------------
>>>
>>>
>>>   
>>>  
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org <mailto:Users at lists.opensips.org>
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>   
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>
>>>       
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>   




More information about the Users mailing list