Debian Codegraph @

src/modules/msrp/README

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