Browse code

modules: readme files regenerated - app_lua_sr ... [skip ci]

Kamailio Dev authored on 25/05/2020 09:21:05
Showing 1 changed files
... ...
@@ -10,8 +10,6 @@ Daniel-Constantin Mierla
10 10
 
11 11
    <miconda@gmail.com>
12 12
 
13
-Edited by
14
-
15 13
 Alex Balashov
16 14
 
17 15
    <abalashov@evaristesys.com>
Browse code

modules: readme files regenerated - msrp ... [skip ci]

Kamailio Dev authored on 05/11/2017 10:31:25
Showing 1 changed files
... ...
@@ -264,7 +264,7 @@ modparam("msrp", "use_path_addr", "msrp.kamailio.org:5061")
264 264
 
265 265
    Example 1.7. Set event_callback parameter
266 266
 ...
267
-modparam("htable", "event_callback", "ksr_msrp_event")
267
+modparam("msrp", "event_callback", "ksr_msrp_event")
268 268
 ...
269 269
 -- event callback function implemented in Lua
270 270
 function ksr_msrp_event(evname)
Browse code

modules: readme files regenerated - msrp ... [skip ci]

Kamailio Dev authored on 05/11/2017 09:46:32
Showing 1 changed files
... ...
@@ -37,6 +37,7 @@ Alex Balashov
37 37
               3.4. auth_min_expires (int)
38 38
               3.5. auth_max_expires (int)
39 39
               3.6. use_path_addr (str)
40
+              3.7. event_callback (str)
40 41
 
41 42
         4. Functions
42 43
 
... ...
@@ -66,17 +67,18 @@ Alex Balashov
66 67
    1.4. Set auth_min_expires parameter
67 68
    1.5. Set auth_max_expires parameter
68 69
    1.6. Set use_path_addr parameter
69
-   1.7. msrp_relay usage
70
-   1.8. msrp_reply usage
71
-   1.9. msrp_is_request usage
72
-   1.10. msrp_is_reply usage
73
-   1.11. msrp_set_dst usage
74
-   1.12. msrp_relay_flags usage
75
-   1.13. msrp_reply_flags usage
76
-   1.14. msrp_cmap_save usage
77
-   1.15. msrp_cmap_lookup usage
78
-   1.16. Event Route (using htable for MSRP connection tracking)
79
-   1.17. Event Route (using msrp_cmap_ functions for connection tracking)
70
+   1.7. Set event_callback parameter
71
+   1.8. msrp_relay usage
72
+   1.9. msrp_reply usage
73
+   1.10. msrp_is_request usage
74
+   1.11. msrp_is_reply usage
75
+   1.12. msrp_set_dst usage
76
+   1.13. msrp_relay_flags usage
77
+   1.14. msrp_reply_flags usage
78
+   1.15. msrp_cmap_save usage
79
+   1.16. msrp_cmap_lookup usage
80
+   1.17. Event Route (using htable for MSRP connection tracking)
81
+   1.18. Event Route (using msrp_cmap_ functions for connection tracking)
80 82
 
81 83
 Chapter 1. Admin Guide
82 84
 
... ...
@@ -96,6 +98,7 @@ Chapter 1. Admin Guide
96 98
         3.4. auth_min_expires (int)
97 99
         3.5. auth_max_expires (int)
98 100
         3.6. use_path_addr (str)
101
+        3.7. event_callback (str)
99 102
 
100 103
    4. Functions
101 104
 
... ...
@@ -175,6 +178,7 @@ Chapter 1. Admin Guide
175 178
    3.4. auth_min_expires (int)
176 179
    3.5. auth_max_expires (int)
177 180
    3.6. use_path_addr (str)
181
+   3.7. event_callback (str)
178 182
 
179 183
 3.1. sipmsg (int)
180 184
 
... ...
@@ -247,6 +251,28 @@ modparam("msrp", "auth_max_expiresl", 1800)
247 251
 modparam("msrp", "use_path_addr", "msrp.kamailio.org:5061")
248 252
 ...
249 253
 
254
+3.7. event_callback (str)
255
+
256
+   The name of the function in the kemi configuration file (embedded
257
+   scripting language such as Lua, Python, ...) to be executed instead of
258
+   event_route[...] blocks.
259
+
260
+   The function receives a string parameter with the name of the event,
261
+   the values can be: 'msrp:frame-in'.
262
+
263
+   Default value is 'empty' (no function is executed for events).
264
+
265
+   Example 1.7. Set event_callback parameter
266
+...
267
+modparam("htable", "event_callback", "ksr_msrp_event")
268
+...
269
+-- event callback function implemented in Lua
270
+function ksr_msrp_event(evname)
271
+        KSR.info("===== msrp module triggered event: " .. evname .. "\n");
272
+        return 1;
273
+end
274
+...
275
+
250 276
 4. Functions
251 277
 
252 278
    4.1. msrp_relay()
... ...
@@ -268,7 +294,7 @@ modparam("msrp", "use_path_addr", "msrp.kamailio.org:5061")
268 294
 
269 295
    This function can be used in ANY_ROUTE.
270 296
 
271
-   Example 1.7. msrp_relay usage
297
+   Example 1.8. msrp_relay usage
272 298
 ...
273 299
 event_route[msrp:frame-in] {
274 300
     msrp_relay();
... ...
@@ -283,7 +309,7 @@ event_route[msrp:frame-in] {
283 309
 
284 310
    This function can be used in ANY_ROUTE.
285 311
 
286
-   Example 1.8. msrp_reply usage
312
+   Example 1.9. msrp_reply usage
287 313
 ...
288 314
 event_route[msrp:frame-in] {
289 315
     msrp_reply("403", "Not allowed");
... ...
@@ -296,7 +322,7 @@ event_route[msrp:frame-in] {
296 322
 
297 323
    This function can be used in ANY_ROUTE.
298 324
 
299
-   Example 1.9. msrp_is_request usage
325
+   Example 1.10. msrp_is_request usage
300 326
 ...
301 327
 event_route[msrp:frame-in] {
302 328
     if(msrp_is_request())
... ...
@@ -313,7 +339,7 @@ event_route[msrp:frame-in] {
313 339
 
314 340
    This function can be used in ANY_ROUTE.
315 341
 
316
-   Example 1.10. msrp_is_reply usage
342
+   Example 1.11. msrp_is_reply usage
317 343
 ...
318 344
 event_route[msrp:frame-in] {
319 345
     if(msrp_is_reply())
... ...
@@ -333,7 +359,7 @@ event_route[msrp:frame-in] {
333 359
 
334 360
    This function can be used in ANY_ROUTE.
335 361
 
336
-   Example 1.11. msrp_set_dst usage
362
+   Example 1.12. msrp_set_dst usage
337 363
 ...
338 364
 event_route[msrp:frame-in] {
339 365
     ...
... ...
@@ -352,7 +378,7 @@ event_route[msrp:frame-in] {
352 378
 
353 379
    This function can be used in ANY_ROUTE.
354 380
 
355
-   Example 1.12. msrp_relay_flags usage
381
+   Example 1.13. msrp_relay_flags usage
356 382
 ...
357 383
 event_route[msrp:frame-in] {
358 384
     ...
... ...
@@ -371,7 +397,7 @@ event_route[msrp:frame-in] {
371 397
 
372 398
    This function can be used in ANY_ROUTE.
373 399
 
374
-   Example 1.13. msrp_reply_flags usage
400
+   Example 1.14. msrp_reply_flags usage
375 401
 ...
376 402
 event_route[msrp:frame-in] {
377 403
     ...
... ...
@@ -387,7 +413,7 @@ event_route[msrp:frame-in] {
387 413
 
388 414
    This function can be used in ANY_ROUTE.
389 415
 
390
-   Example 1.14. msrp_cmap_save usage
416
+   Example 1.15. msrp_cmap_save usage
391 417
 ...
392 418
 event_route[msrp:frame-in] {
393 419
     ...
... ...
@@ -402,7 +428,7 @@ event_route[msrp:frame-in] {
402 428
 
403 429
    This function can be used in ANY_ROUTE.
404 430
 
405
-   Example 1.15. msrp_cmap_lookup usage
431
+   Example 1.16. msrp_cmap_lookup usage
406 432
 ...
407 433
 event_route[msrp:frame-in] {
408 434
     ...
... ...
@@ -510,7 +536,7 @@ Content-Type: text/plain
510 536
    Next is an example of configuration file with the routing block for
511 537
    MSRP frames. In this config, the SIP traffic is rejected.
512 538
 
513
-   Example 1.16. Event Route (using htable for MSRP connection tracking)
539
+   Example 1.17. Event Route (using htable for MSRP connection tracking)
514 540
 ...
515 541
 
516 542
 #!KAMAILIO
... ...
@@ -669,7 +695,7 @@ event_route[msrp:frame-in] {
669 695
 
670 696
 ...
671 697
 
672
-   Example 1.17. Event Route (using msrp_cmap_ functions for connection
698
+   Example 1.18. Event Route (using msrp_cmap_ functions for connection
673 699
    tracking)
674 700
 ...
675 701
 
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
<
1 1
new file mode 100644
... ...
@@ -0,0 +1,800 @@
1
+MSRP Module
2
+
3
+Daniel-Constantin Mierla
4
+
5
+   <miconda@gmail.com>
6
+
7
+Edited by
8
+
9
+Daniel-Constantin Mierla
10
+
11
+   <miconda@gmail.com>
12
+
13
+Edited by
14
+
15
+Alex Balashov
16
+
17
+   <abalashov@evaristesys.com>
18
+
19
+   Copyright © 2012 asipto.com
20
+     __________________________________________________________________
21
+
22
+   Table of Contents
23
+
24
+   1. Admin Guide
25
+
26
+        1. Overview
27
+        2. Dependencies
28
+
29
+              2.1. Kamailio Modules
30
+              2.2. External Libraries or Applications
31
+
32
+        3. Parameters
33
+
34
+              3.1. sipmsg (int)
35
+              3.2. cmap_size (int)
36
+              3.3. timer_interval (int)
37
+              3.4. auth_min_expires (int)
38
+              3.5. auth_max_expires (int)
39
+              3.6. use_path_addr (str)
40
+
41
+        4. Functions
42
+
43
+              4.1. msrp_relay()
44
+              4.2. msrp_reply(code, text [, hdrs])
45
+              4.3. msrp_is_request()
46
+              4.4. msrp_is_reply()
47
+              4.5. msrp_set_dst(addr, sock)
48
+              4.6. msrp_relay_flags(flags)
49
+              4.7. msrp_reply_flags(flags)
50
+              4.8. msrp_cmap_save()
51
+              4.9. msrp_cmap_lookup()
52
+
53
+        5. Pseudo Variables
54
+        6. RPC Commands
55
+
56
+              6.1. msrp.cmaplist
57
+
58
+        7. Event Routes
59
+        8. Usage
60
+
61
+   List of Examples
62
+
63
+   1.1. Set sipmsg parameter
64
+   1.2. Set cmap_size parameter
65
+   1.3. Set timer_interval parameter
66
+   1.4. Set auth_min_expires parameter
67
+   1.5. Set auth_max_expires parameter
68
+   1.6. Set use_path_addr parameter
69
+   1.7. msrp_relay usage
70
+   1.8. msrp_reply usage
71
+   1.9. msrp_is_request usage
72
+   1.10. msrp_is_reply usage
73
+   1.11. msrp_set_dst usage
74
+   1.12. msrp_relay_flags usage
75
+   1.13. msrp_reply_flags usage
76
+   1.14. msrp_cmap_save usage
77
+   1.15. msrp_cmap_lookup usage
78
+   1.16. Event Route (using htable for MSRP connection tracking)
79
+   1.17. Event Route (using msrp_cmap_ functions for connection tracking)
80
+
81
+Chapter 1. Admin Guide
82
+
83
+   Table of Contents
84
+
85
+   1. Overview
86
+   2. Dependencies
87
+
88
+        2.1. Kamailio Modules
89
+        2.2. External Libraries or Applications
90
+
91
+   3. Parameters
92
+
93
+        3.1. sipmsg (int)
94
+        3.2. cmap_size (int)
95
+        3.3. timer_interval (int)
96
+        3.4. auth_min_expires (int)
97
+        3.5. auth_max_expires (int)
98
+        3.6. use_path_addr (str)
99
+
100
+   4. Functions
101
+
102
+        4.1. msrp_relay()
103
+        4.2. msrp_reply(code, text [, hdrs])
104
+        4.3. msrp_is_request()
105
+        4.4. msrp_is_reply()
106
+        4.5. msrp_set_dst(addr, sock)
107
+        4.6. msrp_relay_flags(flags)
108
+        4.7. msrp_reply_flags(flags)
109
+        4.8. msrp_cmap_save()
110
+        4.9. msrp_cmap_lookup()
111
+
112
+   5. Pseudo Variables
113
+   6. RPC Commands
114
+
115
+        6.1. msrp.cmaplist
116
+
117
+   7. Event Routes
118
+   8. Usage
119
+
120
+1. Overview
121
+
122
+   This module provides a MSRP routing engine, a.k.a. MSRP relay. MSRP
123
+   (Message Session Relay Protocol) is defined by RFC4975, and the
124
+   extensions for an MSRP relay are covered in RFC4976.
125
+
126
+   A typical use of MSRP is instant messaging sessions initiated via SIP.
127
+   Unlike page-mode instant messaging, which is done via the SIP MESSAGE
128
+   request, MSRP uses a different communication channel which is
129
+   negotiated via INVITE-200 OK-ACK.
130
+
131
+   However, MSRP is still a text-based protocol. It uses several routing
132
+   mechanisms similar to what exists in SIP. Furthermore, MSRP requires
133
+   TCP, and recommends TLS for confidentiality and security. In light of
134
+   the scalability and performance of Kamailio in handling TCP/TLS, this
135
+   module reuses Kamailio's core framework to offer MSRP routing
136
+   capabilities. Along with embedded Presence and XCAP servers, Kamailio
137
+   now offers a complete solution for SIP beyond VoIP.
138
+
139
+   One of the main benefits of this module is the ability to reuse all the
140
+   other extensions that exist in the SIP server, including accounting,
141
+   authentication, authorization to database connectors, security and DoS
142
+   attack protections.
143
+
144
+   Kamailio can handle SIP and MSRP traffic received on the same port; the
145
+   appropriate configuration file block being executed based on the type
146
+   of message. Therefore, you can use Kamailio as a stand-alone MSRP relay
147
+   or you can have an instance handling both SIP and MSRP. Another option
148
+   is to configure Kamailio to listen on multiple ports, some of them for
149
+   SIP and others for MSRP.
150
+
151
+2. Dependencies
152
+
153
+   2.1. Kamailio Modules
154
+   2.2. External Libraries or Applications
155
+
156
+2.1. Kamailio Modules
157
+
158
+   The following modules must be loaded before this module:
159
+     * None.
160
+
161
+   The following modules are required to make proper use of this module:
162
+     * tls.
163
+
164
+2.2. External Libraries or Applications
165
+
166
+   The following libraries or applications must be installed before
167
+   running Kamailio with this module loaded:
168
+     * None
169
+
170
+3. Parameters
171
+
172
+   3.1. sipmsg (int)
173
+   3.2. cmap_size (int)
174
+   3.3. timer_interval (int)
175
+   3.4. auth_min_expires (int)
176
+   3.5. auth_max_expires (int)
177
+   3.6. use_path_addr (str)
178
+
179
+3.1. sipmsg (int)
180
+
181
+   If set to 1, the module will build a SIP message from MSRP frame
182
+   headers, providing it to “event_route[msrp:frame-in]”. All the config
183
+   file functions (apart from SIP request relay) that can be used in a
184
+   request route block can be used in the MSRP event_route.
185
+
186
+   Default value is '1'.
187
+
188
+   Example 1.1. Set sipmsg parameter
189
+...
190
+modparam("msrp", "sipmsg", 1)
191
+...
192
+
193
+3.2. cmap_size (int)
194
+
195
+   The size of connection map table, to be computed as power of 2 (e.g.,
196
+   if the value is 4, then the number of slots in map table is 2^4 = 16).
197
+
198
+   Default value is '0' (no internal map table to be used).
199
+
200
+   Example 1.2. Set cmap_size parameter
201
+...
202
+modparam("msrp", "cmap_size", 8)
203
+...
204
+
205
+3.3. timer_interval (int)
206
+
207
+   The timer interval in seconds to run the procedure for cleaning expired
208
+   connections.
209
+
210
+   Default value is '60'.
211
+
212
+   Example 1.3. Set timer_interval parameter
213
+...
214
+modparam("msrp", "timer_interval", 90)
215
+...
216
+
217
+3.4. auth_min_expires (int)
218
+
219
+   The minimum value accepted for the “Expires” header in AUTH requests.
220
+
221
+   Default value is '60'.
222
+
223
+   Example 1.4. Set auth_min_expires parameter
224
+...
225
+modparam("msrp", "auth_min_expiresl", 90)
226
+...
227
+
228
+3.5. auth_max_expires (int)
229
+
230
+   The maximum value accepted for “Expires” header in AUTH requests.
231
+
232
+   Default value is '3600'.
233
+
234
+   Example 1.5. Set auth_max_expires parameter
235
+...
236
+modparam("msrp", "auth_max_expiresl", 1800)
237
+...
238
+
239
+3.6. use_path_addr (str)
240
+
241
+   The hostname:port to be used when building the Path header.
242
+
243
+   Default value is NULL (server IP and port are used).
244
+
245
+   Example 1.6. Set use_path_addr parameter
246
+...
247
+modparam("msrp", "use_path_addr", "msrp.kamailio.org:5061")
248
+...
249
+
250
+4. Functions
251
+
252
+   4.1. msrp_relay()
253
+   4.2. msrp_reply(code, text [, hdrs])
254
+   4.3. msrp_is_request()
255
+   4.4. msrp_is_reply()
256
+   4.5. msrp_set_dst(addr, sock)
257
+   4.6. msrp_relay_flags(flags)
258
+   4.7. msrp_reply_flags(flags)
259
+   4.8. msrp_cmap_save()
260
+   4.9. msrp_cmap_lookup()
261
+
262
+4.1.  msrp_relay()
263
+
264
+   Relay MSRP frame according to the To-Path. This function has to be
265
+   executed for each MSRP request or reply that has to be forwarded. Note
266
+   that due to nature of the MSRP transport layer, which is reliable
267
+   (TCP/TLS), there is no retransmission of MSRP frames.
268
+
269
+   This function can be used in ANY_ROUTE.
270
+
271
+   Example 1.7. msrp_relay usage
272
+...
273
+event_route[msrp:frame-in] {
274
+    msrp_relay();
275
+}
276
+...
277
+
278
+4.2.  msrp_reply(code, text [, hdrs])
279
+
280
+   Send a reply for the current MSRP request, adding optional headers.
281
+
282
+   The parameter can be a pseudo-variable.
283
+
284
+   This function can be used in ANY_ROUTE.
285
+
286
+   Example 1.8. msrp_reply usage
287
+...
288
+event_route[msrp:frame-in] {
289
+    msrp_reply("403", "Not allowed");
290
+}
291
+...
292
+
293
+4.3.  msrp_is_request()
294
+
295
+   Return true if the MSRP frame is a request.
296
+
297
+   This function can be used in ANY_ROUTE.
298
+
299
+   Example 1.9. msrp_is_request usage
300
+...
301
+event_route[msrp:frame-in] {
302
+    if(msrp_is_request())
303
+    {
304
+        msrp_relay();
305
+        exit;
306
+    }
307
+}
308
+...
309
+
310
+4.4.  msrp_is_reply()
311
+
312
+   Return true if the MSRP frame is a reply.
313
+
314
+   This function can be used in ANY_ROUTE.
315
+
316
+   Example 1.10. msrp_is_reply usage
317
+...
318
+event_route[msrp:frame-in] {
319
+    if(msrp_is_reply())
320
+    {
321
+        msrp_relay();
322
+        exit;
323
+    }
324
+}
325
+...
326
+
327
+4.5.  msrp_set_dst(addr, sock)
328
+
329
+   Set destination attributes: addr - target address as MSRP URI; sock -
330
+   local socket to be used (format 'proto:ip:port').
331
+
332
+   The parameter can be a pseudo-variable.
333
+
334
+   This function can be used in ANY_ROUTE.
335
+
336
+   Example 1.11. msrp_set_dst usage
337
+...
338
+event_route[msrp:frame-in] {
339
+    ...
340
+    msrp_set_dst("msrp://127.0.0.1:8000", "tcp:127.0.0.1:5060");
341
+    ...
342
+}
343
+...
344
+
345
+4.6.  msrp_relay_flags(flags)
346
+
347
+   Set transport layer sending flags for forwarding current MSRP frame;
348
+   flags - a bitmask of flags - 1 (don't create a new connection), 2
349
+   (close connection after send).
350
+
351
+   The parameter can be a pseudo-variable.
352
+
353
+   This function can be used in ANY_ROUTE.
354
+
355
+   Example 1.12. msrp_relay_flags usage
356
+...
357
+event_route[msrp:frame-in] {
358
+    ...
359
+    msrp_relay_flags("1");
360
+    ...
361
+}
362
+...
363
+
364
+4.7.  msrp_reply_flags(flags)
365
+
366
+   Set transport layer sending flags for replies to the current MSRP
367
+   frame; flags - a bitmask of flags - 1 (don't create a new connection),
368
+   2 (close connection after send).
369
+
370
+   The parameter can be a pseudo-variable.
371
+
372
+   This function can be used in ANY_ROUTE.
373
+
374
+   Example 1.13. msrp_reply_flags usage
375
+...
376
+event_route[msrp:frame-in] {
377
+    ...
378
+    msrp_reply_flags("1");
379
+    ...
380
+}
381
+...
382
+
383
+4.8.  msrp_cmap_save()
384
+
385
+   Save details of a MSRP connection upon AUTH request inside the internal
386
+   map table, indexed by session id.
387
+
388
+   This function can be used in ANY_ROUTE.
389
+
390
+   Example 1.14. msrp_cmap_save usage
391
+...
392
+event_route[msrp:frame-in] {
393
+    ...
394
+        if(method=="AUTH") { msrp_cmap_save(); exit; }
395
+    ...
396
+}
397
+...
398
+
399
+4.9.  msrp_cmap_lookup()
400
+
401
+   Lookup MSRP connection details for current session id.
402
+
403
+   This function can be used in ANY_ROUTE.
404
+
405
+   Example 1.15. msrp_cmap_lookup usage
406
+...
407
+event_route[msrp:frame-in] {
408
+    ...
409
+        if(method=="SEND" and $msrp(nexthops)==1) {
410
+                if(msrp_cmap_lookup()) {
411
+                        msrp_relay();
412
+                } else {
413
+                        msrp_reply("481", "Session not found");
414
+                }
415
+        }
416
+    ...
417
+}
418
+...
419
+
420
+5. Pseudo Variables
421
+
422
+   The module exports a pseudo-variable class, $msrp(key), to access the
423
+   MSRP frame (e.g. first line attributes, body, all frame content).
424
+
425
+   The module exports a transformations class, 'msrpuri', to allow access
426
+   attributes of a MSRP URI.
427
+
428
+   These are documented in the appropriate Wiki pages hosted on the
429
+   project web site.
430
+
431
+6. RPC Commands
432
+
433
+   6.1. msrp.cmaplist
434
+
435
+6.1.  msrp.cmaplist
436
+
437
+   List active MSRP connections.
438
+
439
+   Example:
440
+...
441
+kamcmd msrp.cmaplist
442
+...
443
+
444
+7. Event Routes
445
+
446
+   For each MSRP frame received from the network, the module executes
447
+   event_route[msrp:frame-in] block in the config file.
448
+
449
+8. Usage
450
+
451
+   When the sipmsg parameter is set to 1 (which is the default), the
452
+   module internally builds a SIP request from the MSRP frame and exposes
453
+   it to the config file interpreter. This way, all the functions that are
454
+   valid for SIP requests can be used safely in
455
+   event_route[msrp:frame-in].
456
+
457
+   To build the SIP request, the module takes the first line and the
458
+   headers from an MSRP message and appends them to a static buffer. The
459
+   next two examples show an MSRP frame and the resulting SIP request.
460
+...
461
+MSRP 6aef SEND
462
+To-Path: msrps://a.example.org:9000/kjfjan;tcp \
463
+  msrps://b.example.net:9000/aeiug;tcp \
464
+  msrps://bob.example.net:8145/foo;tcp
465
+From-Path: msrps://alice.example.org:7965/bar;tcp
466
+Success-Report: yes
467
+Byte-Range: 1-*/*
468
+Message-ID: 87652
469
+Content-Type: text/plain
470
+
471
+Hi Bob, I'm about to send you a photo.
472
+-------6aef$
473
+...
474
+...
475
+MSRP sip:a@127.0.0.1 SIP/2.0
476
+Via: SIP/2.0/UDP 127.0.0.1:9;branch=z9hG4bKa
477
+From: <b@127.0.0.1>;tag=a
478
+To: <a@127.0.0.1>
479
+Call-ID: a
480
+CSeq: 1 MSRP
481
+Content-Length: 0
482
+MSRP-First-Line: MSRP 6aef SEND
483
+To-Path: msrps://a.example.org:9000/kjfjan;tcp \
484
+  msrps://b.example.net:9000/aeiug;tcp \
485
+  msrps://bob.example.net:8145/foo;tcp
486
+From-Path: msrps://alice.example.org:7965/bar;tcp
487
+Success-Report: yes
488
+Byte-Range: 1-*/*
489
+Message-ID: 87652
490
+Content-Type: text/plain
491
+
492
+...
493
+
494
+   Note that MSRP does not permit line folding. A "\" in the examples
495
+   shows a line continuation due to the limitations of line length of this
496
+   document. Neither the backslash nor the extra CRLF is included in the
497
+   actual request or response.
498
+
499
+   As can be observed, the MSRP frame content starts with the body of the
500
+   'MSRP-First-Line:' header. Using static content to get to a valid SIP
501
+   request is a perfect trade-off for performance.
502
+
503
+   Besides the option to access parts of MSRP frame via an
504
+   internally-built SIP message, the module exports a new pseudo-variable
505
+   class $msrp(key) which returns attributes from the MSRP frame. There is
506
+   also a new transformation, {msrpuri.key}, to get access to parts of an
507
+   MSRP URI. See the appropriate Wiki pages on the project's web site for
508
+   full details about new pseudo-variable and transformation classes.
509
+
510
+   Next is an example of configuration file with the routing block for
511
+   MSRP frames. In this config, the SIP traffic is rejected.
512
+
513
+   Example 1.16. Event Route (using htable for MSRP connection tracking)
514
+...
515
+
516
+#!KAMAILIO
517
+
518
+debug=2
519
+memdbg=5
520
+memlog=5
521
+
522
+children=4
523
+
524
+log_stderror=yes
525
+auto_aliases=no
526
+
527
+tcp_accept_no_cl=yes
528
+tcp_connection_lifetime=1810
529
+
530
+listen=127.0.0.1:5060
531
+
532
+mpath="modules_k/:modules/"
533
+
534
+loadmodule "sl.so"
535
+loadmodule "kex.so"
536
+loadmodule "mi_fifo.so"
537
+loadmodule "ctl.so"
538
+loadmodule "msrp.so"
539
+loadmodule "pv.so"
540
+loadmodule "auth.so"
541
+loadmodule "cfgutils.so"
542
+loadmodule "htable.so"
543
+loadmodule "xlog.so"
544
+
545
+modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
546
+
547
+modparam("auth", "nonce_count", 1)
548
+modparam("auth", "qop", "auth")
549
+
550
+#!substdef "!MSRP_MIN_EXPIRES!1800!g"
551
+#!substdef "!MSRP_MAX_EXPIRES!3600!g"
552
+modparam("htable", "htable", "msrp=>size=8;autoexpire=MSRP_MAX_EXPIRES;")
553
+
554
+request_route {
555
+        sl_send_reply("403", "No SIP Here");
556
+        exit;
557
+}
558
+
559
+reply_route {
560
+        drop;
561
+}
562
+
563
+event_route[msrp:frame-in] {
564
+        xdbg("============#[[$msrp(method)]]===========\n");
565
+        xdbg("============*[[$si:$sp]]\n");
566
+        xdbg("============ crthop:   [$msrp(crthop)]\n");
567
+        xdbg("============ prevhop:  [$msrp(prevhop)]\n");
568
+        xdbg("============ nexthop:  [$msrp(nexthop)]\n");
569
+        xdbg("============ firsthop: [$msrp(firsthop)]\n");
570
+        xdbg("============ lasthop:  [$msrp(lasthop)]\n");
571
+        xdbg("============ prevhops: [$msrp(prevhops)]\n");
572
+        xdbg("============ nexthops: [$msrp(nexthops)]\n");
573
+        xdbg("============ srcaddr:  [$msrp(srcaddr)]\n");
574
+        xdbg("============ srcsock:  [$msrp(srcsock)]\n");
575
+        xdbg("============ sessid:   [$msrp(sessid)]\n");
576
+
577
+        msrp_reply_flags("1");
578
+
579
+        if(msrp_is_reply())
580
+        {
581
+                msrp_relay();
582
+        }
583
+        else if($msrp(method)=="AUTH")
584
+        {
585
+                if($msrp(nexthops)>0)
586
+                {
587
+                        msrp_relay();
588
+                        exit;
589
+                }
590
+
591
+                # frame for local server - send Use-Path
592
+                # -- passwd can be loaded from DB based on $au
593
+                $var(passwd) = "xyz123";
594
+                if(!pv_www_authenticate("myrealm", "$var(passwd)", "0",
595
+                                        "$msrp(method)"))
596
+                {
597
+                        if(auth_get_www_authenticate("myrealm", "1",
598
+                                                        "$var(wauth)"))
599
+                        {
600
+                                msrp_reply("401", "Unauthorized",
601
+                                                "$var(wauth)");
602
+                        } else {
603
+                                msrp_reply("500", "Server Error");
604
+                        }
605
+                        exit;
606
+                }
607
+
608
+                if ($hdr(Expires) != $null) {
609
+                        $var(expires) = (int) $hdr(Expires);
610
+                        if ($var(expires) < MSRP_MIN_EXPIRES) {
611
+                                msrp_reply("423", "Interval Out-of-Bounds",
612
+                                        "Min-Expires: MSRP_MIN_EXPIRES\r\n");
613
+                                exit;
614
+                        } else {
615
+                                msrp_reply("423", "Interval Out-of-Bounds",
616
+                                        "Max-Expires: MSRP_MAX_EXPIRES\r\n");
617
+                                exit;
618
+                        }
619
+
620
+                } else
621
+                        $var(expires) = MSRP_MAX_EXPIRES;
622
+
623
+                $var(cnt) = $var(cnt) + 1;
624
+                pv_printf("$var(sessid)", "s.$(pp).$(var(cnt)).$(RANDOM)");
625
+                $sht(msrp=>$var(sessid)::srcaddr) = $msrp(srcaddr);
626
+                $sht(msrp=>$var(sessid)::srcsock) = $msrp(srcsock);
627
+                $shtex(msrp=>$var(sessid)) = $var(expires) + 5;
628
+                # - Use-Path: the MSRP address for server + session id
629
+                $var(headers) = "Use-Path: msrp://127.0.0.1:5060/"
630
+                                + $var(sessid) + ";tcp\r\n"
631
+                                + "Expires: " + $var(expires) + "\r\n";
632
+                msrp_reply("200", "OK", "$var(headers)");
633
+        }
634
+        else if($msrp(method)=="SEND" || $msrp(method)=="REPORT")
635
+        {
636
+                if($msrp(nexthops)>1)
637
+                {
638
+                        if ($msrp(method)!="REPORT")
639
+                        {
640
+                                msrp_reply("200", "OK");
641
+                        }
642
+                        msrp_relay();
643
+                        exit;
644
+                }
645
+                $var(sessid) = $msrp(sessid);
646
+                if($sht(msrp=>$var(sessid)::srcaddr) == $null)
647
+                {
648
+                        # one more hop, but we don't have address in htable
649
+                        if ($msrp(method)!="REPORT")
650
+                        {
651
+                                msrp_reply("481", "Session-does-not-exist");
652
+                        }
653
+                        exit;
654
+                }
655
+                else if($msrp(method)!="REPORT")
656
+                {
657
+                        msrp_reply("200", "OK");
658
+                }
659
+                msrp_relay_flags("1");
660
+                msrp_set_dst("$sht(msrp=>$var(sessid)::srcaddr)",
661
+                                "$sht(msrp=>$var(sessid)::srcsock)");
662
+                msrp_relay();
663
+        }
664
+        else
665
+        {
666
+                msrp_reply("501", "Request-method-not-understood");
667
+        }
668
+}
669
+
670
+...
671
+
672
+   Example 1.17. Event Route (using msrp_cmap_ functions for connection
673
+   tracking)
674
+...
675
+
676
+#!KAMAILIO
677
+
678
+debug=2
679
+memdbg=5
680
+memlog=5
681
+
682
+children=4
683
+
684
+log_stderror=yes
685
+auto_aliases=no
686
+
687
+tcp_accept_no_cl=yes
688
+tcp_connection_lifetime=1810
689
+
690
+listen=127.0.0.1:5060
691
+
692
+mpath="modules_k/:modules/"
693
+
694
+loadmodule "sl.so"
695
+loadmodule "kex.so"
696
+loadmodule "mi_fifo.so"
697
+loadmodule "ctl.so"
698
+loadmodule "msrp.so"
699
+loadmodule "pv.so"
700
+loadmodule "auth.so"
701
+loadmodule "cfgutils.so"
702
+loadmodule "xlog.so"
703
+
704
+modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
705
+
706
+modparam("auth", "nonce_count", 1)
707