On 30.03.18 13:49, Eugene Prokopiev wrote: > Tried to do the same and even less with KEMI/Lua: > > $ cat kamailio/config/kamailio.lua > > function ksr_request_route() > KSR.info("Lua route\n") > if (KSR.textops.has_body("application/isup")) { > KSR.info("ISUP body exists\n") > } > local opv = "" > KSR.textops.get_body_part("application/isup", opv) The second parameter above must be a string with the name of a kamailio variable, not a Lua variable, like "$var(x)".
Cheers, Daniel > KSR.info("ISUP body content : "..opv.."\n") > KSR.sl.send_reply(503, "Server not configured") > end > > I see only endless loop as result: > > ... > kamailio_1 | 12(18) ERROR: <core> [core/io_wait.h:1040]: > io_wait_loop_epoll(): epoll_wait(16, 0x7f82df873580, 0, 5000): Invalid > argument [22] > kamailio_1 | 12(18) ERROR: <core> [core/io_wait.h:1040]: > io_wait_loop_epoll(): epoll_wait(16, 0x7f82df873580, 0, 5000): Invalid > argument [22] > kamailio_1 | 12(18) ERROR: <core> [core/io_wait.h:1040]: > io_wait_loop_epoll(): epoll_wait(16, 0x7f82df873580, 0, 5000): Invalid > argument [22] > ... > > Result is not good without 'if (KSR.textops.has_body(...' too: > > kamailio_1 | 1(7) INFO: <core> [core/kemi.c:91]: > sr_kemi_core_info(): Lua route > kamailio_1 | 1(7) ERROR: <core> [core/pvapi.c:416]: pv_cache_get(): > invalid parameters > kamailio_1 | 1(7) ERROR: textops [textops.c:2560]: > ki_get_body_part(): failed to get pv spec > kamailio_1 | 1(7) INFO: <core> [core/kemi.c:91]: > sr_kemi_core_info(): ISUP body content : > > What is wrong in my code? > > > 2018-03-29 21:53 GMT+03:00 Eugene Prokopiev <e...@itx.ru>: >> Tried to use get_body_part and isup_to_json first, but looks like I >> can't understand syntax. My config: >> >> loadmodule "tm.so" >> loadmodule "sl.so" >> loadmodule "xlog.so" >> loadmodule "textops.so" >> loadmodule "ss7ops.so" >> >> listen=udp:0.0.0.0:5060 >> >> route { >> get_body_part("application/isup", "$var(pbody)"); >> isup_to_json(8); >> xlog("$isup(1)\n"); >> sl_send_reply("503", "Server is not configured"); >> } >> >> Can't even run it due to: >> >> kamailio_1 | 0(1) ERROR: textops [textops.c:2615]: >> fixup_get_body_part(): failed to fixup result pvar >> kamailio_1 | 0(1) ERROR: <core> [core/route.c:1154]: fix_actions(): >> fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:10 >> kamailio_1 | error -1 while trying to fix configuration >> >> Can you show me working example with get_body_part and isup_to_json >> and json dump to stdout? >> >> 2018-03-29 18:21 GMT+03:00 Daniel-Constantin Mierla <mico...@gmail.com>: >>> As I got it, there is an ISUP parser inside ss7ops module. >>> >>> It may require a bit of C coding to build a function for helping with >>> what you need -- the two functions that are useful for doing it are: >>> >>> * >>> https://www.kamailio.org/docs/modules/stable/modules/textops.html#textops.f.get_body_part >>> * >>> https://www.kamailio.org/docs/modules/stable/modules/ss7ops.html#ss7ops.f.isup_to_json >>> >>> The first one shows how to extract the part of the body from the sip >>> message with the ISUP, the second one shows to convert the ISUP data to >>> json. From there you can use jansson module to extract fields. >>> >>> If you are not familiar with C coding, open a feature request on >>> kamailio issue tracker on github.com, maybe someone can get to it soon, >>> otherwise I will look at it when I get a chance. >>> >>> The other option right now is to use some Python or Lua script to do the >>> parsing of ISUP there, maybe there are libraries for it in those >>> languages. You get get the body of the SIP message inside these messages >>> using $rb variable or the textops function via KSR KEMI module: >>> >>> - >>> http://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/kemimods/#ksrpvget >>> - >>> http://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/modules/#ksrtextopsget_body_part >>> >>> Cheers, >>> Daniel >>> >>> On 29.03.18 12:50, Eugene Prokopiev wrote: >>>> I can attach screenshot of ISUP part of pcap. >>>> >>>> Is it possible to extract all ISUP parameters or at least 'Redirecting >>>> number' or 'Called IN number'? Can extract ISUP part as is in binary >>>> form and read by some external script? Are you know about any library >>>> to parse ISUP binary data? >>>> >>>> 2018-03-29 11:30 GMT+03:00 Daniel-Constantin Mierla <mico...@gmail.com>: >>>>> Hello, >>>>> >>>>> can you provide a pcap (or ngrep output) with such invite in order to >>>>> see what can be done with existing modules? Maybe it needs just some >>>>> script operations. >>>>> >>>>> Cheers, >>>>> Daniel >>>>> >>>>> >>>>> On 28.03.18 17:26, Eugene Prokopiev wrote: >>>>>> Hi, >>>>>> >>>>>> I need to extract ISUP parameter 'Redirecting number' from SIP-I >>>>>> INVITE request and add it as SIP header with 'X-' prefix to process in >>>>>> FreeSWITCH. I tried to read >>>>>> https://kamailio.org/docs/modules/5.1.x/modules/sipt.html (but it is >>>>>> about updating headers) and >>>>>> https://kamailio.org/docs/modules/5.1.x/modules/ss7ops.html (but I >>>>>> have only ISUP encapsulated in SIP), so not found any solution. Help >>>>>> me to find it please. >>>>>> >>>>> -- >>>>> Daniel-Constantin Mierla >>>>> www.twitter.com/miconda -- www.linkedin.com/in/miconda >>>>> Kamailio Advanced Training - April 16-18, 2018, Berlin - www.asipto.com >>>>> Kamailio World Conference - May 14-16, 2018 - www.kamailioworld.com >>>>> >>>> >>> -- >>> Daniel-Constantin Mierla >>> www.twitter.com/miconda -- www.linkedin.com/in/miconda >>> Kamailio Advanced Training - April 16-18, 2018, Berlin - www.asipto.com >>> Kamailio World Conference - May 14-16, 2018 - www.kamailioworld.com >>> >> >> >> -- >> WBR, >> Eugene Prokopiev > > -- Daniel-Constantin Mierla www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - April 16-18, 2018, Berlin - www.asipto.com Kamailio World Conference - May 14-16, 2018 - www.kamailioworld.com _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users