Debian Codegraph @

src/modules/lwsc/README

raw
1 LWSC 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 © 2021 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. Parameters
27
28 3.1. protocol (str)
29 3.2. timeout_init (int)
30 3.3. timeout_read (int)
31 3.4. verbosity (int)
32
33 4. Functions
34
35 4.1. lwsc_notify(wsurl, data)
36 4.2. lwsc_notify_proto(wsurl, wsproto, data)
37 4.3. lwsc_request(wsurl, data)
38 4.4. lwsc_request_proto(wsurl, wsproto, data)
39
40 5. Variables
41
42 5.1. $lwsc(key)
43
44 List of Examples
45
46 1.1. Set protocol parameter
47 1.2. Set timeout_init parameter
48 1.3. Set timeout_read parameter
49 1.4. Set verbosity parameter
50 1.5. lwsc_notify usage
51 1.6. lwsc_notify_proto usage
52 1.7. lwsc_request usage
53 1.8. lwsc_request_proto usage
54 1.9. $lwsc(name) usage
55
56 Chapter 1. Admin Guide
57
58 Table of Contents
59
60 1. Overview
61 2. Dependencies
62
63 2.1. Kamailio Modules
64 2.2. External Libraries or Applications
65
66 3. Parameters
67
68 3.1. protocol (str)
69 3.2. timeout_init (int)
70 3.3. timeout_read (int)
71 3.4. verbosity (int)
72
73 4. Functions
74
75 4.1. lwsc_notify(wsurl, data)
76 4.2. lwsc_notify_proto(wsurl, wsproto, data)
77 4.3. lwsc_request(wsurl, data)
78 4.4. lwsc_request_proto(wsurl, wsproto, data)
79
80 5. Variables
81
82 5.1. $lwsc(key)
83
84 1. Overview
85
86 This module provides a websocket client implementation to interact with
87 external systems, similar to http client. It is not for routing SIP
88 traffic.
89
90 It relies on libwebsockets library (https://libwebsockets.org/).
91
92 2. Dependencies
93
94 2.1. Kamailio Modules
95 2.2. External Libraries or Applications
96
97 2.1. Kamailio Modules
98
99 The following modules must be loaded before this module:
100 * none.
101
102 2.2. External Libraries or Applications
103
104 The following libraries or applications must be installed before
105 running Kamailio with this module loaded:
106 * libwebsockets - probably v2.0 or newer.
107
108 3. Parameters
109
110 3.1. protocol (str)
111 3.2. timeout_init (int)
112 3.3. timeout_read (int)
113 3.4. verbosity (int)
114
115 3.1. protocol (str)
116
117 The websocket sub-protocol.
118
119 Default value is "kmsg".
120
121 Example 1.1. Set protocol parameter
122 ...
123 modparam("lwsc", "protocol", "ksr")
124 ...
125
126 3.2. timeout_init (int)
127
128 The interval in microseconds to wait for websocket connection to be
129 initialized.
130
131 Default value is 2000000 (2 seconds).
132
133 Example 1.2. Set timeout_init parameter
134 ...
135 modparam("lwsc", "timeout_init", 4000000)
136 ...
137
138 3.3. timeout_read (int)
139
140 The interval in microseconds to wait for the response of the
141 lwsc_request() group of functions.
142
143 Default value is 2000000 (2 seconds).
144
145 Example 1.3. Set timeout_read parameter
146 ...
147 modparam("lwsc", "timeout_init", 1000000)
148 ...
149
150 3.4. verbosity (int)
151
152 Control the verbosity of debug messages on libwebsockets events, higher
153 value means more debug messages. It has to be a positive number,
154 currently 2 or higher results in maximum verbosity.
155
156 Default value is 0.
157
158 Example 1.4. Set verbosity parameter
159 ...
160 modparam("lwsc", "verbosity", 1)
161 ...
162
163 4. Functions
164
165 4.1. lwsc_notify(wsurl, data)
166 4.2. lwsc_notify_proto(wsurl, wsproto, data)
167 4.3. lwsc_request(wsurl, data)
168 4.4. lwsc_request_proto(wsurl, wsproto, data)
169
170 4.1. lwsc_notify(wsurl, data)
171
172 Send data via websockets to the address specified by wsurl. No response
173 is expected. Transmission is not guaranteed (e.g., cannot connect to
174 target).
175
176 The parameters are:
177 * wsurl - websocket url
178 * data - what to send
179
180 The parameters can contain pseudo-variables.
181
182 This function can be used from ANY_ROUTE.
183
184 Example 1.5. lwsc_notify usage
185 ...
186 jwt_notify("ws://10.1.1.10:8080/log",
187 "caller=$fU;callee=$tU;callid=$ci");
188 ...
189
190 4.2. lwsc_notify_proto(wsurl, wsproto, data)
191
192 Send data via websockets to the address specified by wsurl, providing
193 websocket protocol. No response is expected. Transmission is not
194 guaranteed (e.g., cannot connect to target).
195
196 The parameters are:
197 * wsurl - websocket url
198 * wsproto - websocket protocol
199 * data - what to send
200
201 The parameters can contain pseudo-variables.
202
203 This function can be used from ANY_ROUTE.
204
205 Example 1.6. lwsc_notify_proto usage
206 ...
207 jwt_notify_proto("ws://10.1.1.10:8080/log", "kmsg"
208 "caller=$fU;callee=$tU;callid=$ci");
209 ...
210
211 4.3. lwsc_request(wsurl, data)
212
213 Send data via websockets to the address specified by wsurl, a response
214 is expected and made available in $lwsc(rdata).
215
216 The parameters are:
217 * wsurl - websocket url
218 * data - what to send
219
220 The parameters can contain pseudo-variables.
221
222 This function can be used from ANY_ROUTE.
223
224 Example 1.7. lwsc_request usage
225 ...
226 jwt_request("ws://10.1.1.10:8080/log",
227 "caller=$fU;callee=$tU;srcip=$si");
228 ...
229
230 4.4. lwsc_request_proto(wsurl, wsproto, data)
231
232 Send data via websockets to the address specified by wsurl, providing
233 websocket protocol. A response is expected and made available in
234 $lwsc(rdata).
235
236 The parameters are:
237 * wsurl - websocket url
238 * wsproto - websocket protocol
239 * data - what to send
240
241 The parameters can contain pseudo-variables.
242
243 This function can be used from ANY_ROUTE.
244
245 Example 1.8. lwsc_request_proto usage
246 ...
247 jwt_request_proto("ws://10.1.1.10:8080/log", "kmsg",
248 "caller=$fU;callee=$tU;srcip=$si");
249 ...
250
251 5. Variables
252
253 5.1. $lwsc(key)
254
255 5.1. $lwsc(key)
256
257 Get the values and attributes after using LWSC functions.
258
259 The key can be:
260 * rdata - the response retrieved after lwsc_request().
261 * status - the status of verification after a failed jwt_verify().
262
263 Example 1.9. $lwsc(name) usage
264 ...
265 jwt_request("ws://10.1.1.10:8080/log",
266 "caller=$fU;callee=$tU;srcip=$si");
267 xinfo("jwt is: $lwsc(rdata)");
268 ...