Hi,
I'm using remove_hf() and append_hf() to manipulate the sip headers on my application. Apparently, calling insert_hf("foo") after remove_hf("bar") if bar is the last header (not including Content-Length) is a bad idea, foo doesn't get inserted (I understand that the append_hf() command tries to insert foo after bar, and since bar just disappeared, well, it fails)
What is the safest way to both remove and append headers on the same message?
Regards
Hello,
On 11/5/13 12:37 PM, Camille Oudot wrote:
Hi,
I'm using remove_hf() and append_hf() to manipulate the sip headers on my application. Apparently, calling insert_hf("foo") after remove_hf("bar") if bar is the last header (not including Content-Length) is a bad idea, foo doesn't get inserted (I understand that the append_hf() command tries to insert foo after bar, and since bar just disappeared, well, it fails)
What is the safest way to both remove and append headers on the same message?
Even if the header is not present, insert/append_hf() should not fail, first will add as first header and the second will add as last header. Can you send the output with debug=3 and the ngrep for this processing?
Cheers, Daniel
Le Tue, 5 Nov 2013 14:53:34 +0100, Daniel-Constantin Mierla miconda@gmail.com a écrit :
Even if the header is not present, insert/append_hf() should not fail
Ok I assumed wrong. The issue looks trickier: I've made tests that go OK or KO depending on a harmless looking cfg change. In the KO situation, a Path header is set depending on a !ifdef directive + if condition, while in the OK case, it's inserted without condition.
After the Path hdr insertion, three other headers are appended.
In the KO log, on line 3508, there are only three append_hf while in the OK log, there are four (line 3408).
The network traces show that the Require header is not inserted as requested in the cfg.
Update: adding a dummy xlog line on line 22 of kamailio.ko.cfg makes it work: the Require header is inserted but the log line is not printed.
Regards,
Hello,
On 11/5/13 4:49 PM, Camille Oudot wrote:
Le Tue, 5 Nov 2013 14:53:34 +0100, Daniel-Constantin Mierla miconda@gmail.com a écrit :
Even if the header is not present, insert/append_hf() should not fail
Ok I assumed wrong. The issue looks trickier: I've made tests that go OK or KO depending on a harmless looking cfg change. In the KO situation, a Path header is set depending on a !ifdef directive + if condition, while in the OK case, it's inserted without condition.
After the Path hdr insertion, three other headers are appended.
In the KO log, on line 3508, there are only three append_hf while in the OK log, there are four (line 3408).
The network traces show that the Require header is not inserted as requested in the cfg.
Update: adding a dummy xlog line on line 22 of kamailio.ko.cfg makes it work: the Require header is inserted but the log line is not printed.
What defines you set for each of the cases? I see there is an else left open inside the #!ifdef, which ends up in getting an append_hf() if the define id is set.
Cheers, Daniel
Le Wed, 6 Nov 2013 12:48:47 +0100, Daniel-Constantin Mierla miconda@gmail.com a écrit :
What defines you set for each of the cases? I see there is an else left open inside the #!ifdef, which ends up in getting an append_hf() if the define id is set.
Hello Daniel,
thanks, you figured it right: the WITH_NAT define was set. I changed the pcscf cfg example and somehow misread the #!ifdef/#!else and if/else logic.
I changed the config back to
#!ifdef WITH_NAT if (...) {
} else #!endif append_hf("Path: <sip:term@" + NETWORK_INTERNAL_IP_S+":"+SIP_INTERNAL_PORT+";lr>\r\n");
as it was intended in the first place, and everything went back to normal.
Thanks