Discussion:
[SR-Users] How to extract SIP-I ISUP parameters
Eugene Prokopiev
2018-03-28 15:26:06 UTC
Permalink
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.
--
WBR,
Eugene Prokopiev

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-***@lists.kamailio.org
https:
Daniel-Constantin Mierla
2018-03-29 08:30:06 UTC
Permalink
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
Post by Eugene Prokopiev
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


_______________________________________________
Kamailio (SER) - Users Mailing List
sr-***@lists.kamailio.org
https://lists.k
Daniel-Constantin Mierla
2018-03-29 15:21:53 UTC
Permalink
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
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 Mierla
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
Post by Eugene Prokopiev
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


_______________________________________________
Kamailio (SER) - Users Mailing List
sr-***@lists.kamailio.org
https://lists.kamailio.org/cgi-bin
Eugene Prokopiev
2018-03-29 18:53:03 UTC
Permalink
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?
Post by Daniel-Constantin Mierla
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
*
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 Mierla
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
Post by Eugene Prokopiev
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

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-***@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinf
Eugene Prokopiev
2018-03-30 11:49:02 UTC
Permalink
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 Prokopiev
Tried 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 Mierla
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
*
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 Mierla
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
Post by Eugene Prokopiev
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
--
WBR,
Eugene Prokopiev

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-***@lists.kamailio.org
https://lists.kamai
Daniel-Constantin Mierla
2018-04-02 06:53:47 UTC
Permalink
Post by Eugene Prokopiev
$ 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
Post by Eugene Prokopiev
KSR.info("ISUP body content : "..opv.."\n")
KSR.sl.send_reply(503, "Server not configured")
end
...
io_wait_loop_epoll(): epoll_wait(16, 0x7f82df873580, 0, 5000): Invalid
argument [22]
io_wait_loop_epoll(): epoll_wait(16, 0x7f82df873580, 0, 5000): Invalid
argument [22]
io_wait_loop_epoll(): epoll_wait(16, 0x7f82df873580, 0, 5000): Invalid
argument [22]
...
sr_kemi_core_info(): Lua route
invalid parameters
ki_get_body_part(): failed to get pv spec
What is wrong in my code?
Post by Eugene Prokopiev
Tried 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 Mierla
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
*
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 Mierla
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
Post by Eugene Prokopiev
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-***@lists.kamailio.org
https://lists.kamailio.org/c
Daniel-Constantin Mierla
2018-04-02 06:51:50 UTC
Permalink
I said that this needs C code development to combine parts of
get_body_part and isup_to_json.

You are trying to do it in config.

Cheers,
Daniel
Post by Eugene Prokopiev
Tried 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 Mierla
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
*
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 Mierla
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
Post by Eugene Prokopiev
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
--
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-***@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listi
Loading...