Summary:ASTERISK-14739: [patch] Fetching SIP headers from BYE sent by callee
Reporter:Sergey Tamkovich (sergee)Labels:
Date Opened:2009-08-31 08:04:36Date Closed:2011-06-07 14:00:20
Versions:Frequency of
Environment:Attachments:( 0) sipbye-160-r214934.diff
( 1) sipbye-trunk-r214898.diff
Description:We have simple situation:

exten => _X.,1,DIAL(SIP/mypeer/${EXTEN})
exten => h,1,AGI(billing)

There is no way to get headers from BYE message sent by callee. But a lot of harware provide usefull headers in BYE message, for example Linksys provide header P-RTP-Stat which contain packet counters, jitter, delay etc..:

P-RTP-Stat: PS=256,OS=40960,PR=244,OR=39040,PL=29920,JI=5,LA=0,DU=4,EN=G711a,DE=G711a

Cisco provides another usefull header 'Reason' which contain ISDN hangup cause code:

Reason: Q.850;cause=16

This patch allows user to fetch any header from BYE sent by callee. It introduces special variable SIPREMOTEBYEHEADER. This variable should contain 2 coma separated values. 1st value - a sip header that should be fetched, 2nd value - name of variable to put sip header in.

So to fetch Header 'Reason' sent by cisco, you simply need to set variable:

exten => _X.,2,DIAL(SIP/mypeer/${EXTEN})
exten => h,1,AGI(billing)

Right after mypeer sends a BYE, you will have variable MYVAR defined on your channel.

Patches against branch 1.6.0 and trunk provided.
Comments:By: Leif Madsen (lmadsen) 2009-08-31 08:37:09

Confirming issues as we're discussing this on IRC and there are patches attached for initial review.

By: Olle Johansson (oej) 2009-08-31 08:39:09

From IRC:
I don't like that it is a special variable though
[15:35] leifmadsen:
I think it should be in a function of some sort
[15:35] oej:
I don't like using variables like this at all
[15:36] mvanbaak:
me neither
[15:36] oej:
The problem is that the SIP channel doesn't save the incoming BYE, so we can't pick headers from it today
[15:36] oej:
So I think we should add a way to save the BYE request in the sip_pvt, like the initreq, and then a dialplan function to pick headers from it in the "h"
[15:37] oej:
That would feel much better
[15:37] leifmadsen:
I agree with that approach
[15:37] leifmadsen:
it makes more sense from the standpoint of dialplan usage too
[15:37] leifmadsen:
you want something from BYE, so access it in the 'h' exten

By: Miguel Molina (coolmig) 2010-03-18 12:30:03

Any updates on this? This could be very helpful to gather the IDSN hangup cause sent from SIP providers, as the original poster said on the description. Or there is another method to do this that I missed?

By: Leif Madsen (lmadsen) 2011-05-06 16:23:30

Closing this issue as suspended. If the original reporter wishes to make improvements per the discussion posted by oej, that would be great. Thanks!