[OpenSIPS-Users] Feature request - RFC 3994 and RFC 5438 support for instant messaging
Bogdan-Andrei Iancu
bogdan at opensips.org
Thu May 14 14:13:11 UTC 2026
OK, I see, from SIP msg is a single body part, the `message/cpim`, which
has a more complex structure - and the XML is just a bit of that cpim
https://datatracker.ietf.org/doc/html/rfc3862
I'm afaid right now there is no way to do the CPIM paring is OpenSIPS,
in order to extract the XML. - maybe you can find the third element if
you split by a double "\r\n" ? using a s.select transformation...
Regards
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
https://www.opensips-solutions.com
https://www.siphub.com
On 5/13/26 17:33, Robert Dyck wrote:
> See attached files.
>
> On Wednesday, May 13, 2026 1:29:26 a.m. Pacific Daylight Time you wrote:
>> Could you send me the SIP message as pcap?
>>
>> Regards,
>>
>> Bogdan-Andrei Iancu
>>
>> OpenSIPS Founder and Developer
>> https://www.opensips-solutions.com
>> https://www.siphub.com
>>
>> On 5/12/26 17:52, Robert Dyck wrote:
>>> Experimenting - Try to expose for example state.
>>>
>>>
>>> $xml(bla) = $rb(application/im-iscomposing+xml);
>>> xlog("$xml(bla/isComposing/state)\n");
>>>
>>>
>>> *NOTICE:If content-type is message/cpim don't store it*
>>>
>>> DBG:core:parse_headers_aux: flags=ffffffffffffffff
>>>
>>> DBG:core:decode_mime_type: Decoding MIME type
>>> for:[message/cpim]DBG:core:pv_get_msg_body: --------mime is <196863>,
>>> idx=0DBG:core:pv_get_msg_body: Index too big [0],
>>> body_part=(nil)*ERROR:xml:pv_set_xml: Uninitialized xml object:
>>> bla**ERROR:core:do_assign: setting PV failed**ERROR:core:do_assign:
>>> error at /usr/local/etc/opensips/opensips.cfg:670*
>>>
>>> DBG:xml:pv_get_xml: Unknown object <bla>
>>> *NOTICE:<null>*
>>>
>>> The second content-type is invisible to opensips.
>>>
>>>
>>> I don't think opensips knows about mime message/cpim.
>>>
>>> Some functions, for instance handle_publish assume that the start of
>>> the body is also the start of xml. With message/cpim that is not the case.
>>>
>>>
>>> Here is the part of MESSAGE that is of interest.
>>>
>>>
>>> Content-Encoding: deflate
>>>
>>> Content-Type: message/cpim
>>>
>>> Content-Length: 249
>>>
>>> Priority: non-urgent
>>>
>>> Expires: 0
>>>
>>> User-Agent: Linphone-Desktop/6.2.0-beta.19+1d6910749 (silver.mylan)
>>> fedora/44 Qt/6.9.1 LinphoneSDK/5.5.0-beta-84-g7a481f7e71
>>>
>>> Message Body
>>>
>>> From: <sip:8 at 192.168.1.2>\r\n
>>>
>>> To: <sip:9 at 192.168.1.2>\r\n
>>>
>>> DateTime: 2026-05-04T16:46:24Z\r\n
>>>
>>> \r\n
>>>
>>> Content-Type: application/im-iscomposing+xml\r\n
>>>
>>> Content-Length: 207\r\n
>>>
>>> \r\n
>>>
>>> <?xml version="1.0" encoding="UTF-8" standalone="no" ?><isComposing
>>> xmlns="urn:ietf:params:xml:ns:im-iscomposing"><state>active</state><conten
>>> ttype>text/plain</contenttype><refresh>60</refresh></isComposing>
>>>
>>>
>>> message/cpim enforces this format for the body.
>>>
>>> On Tuesday, May 12, 2026 2:49:49 a.m. Pacific Daylight Time you wrote:
>>>> IF you have a multi-part body, shouldn't this do the trick:
>>>>
>>>>
>>>>
>>>> $xml(bla) = $rb(application/im-iscomposing+xml);
>>>>
>>>>
>>>>
>>>> [1] https://opensips.org/Documentation/Script-CoreVar-3-6#rb
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Regards,
>>>>
>>>>
>>>>
>>>> Bogdan-Andrei Iancu
>>>>
>>>>
>>>>
>>>> OpenSIPS Founder and Developer
>>>>
>>>> https://www.opensips-solutions.com
>>>>
>>>> https://www.siphub.com
>>>>
>>>> On 5/11/26 18:40, Robert Dyck wrote:
>>>>> I don't think that $xml() can be made to work. The first parameter for
>>>>>
>>>>> $xml() is the name of an xml object. This would work for the xml we
>>>>>
>>>>> create ourself with xml module. How would we extract an xml and
>>> name it.
>>>
>>>>> I thought about using the content type as a filter. This was
>>> problematic
>>>
>>>>> because MESSAGE ( RFC 3248 page mode ) allows SIP headers in the
>>> body. We
>>>
>>>>> receive two Content-Type headers. I tried using $cT[index] but the
>>> second
>>>
>>>>> Content-Type is never found. Using any index always just returns
>>> the first
>>>
>>>>> instance.
>>>>>
>>>>>
>>>>>
>>>>> I tried using sipmsgops has_body_part( mime ). This doesn't work
>>> for the
>>>
>>>>> same reason filtering the content type didn't work. This function uses
>>>>>
>>>>> the content type as the first step in its filter. It will never find
>>>>>
>>>>> "Content-Type: application/im-iscomposing+xml".
>>>>>
>>>>>
>>>>>
>>>>> I can keep the xml from being stored in the silo by filtering on
>>>>>
>>>>> "Content-Type message/cpim" but I am not happy with it. It is not
>>>>>
>>>>> specific enough and may cause issues.
>>>>>
>>>>> On Thursday, May 7, 2026 1:36:49 a.m. Pacific Daylight Time you wrote:
>>>>>> if you have $xml(bla) = "....some xml....";
>>>>>>
>>>>>>
>>>>>>
>>>>>> Try like $xml(bla/isComposing.attr/xmlns)
>>>>>>
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>>
>>>>>>
>>>>>> Bogdan-Andrei Iancu
>>>>>>
>>>>>>
>>>>>>
>>>>>> OpenSIPS Founder and Developer
>>>>>>
>>>>>>
>>>>>>
>>>>>> https://www.opensips-solutions.com
>>>>>>
>>>>>> https://www.siphub.com
>>>>>>
>>>>>> On 5/6/26 22:19, Robert Dyck wrote:
>>>>>>> I am trying to understand $xml() and added some logging to the
>>> script.
>>>
>>>>>>> I know the contents of the xml doc.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> <isComposing xmlns="urn:ietf:params:xml:ns:im-iscomposing">
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> <state>active</state>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> <contenttype>text/plain</contenttype>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> <refresh>60</refresh>
>>>>>>>
>>>>>>> </isComposing>'
>>>>>>>
>>>>>>> Using statements such as "xlog("xlm is $xml(?xml/isComposing)\n");"
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I get DBG:xml:pv_get_xml: Unknown object <?xml>
>>>>>>>
>>>>>>> The same if I ignore the version element and try "isComposing".
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> It says Unknown object <isComposing>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Printing the entire $xml doesn't work.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> BG:core:parse_headers_aux: flags=ffffffffffffffff
>>>>>>>
>>>>>>> [266B blob data]
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wednesday, May 6, 2026 1:08:11 a.m. Pacific Daylight Time you
>>> wrote:
>>>>>>>> According to the grammar [1], you have access to the attributes:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> access = .val | .attr/string | .attr/$var
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> An example:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> $xml(my_doc/doc/list.attr/sort) = "asc"; # add
>>>>>>> attribute "sort"
>>>>>>>
>>>>>>>> to list node
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> [1] https://opensips.org/docs/modules/3.6.x/xml.html#pv_xml
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Bogdan-Andrei Iancu
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> OpenSIPS Founder and Developer
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> https://www.opensips-solutions.com
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> https://www.siphub.com
>>>>>>>>
>>>>>>>> On 5/4/26 17:31, Robert Dyck wrote:
>>>>>>>>> Yes.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Or perhaps just detect the the presence of xlm. It should not go
>>>>>>> into the
>>>>>>>
>>>>>>>>> silo.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Monday, May 4, 2026 6:48:50 a.m. Pacific Daylight Time you
>>> wrote:
>>>>>>>>>> You mean the xmlns attribute of the isComposing node ?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Regards,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Bogdan-Andrei Iancu
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> OpenSIPS Founder and Developer
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> https://www.opensips-solutions.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> https://www.siphub.com
>>>>>>>>>>
>>>>>>>>>> On 4/27/26 19:21, Robert Dyck wrote:
>>>>>>>>>>> I have looked at the module and it is not clear to me how
>>> one would
>>>
>>>>>>>>>>> extract the name space from the xml.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> <isComposing xmlns="urn:ietf:params:xml:ns:im-iscomposing">
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> <state>active</state>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> <contenttype>text/plain</contenttype>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> <refresh>60</refresh>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> </isComposing>'
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>>
>>>>>>>>>>>>> Users mailing list
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Users at lists.opensips.org
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>>>>>>>>> On Monday, April 27, 2026 7:31:14 a.m. Pacific Daylight Time you
>>>>>>> wrote:
>>>>>>>>>>>> Robert,
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Check thishttps://opensips.org/docs/modules/3.6.x/xml.html
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Regards,
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Bogdan-Andrei Iancu
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> OpenSIPS Founder and Developer
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> https://www.opensips-solutions.com
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> https://www.siphub.com
More information about the Users
mailing list