Debian Codegraph @

src/modules/topoh/README

raw
1 topoh 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 © 2009 FhG FOKUS
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. mask_key (str)
29 3.2. mask_ip (str)
30 3.3. mask_callid (integer)
31 3.4. mask_mode (integer)
32 3.5. uparam_name (str)
33 3.6. uparam_prefix (str)
34 3.7. vparam_name (str)
35 3.8. vparam_prefix (str)
36 3.9. callid_prefix (str)
37 3.10. sanity_checks (integer)
38 3.11. uri_prefix_checks (integer)
39 3.12. event_callback (str)
40 3.13. event_mode (int)
41 3.14. use_mode (int)
42
43 4. Event Routes
44
45 4.1. event_route[topoh:msg-outgoing]
46 4.2. event_route[topoh:msg-sending]
47
48 5. Pesudo-Variables
49
50 List of Examples
51
52 1.1. Set mask_key parameter
53 1.2. Set mask_ip parameter
54 1.3. Set mask_callid parameter
55 1.4. Set mask_mode parameter
56 1.5. Set uparam_name parameter
57 1.6. Set uparam_prefix parameter
58 1.7. Set vparam_name parameter
59 1.8. Set vparam_prefix parameter
60 1.9. Set callid_prefix parameter
61 1.10. Set sanity_checks parameter
62 1.11. Set uri_prefix_checks parameter
63 1.12. Set event_callback parameter
64 1.13. Set event_mode parameter
65 1.14. Set use_mode parameter
66 1.15. Usage of event_route[topoh:msg-outgoing]
67 1.16. Usage of event_route[topoh:msg-sending]
68
69 Chapter 1. Admin Guide
70
71 Table of Contents
72
73 1. Overview
74 2. Dependencies
75
76 2.1. Kamailio Modules
77 2.2. External Libraries or Applications
78
79 3. Parameters
80
81 3.1. mask_key (str)
82 3.2. mask_ip (str)
83 3.3. mask_callid (integer)
84 3.4. mask_mode (integer)
85 3.5. uparam_name (str)
86 3.6. uparam_prefix (str)
87 3.7. vparam_name (str)
88 3.8. vparam_prefix (str)
89 3.9. callid_prefix (str)
90 3.10. sanity_checks (integer)
91 3.11. uri_prefix_checks (integer)
92 3.12. event_callback (str)
93 3.13. event_mode (int)
94 3.14. use_mode (int)
95
96 4. Event Routes
97
98 4.1. event_route[topoh:msg-outgoing]
99 4.2. event_route[topoh:msg-sending]
100
101 5. Pesudo-Variables
102
103 1. Overview
104
105 This module hides the SIP routing headers that show topology details.
106 It is not affected by the server being transaction stateless or
107 stateful. The script interpreter gets the SIP messages decoded, so all
108 existing functionality is preserved.
109
110 The module is transparent for the configuration writer. It only needs
111 to be loaded (tune the parameters if needed). The SIP server can be
112 restarted without affecting ongoing calls - once it is up, can
113 encode/decode topology details, thus no call will be lost.
114
115 By using same mask_key, many SIP servers can decode the message, for
116 example, applicable for servers behind load balancers.
117
118 2. Dependencies
119
120 2.1. Kamailio Modules
121 2.2. External Libraries or Applications
122
123 2.1. Kamailio Modules
124
125 The following modules must be loaded before this module:
126 * rr module - server must perform record routing to ensure in-dialog
127 requests are encoded/decoded.
128
129 2.2. External Libraries or Applications
130
131 The following libraries or applications must be installed before
132 running Kamailio with this module loaded:
133 * None. In the future the module can be enhanced to use a stronger
134 encryption algorithm.
135
136 3. Parameters
137
138 3.1. mask_key (str)
139 3.2. mask_ip (str)
140 3.3. mask_callid (integer)
141 3.4. mask_mode (integer)
142 3.5. uparam_name (str)
143 3.6. uparam_prefix (str)
144 3.7. vparam_name (str)
145 3.8. vparam_prefix (str)
146 3.9. callid_prefix (str)
147 3.10. sanity_checks (integer)
148 3.11. uri_prefix_checks (integer)
149 3.12. event_callback (str)
150 3.13. event_mode (int)
151 3.14. use_mode (int)
152
153 3.1. mask_key (str)
154
155 Keyword to mask the headers.
156
157 Default value is "_static_value_".
158
159 Example 1.1. Set mask_key parameter
160 ...
161 modparam("topoh", "mask_key", "some secret here")
162 ...
163
164 3.2. mask_ip (str)
165
166 IP address to be used in masked headers to build valid SIP URIs. Can be
167 any IP address, even a private-space or non-existing IP address (e.g.,
168 192.168.1.1, 127.0.0.2), including the SIP server address, but must not
169 be an address potentially used by clients. If set to empty string, the
170 advertised IP of the incoming or outgoing socket is used when
171 specified, otherwise the IP of the socket is used. Note that the value
172 is actually not used at all for SIP routing.
173
174 Default value is "127.0.0.8".
175
176 Example 1.2. Set mask_ip parameter
177 ...
178 modparam("topoh", "mask_ip", "192.168.0.1")
179 ...
180
181 3.3. mask_callid (integer)
182
183 Whether to encode the Call-id: header. Some SIP extensions include the
184 Call-id in the SIP message payload or header, so it is safe to not
185 encode Call-id in such cases. Well-known extensions such as call
186 transfer or conference join will be added to work with encoded Call-id.
187
188 NOTE: if you are using dialog module to terminate calls and this
189 parameter is enabled, you must set the dialog module parameter
190 'lreq_callee_headers' to include the header: 'TH: dlh\r\n'.
191
192 Default value is 0 (do not mask).
193
194 Example 1.3. Set mask_callid parameter
195 ...
196 modparam("topoh", "mask_callid", 1)
197 ...
198
199 3.4. mask_mode (integer)
200
201 Control when and what parts of SIP message are masked.
202
203 It works as a bitmask value. The following options are available: (1) -
204 skip masking Contact headers in 3XX (redirect) replies.
205
206 Default value is 0.
207
208 Example 1.4. Set mask_mode parameter
209 ...
210 modparam("topoh", "mask_mode", 1)
211 ...
212
213 3.5. uparam_name (str)
214
215 Name of URI parameter where to store encoded value.
216
217 Default value is "line".
218
219 Example 1.5. Set uparam_name parameter
220 ...
221 modparam("topoh", "uparam_name", "myparam")
222 ...
223
224 3.6. uparam_prefix (str)
225
226 Prefix to be added in encoded URI parameters.
227
228 Default value is "sr-".
229
230 Example 1.6. Set uparam_prefix parameter
231 ...
232 modparam("topoh", "uparam_prefix", "xyz")
233 ...
234
235 3.7. vparam_name (str)
236
237 Name of Via: parameter used to store encoded value.
238
239 Default value is "branch".
240
241 Example 1.7. Set vparam_name parameter
242 ...
243 modparam("topoh", "vparam_name", "myv")
244 ...
245
246 3.8. vparam_prefix (str)
247
248 Prefix to be added in encoded Via: parameters.
249
250 Default value is "z9hG4bKsr-".
251
252 Example 1.8. Set vparam_prefix parameter
253 ...
254 modparam("topoh", "vparam_prefix", "xyz")
255 ...
256
257 3.9. callid_prefix (str)
258
259 Prefix to be added in encoded Call-ID: headers.
260
261 Default value is "!!:".
262
263 Example 1.9. Set callid_prefix parameter
264 ...
265 modparam("topoh", "callid_prefix", "***")
266 ...
267
268 3.10. sanity_checks (integer)
269
270 If set to 1, topoh module will bind to sanity module in order to
271 perform sanity checks over received SIP request. Default sanity checks
272 are done. It is useful to check if received request is well formatted
273 before proceeding to encoding/decoding.
274
275 Default value is 0 (do not bind to sanity module).
276
277 Example 1.10. Set sanity_checks parameter
278 ...
279 modparam("topoh", "sanity_checks", 1)
280 ...
281
282 3.11. uri_prefix_checks (integer)
283
284 If set to 1, topoh module will check if URIs to be decoded match the
285 expected prefix composed from mask IP and parameter name prefix. It can
286 make the topoh processing safer by avoiding to try decoding URIs which
287 were not encoded previously by topoh.
288
289 Note: do not enable this option if you have SIP devices that can alter
290 the URI values it takes from Contact or Record-Route headers (like
291 adding port 5060 when no port is in received URIs, or that introduces
292 new parameters at an unknown position).
293
294 Default value is 0.
295
296 Example 1.11. Set uri_prefix_checks parameter
297 ...
298 modparam("topoh", "uri_prefix_checks", 1)
299 ...
300
301 3.12. event_callback (str)
302
303 The name of the function in the KEMI configuration file (embedded
304 scripting language such as Lua, Python, ...) to be executed instead of
305 event_route[...] blocks.
306
307 The function receives a string parameter with the name of the event.
308
309 Default value is 'empty' (no function is executed for events).
310
311 Example 1.12. Set event_callback parameter
312 ...
313 modparam("topoh", "event_callback", "ksr_topoh_event")
314 ...
315 -- event callback function implemented in Lua
316 function ksr_topoh_event(evname)
317 KSR.info("===== topoh module triggered event: " .. evname .. "\n");
318 return 1;
319 end
320 ...
321
322 3.13. event_mode (int)
323
324 Control what event_route blocks to be executed. It is a bitmask of: 1 -
325 execute event_route[topoh:msg-outgoing]; 2 - execute
326 event_route[topoh:msg-sending].
327
328 Default value is 3 (execute both event_route blocks).
329
330 Example 1.13. Set event_mode parameter
331 ...
332 modparam("topoh", "event_mode", 2)
333 ...
334
335 3.14. use_mode (int)
336
337 Control how the module is initialized. If set to 1, the module is only
338 initialized to be used as a library via inter-module API functions. If
339 set to 0, the module is initialized for SIP messages processing.
340
341 Default value is 0 (to process SIP messages).
342
343 Example 1.14. Set use_mode parameter
344 ...
345 modparam("topoh", "use_mode", 1)
346 ...
347
348 4. Event Routes
349
350 4.1. event_route[topoh:msg-outgoing]
351 4.2. event_route[topoh:msg-sending]
352
353 4.1. event_route[topoh:msg-outgoing]
354
355 It is executed before doing topology hiding processing for an outgoing
356 SIP message. If 'drop' is executed inside the event route, then the
357 module skips doing the topology hiding.
358
359 Inside the event route the variables $sndto(ip), $sndto(port) and
360 $sndto(proto) point to the destination. The SIP message is not the one
361 to be sent out, but an internally generated one at startup, to avoid
362 reparsing the outgoing SIP message for the cases when topology hiding
363 is not wanted.
364
365 Example 1.15. Usage of event_route[topoh:msg-outgoing]
366 ...
367 event_route[topoh:msg-outgoing] {
368 if($sndto(ip)=="10.1.1.10") {
369 drop;
370 }
371 }
372 ...
373
374 4.2. event_route[topoh:msg-sending]
375
376 It is executed before doing topology hiding processing for a SIP
377 message to be sent out, being executed after
378 event_route[topoh:msg-outgoing].
379
380 Inside the event route the variables $sndto(ip), $sndto(port) and
381 $sndto(proto) point to the destination. The SIP message is the one to
382 be sent out.
383
384 Example 1.16. Usage of event_route[topoh:msg-sending]
385 ...
386 event_route[topoh:msg-sending] {
387 if(is_request() and $fU=="alice") {
388 drop;
389 }
390 }
391 ...
392
393 5. Pesudo-Variables
394
395 - $th(ecallid) - return the topoh-encoded Call-Id