[SR-Users] How to do replace_body_all with Kemi python version kamailio 5.0.x

Muhammad Zaka muhammad.zaka at cloudcall.com
Fri Oct 6 18:41:30 CEST 2017


Hi Daniel,
Unfortunately, it didn't help as the "self" pointer is null in the following code at python_msgobj.c:175
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
              Py_INCREF(Py_None);
                              return Py_None;
}

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/sbin/kamailio -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f688ae37009 in msg_call_function (self=0x0, args=0x7f68786b7aa0) at python_msgobj.c:175
175     python_msgobj.c: No such file or directory.
(gdb) bt
#0  0x00007f688ae37009 in msg_call_function (self=0x0, args=0x7f68786b7aa0) at python_msgobj.c:175
#1  0x00007f688a9f0e6c in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#2  0x00007f688aa64190 in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#3  0x00007f688a9b332c in ?? () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#4  0x00007f688a9bbbe3 in PyObject_Call () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#5  0x00007f688a9fe0e5 in ?? () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#6  0x00007f688a9bbbe3 in PyObject_Call () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#7  0x00007f688aa636e7 in PyEval_CallObjectWithKeywords () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#8  0x00007f688ae32eac in apy_exec (_msg=0x7f688f3d15c8, fname=0x7f688ae37dc0 "ksr_request_route", fparam=0x0, emode=1) at python_exec.c:143
#9  0x00007f688ae136f6 in sr_kemi_config_engine_python (msg=0x7f688f3d15c8, rtype=1, rname=0x0, rparam=0x0) at apy_kemi.c:53
#10 0x0000000000579b6c in receive_msg (
    buf=0xa395c0 <buf> "INVITE sip:+441992878768 at 185.28.212.141:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 185.28.212.125:5060;branch=z9hG4bK-15930-1-0\r\nFrom: anonymous <sip:anonymous at 185.28.212.141>;tag=15930Tag001\r\nTo: <sip:+441992878"..., len=858, rcv_info=0x7fff0791c6e0) at core/receive.c:260
#11 0x00000000004a86f9 in udp_rcv_loop () at core/udp_server.c:515
#12 0x0000000000422d08 in main_loop () at main.c:1623
#13 0x000000000042a408 in main (argc=13, argv=0x7fff0791cb88) at main.c:2643

Do we have any timelines when Kamailio 5.1 will be available?

Thanks

Regards

Muhammad Zaka



From: Daniel-Constantin Mierla [mailto:miconda at gmail.com]
Sent: 27 September 2017 10:06
To: Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>>; Muhammad Zaka <muhammad.zaka at cloudcall.com<mailto:muhammad.zaka at cloudcall.com>>
Subject: Re: [SR-Users] How to do replace_body_all with Kemi python version kamailio 5.0.x


Hello,

the version 5.0 doesn't have too many exports to kemi. In master branch there is already subst_body():

  - https://github.com/kamailio/kamailio/blob/master/src/modules/textops/textops.c#L3541

I will add more as I get time before 5.1 release.
Anyhow, even in 5.0 is a generic kemi function that allows executing any kamailio.cfg function, respectively:

KSR.x.modf(func, param1, ...)

In your case, try:

KSR.x.modf("replace_body_all", "a=sendonly", "a=sendrecv")

You should be careful with KSR.x.modf(...), because is some cases it may result in pkg leak due to cfg param fixup. So, do some tests and be sure that pkg memory stats are not indicating a leak.

Cheers,
Daniel
On 26.09.17 10:48, Muhammad Zaka wrote:
Hi

We are experiencing issue with python script KSR. textops.replace_body_all using branch 5.0.2: -

Example Code:
KSR.textops.replace_body_all("a=sendonly", "a=sendrecv")

It looks like that the module textops and textopsx are not available. Using $rb or $msg(body) pseudo variables isn't working as they are readonly.

Is there any other way to replace the body?

Many Thanks

Regards

Muhammad Zaka





_______________________________________________

Kamailio (SER) - Users Mailing List

sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>

https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


--

Daniel-Constantin Mierla

www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda>

Kamailio Advanced Training - www.asipto.com<http://www.asipto.com>

Kamailio World Conference - www.kamailioworld.com<http://www.kamailioworld.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20171006/07139beb/attachment.html>


More information about the sr-users mailing list