reason headers

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

reason headers

Jan D.
Our opensips setup sits in between a Cisco-SIPGateway/IOS-12.x and a Philips/NEC PaBX (NEC-i SV8100-GE 06.01/2.1)

If a call is setup and canceled from the Cisco site, there is a 'Reason' header in the Cancel request, this Cancel request is generated by the Cisco:

Reason: SIP;cause=487;text=ORIGINATOR_CANCEL

The Philips/NEC response is a 'Status-Line: SIP/2.0 400 Bad Request'

Because I can not change the Cisco (this is not our applience) I have to filter out the Reason header. I already tried a remove_hf, but this didn't work.

Any thought / tips how to do this?

Gr.

Jan
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

osiris123d
How exactly are you using the remove_hf in your OpenSIPS config.  Can you post that section of code?





On Fri, Dec 30, 2011 at 4:39 AM, Jan D. <[hidden email]> wrote:
Our opensips setup sits in between a Cisco-SIPGateway/IOS-12.x and a
Philips/NEC PaBX (NEC-i SV8100-GE 06.01/2.1)

If a call is setup and canceled from the Cisco site, there is a 'Reason'
header in the Cancel request, this Cancel request is generated by the Cisco:

Reason: SIP;cause=487;text=ORIGINATOR_CANCEL

The Philips/NEC response is a 'Status-Line: SIP/2.0 400 Bad Request'

Because I can not change the Cisco (this is not our applience) I have to
filter out the Reason header. I already tried a remove_hf, but this didn't
work.

Any thought / tips how to do this?

Gr.

Jan

--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/reason-headers-tp7137781p7137781.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



--
--
*--*--*--*--*--*
Duane
*--*--*--*--*--*
--

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
This is the part of the code i tried (without any luck)

route[0]
{

        ...

        if(search("Reason"))
        {
                remove_hf("Reason");
                xlog("L_INFO", " INFO : delete Reason header\n");
        }

        ...

        t_on_failure("1");
        if(t_relay("0x05"))
        {
                xlog("L_INFO", " INFO : t_relay O.K.\n");
        }
        else
        {
                xlog("L_INFO", " INFO : t_relay_error\n");
                sl_reply_error();
        }

}

I also tried a t_relay("0x13"), because the 0x08 flag has something to do with the reason header. My opensips version is the latest (1.7.1), compiled from sources as deb file for debian.
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
Also a rewrite of a Reason header in route[0] is not possible:

route[0]
...
if(search("Reason"))
{
  replace("Reason", "ReasonIsRewrited");
}
...
Is this a special header?
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Vlad Paiu
Hello,

What you are doing is pretty unsafe.
Search and Replace do not work at header level, but will match any
string within the SIP msg, such as a 'reason' URI parameter, or whatever
else, so you might end up in overwriting something else.
The textops module has functions that operate at SIP header level.

Check is_present_hf [1], remove_hf [2] and append_hf [3]. So basically
what you want to do is, if the header is present, get it's body, remove
it, and add a new header, called differently, but with the same body as
the previous one.

[1] http://www.opensips.org/html/docs/modules/devel/textops.html#id293261
[2] http://www.opensips.org/html/docs/modules/devel/textops.html#id293514
[3] http://www.opensips.org/html/docs/modules/devel/textops.html#id292953

Regards,

Vlad Paiu
OpenSIPS Developer


On 01/04/2012 11:21 AM, Jan D. wrote:

> Also a rewrite of a Reason header in route[0] is not possible:
>
> route[0]
> ...
> if(search("Reason"))
> {
>    replace("Reason", "ReasonIsRewrited");
> }
> ...
> Is this a special header?
>
> --
> View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/reason-headers-tp7137781p7149721.html
> Sent from the OpenSIPS - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
Dear Vlat,

Thank you for your response!

In fact I just want to remove the 'Reason' header (Reason: SIP;cause=487;text=ORIGINATOR_CANCEL), not replace it, because the Philips/NEC does not support rfc3326 and even sents a 'Bad Request' if this line is in a header.

At the start of the post I tried the remove_hf("Reason"), but the field is not deleted.

I also tried in route[0]:
if(is_present_hf("Reason"))
{
  remove_hf("Reason");
}

but the line is stil present in the response to the far end (Philips/Nec). So it looks like the remove_hf("Reason") does not work...

(I of cause already read the parts in the textops cookbook)
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Vlad Paiu
Hello,

Are you sure that your piece of code is actually reachable in your
script ? Maybe the remove_hf() function is not even called.

Put a couple of xlog messages before the is_present_hf() if and actually
in the if brackets and check with your OpenSIPS logs if your script
logic actually takes you there.

Regards,

Vlad Paiu
OpenSIPS Developer


On 01/04/2012 04:25 PM, Jan D. wrote:

> Dear Vlat,
>
> Thank you for your response!
>
> In fact I just want to remove the 'Reason' header (Reason:
> SIP;cause=487;text=ORIGINATOR_CANCEL), not replace it, because the
> Philips/NEC does not support rfc3326 and even sents a 'Bad Request' if this
> line is in a header.
>
> At the start of the post I tried the remove_hf("Reason"), but the field is
> not deleted.
>
> I also tried in route[0]:
> if(is_present_hf("Reason"))
> {
>    remove_hf("Reason");
> }
>
> but the line is stil present in the response to the far end (Philips/Nec).
> So it looks like the remove_hf("Reason") does not work...
>
> (I of cause already read the parts in the textops cookbook)
>
> --
> View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/reason-headers-tp7137781p7150616.html
> Sent from the OpenSIPS - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
Dear Vlad,

I'm sure the code is called, I also tried:

if(is_present_hf("Reason"))
{
  remove_hf("Reason");
  xlog("L_INFO", " INFO : delete Reason header\n");
}

We the Cancel is fired the INFO line appearse in my log file (tail -f).

I also tried this on several servers with opensips 1.7.1.
I think i run the right script code but it does not do what i want (bug?). Maybe somebody can reproduce this behavior?
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

osiris123d
You can change your debug to
debug=6

And then do a

if(is_present_hf("Reason"))
{
xlog("L_INFO", " INFO : ***BEFORE*** delete Reason header\n");
remove_hf("Reason");
xlog("L_INFO", " INFO : ***AFTER*** delete Reason header\n");
}


Your syslog will have a lot of stuff in it but you can search for your xlog messages to find all the stuff that happens after your ***BEFORE*** and before your ***AFTER***. Maybe that will point to the issue. Post the debug info (if it is a lot of output then you can post on pastebin.com and they reply to this thread with the link).



On , "Jan D." <[hidden email]> wrote:

> Dear Vlad,
>
>
>
> I'm sure the code is called, I also tried:
>
>
>
> if(is_present_hf("Reason"))
>
> {
>
>  remove_hf("Reason");
>
>  xlog("L_INFO", " INFO : delete Reason header\n");
>
> }
>
>
>
> We the Cancel is fired the INFO line appearse in my log file (tail -f).
>
>
>
> I also tried this on several servers with opensips 1.7.1.
>
> I think i run the right script code but it does not do what i want (bug?).
>
> Maybe somebody can reproduce this behavior?
>
>
>
> --
>
> View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/reason-headers-tp7137781p7150742.html
>
> Sent from the OpenSIPS - Users mailing list archive at Nabble.com.
>
>
>
> _______________________________________________
>
> Users mailing list
>
> [hidden email]
>
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
I used the above code with a debug level 6. The significant part of the output is in http://pastebin.com/download.php?i=jKxiskjy

If you would have a look and give some advise that would be great.

Gr.

Jan
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
I still need to filter out the Reason header.

Till now this is not possible with a remove_hf (see previous post, please look at pastbin too).

Should we consider this a bug? If so, should I post this problem under OpenSIPS - Devel?
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Saúl Ibarra Corretgé

On Jan 6, 2012, at 11:17 AM, Jan D. wrote:

> I still need to filter out the Reason header.
>
> Till now this is not possible with a remove_hf (see previous post, please
> look at pastbin too).
>
> Should we consider this a bug? If so, should I post this problem under
> OpenSIPS - Devel?
>

The reason header pasted in the first email of this thread is added by OpenSIPS itself (the one with ORIGINATOR_CANCEL). Could it be that you can't remove it because OpenSIPS adds it?

--
Saúl Ibarra Corretgé
AG Projects




_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
Dear Saúl,

This could be the case:
Sent to opensips:        Reason: Q.850;cause=16
From opensips to ATA: Reason: SIP;cause=487;text=ORIGINATOR_CANCEL

So the Reason header is different, this is true.

If I read the TM docs: http://www.opensips.org/html/docs/modules/devel/tm.html#id293417

0x08 - If the request is a CANCEL, trust and pass further the Reason header from the received CANCEL - shortly, will propagate the Reason header.

So I presume the Reason header should be sent to the ATA with ie. a t_relay(0x08), but not with a t_relay() or a t_relay(0x05), please correct me if i'm wrong.

The question still is: How can I push a Cancel without a Reason header to the ATA, even if the original headers contain a Reason header?
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Saúl Ibarra Corretgé
Hi,

On Jan 6, 2012, at 11:49 AM, Jan D. wrote:

> Dear Saúl,
>
> This could be the case:
> Sent to opensips:        Reason: Q.850;cause=16
> From opensips to ATA: Reason: SIP;cause=487;text=ORIGINATOR_CANCEL
>
> So the Reason header is different, this is true.
>
> If I read the TM docs:
> http://www.opensips.org/html/docs/modules/devel/tm.html#id293417
>
> 0x08 - If the request is a CANCEL, trust and pass further the Reason header
> from the received CANCEL - shortly, will propagate the Reason header.
>
> So I presume the Reason header should be sent to the ATA with ie. a
> t_relay(0x08), but not with a t_relay() or a t_relay(0x05), please correct
> me if i'm wrong.
>

Yes. But take into account that what that flag does is propagate the Reason header, that is, add it to the generated CANCEL if the *received* CANCEL already has one. I don't think that is your scenario. In your scenario OpenSIPS is the one sending the CANCEL with a Reson, right?

> The question still is: How can I push a Cancel without a Reason header to
> the ATA, even if the original headers contain a Reason header?
>

If the CANCEL is locally generated perhaps you could catch it in a local route and remove the header there... is that possible Vlad?


Regards,

--
Saúl Ibarra Corretgé
AG Projects




_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
Hi Saúl / Vlad,

I think your totaly right. I had a look at all Cancels in my sip traces and even Cancels coming in without a Reason header are coming out with a Reason header.

So my question should be:
- can I disable the output of Reason headers /
- a feature request for disableling the output of Reason headers in a Cancel request.

I also tried to put the remove_hf in a local route, but the local_route did not give any output with debug 3:

local_route
{
        xlog("L_INFO", "********** ROUTE local_route ********** $rm $si\n");
        append_hf("P-hint: Local_Route\r\n");

        if(is_present_hf("Reason"))
        {
                xlog("L_INFO", " INFO : ***BEFORE*** delete Reason header\n");
                remove_hf("Reason");
                xlog("L_INFO", " INFO : ***AFTER*** delete Reason header\n");
        }
}

So summing up to be clear (I hope):

Our Cisco (S7 - ) sents a Cancel request to opensips:
    Session Initiation Protocol
    Request-Line: CANCEL sip:31201234567@sip.client.nl:5060 SIP/2.0
    Message Header
        From: <sip:0622334455@sip.provider.nl>;tag=6CA89598-AD9
        To: <sip:31201234567@sip.client.nl>
        Date: Fri, 16 Dec 2011 19:27:16 GMT
        Call-ID: CC46DCEF-275211E1-B6F2F4AB-C7084FB4@sip.provider.nl
        CSeq: 101 CANCEL
        Max-Forwards: 70
        Timestamp: 1324063688
        Reason: Q.850;cause=16
        Content-Length: 0


And opensips processes the request and sents this to the clients ATA:
    Session Initiation Protocol
    Request-Line: CANCEL sip:myusername@81.82.83.10:1030 SIP/2.0
    Message Header
        From: <sip:0622334455@sip.opensips.nl>;tag=6CA89598-AD9
        Call-ID: CC46DCEF-275211E1-B6F2F4AB-C7084FB4@sip.provider.nl
        To: <sip:31201234567@sip.client.nl>
        CSeq: 101 CANCEL
        Max-Forwards: 70
        Content-Length: 0

In the processed request the Reason header (above Content-Length) is filtered out.
(left the Via records out).
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
I got feedback on the ticket i opened at NEC/Philips on the question why a 400 bad packet response is sent.

This is their answer:

This time SV8100 responded a 400 Bad because the received message did not meet RFC. According to RFC, the text following after 'text=' should be enclosed in double quotation marks.

Bad - SIP;cause=487;text=ORIGINATOR_CANCEL
Good - SIP;cause=487;text="ORIGINATOR_CANCEL"

Can one of the maintainers respond to this. If this is true, how can i add the quotation marks or can this be repaired in 1.8.x?
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Saúl Ibarra Corretgé
It's already fixed, at least in trunk. Not sure about 1.7 branch, but you can check it in the code ;-)

On Jan 10, 2012, at 10:25 AM, Jan D. wrote:

> I got feedback on the ticket i opened at NEC/Philips on the question why a
> 400 bad packet response is sent.
>
> This is their answer:
>
> This time SV8100 responded a 400 Bad because the received message did not
> meet RFC. According to RFC, the text following after 'text=' should be
> enclosed in double quotation marks.
>
> Bad - SIP;cause=487;text=ORIGINATOR_CANCEL
> Good - SIP;cause=487;text="ORIGINATOR_CANCEL"
>
> Can one of the maintainers respond to this. If this is true, how can i add
> the quotation marks or can this be repaired in 1.8.x?
>
> --
> View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/reason-headers-tp7137781p7171387.html
> Sent from the OpenSIPS - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

--
Saúl Ibarra Corretgé
AG Projects




_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
Hi,

Thanks for the quick response. I will test vrom trunk later and will let you know if its fixed.

For now, we run a production server under 1.7.1 and have problems at this moment.

So I have still the question, can I get rid of the Reason header or change the text (add quotations?).
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Saúl Ibarra Corretgé

On Jan 10, 2012, at 10:52 AM, Jan D. wrote:

> Hi,
>
> Thanks for the quick response. I will test vrom trunk later and will let you
> know if its fixed.
>
> For now, we run a production server under 1.7.1 and have problems at this
> moment.
>
> So I have still the question, can I get rid of the Reason header or change
> the text (add quotations?).
>

Latest trunk does have quotations, so if you can you should use that. I f you want to get rid of it I'm afraid you'll need to manually edit the code.

Now, I do think that having a way to toggle adding the Reason header to CANCEL requests could be useful... perhaps a tm modparam would make sense.


Regards,

--
Saúl Ibarra Corretgé
AG Projects




_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: reason headers

Jan D.
A option to toggle the reason header would be great, tm modparam is a good idea!

1. How / where do I submit such a feature request?


2. NEC/Philips confirmed that they replied the unquoted text= in the Reason header with a 400 Bad request. Is this a good reply or should they ignore the header so the call / cancel continues?
12