I'm trying to integrate to an integrics enswitch, almost everything works like a charm, except on BYE packets as Kamailio in my setup forwards these incorrectly.

Digging somewhat I believe the culprit sits in the Route header which comes from the enswitch:

Route: <sip:their_sbc;lr=on;ftag=as5716fec8>,<sip:36d0a5cfbaeb6b055d5bb02c32127b49_32123456789@my_kamailio;lr=on;ftag=as5716fec8>

Kamailio takes into account the first argument (the thing sip:their_sbc...) on which it cannot find the correct transaction. And forwards it back to the sender, instead of forwarding it correctly to my freeswitch. which gives a storm of traffic ;)

If I compare that with an ACK packet in the same transaction , having this as a Route header :

Route: <sip:36d0a5cfbaeb6b055d5bb02c32127b49_32123456789@my_kamailio;lr=on;ftag=as5716fec8>

Kamailio sends it along correctly.

IMHO if I could convince Kamailio to always take the last part of the Route header into account and ignore the first one it would correctly work. What would be a good approach? Rewriting the route header looks abit harsch.

disclaimer : I'm not sure which component is disrespecting the RFC, if any, or if I just fully not get something :)

Short overview + packet detail (with some obfuscation):

My setup:

their_sbc ---  my_kamailio --- freeswitch --- my_kamailio --- enduser


BYE sip:05xxxxxx@my_kamailio:5060;transport=udp SIP/2.0
Record-Route: <sip:their_sbc;lr=on;ftag=as5716fec8>
Via: SIP/2.0/UDP their_sbc;branch=z9hG4bK1ae8.269e4f67.0
Via: SIP/2.0/UDP their_internals:5060;received=their_internals;branch=z9hG4bK4f9044a7;rport=5060
Route: <sip:their_sbc;lr=on;ftag=as5716fec8>,<sip:36d0a5cfbaeb6b055d5bb02c32127b49_32123456789@my_kamailio;lr=on;ftag=as5716fec8>
Max-Forwards: 69
From: "Some_Telecom" <sip:02xxxxxxxx@their_sbc>;tag=as5716fec8
To: <sip:05xxxxxx@their_sbc:5060>;tag=U3FrFDm5Zr0KF
Call-ID: 68fe6a470986bd087ce4ed860f603af6@their_sbc
CSeq: 103 BYE
User-Agent: Integrics Enswitch
X-Asterisk-HangupCause: Normal Clearing
X-Asterisk-HangupCauseCode: 16
Content-Length: 0
X-Enswitch-RURI: sip:05xxxxxx@my_kamailio:5060;transport=udp
X-Enswitch-Source: their_internals:5060

BYE sip:36d0a5cfbaeb6b055d5bb02c32127b49_32123456789@my_kamailio;lr=on;ftag=as5716fec8 SIP/2.0
Record-Route: <sip:05xxxxxx@my_kamailio;lr=on;ftag=as5716fec8>
Record-Route: <sip:their_sbc;lr=on;ftag=as5716fec8>
Via: SIP/2.0/UDP my_kamailio;branch=z9hG4bK1ae8.b4f95af2.0
Via: SIP/2.0/UDP my_kamailio;rport=5060;branch=z9hG4bK1ae8.a4f95af2.0
Via: SIP/2.0/UDP their_sbc;rport=5060;branch=z9hG4bK1ae8.269e4f67.0
Via: SIP/2.0/UDP their_internals:5060;received=their_internals;branch=z9hG4bK4f9044a7;rport=5060
Route: <sip:their_sbc;lr=on;ftag=as5716fec8>
Max-Forwards: 67
From: "Some_Telecom" <sip:02xxxxxxxx@their_sbc>;tag=as5716fec8
To: <sip:05xxxxxx@their_sbc:5060>;tag=U3FrFDm5Zr0KF
Call-ID: 68fe6a470986bd087ce4ed860f603af6@their_sbc
CSeq: 103 BYE
User-Agent: Integrics Enswitch
X-Asterisk-HangupCause: Normal Clearing
X-Asterisk-HangupCauseCode: 16
Content-Length: 0
X-Enswitch-RURI: sip:05xxxxxx@my_kamailio:5060;transport=udp
X-Enswitch-Source: their_internals:5060