<p>Hello,</p>

<p>If I understand correctly to insert some additional ISUP(SIP-T) data after SDP into INVITE SIP message the first step would be to convert a single body of this SIP message to a multipart body with <code>set_body_multipart</code> (from <code>textops</code> module) without any parameters (according to <a href="https://www.kamailio.org/docs/modules/stable/modules/textops.html#textops.f.set_body_multipart">https://www.kamailio.org/docs/modules/stable/modules/textops.html#textops.f.set_body_multipart</a>) and then it would convert this message to a multipart one.  Then use <code>append_body_part</code> from the same module to insert ISUP data.  However when we tested the first step <code>set_body_multipart</code> didn't insert a proper closing boundary delimiter (ending with two more hyphens) as it's supposed to according its documentation: <em>The core will take care of the last boundary ending "--". Detecting which one is the last and fixing the others if needed.</em></p>

<p>We tested with the latest release 4.4.1:</p>

<p>kamailio.cfg:</p>

<pre><code>route {
        # CANCEL processing                                                                                                                                                       
        if (is_method("CANCEL"))
        {
                if (t_check_trans())
                        t_relay();
                exit;
        }

        # account only INVITEs                                                                                                                                                    
        if (is_method("INVITE"))
        {
                setflag(1); # do accounting   

                if(!ds_is_from_list("1")){
                    ## handle INBOUND ISUP                                                                                                                                        
                    route(ISUP);
                } else {
                    xlog("SIP message from $ru\n");
                    ## handle OUTBOUND ISUP                                                                                                                                       
                    route(TO_PSTN);
                }
        }

        if ($rU==$null)
        {
                # request with no Username in RURI                                                                                                                                
                sl_send_reply("484","Address Incomplete");
                exit;
        }

        # dispatch destinations                                                                                                                                                   
        route(DISPATCH);
}

route[TO_PSTN] {
    set_body_multipart(); # supposed to do the right thing
    msg_apply_changes(); # tested with and without this call, still the same result
}
</code></pre>

<p>Malformed INVITE SIP message (from Wireshark):</p>

<pre><code>INVITE sip:1000@192.168.38.88:5080 SIP/2.0
Record-Route: <sip:192.168.38.88:5080;lr=on;callgenie=true>
Via: SIP/2.0/UDP 192.168.38.88:5080;branch=z9hG4bK61df.358abca8ab3f0186f30b081e906e09d0.0
Via: SIP/2.0/UDP 192.168.38.88:5060;branch=z9hG4bK0fdf4145
Max-Forwards: 69
From: "Anonymous" <sip:anonymous@anonymous.invalid>;tag=as6510bcf9
To: <sip:1000@192.168.38.88:5080>
Contact: <sip:anonymous@192.168.38.88:5060>
Call-ID: 4ad0a0133cdbea9c6a05677715d4bd21@192.168.38.88:5060
CSeq: 102 INVITE
User-Agent: Asterisk PBX 13.6.0
Date: Tue, 07 Jun 2016 08:38:02 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
X-ISUP-ANI: 081101213
Content-Length: 435
Content-Type: multipart/mixed;boundary="unique-boundary-1"
Mime-Version: 1.0

--unique-boundary-1
Content-Type: application/sdp

v=0
o=root 957277759 957277759 IN IP4 192.168.38.88
s=Asterisk PBX 13.6.0
c=IN IP4 192.168.38.88
b=CT:384
t=0 0
m=audio 11424 RTP/AVP 0 8 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv
m=video 13788 RTP/AVP 34
a=rtpmap:34 H263/90000
a=sendrecv

--unique-boundary-1
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.38.88:5080;branch=z9hG4bK61df.358abca8ab3f0186f30b081e906e09d0.0
Via: SIP/2.0/UDP 192.168.38.88:5060;branch=z9hG4bK0fdf4145
To: <sip:1000@192.168.38.88:5080>
From: "Anonymous" <sip:anonymous@anonymous.invalid>;tag=as6510bcf9
Call-ID: 4ad0a0133cdbea9c6a05677715d4bd21@192.168.38.88:5060
CSeq: 102 INVITE
Content-Length: 0

<skipped>
</code></pre>

<p>Thanks.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/661">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AF36ZW56YKcEDQKHALsKbOBLF-Q88lfaks5qJT4sgaJpZM4IvvnJ">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZR1NfxrHisgE06opnQ7T3mOfmHMzks5qJT4sgaJpZM4IvvnJ.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/661"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>