<div dir="auto"><div>Hi Oded,</div><div dir="auto"><br></div><div dir="auto">I would better use uac_replace_from like </div><div dir="auto">described in the Kamailio wiki. (link below) </div><div dir="auto">This function takes also care of rewriting it back AFAIK. </div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><a href="http://www.kamailio.org/wiki/tutorials/faq/main#how_to_set_different_header_va">http://www.kamailio.org/wiki/tutorials/faq/main#how_to_set_different_header_va</a><br><br>Cheers</div><div dir="auto">Karsten Horsmann <br><br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">Oded Arbel <<a href="mailto:odeda@cloudonix.io">odeda@cloudonix.io</a>> schrieb am So., 26. Mai 2019, 17:02:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm trying to rewrite the `From` header in an invite going out to an<br>
external system (*), by calling remove_hf("From");<br>
followed by<br>
append_hf("From: <some value>\r\n");<br>
<br>
but the result is an invalid SIP message, because apparently after<br>
`remove_hf()` finishes, it leaves the content of $fU in place of the<br>
`From` header - just the raw text, without a header name or even a<br>
"\r\n" - and that eats the next header line and breaks the INVITE.<br>
<br>
Here is how the INVITE originally looks (without either `remove_hf()`<br>
or `append_hf()`):<br>
<br>
---8<---<br>
INVITE <a href="http://sip:972522353283@10.20.30.40:5060" rel="noreferrer noreferrer" target="_blank">sip:972522353283@10.20.30.40:5060</a> SIP/2.0<br>
Record-Route: <sip:10.90.80.70;lr;did=649.f0b><br>
Via: SIP/2.0/UDP<br>
10.90.80.70:5060;branch=z9hG4bK6188.ff5c4fd855bd2970fdf32d4807b114c2.0<br>
Via: SIP/2.0/UDP<br>
10.90.80.71:5066;received=10.90.80.71;branch=z9hG4bK581897a4;rport=5066<br>
Max-Forwards: 69<br>
From: <<a href="http://sip:972515340014@example.com:5066" rel="noreferrer noreferrer" target="_blank">sip:972515340014@example.com:5066</a>>;tag=as0bcee217<br>
To: <<a href="http://sip:972522353283@10.20.30.40:5060" rel="noreferrer noreferrer" target="_blank">sip:972522353283@10.20.30.40:5060</a>><br>
Contact: <<a href="http://sip:972515340014@10.90.80.71:5066" rel="noreferrer noreferrer" target="_blank">sip:972515340014@10.90.80.71:5066</a>><br>
Call-ID: <a href="http://722299dc15aad53d28172d433e8665f4@10.90.80.71:5066" rel="noreferrer noreferrer" target="_blank">722299dc15aad53d28172d433e8665f4@10.90.80.71:5066</a><br>
CSeq: 102 INVITE<br>
User-Agent: Asterisk PBX 14.7.2<br>
Date: Sun, 26 May 2019 14:42:52 GMT<br>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY,<br>
INFO, PUBLISH, MESSAGE<br>
Supported: replaces<br>
X-CID: ad199638-4df3-4aef-81f1-1b50581032a7<br>
Content-Type: application/sdp<br>
Content-Length: 280<br>
<br>
v=0<br>
o=root 817636675 817636675 IN IP4 10.50.60.70<br>
s=Asterisk PBX 14.7.2<br>
c=IN IP4 10.50.60.70<br>
t=0 0<br>
m=audio 39064 RTP/AVP 8 0 18 9<br>
a=maxptime:60<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:0 PCMU/8000<br>
a=rtpmap:18 G729/8000<br>
a=rtpmap:9 G722/8000<br>
a=sendrecv<br>
a=rtcp:39065<br>
a=ptime:20<br>
---8<---<br>
<br>
and here is another call with the same setup, with just<br>
`remove_hf("From");` being invoked (without calling `append_hf()` -<br>
this is just for reproduction):<br>
<br>
---8<---<br>
INVITE <a href="http://sip:972522353283@10.20.30.40:5060" rel="noreferrer noreferrer" target="_blank">sip:972522353283@10.20.30.40:5060</a> SIP/2.0<br>
Record-Route: <sip:10.90.80.70;lr;did=f45.91b1><br>
Via: SIP/2.0/UDP<br>
10.90.80.70:5060;branch=z9hG4bK024d.2690ebf7a809edca2208e6b2561ccf9e.0<br>
Via: SIP/2.0/UDP<br>
10.90.80.71:5066;received=10.90.80.71;branch=z9hG4bK79ae3073;rport=5066<br>
Max-Forwards: 69<br>
972515340014To: <<a href="http://sip:972522353283@10.20.30.40:5060" rel="noreferrer noreferrer" target="_blank">sip:972522353283@10.20.30.40:5060</a>><br>
Contact: <<a href="http://sip:972515340014@10.90.80.71:5066" rel="noreferrer noreferrer" target="_blank">sip:972515340014@10.90.80.71:5066</a>><br>
Call-ID: <a href="http://7b20ba5a549f6f886c22985146765736@10.90.80.71:5066" rel="noreferrer noreferrer" target="_blank">7b20ba5a549f6f886c22985146765736@10.90.80.71:5066</a><br>
CSeq: 102 INVITE<br>
User-Agent: Asterisk PBX 14.7.2<br>
Date: Sun, 26 May 2019 14:44:20 GMT<br>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY,<br>
INFO, PUBLISH, MESSAGE<br>
Supported: replaces<br>
X-CID: ffbb4ac1-3a0f-4dd6-9ce9-7ad24361081a<br>
Content-Type: application/sdp<br>
Content-Length: 280<br>
<br>
v=0<br>
o=root 509740923 509740923 IN IP4 10.50.60.70<br>
s=Asterisk PBX 14.7.2<br>
c=IN IP4 10.50.60.70<br>
t=0 0<br>
m=audio 39102 RTP/AVP 8 0 18 9<br>
a=maxptime:60<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:0 PCMU/8000<br>
a=rtpmap:18 G729/8000<br>
a=rtpmap:9 G722/8000<br>
a=sendrecv<br>
a=rtcp:39103<br>
a=ptime:20<br>
---8<---<br>
<br>
As you can see, the `From` header is indeed gone, but it left the $fU<br>
just before the `To` header.<br>
<br>
WTF?<br>
<br>
I'm running Kamailio 5.2.2 built locally.<br>
<br>
Notes:<br>
*) the problem I'm trying to solve is that I can't get my Asterisk<br>
installation to generate the `From` header I want, the reason is out<br>
of scope of this question, so I'm sending custom SIP headers over to<br>
Kamaiio and I want to rewrite the header in Kamailio to the "correct"<br>
value.<br>
<br>
-- <br>
Oded Arbel<br>
<br>
_______________________________________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org" target="_blank" rel="noreferrer">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div></div></div>