I made it work but I have to set multipart always in request route  (as the manual says) to apply the changes. Just a comment. If I don't apply changes after append_body_part, kamailio crashes.

if (is_method("INVITE") && !has_totag()) {
                set_body_multipart();
                msg_apply_changes();
                $var(gtd) = "IAM,\r\nCPC,"+$avp("ch")+"\r\nGCI,asdfasd\r\n\r\n";        
                append_body_part("$var(gtd)", "application/gtd", "signal;handling=optional");
                msg_apply_changes(); 
}


I know that this is the way as it works (just apply changes in request route) but with rtjson and the evapi module I decide if it has to have or not multipart later and not in the first invite.
Is It possible to add in new versions of kamailio to apply the changes in branch route too? (this would be a new request)

Cheers.

Diego.






2016-12-26 13:21 GMT-03:00 Diego Nadares <dnadares@gmail.com>:
Hi Sergey, 

Thanks for your reply. You are right. 
 
I added a test with results in the second email  calling only set_body_multipart.

Do you have any idea what is happening?

Thanks again!

Diego

El El lun, 26 de dic. de 2016 a las 13:10, Sergey Basov <sergey.v.basov@gmail.com> escribió:
Hi. 

As from textopsx module doc: "This function can be used from REQUEST_ROUTE or ONREPLY_ROUTE." 

And you have error in your log: "Dec 26 11:36:22 dwrfsd01 ./kamailio[8847]: ERROR: textopsx [textopsx.c:159]: msg_apply_changes_f(): invalid usage - not in request route" 

--
Sergey Basov


26 дек. 2016 г. 5:05 PM пользователь "Diego Nadares" <dnadares@gmail.com> написал:
Sorry, I forgot to paste two log lines.

.....
Dec 26 11:36:22 dwrfsd01 ./kamailio[8847]: ERROR: textopsx [textopsx.c:159]: msg_apply_changes_f(): invalid usage - not in request route
Dec 26 11:36:22 dwrfsd01 ./kamailio[8847]: ERROR: textops [textops.c:1879]: append_multibody_helper(): Cannot get boundary. Is body multipart?
Dec 26 11:36:22 dwrfsd01 ./kamailio[8847]: INFO: <script>: NATMANAGE 172.16.213.38 172.16.208.11  <null>
Dec 26 11:36:22 dwrfsd01 ./kamailio[8847]: INFO: <script>: NATMANAGE 172.16.208.11 Priv
Dec 26 11:36:22 dwrfsd01 ./kamailio[8847]: INFO: <core> [msg_translator.c:1693]: get_boundary(): Content-Type hdr has no params <application/sdp>
Dec 26 11:36:22 dwrfsd01 ./kamailio[8847]: WARNING: <core> [msg_translator.c:1959]: build_req_buf_from_sip_req(): check_boundaries error
....

For what I can see, it's not applying the changes.

I tested again with just set_body_multipart. The GTD content is set OK but SDP content IS NOT and there is no boundary at the end of the body.

if ($avp(ch)){
                     $var(gtd) ="IAM,\r\nGCI,asdafsdfasd\r\n\r\n";       
                     set_body_multipart("$var(gtd)", "application/gtd", "uniqueBoundary-1");
}

Dec 26 11:55:19 dwrfsd01 ./kamailio[8916]: INFO: <core> [msg_translator.c:1693]: get_boundary(): Content-Type hdr has no params <application/sdp>
Dec 26 11:55:19 dwrfsd01 ./kamailio[8916]: WARNING: <core> [msg_translator.c:1959]: build_req_buf_from_sip_req(): check_boundaries error

body result:

Content-Length:   501.
Content-Type: multipart/mixed;boundary="uniqueBoundary-1".
Mime-Version: 1.0. 

--uniqueBoundary-1.
Content-Type: application/gtd.
.
IAM,.
CPC,.
GCI,sdfasdf.
.
--uniqueBoundary-1.
v=0.
o=user1 53655765 2353687637 IN IP4 172.16.213.38.
s=-.
c=IN IP4 172.16.213.38.
t=0 0.
m=audio 58778 RTP/AVP 8.
a=rtpmap:8 PCMA/8000.
a=sendrecv.
a=rtcp:58779.
a=ice-ufrag:2NRZkfr2.
a=ice-pwd:rzffP1tp831WzYH0PTIOSMoVye.
a=candidate:fw7LZeIomEu5faq4 1 UDP 2130706431 172.16.213.38 58778 typ host.
a=candidate:fw7LZeIomEu5faq4 2 UDP 2130706430 172.16.213.38 58779 typ host.

Thanks!

Diego


2016-12-26 11:46 GMT-03:00 Diego Nadares <dnadares@gmail.com>:
Hi guys,

I'm trying to append a content type to a message that has only one content type. I tried using just set_body_multipart and now I'm using set_body multipart and append_body_part with no success too. 

The result is a message with multipart but has "two" sdp and no gtd. It has the old sdp with no ip changed for rtpproxy and the new sdp with ip changed BUT with no content type.  And the message has not the end boundary (--unique-boundary-1.)

Kamailio log has an info and a warning

Dec 26 11:36:22 dwrfsd01 ./kamailio[8847]: INFO: <core> [msg_translator.c:1693]: get_boundary(): Content-Type hdr has no params <application/sdp>
Dec 26 11:36:22 dwrfsd01 ./kamailio[8847]: WARNING: <core> [msg_translator.c:1959]: build_req_buf_from_sip_req(): check_boundaries error


kamailio.cfg

......

route[RELAY]{
$avp(ch) = 1
....
if ($avp(ch)){
                     set_body_multipart();
                     msg_apply_changes();
                     $var(gtd) ="IAM,\r\nGCI,asdafsdfasd\r\n\r\n";       
                     append_body_part("$var(gtd)", "application/gtd", "signal;handling=optional");
}
....
}

Ngrep

U 2016/12/26 11:36:22.496634 172.16.213.21:5060 -> 172.16.213.38:5060
...
Content-Type: application/sdp.
Content-Length:   137.
.
v=0.
o=user1 53655765 2353687637 IN IP4 172.16.213.21.
s=-.
c=IN IP4 172.16.213.21.
t=0 0.
m=audio 6000 RTP/AVP 8.
a=rtpmap:8 PCMA/8000.

U 2016/12/26 11:36:22.688458 172.16.213.38:5060 -> 172.16.208.11:5060
....
Content-Type: multipart/mixed;boundary="unique-boundary-1".
Mime-Version: 1.0.
Remote-Party-ID: <sip:1152565064@172.16.213.38:5060>;party=calling;privacy=off;screen=no.
.
--unique-boundary-1.
Content-Type: application/sdp.
.
v=0.
o=user1 53655765 2353687637 IN IP4 172.16.213.21.
s=-.
c=IN IP4 172.16.213.21.
t=0 0.
m=audio 6000 RTP/AVP 8.
a=rtpmap:8 PCMA/8000.
.
--unique-boundary-1.
v=0.
o=user1 53655765 2353687637 IN IP4 172.16.213.38.
s=-.
c=IN IP4 172.16.213.38.
t=0 0.
m=audio 58724 RTP/AVP 8.
a=rtpmap:8 PCMA/8000.
a=sendrecv.
a=rtcp:58725.
a=ice-ufrag:hhXDwrco.
a=ice-pwd:5temIXP8veOGuD8Dsllm5HXkWU.

Any help will be very very appreciated!

Thanks in advance.

Diego






_______________________________________________


SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list


sr-users@lists.sip-router.org


http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users






_______________________________________________

SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list

sr-users@lists.sip-router.org

http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users