Debian Codegraph @

src/modules/sipjson/README

raw
1 SIPJSON Module
2
3 Daniel-Constantin Mierla
4
5 <[email protected]>
6
7 Edited by
8
9 Daniel-Constantin Mierla
10
11 <[email protected]>
12
13 Copyright © 2018 asipto.com
14 __________________________________________________________________
15
16 Table of Contents
17
18 1. Admin Guide
19
20 1. Overview
21 2. Dependencies
22
23 2.1. Kamailio Modules
24 2.2. External Libraries or Applications
25
26 3. Functions
27
28 3.1. sj_serialize(opt, ovar)
29
30 4. Output Samples
31
32 List of Examples
33
34 1.1. sj_serialize usage
35 1.2. sj_serialize output
36
37 Chapter 1. Admin Guide
38
39 Table of Contents
40
41 1. Overview
42 2. Dependencies
43
44 2.1. Kamailio Modules
45 2.2. External Libraries or Applications
46
47 3. Functions
48
49 3.1. sj_serialize(opt, ovar)
50
51 4. Output Samples
52
53 1. Overview
54
55 This module serializes SIP message attributes into a JSON document.
56
57 It can facilitate getting the SIP attributes in a structure inside one
58 of the embedded interpreters (e.g., KEMI interpreters, Lua can parse
59 JSON in an internal hash table).
60
61 2. Dependencies
62
63 2.1. Kamailio Modules
64 2.2. External Libraries or Applications
65
66 2.1. Kamailio Modules
67
68 The following modules must be loaded before this module:
69 * none.
70
71 2.2. External Libraries or Applications
72
73 The following libraries or applications must be installed before
74 running Kamailio with this module loaded:
75 * none
76
77 3. Functions
78
79 3.1. sj_serialize(opt, ovar)
80
81 3.1. sj_serialize(opt, ovar)
82
83 Do the serialization of SIP message attributes into a JSON document.
84
85 When there is a match, it uses the corresponding pseudo-variable name
86 for JSON attribute (e.g., 'ru' is the R-URI attribute name).
87
88 Meaning of the parameters:
89 * opt - list of optional groups of attributes to be serialized. Each
90 group of attributes has a corresponding character. These are:
91 + 0 - (zero) default attributes to be serialized. They are added
92 even if '0' is not provided as parameter, however, because
93 'opt' parameter cannot be empty, '0' can be given when only
94 default attributes are wanted.
95 + B - (uppercase B) SIP message body
96 + c - (lowercase c) CSeq attributes
97 + t - (lowercase t) To header attributes
98 * ovar - name of the output pseduo-variable
99
100 This function can be used from ANY_ROUTE.
101
102 Example 1.1. sj_serialize usage
103 ...
104 sj_serialize("0B", "$var(json)");
105 ...
106
107 4. Output Samples
108
109 The content of the output variable is a JSON. Next are some samples.
110 Note that the content might change with future development and this
111 example become outdated, simply print the document when you start
112 testing your config and match the name of the attribute with the name
113 of pseudo-variables to understand what values can be there. Unlike
114 pseudo-variables, the $null values might converted to empty strings.
115
116 Example 1.2. sj_serialize output
117 ...
118 # the content of $var(json) after sj_serialize("0B", "$var(json)")
119 # - the content is compacted, next it has been pretty-formatted for better view
120 ing
121 ...
122 {
123 "mt":2,
124 "rm":"OPTIONS",
125 "pr":"udp",
126 "si":"127.0.0.1",
127 "sp":36747,
128 "Ri":"127.0.0.1",
129 "Rp":5060,
130 "ru":"sip:[email protected]",
131 "rU":"alice",
132 "rd":"127.0.0.1",
133 "rp":0,
134 "fU":"sipsak",
135 "fd":"172.17.0.2",
136 "ua":"sipsak 0.9.7pre",
137 "ci":"[email protected]",
138 "rb":""
139 ...
140 }
141 ...
142 # the sip message sent to Kamailio:
143 ...
144 OPTIONS sip:[email protected] SIP/2.0
145 Via: SIP/2.0/UDP 127.0.0.1:65502;branch=z9hG4bK.79e78613;rport;alias
146 From: sip:[email protected];tag=74806173
147 To: sip:[email protected]
148 Call-ID: [email protected]
149 CSeq: 1 OPTIONS
150 Contact: sip:[email protected]:65502
151 Content-Length: 0
152 Max-Forwards: 70
153 User-Agent: sipsak 0.9.7pre
154 Accept: text/plain
155
156 ...