Debian Codegraph @

src/modules/posops/README

raw
1 POSOPS Module
2
3 Daniel-Constantin Mierla
4
5 asipto.com
6 <[email protected]>
7
8 Edited by
9
10 Daniel-Constantin Mierla
11
12 <[email protected]>
13
14 Copyright © 2021 http://www.asipto.com
15 __________________________________________________________________
16
17 Table of Contents
18
19 1. Admin Guide
20
21 1. Overview
22 2. Dependencies
23
24 2.1. Kamailio Modules
25 2.2. External Libraries or Applications
26
27 3. Parameters
28
29 3.1. idx0 (int)
30
31 4. Functions
32
33 4.1. pos_append(idx, val)
34 4.2. pos_insert(idx, val)
35 4.3. pos_rm(idx, len)
36 4.4. pos_set_char(idx, val)
37 4.5. pos_headers_start()
38 4.6. pos_headers_end()
39 4.7. pos_body_start()
40 4.8. pos_body_end()
41 4.9. pos_find_str(idx, val)
42 4.10. pos_findi_str(idx, val)
43 4.11. pos_rfind_str(idx, val)
44 4.12. pos_rfindi_str(idx, val)
45 4.13. pos_search(idx, re)
46 4.14. pos_rsearch(idx, re)
47
48 5. Pseudo Variables
49
50 List of Examples
51
52 1.1. Set idx0 parameter
53 1.2. pos_append() usage
54 1.3. pos_insert() usage
55 1.4. pos_rm() usage
56 1.5. pos_set_char() usage
57 1.6. pos_headers_start() usage
58 1.7. pos_headers_end() usage
59 1.8. pos_body_start() usage
60 1.9. pos_body_end() usage
61 1.10. pos_find_str() usage
62 1.11. pos_findi_str() usage
63 1.12. pos_find_str() usage
64 1.13. pos_rfindi_str() usage
65 1.14. pos_search() usage
66 1.15. pos_rsearch() usage
67
68 Chapter 1. Admin Guide
69
70 Table of Contents
71
72 1. Overview
73 2. Dependencies
74
75 2.1. Kamailio Modules
76 2.2. External Libraries or Applications
77
78 3. Parameters
79
80 3.1. idx0 (int)
81
82 4. Functions
83
84 4.1. pos_append(idx, val)
85 4.2. pos_insert(idx, val)
86 4.3. pos_rm(idx, len)
87 4.4. pos_set_char(idx, val)
88 4.5. pos_headers_start()
89 4.6. pos_headers_end()
90 4.7. pos_body_start()
91 4.8. pos_body_end()
92 4.9. pos_find_str(idx, val)
93 4.10. pos_findi_str(idx, val)
94 4.11. pos_rfind_str(idx, val)
95 4.12. pos_rfindi_str(idx, val)
96 4.13. pos_search(idx, re)
97 4.14. pos_rsearch(idx, re)
98
99 5. Pseudo Variables
100
101 1. Overview
102
103 The module exports utility functions to work with position inside the
104 SIP message buffer.
105
106 Among them are function to add or remove content at a specific
107 position.
108
109 2. Dependencies
110
111 2.1. Kamailio Modules
112 2.2. External Libraries or Applications
113
114 2.1. Kamailio Modules
115
116 The following modules must be installed (but not loaded) to use this
117 module:
118 * none.
119
120 2.2. External Libraries or Applications
121
122 The following libraries or applications must be installed before
123 running Kamailio with this module loaded:
124 * none.
125
126 3. Parameters
127
128 3.1. idx0 (int)
129
130 3.1. idx0 (int)
131
132 The value to return by functions seeking a position when the index is 0
133 (note: returning 0 is stopping the execution of configuration file like
134 'exit', but for KEMI usage it is ok).
135
136 Default value is -255.
137
138 Example 1.1. Set idx0 parameter
139 ...
140 modparam("posops", "idx0", -200)
141 ...
142
143 4. Functions
144
145 4.1. pos_append(idx, val)
146 4.2. pos_insert(idx, val)
147 4.3. pos_rm(idx, len)
148 4.4. pos_set_char(idx, val)
149 4.5. pos_headers_start()
150 4.6. pos_headers_end()
151 4.7. pos_body_start()
152 4.8. pos_body_end()
153 4.9. pos_find_str(idx, val)
154 4.10. pos_findi_str(idx, val)
155 4.11. pos_rfind_str(idx, val)
156 4.12. pos_rfindi_str(idx, val)
157 4.13. pos_search(idx, re)
158 4.14. pos_rsearch(idx, re)
159
160 4.1. pos_append(idx, val)
161
162 Append the value val after the position idx in the SIP message buffer.
163
164 The idx can be an integer value or a variable holding an integer. If
165 the value is negative, the position is counted from the end of the
166 buffer.
167
168 The val can be a static string or variables.
169
170 This function can be used from ANY_ROUTE.
171
172 Example 1.2. pos_append() usage
173 ...
174 pos_append("100", "kamailio-$si");
175 ...
176
177 4.2. pos_insert(idx, val)
178
179 Insert the value val at the position idx in the SIP message buffer.
180
181 The idx can be an integer value or a variable holding an integer. If
182 the value is negative, the position is counted from the end of the
183 buffer.
184
185 The val can be a static string or variables.
186
187 This function can be used from ANY_ROUTE.
188
189 Example 1.3. pos_insert() usage
190 ...
191 pos_insert("100", "kamailio-$si");
192 ...
193
194 4.3. pos_rm(idx, len)
195
196 Remove len characters starting at the position idx in the SIP message
197 buffer.
198
199 The idx can be an integer value or a variable holding an integer. If
200 the value is negative, the position is counted from the end of the
201 buffer.
202
203 The idx can be a positive integer value or a variable holding a
204 positive integer.
205
206 This function can be used from ANY_ROUTE.
207
208 Example 1.4. pos_rm() usage
209 ...
210 pos_insert("100", "10");
211 ...
212
213 4.4. pos_set_char(idx, val)
214
215 Set the char at position index to first character in val.
216
217 Important: it changes the character directly in the SIP message buffer,
218 the update being immediately visible.
219
220 The idx can be an integer value or a variable holding an integer. If
221 the value is negative, the position is counted from the end of the
222 buffer.
223
224 The val can be a static string or variables.
225
226 This function can be used from ANY_ROUTE.
227
228 Example 1.5. pos_set_char() usage
229 ...
230 pos_set_char("100", "x");
231 ...
232
233 4.5. pos_headers_start()
234
235 Return the position in the message buffer where headers start.
236
237 This function can be used from ANY_ROUTE.
238
239 Example 1.6. pos_headers_start() usage
240 ...
241 $var(pos) = pos_headers_start();
242 ...
243
244 4.6. pos_headers_end()
245
246 Return the position in the message buffer where headers end.
247
248 This function can be used from ANY_ROUTE.
249
250 Example 1.7. pos_headers_end() usage
251 ...
252 $var(pos) = pos_headers_end();
253 ...
254
255 4.7. pos_body_start()
256
257 Return the position in the message buffer where body starts.
258
259 This function can be used from ANY_ROUTE.
260
261 Example 1.8. pos_body_start() usage
262 ...
263 $var(pos) = pos_body_start();
264 ...
265
266 4.8. pos_body_end()
267
268 Return the position in the message buffer where body ends.
269
270 This function can be used from ANY_ROUTE.
271
272 Example 1.9. pos_body_end() usage
273 ...
274 $var(pos) = pos_body_end();
275 ...
276
277 4.9. pos_find_str(idx, val)
278
279 Return the position of the val in message buffer starting at idx. In
280 case of not finding it or error, the return code is negative. If val is
281 at index 0, it returns the value specified by modparam idx0.
282
283 The idx can be an integer value or a variable holding an integer. If
284 the value is negative, the position is counted from the end of the
285 buffer.
286
287 The val can be a static string or variables.
288
289 This function can be used from ANY_ROUTE.
290
291 Example 1.10. pos_find_str() usage
292 ...
293 $var(idx) = pos_find_str("100", "kamailio");
294 ...
295
296 4.10. pos_findi_str(idx, val)
297
298 Return the position of the val (matching case insensitive) in message
299 buffer starting at idx. In case of not finding it or error, the return
300 code is negative. If val is at index 0, it returns the value specified
301 by modparam idx0.
302
303 The idx can be an integer value or a variable holding an integer. If
304 the value is negative, the position is counted from the end of the
305 buffer.
306
307 The val can be a static string or variables.
308
309 This function can be used from ANY_ROUTE.
310
311 Example 1.11. pos_findi_str() usage
312 ...
313 $var(idx) = pos_findi_str("100", "kamailio");
314 ...
315
316 4.11. pos_rfind_str(idx, val)
317
318 Return the last position of the val in message buffer starting at idx
319 (reverse search). In case of not finding it or error, the return code
320 is negative. If val is at index 0, it returns the value specified by
321 modparam idx0.
322
323 The idx can be an integer value or a variable holding an integer. If
324 the value is negative, the position is counted from the end of the
325 buffer.
326
327 The val can be a static string or variables.
328
329 This function can be used from ANY_ROUTE.
330
331 Example 1.12. pos_find_str() usage
332 ...
333 $var(idx) = pos_rfind_str("100", "kamailio");
334 ...
335
336 4.12. pos_rfindi_str(idx, val)
337
338 Return the last position of the val (matching case insensitive) in
339 message buffer starting at idx (reverse search). In case of not finding
340 it or error, the return code is negative. If val is at index 0, it
341 returns the value specified by modparam idx0.
342
343 The idx can be an integer value or a variable holding an integer. If
344 the value is negative, the position is counted from the end of the
345 buffer.
346
347 The val can be a static string or variables.
348
349 This function can be used from ANY_ROUTE.
350
351 Example 1.13. pos_rfindi_str() usage
352 ...
353 $var(idx) = pos_rfindi_str("100", "kamailio");
354 ...
355
356 4.13. pos_search(idx, re)
357
358 Return the position that starts matching the regular expression re in
359 message buffer starting at idx. In case of not finding it or error, the
360 return code is negative. If val is at index 0, it returns the value
361 specified by modparam idx0.
362
363 The idx can be an integer value or a variable holding an integer. If
364 the value is negative, the position is counted from the end of the
365 buffer.
366
367 The re can be a static regular expression string.
368
369 This function can be used from ANY_ROUTE.
370
371 Example 1.14. pos_search() usage
372 ...
373 $var(idx) = pos_search("100", "[0-9]+");
374 ...
375
376 4.14. pos_rsearch(idx, re)
377
378 Return the position of last match that starts matching the regular
379 expression re in message buffer starting at idx. In case of not finding
380 it or error, the return code is negative. If val is at index 0, it
381 returns the value specified by modparam idx0.
382
383 The idx can be an integer value or a variable holding an integer. If
384 the value is negative, the position is counted from the end of the
385 buffer.
386
387 The re can be a static regular expression string.
388
389 This function can be used from ANY_ROUTE.
390
391 Example 1.15. pos_rsearch() usage
392 ...
393 $var(idx) = pos_rsearch("100", "[0-9]+");
394 ...
395
396 5. Pseudo Variables
397
398 The module exports a pseudo-variable class, $pos(key), to access
399 attributes upon specific function execution.
400
401 These are documented in the appropriate Wiki pages hosted on the
402 project web site.