in my requirement call coming from sbc to kamailio proxy and we route to pbx server in that when
kamailio proxy get the call at that time i am removing Contact header using remove_hf("Contact") and adding contact Header using append_hf("$uac_req(hdrs)") for route to PBX server . in that signaling i am getting modified Contact header but old contact header not removed properly some junks are remain in the signaling
INVITE
sip:user2@domain.org;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 10.212.xxx.xxx:port;branch=z9hG4bK-524287-1---8c5ac8642f321a9e
Max-Forwards: 70
Contact: <sip:user1@10.212.xxx.xxx:39931;transport=UDP>
To: <
sip:user2@domain.org;transport=UDP>
From: <
sip:user1@domain.org;transport=UDP>;tag=891fd646
Call-ID: t9Ff-fCrin_VN1IO9Xf1mA..
CSeq: 2 INVITE
Content-Type: application/sdp
Proxy-Authorization: Digest username="user1",realm="domain
.org",nonce="5ff5a660afc72502212b4a611bb0d689efadafab",uri="
sip:user2@domain.org;transport=UDP",response="f926e3742cbdcb8c68ea9b5
82ac2dc",cnonce="9b3276d6d37aaa6107a835df8e5b3a87",nc=00000001,qop=auth,algorithm=MD5
User-Agent: Z 3.15.40006 rv2.8.20
Allow-Events: presence, kpml, talk
Content-Length: 243
v=0
o=Z 0 0 IN IP4 10.212.xxx.xxx
s=Z
c=IN IP4 10.212.xxx.xxx
t=0 0
m=audio 8000 RTP/AVP 3 110 8 0 97 101
a=rtpmap:110 speex/8000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=30
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
after using remove-hf("Contact") function removing contact header but some junks are left and that eats next To header line and breaks Invite packet
INVITE sip:user2@domain.org:;transport=UDP SIP/2.0
Record-Route: <sip:172.xx.xx.xxx;lr=on;ftag=891fd646;vst=AAAAAFFTQVkuCENVXUEpHwNLAQEOSwdcDhwUcG9ydD1VRFA-;vsf=AAAAAFVCQ1U0ChwlAQMMHgBHHwFJVAYVYW5zcG9ydD1VRFA->
Via: SIP/2.0/UDP 172.xx.xx.xxx;branch=z9hG4bKbe4c.9743b885ad3452287530994a2cad6e50.0
Via: SIP/2.0/UDP 10.212.xxx.xxx:39931;rport=39931;received=172.xx.xx.x;branch=z9hG4bK-524287-1---8c5ac8642f321a9e
Max-Forwards: 69
sip:user1@172.xx.xx.x:39931;transport=UDPTo: <sip:user2@domain.org>
From: <sip:user1@domain.org>;tag=891fd646
Call-ID: t9Ff-fCrin_VN1IO9Xf1mA..
CSeq: 2 INVITE
Content-Type: application/sdp
User-Agent: Z 3.15.40006 rv2.8.20
Allow-Events: presence, kpml, talk
Content-Length: 534
Contact: <sip:user2@172.xx.xx.xxx:5060>
v=0
o=Z 0 0 IN IP4 10.212.xxx.xxx
s=Z
c=IN IP4 172.xx.xx.xxx
t=0 0
m=audio 11210 RTP/AVP 3 110 8 0 97 101
a=rtpmap:3 GSM/8000
a=rtpmap:110 speex/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:97 iLBC/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:97 mode=30
a=fmtp:101 0-16
a=sendrecv
a=rtcp:11211
a=ice-ufrag:lzjregPe
a=ice-pwd:RtA9x3jUWk4yNpJlzPL60nsRck
a=candidate:LhtmUSbPt9BJs4ZC 1 UDP 2130706431 172.16.16.163 11210 typ host
a=candidate:LhtmUSbPt9BJs4ZC 2 UDP 2130706430 172.16.16.163 11211 typ host
As you can see Contact header is gone but sip:1234@172.xx.xx.x:39931;transport=UDP part left before To header . and its breake invite packet .
Any suggestion will be highly appreciated.