Strip SIP Headers

From FreeSWITCH Wiki
Jump to: navigation, search


Sometimes a SIP provider will add extra header information. Most of the time they do that for their own use (tracking calls). But that extra information can cause a lot of problems. For example: I get a call from the PSTN via a DID provider (provider1). Since im not in the office the call gets bridged to my cell phone (provider2). Provider1 add's extra information to the sip packet like displayed below:

X-voipnow-did: 01234567890
X-voipnow-extension: 987654321
X-voipnow-infrastructureid: 0081b0675fcb
X-voipnow-chargingid: yxru57b4
X-voipnow-did: 01234567890

If we bridge this call directly to provider2 the calls get dropped since provider2 doesnt accept the X-voipnow header, so we have to strip off this crap. First we need to know wich variable to strip, so we need the INFO application. Add the following line to your dialplan to display all the channel variables:

<action application="info"/>

Now we can make the call again and we're going to search for those variables. When the call hits the dialplan the following variables will be shown:

variable_sip_h_X-voipnow-did: [01234567890]
variable_sip_h_X-voipnow-extension: [987654321]
variable_sip_h_X-voipnow-infrastructureid: [0081b0675fcb]
variable_sip_h_X-voipnow-chargingid: [yxru57b4]
variable_sip_h_X-voipnow-did-1: [01234567890]

Now we know which variables are the ones causing the problem. To strip them off, use the application UNSET in the dialplan (the inverse of SET):

<action application="unset" data="sip_h_X-voipnow-did"/>
<action application="unset" data="sip_h_X-voipnow-extension"/>
<action application="unset" data="sip_h_X-voipnow-infrastructureid"/>
<action application="unset" data="sip_h_X-voipnow-chargingid"/>
<action application="unset" data="sip_h_X-voipnow-did-1"/>

After we added the above into the dialplan the X-Voipnow headers are gone.