Skip to content

Commit

Permalink
sipjson: new module to serialize sip message attributes into a json doc
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Aug 28, 2018
1 parent d014e2c commit 120aad0
Show file tree
Hide file tree
Showing 6 changed files with 621 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/modules/sipjson/Makefile
@@ -0,0 +1,15 @@
#
#
# WARNING: do not run this directly, it should be run by the master Makefile

include ../../Makefile.defs
auto_gen=
NAME=sipjson.so
DEFS +=
LIBS +=

DEFS+=-DKAMAILIO_MOD_INTERFACE
SERLIBPATH=../../lib
SER_LIBS+=$(SERLIBPATH)/srutils/srutils

include ../../Makefile.modules
97 changes: 97 additions & 0 deletions src/modules/sipjson/README
@@ -0,0 +1,97 @@
SIPJSON Module

Daniel-Constantin Mierla

<miconda@gmail.com>

Edited by

Daniel-Constantin Mierla

<miconda@gmail.com>

Copyright � 2018 asipto.com
__________________________________________________________________

Table of Contents

1. Admin Guide

1. Overview
2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

3. Functions

3.1. sj_serialize(opt, ovar)

List of Examples

1.1. sj_serialize usage

Chapter 1. Admin Guide

Table of Contents

1. Overview
2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

3. Functions

3.1. sj_serialize(opt, ovar)

1. Overview

This module serializes SIP message attributes into a JSON document.

It can facilitate getting the SIP attributes in a structure inside one
of the embedded interpreters (e.g., KEMI interpreters).

2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

2.1. Kamailio Modules

The following modules must be loaded before this module:
* none.

2.2. External Libraries or Applications

The following libraries or applications must be installed before
running Kamailio with this module loaded:
* none

3. Functions

3.1. sj_serialize(opt, ovar)

3.1. sj_serialize(opt, ovar)

Do the serialization of SIP messagge attributes into a JSON document.

When there is a match, it uses the corresponding pseudo-variable name
for JSON attribute (e.g., 'ru' is the R-URI attribute name).

Meaning of the parameters:
* opt - list of optional groups of attributes to be serialized. Each
group of attributes has a corresponding character. These are:
+ 0 - (zero) default attributes to be serialized. They are added
even if '0' is not provided as parameter, however, because
'opt' parameter cannot be empty, '0' can be given when only
default attributes are wanted.
+ B - (uppercase B) SIP message body
* ovar - name of the output pseduo-variable

This function can be used from ANY_ROUTE.

Example 1.1. sj_serialize usage
...
sj_serialize("0B", "$var(json)");
...
4 changes: 4 additions & 0 deletions src/modules/sipjson/doc/Makefile
@@ -0,0 +1,4 @@
docs = sipjson.xml

docbook_dir = ../../../../doc/docbook
include $(docbook_dir)/Makefile.module
36 changes: 36 additions & 0 deletions src/modules/sipjson/doc/sipjson.xml
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
%docentities;

]>

<book xmlns:xi="http://www.w3.org/2001/XInclude">
<bookinfo>
<title>SIPJSON Module</title>
<productname class="trade">kamailio.org</productname>
<authorgroup>
<author>
<firstname>Daniel-Constantin</firstname>
<surname>Mierla</surname>
<email>miconda@gmail.com</email>
</author>
<editor>
<firstname>Daniel-Constantin</firstname>
<surname>Mierla</surname>
<email>miconda@gmail.com</email>
</editor>
</authorgroup>
<copyright>
<year>2018</year>
<holder>asipto.com</holder>
</copyright>
</bookinfo>
<toc></toc>

<xi:include href="sipjson_admin.xml"/>

</book>
120 changes: 120 additions & 0 deletions src/modules/sipjson/doc/sipjson_admin.xml
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
%docentities;

]>
<!-- Module User's Guide -->

<chapter>

<title>&adminguide;</title>

<section>
<title>Overview</title>
<para>
This module serializes SIP message attributes into a JSON document.
</para>
<para>
It can facilitate getting the SIP attributes in a structure inside one
of the embedded interpreters (e.g., KEMI interpreters).
</para>
</section>

<section>
<title>Dependencies</title>
<section>
<title>&kamailio; Modules</title>
<para>
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>none</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External Libraries or Applications</title>
<para>
The following libraries or applications must be installed before running
&kamailio; with this module loaded:
<itemizedlist>
<listitem>
<para>
<emphasis>none</emphasis>
</para>
</listitem>
</itemizedlist>
</para>
</section>
</section>

<section>
<title>Functions</title>
<section id="sipjson.f.sj_serialize">
<title>
<function moreinfo="none">sj_serialize(opt, ovar)</function>
</title>
<para>
Do the serialization of SIP messagge attributes into a JSON document.
</para>
<para>
When there is a match, it uses the corresponding pseudo-variable name
for JSON attribute (e.g., 'ru' is the R-URI attribute name).
</para>
<para>
Meaning of the parameters:
</para>
<itemizedlist>
<listitem>
<para>
opt - list of optional groups of attributes to be serialized.
Each group of attributes has a corresponding character. These
are:
</para>
<itemizedlist>
<listitem>
<para>
0 - (zero) default attributes to be serialized. They are
added even if '0' is not provided as parameter, however,
because 'opt' parameter cannot be empty, '0' can be given
when only default attributes are wanted.
</para>
</listitem>
<listitem>
<para>
B - (uppercase B) SIP message body
</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>
ovar - name of the output pseduo-variable
</para>
</listitem>
</itemizedlist>

<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>sj_serialize</function> usage</title>
<programlisting format="linespecific">
...
sj_serialize("0B", "$var(json)");
...
</programlisting>
</example>
</section>

</section>

</chapter>

0 comments on commit 120aad0

Please sign in to comment.