### Description
fix_nated_contact() and removing and appending a contact will malform the SIP packet.
I read somewhere that all of the *_hf functions are applied only when the packet is sent
out again. Perhaps things are working as intended and I am just asking too much of these
functions.
#### Reproduction
In my onreply_route for 200 OK with SDP:
fix_nated_contact();
#dlg_setflag(1); # I want the contact in the dialog table to be the fixed one
#Then I want to replace that contact with a contact to Kamailio's public IP and route
it to Asterisk
#for ACK response. This contact must be here for Asterisk to relay this back to me.
remove_hf("Contact");
append_hf("Contact: <sip:$sel(cfg_get.global.publicIP):5060>\r\n"); #
insert_hf same problem
### Troubleshooting
This results in two contacts, but does not malform. remove_hf after the nat_fix_contact is
the issue.
fix_nated_contact();
insert_hf("Contact: <sip:$sel(cfg_get.global.publicIP):5060>\r\n");
#### SIP Traffic
The inbound 200 OK
CSeq: 9865 INVITE
Contact: <sip:424242143@devicePrivateIP:5060>
Content-Type: application/sdp
After fix_nated_contact(); remove_hf("Contact"); append_hf("Contact:
<sip:serverIP:5060>\r\n");
CSeq: 9865 INVITE
sip:424242143@devicePublicIP:1026Content-Type: application/sdp
### Possible Solutions
I managed to get the functionality I wanted with either of these, but they result in two
contact headers.
I have also noticed that a remove->append->remove->append ignores the remove
between appends.
Workaround 1
remove_hf("Contact");
insert_hf("Contact: <sip:$tU@$si:$sp>\r\n");
dlg_setflag(1);
insert_hf("Contact: <sip:$sel(cfg_get.global.publicIP):5060>\r\n");
Workaround 2
fix_nated_contact();
dlg_setflag(1);
insert_hf("Contact: <sip:$sel(cfg_get.global.publicIP):5060>\r\n");
### Additional Information
* **Kamailio Version**: kamailio 4.4.5 (x86_64/linux) f98162
* **Operating System**: Linux 3.10.0-514.2.2.el7.x86_64 # 1 SMP Tue Dec 6 23:06:41 UTC
2016 x86_64 x86_64 x86_64 GNU/Linux
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/977