[asterisk-dev] reset/remove SipAddHeader() headers
John Todd
jtodd at digium.com
Wed Jan 14 09:07:29 CST 2009
On Jan 14, 2009, at 8:50 AM, Klaus Darilion wrote:
> Hi!
>
> As far as I saw in chan_sip (at least 1.4.22) once SIP headers are
> added
> with SipAddHeader() there is no way to remove them, which is bad if
> the
> request is rerouted to another SIp destination, e.g:
>
> user Asterisk GW1 GW2
> ---INVITE-->
> add certain
> header for GW1:
> SipAddHeader(..)
>
> ---INVITE--->
> (contains additional
> header)
>
>
> <--500-------
>
> reroute request
> to a different GW
>
>
> ----------INVITE-------->
> this request also contains
> the added SIP header
>
> Headers added with SipAddHeader are added to the incoming channel as
> global channel variables SIPADDHEADER01, SIPADDHEADER02, ....
>
> Then on outgoing requests chan_sip will traverse the channel variables
> for SIPADDHEADERxx and add them.
>
> Thus, it would be useful to reset the channel variables somehow, e.g.
> with an application SipAddHeaderReset();
>
> I could not find any existing solution, thus what do you think about
> this new application?
>
> thanks
> klaus
There be dragons.
I agree that there probably should be some way to do this, but a way
to do this properly does not immediately come to mind. For instance,
in the event that GW2 sends a 302 redirect, how does one execute the
SipAddHeaderReset() application or function? That 302 redirect step
never breaks out of Dial() - the redirect just magically happens. The
dialplan (or AGI, or whatever) never has a chance to execute any other
commands such as adding headers or removing headers or whatever. I
don't have an answer on how this should be handled elegantly.
Even in the instance where a 500 is received and somehow the dialplan
is re-entered, it seems burdensome to remove ALL headers and start
from scratch. Wouldn't you just want to remove the specific header
that is causing problems? This would imply some sort of indexing, or
at the minimum, regexp-style string matching so I could say:
exten => _X11.,SipRemoveHeader(X-PSAP-ID)
which would remove both of these headers:
X-PSAP-ID: 33-MONTCOPA-PRIMARY-9929312311AA
X-PSAP-ID: 33-MONTCOPA-BACK-99283122833CD
Lastly, I wouldn't restrict header removal just to headers that have
been added by prior steps in the dialplan of Asterisk. Why not allow
deletion of arbitrary headers? This would permit more control over
messaging. (Though I will admit a glaring memory hole on my part - I
assume Asterisk passes through headers unmodified from UA-to-UA... is
that correct? My first memory impression is "Yes" but the more I
think about it the less certain I am, and I don't have time to test
right now.)
Or am I missing your concept?
JT
---
John Todd email:jtodd at digium.com
Digium, Inc. | Asterisk Open Source Community Director
445 Jan Davis Drive NW - Huntsville AL 35806 - USA
direct: +1-256-428-6083 http://www.digium.com/
More information about the asterisk-dev
mailing list