[SR-Users] Textops Module - Multipart Body conversion
Federico San Martín
fsanmartin at telecentro.net.ar
Fri Feb 20 16:00:39 CET 2015
Hi guys, I'm trying to convert an SDP body to Multipart/Mixed and add an ISUP encapsulated part (SIP-I) on a 200OK reply. It seems like the module is having trouble with the delimiters. The scenario is like this:
PSTN MGC Kamailio SEMS
|-------IAM------>| | |
| |----INVITE/IAM/SDP---> | |
| | | ---INVITE/IAM/SDP--> |
| | | <------200OK/SDP---- |
| |<-----200OK/ACM/SDP--- | |
|<------ACM-------| | |
This is the config I'm using (just showing the relevant part, let me know if you need the whole config file):
onreply_route[MANAGE_REPLY]{
if (status=~"200"){
xlog("L_INFO","Reply <$rs> Message Interception\n");
route(INSERT_ACM);
}
}
route[INSERT_ACM]{
set_body_multipart();
$var(acm) = "06 02 04 01 29 01 01 00";
append_body_part("$var(acm)","application/isup; version=itu-t92+","signal; handling=optional");
return;
}
The original 200OK Message received is:
#U 2015/02/20 11:40:38.687418 172.30.24.20:5080 -> 172.30.24.20:5060
SIP/2.0 200 OK
Via: SIP/2.0/UDP 172.30.24.20;branch=z9hG4bK8a2b.41161a372680192aa4fdd9efbefd6696.0
Via: SIP/2.0/UDP 172.30.8.66:5060;branch=z9hG4bK+1010ce54853b2a3c7f7b8a220b4b69a41+3a836f1f+1
Call-ID: 4C6CD8F8 at 3a836f1f
From: "Fede SM Test"<sip:1135349910 at 172.30.8.66:5060;user=phone>;tag=3a836f1f+1+1e100002+ef7ba2f0
To: <sip:100 at 172.30.24.20:5060;user=phone>;tag=3DF4D6A2-54E74766000A65EC-41B8C700
CSeq: 221937633 INVITE
Server: Sip Express Media Server (1.5.1 (x86_64/linux))
Contact: <sip:100 at 172.30.24.20:5080>
Content-Type: application/sdp
Content-Length: 224
v=0
o=sems 351367313 715465045 IN IP4 172.30.24.20
s=sems
c=IN IP4 172.30.24.20
t=0 0
m=audio 10054 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
a=direction:both
And the mangled 200OK message I generate with Kamailio to send Upstream with this configuration is:
#
U 2015/02/20 11:40:38.690733 172.30.24.20:5060 -> 172.30.8.66:5060
SIP/2.0 200 OK
Via: SIP/2.0/UDP 172.30.8.66:5060;branch=z9hG4bK+1010ce54853b2a3c7f7b8a220b4b69a41+3a836f1f+1
Call-ID: 4C6CD8F8 at 3a836f1f
From: "Fede SM Test"<sip:1135349910 at 172.30.8.66:5060;user=phone>;tag=3a836f1f+1+1e100002+ef7ba2f0
To: <sip:100 at 172.30.24.20:5060;user=phone>;tag=3DF4D6A2-54E74766000A65EC-41B8C700
CSeq: 221937633 INVITE
Server: Sip Express Media Server (1.5.1 (x86_64/linux))
Contact: <sip:100 at 172.30.24.20:5080>
Content-Length: 301
Content-Type: multipart/mixed;boundary="unique-boundary-1"
Mime-Version: 1.0
--unique-boundary-1
Content-Type: application/sdp
v=0
o=sems 351367313 715465045 IN IP4 172.30.24.20
s=sems
c=IN IP4 172.30.24.20
t=0 0
m=audio 10054 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
a=direction:both
--unique-boundary-1
As you can see, the TEXTOPS module is not adding the ISUP part, also the boundary of the SDP is missing the last "--" to indicate this is the last part. But it is indeed changing the Content-Type to multipart/mixed, although the boundary has a set of quotes that I'm not sure if could be the problem. On the logs I get:
Feb 20 11:51:49 KAMAILIO kamailio[19883]: INFO: Kamlog: Reply <200> Message Interception
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: textops [textops.c:1582]: set_multibody_helper(): delimiter<17>:[unique-boundary-1]
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: <core> [parser/msg_parser.c:204]: get_hdr_field(): DEBUG: get_hdr_body : content_length=225
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: <core> [parser/msg_parser.c:106]: get_hdr_field(): found end of header
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: textops [textops.c:1491]: generate_boundary(): adding final CRLF+CRLF
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: textops [textops.c:1719]: set_multibody_helper(): content-type<44>:[multipart/mixed;boundary="unique-boundary-1"]
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: textops [textops.c:1771]: set_multibody_helper(): set flag FL_BODY_MULTIPART
### Error ###
Feb 20 11:51:49 KAMAILIO kamailio[19883]: ERROR: textops [textops.c:1869]: append_multibody_helper(): Cannot get boundary. Is body multipart?
### ###
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: tm [t_reply.c:1294]: t_should_relay_response(): ->>>>>>>>> T_code=100, new_code=200
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: tm [t_reply.c:1812]: relay_reply(): DEBUG: relay_reply: branch=0, save=0, relay=0 icode=0
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: <core> [msg_translator.c:470]: clen_builder(): clen_builder: content-length: 302 (302)
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: <core> [msg_translator.c:2278]: generate_res_buf_from_sip_res(): old size: 804, new size: 844
Feb 20 11:51:49 KAMAILIO kamailio[19883]: DEBUG: <core> [msg_translator.c:2296]: generate_res_buf_from_sip_res(): copied size: orig:804, new: 844, rest: 0 msg=#012SIP/2.0 200 OK#015#012Via: SIP/2.0/UDP 172.30.8.66:5060;branch=z9hG4bK+68a818f192518f00b46eeddb5c81dd791+3a836f1f+1#015#012Call-ID: CE965967 at 3a836f1f#015#012From: "Fede SM Test"<sip:1135349910 at 172.30.8.66:5060;user=phone>;tag=3a836f1f+1+1e090003+66eb0deb#015#012To: <sip:100 at 172.30.24.20:5060;user=phone>;tag=21E58627-54E74A050009BACD-41C8D700#015#012CSeq: 525107355 INVITE#015#012Server: Sip Express Media Server (1.5.1 (x86_64/linux))#015#012Contact: <sip:100 at 172.30.24.20:5080>#015#012Content-Length: 302#015#012Content-Type: multipart/mixed;boundary="unique-boundary-1"#015#012Mime-Version: 1.0#015#012#015#012--unique-boundary-1#015#012Content-Type: application/sdp#015#012#015#012v=0#015#012o=sems 1379293612 709544991 IN IP4 172.30.24.20#015#012s=sems#015#012c=IN IP4 172.30.24.20#015#012t=0 0#015#012m=audio 10056 RTP/AVP 8 101#015#012a=rtpmap:8 PCMA/8000#015#012a=rtpmap:101 telephone-event/8000#015#012a=fmtp:101 0-15#015#012a=sendrecv#015#012a=direction:both#015#012#015#012--unique-boundary-1#015#012
Could it be that those missing "--" after the unique-boundary-1 delimiter are the ones giving trouble? Or could it be those extra quotes on the Content-Type boundary?
Any help would be appreciated, thanks!!
Federico
Federico San Martín
e-mail : fsanmartin at telecentro.net.ar
More information about the sr-users
mailing list