/
presence_admin.xml
1354 lines (1303 loc) · 37.9 KB
/
presence_admin.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
%docentities;
]>
<!-- Module User's Guide -->
<chapter>
<title>&adminguide;</title>
<section>
<title>Overview</title>
<para> The Presence module implements the core functionality of SIP event notification.
It handles PUBLISH and SUBSCRIBE messages and generates
NOTIFY messages in a general, event independent way. It is extensible and allows registering
events to it from other &kamailio; modules.
Supported SIP event packages are presence, presence.winfo, dialog;sla from the presence_xml
module and message-summary from the presence_mwi module.
</para>
<para>
The module can use database and memory storage (to improve performance).
For subscriptions it supports the 4 storage modes: Memory Only, Write Back,
Write Through and DB Only. For publishes, it stores the state documents in
database only(because of the large size) and it can store a publish cache in
memory to avoid unnecessairy database queries. Read the
<emphasis>subs_db_mode</emphasis> and <emphasis>publ_cache</emphasis> parameter
sections to decide which is the best storage configuration for you.
</para>
<para>The module implements several API functions, that can be used by other
modules. In fact, it can be used only as a resource module, or "library".
This mode of operation is enabled if the db_url parameter is not set to any value.
</para>
<para>
The &kamailio; Presence module implements the specifications in: RFC3265, RFC3856, RFC3857,
RFC3858.
</para>
</section>
<section>
<title>Dependencies</title>
<section>
<title>&kamailio; Modules</title>
<para>
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>a database module</emphasis>.
</para>
</listitem>
<listitem>
<para>
<emphasis>sl</emphasis>.
</para>
</listitem>
<listitem>
<para>
<emphasis>tm</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External Libraries or Applications</title>
<itemizedlist>
<listitem>
<para>
<emphasis>libxml</emphasis>.
</para>
</listitem>
</itemizedlist>
</section>
</section>
<section>
<title>Parameters</title>
<section id="presence.p.db_url">
<title><varname>db_url</varname>(str)</title>
<para>
The database url.
</para>
<para>If set, the module is a fully operational
presence server. Otherwise, it is used as a 'library', for
its exported functions.
</para>
<para>
<emphasis>Default value is <quote>NULL</quote>.</emphasis>
</para>
<example>
<title>Set <varname>db_url</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "db_url",
"&defaultdb;")
...
</programlisting>
</example>
</section>
<section id="presence.p.presentity_table">
<title><varname>presentity_table</varname>(str)</title>
<para>
The name of the db table where PUBLISH presence information is stored.
</para>
<para>
<emphasis> Default value is <quote>presentity</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>presentity_table</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "presentity_table", "presentity")
...
</programlisting>
</example>
</section>
<section id="presence.p.active_watchers_table">
<title><varname>active_watchers_table</varname>(str)</title>
<para>
The name of the db table where active subscription information is stored.
</para>
<para>
<emphasis> Default value is <quote>active_watchers</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>active_watchers_table</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "active_watchers_table", "active_watchers")
...
</programlisting>
</example>
</section>
<section id="presence.p.watchers_table">
<title><varname>watchers_table</varname>(str)</title>
<para>
The name of the db table where subscription states are stored.
</para>
<para>
<emphasis> Default value is <quote>watchers</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>watchers_table</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "watchers_table", "watchers")
...
</programlisting>
</example>
</section>
<section id="presence.p.clean_period">
<title><varname>clean_period</varname> (int)</title>
<para>
The period in seconds between checks if there are expired messages stored in database.
</para>
<para>
<emphasis>Default value is <quote>100</quote>. A zero or negative value disables this activity.
</emphasis>
</para>
<example>
<title>Set <varname>clean_period</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "clean_period", 100)
...
</programlisting>
</example>
</section>
<section id="presence.p.db_update_period">
<title><varname>db_update_period</varname> (int)</title>
<para>
The period at which to synchronize cached subscriber info with the
database.
</para>
<para>
<emphasis>Default value is <quote>100</quote>. A zero or negative value disables synchronization.
</emphasis>
</para>
<example>
<title>Set <varname>db_update_period</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "db_update_period", 100)
...
</programlisting>
</example>
</section>
<section id="presence.p.waitn_time">
<title><varname>waitn_time</varname> (int)</title>
<para>
The maximum time period that NOTIFY requests will
be buffered for. The server will attempt to send
NOTIFY requests within many seconds of a change occurring.
</para>
<para>
Note: this parameter is only used when notifier_processes is
greater than 0. When notifier_processes is less than or equal
to 0 NOTIFY requests are sent immediately.
</para>
<para>
<emphasis>Default value is <quote>5</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>waitn_time</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "waitn_time", 10)
...
</programlisting>
</example>
</section>
<section id="presence.p.notifier_poll_rate">
<title><varname>notifier_poll_rate</varname> (int)</title>
<para>
The number of times per second that the notifier processes
should check for work. Approximately
1/(waitn_time * notifier_poll_rate * notifier_processes) of the
pending updates will be sent each time a notifier process runs.
</para>
<para>
Separate notifier processes are only run when subs_db_mode is 3
(DB only mode).
</para>
<para>
<emphasis>Default value is <quote>10</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>notifier_poll_rate</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "notifier_poll_rate", 20)
...
</programlisting>
</example>
</section>
<section id="presence.p.notifier_processes">
<title><varname>notifier_processes</varname> (int)</title>
<para>
The number of notifier processes that should be started.
</para>
<para>
Separate notifier processes are only run when subs_db_mode is
3 (DB only mode).
</para>
<para>
Note: setting this parameter to 0 when subs_db_mode is 3
keeps the old behaviour (sending NOTIFY requests immediately).
This (old) behaviour is disabled by default in DB only mode
because under load, when lots of NOTIFY requests can be sent
on a dialog at the same time, there are race conditions which
result in CSeq re-use.
</para>
<para>
<emphasis>Default value is <quote>1</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>notifier_processes</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "notifier_processes", 2)
...
</programlisting>
</example>
</section>
<section id="presence.p.force_delete">
<title><varname>force_delete</varname> (int)</title>
<para>
Enabling this parameter will delete expired presentity records without updating watchers.
</para>
<para>
Set this parameter to <quote>1<quote> to enable.
</para>
<para>
<emphasis>Default value is <quote>0</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>force_delete</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "force_delete", 1)
...
</programlisting>
</example>
</section>
<section id="presence.p.to_tag_pref">
<title><varname>to_tag_pref</varname> (str)</title>
<para>
The prefix used when generating to_tag when sending replies for
SUBSCRIBE requests.
</para>
<para>
<emphasis>Default value is <quote>10</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>to_tag_pref</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "to_tag_pref", 'pres')
...
</programlisting>
</example>
</section>
<section id="presence.p.expires_offset">
<title><varname>expires_offset</varname> (int)</title>
<para>
The value in seconds that should be subtracted from the expires value when
sending a 200OK for a publish. It is used for forcing the client
to send an update before the old publish expires.
</para>
<para>
<emphasis>Default value is <quote>0</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>expires_offset</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "expires_offset", 10)
...
</programlisting>
</example>
</section>
<section id="presence.p.max_expires">
<title><varname>max_expires</varname> (int)</title>
<para>
The maximum admissible expires value for PUBLISH/SUBSCRIBE
message (in seconds).
</para>
<para>
<emphasis>Default value is <quote>3600</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>max_expires</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "max_expires", 3600)
...
</programlisting>
</example>
</section>
<section id="presence.p.min_expires">
<title><varname>min_expires</varname> (int)</title>
<para>
The minimum admissible expires value for PUBLISH/SUBSCRIBE
message (in seconds).
</para>
<para>
If > 0 then min_expires_action parameter determines the response.
</para>
<para>
<emphasis>Default value is <quote>0</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>min_expires</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "min_expires", 1800)
...
</programlisting>
</example>
</section>
<section id="presence.p.min_expires_action">
<title><varname>min_expires_action</varname> (int)</title>
<para>
The action to take when UA sends a expires value less then min_expires.
</para>
<para>
<itemizedlist>
<title>Possible Values</title>
<listitem>
<para> 1 : RFC Compliant, returns <quote>423 Interval Too Brief</quote></para>
</listitem>
<listitem>
<para> 2 : forces the min_expires value in the subscription</para>
</listitem>
</itemizedlist>
</para>
<para>
If > 0 then min_expires_action parameter determines the response.
</para>
<para>
<emphasis>Default value is <quote>1</quote>.</emphasis>
</para>
<example>
<title>Set <varname>min_expires</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "min_expires", 1800)
...
</programlisting>
</example>
</section>
<section id="presence.p.server_address">
<title><varname>server_address</varname> (str)</title>
<para>
The presence server address which will become the value of Contact header filed
for 200 OK replies to SUBSCRIBE and PUBLISH and in NOTIFY messages.
</para>
<example>
<title>Set <varname>server_address</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "server_address", "sip:10.10.10.10:5060")
...
</programlisting>
</example>
</section>
<section id="presence.p.subs_db_mode">
<title><varname>subs_db_mode</varname> (int)</title>
<para>
The presence module can utilize database for persistent subscription storage.
If you use database, your subscriptions will survive machine restarts or
SW crashes. The disadvantage is that accessing database can be time consuming.
Therefore, presence module implements four database accessing modes:
</para>
<itemizedlist>
<listitem>
<para>
0 - This disables database completely. Only memory will be used.
Subscriptions will not survive restart. Use this value if you need a
really fast presence module and subscription persistence is not necessary or
is provided by other means.
</para>
</listitem>
<listitem>
<para>
1 - Write-Through scheme. Subscriptions are updated synchronously
in database and in memory(used for read operations). Use this
scheme if speed is not top priority, but it's important that no
subscriptions will be lost during crash or reboot or if you have
an external application that reads the state of the subscriptions
from database and they need to be updated synchronously.
</para>
</listitem>
<listitem>
<para>
2 - Write-Back scheme. This is a combination of previous two
schemes. All changes are made to memory and database
synchronization is done in the timer. The timer deletes all
expired contacts and flushes all modified or new subscriptions to
database. Use this scheme if you encounter high-load peaks
and want them to process as fast as possible. Latency of this
mode is much lower than latency of mode 1, but slightly higher
than latency of mode 0. To control the interval at which data is
flushed to database, set the <emphasis>db_update_period</emphasis>
parameter.
</para>
</listitem>
<listitem>
<para>
3 - DB-Only scheme. No memory cache is kept, all operations being
directly performed with the database. The timer deletes all expired
subscriptions from database. The mode is useful if you configure
more servers sharing the same DB without any replication at SIP
level. The mode may be slower due the high number of DB operation.
</para>
</listitem>
</itemizedlist>
<para>
<emphasis>Default value is 2 (Write-Back scheme).</emphasis>
</para>
<example>
<title>Set <varname>subs_db_mode</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "subs_db_mode", 1)
...
</programlisting>
</example>
</section>
<section id="presence.p.publ_cache">
<title><varname>publ_cache</varname> (int)</title>
<para>
To improve performance, the presence module holds by default a
publish cache that says if a certain publication exists in database.
This is only a list of URI + event, so it does not use much memory.
The cache is used when a Subscription is received to check if there
is any published state in database. This way unnecessary queries in
presentity table are avoided.
</para>
<para>
Setting this parameter to 0 will disable the usage of the publish
cache. This is desirable when you have more servers sharing the same
database or there are other external entities inserting data into the
presentity table.
</para>
<para>
<emphasis>Default value is <quote>1</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>publ_cache</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "publ_cache", 0)
...
</programlisting>
</example>
</section>
<section id="presence.p.subs_htable_size">
<title><varname>subs_htable_size</varname> (int)</title>
<para>
The size of the in-memory hash table to store subscription dialogs.
This parameter will be used as the power of 2 when computing table size.
</para>
<para>
<emphasis>Default value is <quote>9 (512)</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>subs_htable_size</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "subs_htable_size", 11)
...
</programlisting>
</example>
</section>
<section id="presence.p.pres_htable_size">
<title><varname>pres_htable_size</varname> (int)</title>
<para>
The size of the in-memory hash table to store publish records.
This parameter will be used as the power of 2 when computing table size.
</para>
<para>
<emphasis>Default value is <quote>9 (512)</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>pres_htable_size</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "pres_htable_size", 11)
...
</programlisting>
</example>
</section>
<section id="presence.p.send_fast_notify">
<title><varname>send_fast_notify</varname> (int)</title>
<para>
This parameter enables or disables the sending of an initial empty NOTIFY after a SUBSCRIBE/reSUBSCRIBE.
This caused problems for MWI application, because some CPEs (like Samsung) fail to understand an empty
NOTIFY to an message-summary event. This parameter is enabled by default, thus addering to the standard.
</para>
<para>
<emphasis>Default value is <quote>1 </quote>.
</emphasis>
</para>
<example>
<title>Set <varname>send_fast_notify</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "send_fast_notify", 0)
...
</programlisting>
</example>
</section>
<section id="presence.p.enable_sphere_check">
<title><varname>enable_sphere_check</varname> (int)</title>
<para>
This parameter is a flag that should be set if permission rules include
sphere checking.
The sphere information is expected to be present in the RPID body
published by the presentity. The flag is introduced as this check requires
extra processing that should be avoided if this feature is not supported
by the clients.
</para>
<para>
<emphasis>Default value is <quote>0 </quote>.
</emphasis>
</para>
<example>
<title>Set <varname>enable_sphere_check</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "enable_sphere_check", 1)
...
</programlisting>
</example>
</section>
<section id="presence.p.timeout_rm_subs">
<title><varname>timeout_rm_subs</varname> (int)</title>
<para>
This parameter is a flag that should be set if subscriptions should be
removed from the active_watchers when a NOTIFY times out. RFC3265
section 3.2.2 defines this behaviour as a SHOULD, so by default it is
on. Disabling this will keep subscriptions active on unreliable
networks.
</para>
<para>
<emphasis>Default value is <quote>1</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>timeout_rm_subs</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "timeout_rm_subs", 0)
...
</programlisting>
</example>
</section>
<section id="presence.p.fetch_rows">
<title><varname>fetch_rows</varname> (integer)</title>
<para>
Number of rows to be loaded in one step from database.
</para>
<para>
<emphasis>
Default value is 500.
</emphasis>
</para>
<example>
<title>Set <varname>fetch_rows</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "fetch_rows", 1000)
...
</programlisting>
</example>
</section>
<section id="presence.p.db_table_lock_type">
<title><varname>db_table_lock_type</varname> (integer)</title>
<para>
Enable (=1) or disable (=0) the Locks for table during an
transaction. Locking only the "current" table causes problems
with a MySQL-Databases in "DB-Only" mode.
</para>
<para>
In order to use the Presence-Module in "DB_ONLY"-mode with a
MySQL-Backend, set this parameter to "0", otherwise the
MySQL-Operations will fail. The Presence-Module will generate
a "500 Server error" due to the failed MySQL-queries.
</para>
<para>
<emphasis>
Default value is 1 (Write Lock for the Tables).
</emphasis>
</para>
<example>
<title>Set <varname>db_table_lock_type</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "db_table_lock_type", 0)
...
</programlisting>
</example>
</section>
<section id="presence.p.local_log_level">
<title><varname>local_log_level</varname> (int)</title>
<para>
Control log level for some debug messages inside the module.
</para>
<para>
<emphasis>
Default value is 2 (L_INFO).
</emphasis>
</para>
<example>
<title>Set <varname>local_log_level</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "local_log_level", 3)
...
</programlisting>
</example>
</section>
<section id="presence.p.subs_remove_match">
<title><varname>subs_remove_match</varname> (int)</title>
<para>
Control how to match the subscriptions to remove from memory.
If set to 0, then the match is done on To-Tag (local generated),
if set to 1, then the match is done on all dialog attributes
(Call-Id, From-Tag, To-Tag).
</para>
<para>
<emphasis>
Default value is 0.
</emphasis>
</para>
<example>
<title>Set <varname>subs_remove_match</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "subs_remove_match", 1)
...
</programlisting>
</example>
</section>
<section id="presence.p.xavp_cfg">
<title><varname>xavp_cfg</varname> (str)</title>
<para>
The name of the xavp to be used to specify attributes for internal
processing of presence module.
</para>
<para>
Inner attributes inside xavp can be:
</para>
<itemizedlist>
<listitem>
<para><emphasis>priority</emphasis> - integer value to set the
priority of the presence document (higher value, higher priority).
It can set the order of the aggregated presence documents sent by
NOTIFY (first the document with higher priority). If xavp_cfg
parameter is set but this attribute is not in the avp,
the priority of the presence document is based on timestamp,
so newer documents have higher priority.</para>
</listitem>
</itemizedlist>
<para>
Default value is <emphasis>empty</emphasis> (not set).
</para>
<example>
<title>Set <varname>xavp_cfg</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "xavp_cfg", "pres")
...
if(is_method("PUBLISH")) {
$xavp(pres=>priority) = 100;
}
...
</programlisting>
</example>
</section>
<section id="presence.p.retrieve_order">
<title><varname>retrieve_order</varname> (int)</title>
<para>
If set to 0, presentity records are retrieve by received_time order.
if set to 1, presentity records are retrieve by priority order.
</para>
<para>
<emphasis>
Default value is 0.
</emphasis>
</para>
<example>
<title>Set <varname>retrieve_order</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "retrieve_order", 1)
...
</programlisting>
</example>
</section>
<section id="presence.p.sip_uri_match">
<title><varname>sip_uri_match</varname> (int)</title>
<para>
The mode used when comparing uris.
</para>
<para>
<itemizedlist>
<title>Possible Values</title>
<listitem>
<para> 0 : case sensitive</para>
</listitem>
<listitem>
<para> 1 : case insensitive</para>
</listitem>
</itemizedlist>
</para>
<para>
<emphasis>Default value is <quote>0</quote>.</emphasis>
</para>
<example>
<title>Set <varname>sip_uri_match</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence", "sip_uri_match", 1)
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Functions</title>
<section id="presence.f.handle_publish">
<title>
<function moreinfo="none">handle_publish([sender_uri])</function>
</title>
<para>
Handles PUBLISH requests by storing and updating
published information in memory cache and database, then calls functions to send
NOTIFY messages when changes in the published information occur.
It takes one argument -> sender_uri. The parameter was added
for enabling BLA implementation. If present, notification of
a change in published state is not sent to the respective uri
even though a subscription exists.
It should be taken from the Sender header. It was left at the
decision of the administrator whether or not to transmit the
content of this header as parameter for handle_publish, to
prevent security problems.
</para>
<para>
This function can be used from REQUEST_ROUTE.
</para>
<para>
<emphasis>Return code:</emphasis>
<itemizedlist>
<listitem>
<para>
<emphasis> 1 - if success</emphasis>.
</para>
</listitem>
<listitem>
<para>
<emphasis> -1 - if error</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
<para>
The module sends an appropriate stateless reply
in all cases.
</para>
<example>
<title><function>handle_publish</function> usage</title>
<programlisting format="linespecific">
...
if(is_method("PUBLISH"))
{
if($hdr(Sender)!= NULL)
handle_publish("$hdr(Sender)");
else
handle_publish();
t_release();
}
...
</programlisting>
</example>
</section>
<section id="presence.f.handle_subscribe">
<title>
<function moreinfo="none">handle_subscribe([watcher_uri])</function>
</title>
<para>
The function which handles SUBSCRIBE requests. It stores or
updates information in memory and database and calls functions to send NOTIFY
messages when a SUBSCRIBE which initiate a dialog is received.
</para>
<para>
By default this function uses the From: URI from the SUBSCRIBE
request as the Watcher URI. The optional watcher_uri parameter
can be used to specify a different Watcher URI, possibly taken
from a SIP header like P-Asserted-Identity:.
</para>
<para>
This function can be used from REQUEST_ROUTE.
</para>
<para>
<emphasis>Return code:</emphasis>
<itemizedlist>
<listitem>
<para>
<emphasis> 1 - if success</emphasis>.
</para>
</listitem>
<listitem>
<para>
<emphasis> -1 - if error</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
<para>
The module sends an appropriate stateless reply
in all cases.
</para>
<example>
<title><function>handle_subscribe</function> usage</title>
<programlisting format="linespecific">
...
if(method=="SUBSCRIBE")
handle_subscribe();
...
</programlisting>
</example>
</section>
<section id="presence.f.pres_auth_status">
<title>
<function moreinfo="none">pres_auth_status(watcher_uri, presentity_uri)</function>
</title>
<para>
The function checks if watcher is authorized to subscribe
event 'presence' of presentity. Both watcher_uri and
presentity_uri are pseudo variables. Function returns
ACTIVE_STATUS, if subscription is allowed and
PENDING_STATUS, TERMINATED_STATUS, or WAITING_STATUS
otherwise. See presence/subscribe.h for the
corresponding integer codes. In case of error, function
returns -1.
</para>
<para>
This function can be used from REQUEST_ROUTE.
</para>
<example>
<title><function>pres_auth_status</function> usage</title>
<programlisting format="linespecific">
...
if (method=="MESSAGE") {
pres_auth_status("$fu", $ru");
if ($retcode == 1) {
t_relay();
} else {
send_reply("403", "Forbidden");
}
}
...
</programlisting>
</example>
</section>
<section id="presence.f.pres_refresh_watchers">
<title>
<function moreinfo="none">pres_refresh_watchers(uri, event, type[, file_uri, filename])</function>
</title>
<para>
The function can be used in configuration to triger notifies to watchers
if a change in watchers authorization or in published state occurred
(i.e., updates of xcap documents).
</para>
<para>Parameters:</para>
<itemizedlist>
<listitem>
<para>uri - the uri of the user who made the change
and whose watchers should be informed.</para>
</listitem>
<listitem>
<para>event - the event package.</para>
</listitem>
<listitem>
<para>type - it distinguishes between the three different types of events
that can trigger the refresh, depending on its value:
<itemizedlist>
<listitem>
<para>0 - a change in watchers authentication.</para>
</listitem>
<listitem>
<para>1 - a statical update in published state through direct
update in db table.
</para>
</listitem>
<listitem>
<para>2 - a statical update in published state by modifying
the pidf manipulation document.
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
<listitem>
<para>file_uri - the uri of the pidf-manipulation file on
the XCAP server (only used for type 2).</para>
</listitem>
<listitem>
<para>filename - the name of the pidf-manipulation file on
the XCAP server (only used for type 2).</para>
</listitem>