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)
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?
Post by Eugene ProkopievTried to use get_body_part and isup_to_json first, but looks like I
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");
}
fixup_get_body_part(): failed to fixup result pvar
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?
Post by Daniel-Constantin MierlaAs 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
*
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
-
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
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?
Post by Daniel-Constantin MierlaHello,
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
Post by Eugene ProkopievHi,
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
--
WBR,
Eugene Prokopiev
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-***@lists.kamailio.org
https://lists.kamai