Hi all,

Hope everyone is well, and looking forward to seeing you all whenever Kamailio 
World ends up being!

I’m currently dealing with an issue which I’m unsure if it’s due to my own 
implementation, or a bug.

When attempting to manipulate the Contact header via app_ruby, the SIP message 
I send ends up being malformed. Here’s the code I’m using:

def replace_contact_header(uri)
  #KSR::HDR.remove("Contact") if KSR::HDR.is_present('Contact') > 0
  #KSR::HDR.append("Contact: #{uri}\r\n")  
  KSR::HDR.rmappend("Contact", "Contact: #{uri}\r\n")
end

Note that I have tried both rmappend and the commented out functions too. I 
call this with a custom built URI, such as 
<[email protected] 
<mailto:[email protected]>>. This function is called 
just before a KSR::TM.t_relay(). Here’s the result I get watching from tshark 
(some info scrubbed for privacy):

Record-Route: 
<sip:1.2.3.4;lr;ftag=e3p42efd3635HH;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVFHDQAAs83AEGwAAFgwCQA8QY3RlZC5jb20uYXU-;did=927.f0f2>
…
Call-ID: 3de29646-e423-1238-e712-023563fb337c
CSeq: 17736747 INVITE
sip:4.5.6.7:5060;alias=10.100.1.1~5060~1Content-Type: application/sdp
Content-Length: 483
Contact: <sip:[email protected]>

In this case, 4.5.6.7 is the PBX I made the call from (and the value of the 
original Contact header), and 1.2.3.4 is what kamailio.test.uconnected.com.au 
<http://kamailio.test.uconnected.com.au/> resolves to, and is this Kamailio 
instance.

Here’s a copy of the same thing when I don’t call my replace_contact_header 
function and t_relay:

Record-Route: 
<sip:1.2.3.4;lr;ftag=j6jebCSa5Qap6c;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVND38dTgwEGEAEGwAAFgwCQA8Fdn83lZC5jb20uYXU-;did=827.40b>
...
Call-ID: 249571c5-e91a-ae91-6d8e-023563fb337c
CSeq: 17735867 INVITE
Contact: <sip:4.5.6.7:5060;alias=10.100.1.1~5060~1>
Content-Type: application/sdp
Content-Length: 483

Given the relative simplicity of the function, I have to assume this is an 
error with how the function is manipulating the existing Contact header? It 
seems that the “Contact: <“ part of the header is being removed as well as the 
“>\r\n", but the rest being left.

I’m currently using commit 283e468401d809ca9b71368c32badf3a70d48b8b 
<https://github.com/kamailio/kamailio/commit/283e46> on Amazon Linux 2, which 
is CentOS/RHEL based.

Thanks!

Andrew
_______________________________________________
Kamailio (SER) - Users Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to