<HTML><BODY><div>
<div style="-webkit-text-stroke-width:0px; background-color:#ffffff; color:#333333; font-family:Arial,Tahoma,Verdana,sans-serif; font-size:15px; font-style:normal; font-variant-caps:normal; font-variant-ligatures:normal; font-weight:400; letter-spacing:normal; orphans:2; text-align:start; text-decoration-color:initial; text-decoration-style:initial; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px">
<div>It looks like a bug of opensips.</div>

<div>This problem can occur for those who use opensips as a bridge between SIP-I and SIP. <br>
For example, you received a SIP-I message with body, you will want to delete the ISUP part in the processing process in order to send a regular SIP further.</div>

<div>If the incoming body (sdp+isup) is described by a single Content-Length header then everything will be fine.</div>

<div>And if the incoming body will have three Content-Length headers (the first Content-Length-shared of all body, the second on ISUP body and the third on SDP body)</div>

<div> </div>

<div>Content-Length: 477<br>
Content-Type: multipart/mixed;boundary=ssboundary<br>
--ssboundary<br>
Content-Length: 205<br>
Content-Type: application/sdp<br>
v=0<br>
o=xyz 1154444372 1154444373 IN IP4 10.111.18.3<br>
s=SipCall<br>
c=IN IP4 10.249.66.133<br>
t=0 0<br>
m=audio 28644 RTP/AVP 8 116<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:116 telephone-event/8000<br>
a=ptime:20<br>
--ssboundary<br>
Content-Length: 100<br>
Content-Type: application/isup;version=itu-t92+</div>

<div>)"<br>
)HB()EdRx1Z )EdRxa4}à§=?bñ£9<br>
1À4À?ÀoÀuÀ<br>
--ssboundary--</div>

<div><br>
 and you delete ISUP body</div>

<div># delete a mime body from incoming INVITE<br>
    remove_body_part("application/isup");</div>

<div><br>
your outgoing INVITE will contain two identical Content-Length headers and the remote side will drop your call 400.</div>

<div>Content-Length: 205<br>
Content-Length: 205<br>
Content-Type: application/sdp<br>
v=0<br>
o=xyz 1154444372 1154444373 IN IP4 10.111.18.3<br>
s=SipCall<br>
c=IN IP4 10.249.66.133<br>
t=0 0<br>
m=audio 28644 RTP/AVP 8 116<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:116 telephone-event/8000<br>
a=ptime:20<br>
 <br>
One Content-Length header is automatically generated by the "remove_body_part" function. And the second is taken from the incoming INVITE probably</div>

<div><br>
Then the most interesting. You cannot remove this unnecessary extra Content-Length header.</div>

<div>remove_hf("Content-Length");  - doesn't work. I don't know why.</div>

<div>Helped here is such a deception. When you get an incoming INVITE (let me remind you in it a body with three Content-Length)<br>
Before all manipulations do like this: </div>

<div> </div>

<div>## hack for removing Content-Length<br>
   replace_all("Content-Length", "X-");</div>
</div>

<div style="-webkit-text-stroke-width:0px; background-color:#ffffff; color:#333333; font-family:Arial,Tahoma,Verdana,sans-serif; font-size:15px; font-style:normal; font-variant-caps:normal; font-variant-ligatures:normal; font-weight:400; letter-spacing:normal; orphans:2; text-align:start; text-decoration-color:initial; text-decoration-style:initial; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px">And then your outgoing invite will have only one Content-Length and the remote party will not send you 400. In General, all will be well. The only nuance you will send is an X-header that is not needed by the remote side))</div>

<div style="-webkit-text-stroke-width:0px; background-color:#ffffff; color:#333333; font-family:Arial,Tahoma,Verdana,sans-serif; font-size:15px; font-style:normal; font-variant-caps:normal; font-variant-ligatures:normal; font-weight:400; letter-spacing:normal; orphans:2; text-align:start; text-decoration-color:initial; text-decoration-style:initial; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px"> </div>
<br>
<blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">Пятница, 8 ноября 2019, 11:14 +03:00 от users-request@lists.opensips.org:<br>
 
<div id="">
<div class="js-helper js-readmsg-msg">
<style type="text/css">
</style>
<div>
<div id="style_15732008670590935233_BODY">Send Users mailing list submissions to<br>
<a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="/compose?To=users%2drequest@lists.opensips.org">users-request@lists.opensips.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="/compose?To=users%2downer@lists.opensips.org">users-owner@lists.opensips.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Users digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. Opensips generate two Content-lenth headers (Oleg Podguyko)<br>
   2. Re: Opensips generate two Content-lenth headers (Alain Bieuzent)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 07 Nov 2019 21:15:10 +0300<br>
From: Oleg Podguyko <<a href="/compose?To=podguiko@mail.ru">podguiko@mail.ru</a>><br>
To: <a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a><br>
Subject: [OpenSIPS-Users] Opensips generate two Content-lenth headers<br>
Message-ID: <<a href="/compose?To=1573150510.509115405@f514.i.mail.ru">1573150510.509115405@f514.i.mail.ru</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
<br>
I’m using opensips as proxy. I got INVITE from one side, do some logics ,remove ISUP body and send INVITE to destination via dispatcher module.<br>
And I see that outgoing INVITE has two content-lenth headers. Remote side after received such INVITE sends 400 <br>
Bad Contenth-lenth header.<br>
 <br>
 <br>
 <br>
Incoming INVITE:<br>
 <br>
INVITE sip:9222992040@10.66.107.169;transport=sctp;user=phone SIP/2.0<br>
Via: SIP/2.0/SCTP 10.111.18.3:7010;branch=z9hG4bKiz5cvz9x5v5zi4bg84g4vx4zs;X-DispMsg=1408<br>
Route: <sip:10.66.107.169:5060;transport=sctp;lr><br>
Call-ID: <a href="/compose?To=i44czbcvax4gabcdst4iavdbaisji94s@10.18.5.64">i44czbcvax4gabcdst4iavdbaisji94s@10.18.5.64</a><br>
From: "9269918424"<sip:9269918424@10.111.18.3;transport=sctp;user=phone>;tag=i4z5545v-CC-1027-TRC-613805-OFC-14<br>
To: "9222992040"<sip:9222992040@10.66.107.169;transport=sctp;user=phone><br>
CSeq: 1 INVITE<br>
P-Access-Network-Info: GEN-ACCESS;"area-number=<span class="js-phone-number">+79262000601</span>"<br>
Max-Forwards: 70<br>
Contact: <sip:10.111.18.3:7010><br>
Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,INFO,PRACK,NOTIFY,MESSAGE,REFER,UPDATE<br>
P-Asserted-Identity: <tel:9269918424><br>
History-Info: <sip:9254462587@anonymous.invalid?reason=SIP%3Bcause%3D503%3Btext%3D%22Subscriber%20Not%20Reachable%22&Privacy=history>;index=1<br>
History-Info: <sip:9222992040@10.66.107.169:5060;transport=sctp>;index=1.1<br>
P-Early-Media: supported<br>
Supported: 100rel,timer,histinfo<br>
Min-SE: 90<br>
Session-Expires: 1800;refresher=uac<br>
Content-Length: 477<br>
Content-Type: multipart/mixed;boundary=ssboundary<br>
--ssboundary<br>
Content-Length: 205<br>
Content-Type: application/sdp<br>
v=0<br>
o=xyz 1154444372 1154444373 IN IP4 10.111.18.3<br>
s=SipCall<br>
c=IN IP4 10.249.66.133<br>
t=0 0<br>
m=audio 28644 RTP/AVP 8 116<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:116 telephone-event/8000<br>
a=ptime:20<br>
--ssboundary<br>
Content-Length: 100<br>
Content-Type: application/isup;version=itu-t92+<br>
 <br>
)"<br>
)HB()EdRx1Z )EdRxa4}à§=?bñ£9<br>
1À4À?ÀoÀuÀ<br>
--ssboundary--<br>
 <br>
 <br>
Outgoing INVITE<br>
 <br>
INVITE sip:9222992040@10.66.107.169;transport=sctp;user=phone SIP/2.0<br>
Record-Route: <sip:192.168.9.84;r2=on;lr;did=876.0b9c196><br>
Record-Route: <sip:10.66.107.169;transport=sctp;r2=on;lr;did=876.0b9c196><br>
Via: SIP/2.0/UDP 192.168.9.84:5060;branch=z9hG4bKfa6a.b4f80a51.0<br>
Via: SIP/2.0/SCTP 10.111.18.3:7010;branch=z9hG4bKiz5cvz9x5v5zi4bg84g4vx4zs;X-DispMsg=1408<br>
Call-ID: <a href="/compose?To=i44czbcvax4gabcdst4iavdbaisji94s@10.18.5.64">i44czbcvax4gabcdst4iavdbaisji94s@10.18.5.64</a><br>
From: "9269918424"<sip:9269918424@10.111.18.3;transport=sctp;user=phone>;tag=i4z5545v-CC-1027-TRC-613805-OFC-14<br>
To: "9222992040"<sip:9222992040@10.66.107.169;transport=sctp;user=phone><br>
CSeq: 1 INVITE<br>
P-Access-Network-Info: GEN-ACCESS;"area-number=<span class="js-phone-number">+79262000601</span>"<br>
Max-Forwards: 69<br>
Contact: <sip:10.111.18.3:7010><br>
Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,INFO,PRACK,NOTIFY,MESSAGE,REFER,UPDATE<br>
P-Asserted-Identity: <tel:9269918424><br>
History-Info: <sip:9254462587@anonymous.invalid?reason=SIP%3Bcause%3D503%3Btext%3D%22Subscriber%20Not%20Reachable%22&Privacy=history>;index=1<br>
History-Info: <sip:9222992040@10.66.107.169:5060;transport=sctp>;index=1.1<br>
P-Early-Media: supported<br>
Supported: 100rel,timer,histinfo<br>
Min-SE: 90<br>
Session-Expires: 1800;refresher=uac<br>
Content-Length: 205<br>
Content-Length: 205<br>
Content-Type: application/sdp<br>
v=0<br>
o=xyz 1154444372 1154444373 IN IP4 10.111.18.3<br>
s=SipCall<br>
c=IN IP4 10.249.66.133<br>
t=0 0<br>
m=audio 28644 RTP/AVP 8 116<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:116 telephone-event/8000<br>
a=ptime:20<br>
 <br>
 <br>
 <br>
 <br>
 <br>
--<br>
Oleg Podguyko<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.opensips.org/pipermail/users/attachments/20191107/99140cb6/attachment-0001.html" target="_blank">http://lists.opensips.org/pipermail/users/attachments/20191107/99140cb6/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Fri, 08 Nov 2019 09:13:43 +0100<br>
From: Alain Bieuzent <<a href="/compose?To=alain.bieuzent@free.fr">alain.bieuzent@free.fr</a>><br>
To: Oleg Podguyko <<a href="/compose?To=podguiko@mail.ru">podguiko@mail.ru</a>>, OpenSIPS users mailling list<br>
<<a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a>><br>
Subject: Re: [OpenSIPS-Users] Opensips generate two Content-lenth<br>
headers<br>
Message-ID: <<a href="/compose?To=56ECC46C%2dF074%2d4609%2dAE6B%2d79F3657F3D10@free.fr">56ECC46C-F074-4609-AE6B-79F3657F3D10@free.fr</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi Oleg,<br>
<br>
 <br>
<br>
Is it normal your outgoing INVITE have twice « Content-Length: 205 » ?<br>
<br>
 <br>
<br>
Regards<br>
<br>
 <br>
<br>
De : Users <<a href="/compose?To=users%2dbounces@lists.opensips.org">users-bounces@lists.opensips.org</a>> au nom de Oleg Podguyko via Users <<a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a>><br>
Répondre à : Oleg Podguyko <<a href="/compose?To=podguiko@mail.ru">podguiko@mail.ru</a>>, OpenSIPS users mailling list <<a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a>><br>
Date : jeudi 7 novembre 2019 à 19:16<br>
À : <<a href="/compose?To=users@lists.opensips.org">users@lists.opensips.org</a>><br>
Objet : [OpenSIPS-Users] Opensips generate two Content-lenth headers<br>
<br>
 <br>
<br>
I’m using opensips as proxy. I got INVITE from one side, do some logics ,remove ISUP body and send INVITE to destination via dispatcher module.<br>
<br>
And I see that outgoing INVITE has two content-lenth headers. Remote side after received such INVITE sends 400<br>
<br>
Bad Contenth-lenth header.<br>
<br>
 <br>
<br>
 <br>
<br>
 <br>
<br>
Incoming INVITE:<br>
<br>
 <br>
<br>
INVITE sip:9222992040@10.66.107.169;transport=sctp;user=phone SIP/2.0<br>
Via: SIP/2.0/SCTP 10.111.18.3:7010;branch=z9hG4bKiz5cvz9x5v5zi4bg84g4vx4zs;X-DispMsg=1408<br>
Route: <sip:10.66.107.169:5060;transport=sctp;lr><br>
Call-ID: <a href="/compose?To=i44czbcvax4gabcdst4iavdbaisji94s@10.18.5.64">i44czbcvax4gabcdst4iavdbaisji94s@10.18.5.64</a><br>
From: "9269918424"<sip:9269918424@10.111.18.3;transport=sctp;user=phone>;tag=i4z5545v-CC-1027-TRC-613805-OFC-14<br>
To: "9222992040"<sip:9222992040@10.66.107.169;transport=sctp;user=phone><br>
CSeq: 1 INVITE<br>
P-Access-Network-Info: GEN-ACCESS;"area-number=<span class="js-phone-number">+79262000601</span>"<br>
Max-Forwards: 70<br>
Contact: <sip:10.111.18.3:7010><br>
Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,INFO,PRACK,NOTIFY,MESSAGE,REFER,UPDATE<br>
P-Asserted-Identity: <tel:9269918424><br>
History-Info: <sip:9254462587@anonymous.invalid?reason=SIP%3Bcause%3D503%3Btext%3D%22Subscriber%20Not%20Reachable%22&Privacy=history>;index=1<br>
History-Info: <sip:9222992040@10.66.107.169:5060;transport=sctp>;index=1.1<br>
P-Early-Media: supported<br>
Supported: 100rel,timer,histinfo<br>
Min-SE: 90<br>
Session-Expires: 1800;refresher=uac<br>
Content-Length: 477<br>
Content-Type: multipart/mixed;boundary=ssboundary<br>
<br>
--ssboundary<br>
Content-Length: 205<br>
Content-Type: application/sdp<br>
<br>
v=0<br>
o=xyz 1154444372 1154444373 IN IP4 10.111.18.3<br>
s=SipCall<br>
c=IN IP4 10.249.66.133<br>
t=0 0<br>
m=audio 28644 RTP/AVP 8 116<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:116 telephone-event/8000<br>
a=ptime:20<br>
<br>
--ssboundary<br>
Content-Length: 100<br>
Content-Type: application/isup;version=itu-t92+<br>
<br>
 <br>
<br>
)"<br>
)HB()EdRx1Z<br>
)EdRxa4}à§=?bñ£9<br>
1À4À?ÀoÀuÀ<br>
--ssboundary--<br>
<br>
 <br>
<br>
 <br>
<br>
Outgoing INVITE<br>
<br>
 <br>
<br>
INVITE sip:9222992040@10.66.107.169;transport=sctp;user=phone SIP/2.0<br>
Record-Route: <sip:192.168.9.84;r2=on;lr;did=876.0b9c196><br>
Record-Route: <sip:10.66.107.169;transport=sctp;r2=on;lr;did=876.0b9c196><br>
Via: SIP/2.0/UDP 192.168.9.84:5060;branch=z9hG4bKfa6a.b4f80a51.0<br>
Via: SIP/2.0/SCTP 10.111.18.3:7010;branch=z9hG4bKiz5cvz9x5v5zi4bg84g4vx4zs;X-DispMsg=1408<br>
Call-ID: <a href="/compose?To=i44czbcvax4gabcdst4iavdbaisji94s@10.18.5.64">i44czbcvax4gabcdst4iavdbaisji94s@10.18.5.64</a><br>
From: "9269918424"<sip:9269918424@10.111.18.3;transport=sctp;user=phone>;tag=i4z5545v-CC-1027-TRC-613805-OFC-14<br>
To: "9222992040"<sip:9222992040@10.66.107.169;transport=sctp;user=phone><br>
CSeq: 1 INVITE<br>
P-Access-Network-Info: GEN-ACCESS;"area-number=<span class="js-phone-number">+79262000601</span>"<br>
Max-Forwards: 69<br>
Contact: <sip:10.111.18.3:7010><br>
Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,INFO,PRACK,NOTIFY,MESSAGE,REFER,UPDATE<br>
P-Asserted-Identity: <tel:9269918424><br>
History-Info: <sip:9254462587@anonymous.invalid?reason=SIP%3Bcause%3D503%3Btext%3D%22Subscriber%20Not%20Reachable%22&Privacy=history>;index=1<br>
History-Info: <sip:9222992040@10.66.107.169:5060;transport=sctp>;index=1.1<br>
P-Early-Media: supported<br>
Supported: 100rel,timer,histinfo<br>
Min-SE: 90<br>
Session-Expires: 1800;refresher=uac<br>
Content-Length: 205<br>
Content-Length: 205<br>
Content-Type: application/sdp<br>
v=0<br>
o=xyz 1154444372 1154444373 IN IP4 10.111.18.3<br>
s=SipCall<br>
c=IN IP4 10.249.66.133<br>
t=0 0<br>
m=audio 28644 RTP/AVP 8 116<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:116 telephone-event/8000<br>
a=ptime:20<br>
 <br>
<br>
 <br>
<br>
 <br>
<br>
 <br>
<br>
 <br>
<br>
--<br>
Oleg Podguyko<br>
<br>
_______________________________________________ Users mailing list <a href="/compose?To=Users@lists.opensips.org">Users@lists.opensips.org</a> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.opensips.org/pipermail/users/attachments/20191108/c6dfac88/attachment.html" target="_blank">http://lists.opensips.org/pipermail/users/attachments/20191108/c6dfac88/attachment.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="/compose?To=Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Users Digest, Vol 136, Issue 11<br>
**************************************</div>
</div>
</div>
</div>
</blockquote>
 

<div> </div>

<div data-signature-widget="container">
<div data-signature-widget="content">
<div>--<br>
Oleg Podguiko</div>
</div>
</div>

<div> </div>
</div>
</BODY></HTML>