[HELP] Sip Header Manipulation

Hi folks,

I’m using Asterisk 1.6.2.6 and I’m trying to manipulate the SIP header in INVITE messages to remove timers from the Require: field if it’s present, example:

INVITE sip:XXXXXXXXXXX@62.239.169.164:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP 192.168.1.250:5060;branch=z9hG4bK71961607;rport
Max-Forwards: 70
From: “” sip:XXXXXXXXXXX@btsip.bt.com;tag=as5d9e44d0
To: sip:XXXXXXXXXXX@btsip.bt.com;tag=SDv5o2399-0082-0000362c-0762i0
Contact: sip:XXXXXXXXXXX@192.168.1.250
Call-ID: 2397df823320810648a29478403281dd@btsip.bt.com
CSeq: 106 INVITE
[color=#FF0000]Require: timer[/color]
Session-Expires: 450;refresher=uac
Min-SE: 90
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces, timer
X-asterisk-Info: SIP re-invite (Session-Timers)
Content-Type: application/sdp
Content-Length: 245

v=0
o=BTHH 1974787636 1974787639 IN IP4 192.168.1.250
s=-
c=IN IP4 192.168.1.250
t=0 0
m=audio 5064 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv

Is there a way of doing this in Asterisk? Unfortunately my service provider sends a 420 Bad Extension back if the Require field has timer in it so I’m trying to remove Require: timer if it’s present to hopefully work around the issue whilst still retaining timer functionality.

Cheers,

Not sure this function SIPRemoveHeader() works for you or not.

Don’t enable session timers?

Of course, I didn’t think of that :wink:

Unfortunately my service provider requires session timers otherwise they just bin the call. They just don’t like it when you tell them it’s required in a session refresh:

<— SIP read from UDP:62.239.169.164:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;received=xxx.xxx.xxx.xxx;branch=z9hG4bK7759e72a;rport=5060
From: “” sip:xxxxxxxxxxx@btsip.bt.com;tag=as5d9e44d0
To: sip:xxxxxxxxxxx@btsip.bt.com;tag=SDv5o2399-0082-0000362c-0762i0
Call-ID: 2397df823320810648a29478403281dd@btsip.bt.com
CSeq: 105 INVITE
Contact: sip:xxxxxxxxxxx@62.239.169.164:5060;transport=udp
Allow: INVITE,ACK,BYE,CANCEL,UPDATE
Require: timer
Supported: timer
Session-Expires: 450;refresher=uac
Content-Type: application/sdp
Content-Length: 354

SDP NOT SHOWN

<Later that call, the initial refresh>

<— SIP transmitting to UDP:62.239.169.164:5060 —>
INVITE sip:xxxxxxxxxx@62.239.169.164:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;branch=z9hG4bK71961607;rport
Max-Forwards: 70
From: “” sip:xxxxxxxxxxx@btsip.bt.com;tag=as5d9e44d0
To: sip:xxxxxxxxxxx@btsip.bt.com;tag=SDv5o2399-0082-0000362c-0762i0
Contact: sip:xxxxxxxxxxx@xxx.xxx.xxx.xxx
Call-ID: 2397df823320810648a29478403281dd@btsip.bt.com
CSeq: 106 INVITE
Require: timer
Session-Expires: 450;refresher=uac
Min-SE: 90
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces, timer
X-asterisk-Info: SIP re-invite (Session-Timers)
Content-Type: application/sdp
Content-Length: 245

SDP NOT SHOWN

<— SIP read from UDP:62.239.169.164:5060 —>
SIP/2.0 420 Bad Extension
Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;received=86.149.85.155;branch=z9hG4bK71961607;rport=5060
From: “” sip:xxxxxxxxxxx@btsip.bt.com;tag=as5d9e44d0
To: sip:xxxxxxxxxxx@btsip.bt.com;tag=SDv5o2399-0082-0000362c-0762i0
Call-ID: 2397df823320810648a29478403281dd@btsip.bt.com
CSeq: 106 INVITE
Unsupported: timer

Hence why I’m trying to manipulate the SIP header to remove required and see what effect that has on the problem as the Require field isn’t…erm…required, if I read RFC 4028 correctly “The UAC MAY include a Require header field in the request with the value ‘timer’ to indicate that the UAS must support the session timer to participate in the session.”…MAY suggests that it doesn’t have to. “However, usage of either Require or Proxy-Require by the UAC is NOT RECOMMENDED. They are not needed, since the extension works even when only the UAC supports the extension. The Supported header field containing ‘timer’ MUST still be included, even if the Require or Proxy-Require header fields are present containing ‘timer’.”

I suppose that leads to the question, is Asterisk sending this Require field because my service provider specified it originally? Also, as the Require field is not recommended for a UAC, is there an ability to turn Require: timer off whilst still accepting session timers from the service provider and without doing SIP header manipulation to remove the field? Ok, that was two questions.

As I was reading the RFC, it led me onto “A re-INVITE generated to refresh the session is a normal re-INVITE, and an UPDATE generated to refresh a session is a normal UPDATE. If a UAC knows that its peer supports the UPDATE method, it is RECOMMENDED that UPDATE be used instead of a re-INVITE. A UA can make this determination if it has seen an Allow header field from its peer with the value ‘UPDATE’, or through a mid-dialog OPTIONS request.”. I’ve seen an Allow field with UPDATE in it from my service provider therefore why am I using a re-INVITE to refresh the session rather than an UPDATE (assuming my Asterisk is behaving as a UAC here and not a Proxy)?

Cheers for the help so far folks,

I did try this after Dial() and it doesn’t seem to have any effect. It could be that I’m new to the world of Asterisk and I’ve made a mistake:

exten => _X.,n,SIPRemoveHeader(Require:)

also

exten => _X.,n.SIPRemoveHeader(Require: timer)

Also tried it prior to Dial() but again it didn’t work. The Asterisk documentation does state though that it’s for removing previously added headers using SIPAddHeader() so possibly it just doesn’t work in this situation.

Cheers though,

Bump,

Anyone have any thoughts or help to offer?

Cheers,