/
htable_admin.xml
1539 lines (1512 loc) · 41.9 KB
/
htable_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 "../../../../doc/docbook/entities.xml">
%docentities;
]>
<!-- Module User's Guide -->
<chapter>
<title>&adminguide;</title>
<section>
<title>Overview</title>
<para>
The module adds a hash table container to the configuration language. The
hash table is stored in shared memory and the access to it can be
done via pseudo-variables: $sht(htname=>name). The module supports
definition of many hash tables and can load values at startup from
a database table.
</para>
<para>
A typical use case for the SIP server is to implement a cache system
in configuration file - if a value is not found in hash table, load
it from database and store it in hash table so next time the access to
it is very fast. In the definition of the table you can define the
default expiration time of cached items. The expiration time can
be adjusted per item via assignment operation at runtime.
</para>
<para>
Replication between multiple servers is performed automatically (if
enabled) via the DMQ module.
</para>
<para>
You can read more about hash tables at:
http://en.wikipedia.org/wiki/Hash_table.
</para>
<para>
The <quote>name</quote> can be a static string or can include pseudo-
variables that will be replaced at runtime.
</para>
<example>
<title>Accessing $sht(htname=>key)</title>
<programlisting format="linespecific">
...
modparam("htable", "htable", "a=>size=8;")
...
$sht(a=>test) = 1;
$sht(a=>$ci::srcip) = $si;
...
</programlisting>
</example>
<para>
The next example shows a way to protect against dictionary attacks. If
someone fails to authenticate 3 times, it is forbidden for 15 minutes.
Authentication against database is expensive as it does a select
on the <quote>subscriber</quote> table. By disabling the DB auth for 15 minutes,
resources on the server are saved and time to discover the password is increased
substantially. Additional alerting can be done by writing a message
to syslog or sending email, etc.
</para>
<para>
To implement the logic, two hash table variables are used: one counting
the failed authentications per user and one for storing the time of the
last authentication attempt. To ensure a unique name per user, the
hash table uses a combination of authentication username and text
<quote>::auth_count</quote> and <quote>::last_auth</quote>.
</para>
<example>
<title>Dictionary attack limitation</title>
<programlisting format="linespecific">
...
modparam("htable", "htable", "a=>size=8;")
...
if(is_present_hf("Authorization"))
{
if($sht(a=>$au::auth_count)==3)
{
$var(exp) = $Ts - 900;
if($sht(a=>$au::last_auth) > $var(exp))
{
sl_send_reply("403", "Try later");
exit;
} else {
$sht(a=>$au::auth_count) = 0;
}
}
if(!www_authenticate("$td", "subscriber"))
{
switch ($retcode) {
case -1:
sl_send_reply("403", "Forbidden");
exit;
case -2:
if($sht(a=>$au::auth_count) == $null)
$sht(a=>$au::auth_count) = 0;
$sht(a=>$au::auth_count) = $sht(a=>$au::auth_count) + 1;
if($sht(a=>$au::auth_count) == 3)
xlog("auth failed 3rd time - src ip: $si\n");
$sht(a=>$au::last_auth) = $Ts;
break;
}
www_challenge("$td"/*realm*/,"0"/*qop*/);
exit;
}
$sht(a=>$au::auth_count) = 0;
} else {
www_challenge("$td","0");
exit;
}
...
</programlisting>
</example>
<para>
The module also provides a way to store multiple values for a single key.
This is emulated by storing individual keys as 'key_name[n]', where n is
incremented for each key. The total number of keys is stored in a
dedicated key, by default: 'key_name::size'.
</para>
<para>
The array is built when the table is loaded in memory and afterwards all
the keys are treated as individual keys.
If a particular entry in the array is deleted, it is the administrator's
responsibility to update the size of the array and any other elements
(if required).
</para>
<example>
<title>Storing array values</title>
<programlisting format="linespecific">
# Example of dbtext with multiple keys
$ cat /usr/local/etc/kamailio/dbtext/htable
1:key:1:0:value3:0
2:key:1:0:value2:0
3:key:1:0:value1:0
# The array key will be loaded in memory in the following format:
$ kamcmd htable.dump htable
{
entry: 35
size: 1
slot: {
item: {
name: key[0]
value: value1
}
}
}
{
entry: 50
size: 1
slot: {
item: {
name: key::size
value: 3
}
}
}
{
entry: 67
size: 1
slot: {
item: {
name: key[1]
value: value2
}
}
}
{
entry: 227
size: 1
slot: {
item: {
name: key[2]
value: value3
}
}
}
# Now let's delete a particular entry in the array: key[0].
$ kamcmd htable.delete htable key[0]
# The array key will look like this after a key was deleted:
$ kamcmd htable.dump htable
{
entry: 50
size: 1
slot: {
item: {
name: key::size
value: 3
}
}
}
{
entry: 67
size: 1
slot: {
item: {
name: key[1]
value: value2
}
}
}
{
entry: 227
size: 1
slot: {
item: {
name: key[2]
value: value3
}
}
}
</programlisting>
</example>
</section>
<section>
<title>Dependencies</title>
<section>
<title>&kamailio; Modules</title>
<para>
The following modules must be loaded before this module:
<itemizedlist>
<listitem>
<para>
<emphasis>If DMQ replication is enabled, the DMQ module must be loaded first.</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>External Libraries or Applications</title>
<para>
The following libraries or applications must be installed before running
&kamailio; with this module loaded:
<itemizedlist>
<listitem>
<para>
<emphasis>None</emphasis>.
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section>
<title>Loading from database</title>
<para>
The module is able to load values in a hash table at startup upon
providing a DB URL and table name.
</para>
<para>
The structure of the table must contain:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>key name</emphasis> - string containing the name of
the key.
</para>
</listitem>
<listitem>
<para>
<emphasis>key type</emphasis> - the type of the key
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>0</emphasis> - simple key - the key is added
as 'key_name'.
</para>
</listitem>
<listitem>
<para>
<emphasis>1</emphasis> - array key - the key is added
as 'key_name[n]' - n is incremented for each key with this
name to build an array in hash table. In addition, an additional
key is built to hold the total number of key in the array,
by default key_name::size (see array_size_suffix parameter).
</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>
<emphasis>value type</emphasis> - the type of the key value
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>0</emphasis> - value is string.
</para>
</listitem>
<listitem>
<para>
<emphasis>1</emphasis> - value is integer.
</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>
<emphasis>key value</emphasis> - string containing the value of
the key.
</para>
</listitem>
</itemizedlist>
</section>
</section>
<section>
<title>Parameters</title>
<section id="htable.p.htable">
<title><varname>htable</varname> (str)</title>
<para>
The definition of a hash table. The value of the parameter may have the
following format:
</para>
<itemizedlist>
<listitem>
<para>
"htname=>size=_number_;autoexpire=_number_;dbtable=_string_"
</para>
</listitem>
</itemizedlist>
<para>
The parameter can be set multiple times to get more hash tables in
same configuration file.
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>htname</emphasis> - string specifying the name of
the hash table. This string is used by <emphasis>$sht(...)</emphasis>
to refer to the hash table.
</para>
</listitem>
<listitem>
<para>
<emphasis>size</emphasis> - number specifying the size of hash
table. Larger value means less collisions. The number of entries
(aka slots or buckets) in the table is 2^size. The possible range
for this value is from 2 to 31, smaller or larger values will be
increased to 3 (8 slots) or decreased to 14 (16384 slots).
</para>
</listitem>
<listitem>
<para>
<emphasis>autoexpire</emphasis> -time in seconds to delete an item
from a hash table if no update was done to it. If is missing or set
to 0, the items won't expire.
</para>
</listitem>
<listitem>
<para>
<emphasis>dbtable</emphasis> - name of database to be loaded at
startup in hash table. If empty or missing, no data will be loaded.
</para>
</listitem>
<listitem>
<para>
<emphasis>cols</emphasis> - the column names of the database table.
They must be enclosed in quotes in order to form a valid SIP
parameter value and be separated by comma. The first column
corresponds to key_name. When specified, there must be at least
two columns. If this attribute is not specified, then the global
module parameters for column names are used. If more than one
value columns are specified, the hash table will pack the column
values in a comma separated string, which will be associated
with the key (string transformation {s.select,...} can be
used in configuration file to extract a specific column value).
When cols attribute is present, writing back to database table
is disabled.
</para>
</listitem>
<listitem>
<para>
<emphasis>dbmode</emphasis> - if set to 1, the content of hash
table is written to database table when the SIP server is stopped
(i.e., ensure persistency over restarts). Default value is 0 (no
write back to db table).
</para>
</listitem>
<listitem>
<para>
<emphasis>initval</emphasis> - the integer value to be returned
instead of $null when a requested key is not set.
</para>
</listitem>
<listitem>
<para>
<emphasis>updateexpire</emphasis> - if set to 1 (default), the time until
expiration of an item is reset when that item is updated. Certain uses of
htable may dictate that updates should not reset the expiration timeout, however,
in which case this attribute can be set to 0.
</para>
</listitem>
<listitem>
<para>
<emphasis>dmqreplicate</emphasis> - if set to 1, any actions (set, update, delete
etc.) performed upon entries in this table will be replicated to other nodes (htable
peers). Please note, module parameter <quote>enable_dmq</quote> must also be set in
order for this to apply (see below). Default is 0 (no replication).
</para>
</listitem>
</itemizedlist>
<para>
<emphasis>
Default value is NULL.
</emphasis>
</para>
<example>
<title>Set <varname>htable</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "htable", "a=>size=4;autoexpire=7200;dbtable=htable_a;")
modparam("htable", "htable", "b=>size=5;")
modparam("htable", "htable", "c=>size=4;autoexpire=7200;initval=1;dmqreplicate=1;")
...
</programlisting>
</example>
</section>
<section id="htable.p.db_url">
<title><varname>db_url</varname> (str)</title>
<para>
The <acronym>URL</acronym> to connect to database for loading values in hash
table at start up.
</para>
<para>
<emphasis>
Default value is NULL (do not connect).
</emphasis>
</para>
<example>
<title>Set <varname>db_url</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "db_url", "&defaultdb;")
...
</programlisting>
</example>
</section>
<section id="htable.p.key_name_column">
<title><varname>key_name_column</varname> (str)</title>
<para>
The name of the column containing the hash table key name.
</para>
<para>
<emphasis>
Default value is 'key_name'.
</emphasis>
</para>
<example>
<title>Set <varname>key_name_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "key_name_column", "kname")
...
</programlisting>
</example>
</section>
<section id="htable.p.key_type_column">
<title><varname>key_type_column</varname> (str)</title>
<para>
The name of the column containing the hash table key type.
</para>
<para>
<emphasis>
Default value is 'key_type'.
</emphasis>
</para>
<example>
<title>Set <varname>key_type_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "key_type_column", "ktype")
...
</programlisting>
</example>
</section>
<section id="htable.p.value_type_column">
<title><varname>value_type_column</varname> (str)</title>
<para>
The name of the column containing the hash table value type.
</para>
<para>
<emphasis>
Default value is 'value_type'.
</emphasis>
</para>
<example>
<title>Set <varname>value_type_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "value_type_column", "vtype")
...
</programlisting>
</example>
</section>
<section id="htable.p.key_value_column">
<title><varname>key_value_column</varname> (str)</title>
<para>
The name of the column containing hash table key value.
</para>
<para>
<emphasis>
Default value is 'key_value'.
</emphasis>
</para>
<example>
<title>Set <varname>key_value_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "key_value_column", "kvalue")
...
</programlisting>
</example>
</section>
<section id="htable.p.expires_column">
<title><varname>expires_column</varname> (str)</title>
<para>
The name of the column containing the expires value.
</para>
<para>
<emphasis>
Default value is 'expires'.
</emphasis>
</para>
<example>
<title>Set <varname>expires_column</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "expires_column", "expiry")
...
</programlisting>
</example>
</section>
<section id="htable.p.array_size_suffix">
<title><varname>array_size_suffix</varname> (str)</title>
<para>
The suffix to be added to store the number of items in an
array (see key type).
</para>
<para>
<emphasis>
Default value is '::size'.
</emphasis>
</para>
<example>
<title>Set <varname>array_size_suffix</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "array_size_suffix", "-count")
...
</programlisting>
</example>
</section>
<section id="htable.p.fetch_rows">
<title><varname>fetch_rows</varname> (integer)</title>
<para>
How many rows to fetch at once from database.
</para>
<para>
<emphasis>
Default value is 100.
</emphasis>
</para>
<example>
<title>Set <varname>fetch_rows</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "fetch_rows", 1000)
...
</programlisting>
</example>
</section>
<section id="htable.p.timer_interval">
<title><varname>timer_interval</varname> (integer)</title>
<para>
Interval in seconds to check for expired htable values.
</para>
<para>
<emphasis>
Default value is 20.
</emphasis>
</para>
<example>
<title>Set <varname>timer_interval</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "timer_interval", 10)
...
</programlisting>
</example>
</section>
<section id="htable.p.db_expires">
<title><varname>db_expires</varname> (integer)</title>
<para>
If set to 1, the module loads/saves the value for expire of
the items in hash table from/to database. It applies only to hash
tables that have the auto-expires attribute defined. If set to 0,
only the key name and the value are loaded, the expires for each
item being set to 0.
</para>
<para>
Note that the module is not reloading automatically the items from
database when they expire, the reloading can be done only via RPC
command.
</para>
<para>
<emphasis>
Default value is 0.
</emphasis>
</para>
<example>
<title>Set <varname>db_expires</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "db_expires", 1)
...
</programlisting>
</example>
</section>
<section id="htable.p.enable_dmq">
<title><varname>enable_dmq</varname> (integer)</title>
<para>
If set to 1, will enable DMQ replication of actions performed upon
entries in all tables having "dmqreplicate" parameter set. Any update
action performed via pseudo-variables and RPC commands will be
repeated on all other nodes. Therefore, it is important to ensure the
table definition (size, autoexpire etc.) is identical across all instances.
</para>
<para>
<emphasis>
Important: If this parameter is enabled, the DMQ module must be loaded first - otherwise, startup will fail.
</emphasis>
</para>
<para>
Currently, values are not replicated on load from DB as it is expected
that in these cases, all servers will load their values from the same DB.
</para>
<para>
<emphasis>
Default value is 0.
</emphasis>
</para>
<example>
<title>Set <varname>enable_dmq</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "enable_dmq", 1)
...
</programlisting>
</example>
</section>
<section id="htable.p.dmq_init_sync">
<title><varname>dmq_init_sync</varname> (integer)</title>
<para>
If set to 1, will request synchronization from other nodes at startup. It applies
to all tables having the "dmqreplicate" parameter set. As above, it is important to
ensure the definition (size, autoexpire etc.) of replicated tables is identical
across all instances.
</para>
<para>
<emphasis>
Default value is 0.
</emphasis>
</para>
<example>
<title>Set <varname>dmq_init_sync</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "dmq_init_sync", 1)
...
</programlisting>
</example>
</section>
<section id="htable.p.timer_procs">
<title><varname>timer_procs</varname> (integer)</title>
<para>
If set to 1 or greater, the module will create its own timer
processes to scan for expired items in hash tables. If set to zero,
it will use the core timer for this task. Set it to 1 if you store
a lot of items with autoexpire property.
</para>
<para>
<emphasis>
Default value is 0.
</emphasis>
</para>
<example>
<title>Set <varname>timer_procs</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "timer_procs", 4)
...
</programlisting>
</example>
</section>
<section id="htable.p.event_callback">
<title><varname>event_callback</varname> (str)</title>
<para>
The name of the function in the kemi configuration file (embedded
scripting language such as Lua, Python, ...) to be executed instead
of event_route[...] blocks.
</para>
<para>
The function receives a string parameter with the name of the event,
the values can be: 'htable:mod-init', 'htable:expired:htname'
('htname' being the name of hash table).
</para>
<para>
<emphasis>
Default value is 'empty' (no function is executed for events).
</emphasis>
</para>
<example>
<title>Set <varname>event_callback</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "event_callback", "ksr_htable_event")
...
-- event callback function implemented in Lua
function ksr_htable_event(evname)
KSR.info("===== htable module triggered event: " .. evname .. "\n");
return 1;
end
...
</programlisting>
</example>
</section>
<section id="htable.p.event_callback_mode">
<title><varname>event_callback_mode</varname> (int)</title>
<para>
Control when event_route[htable:init] is executed: 0 - after all
modules were initialized; 1 - in first worker process.
</para>
<para>
Set it to 1 if used in a KEMI script or when needing to use database
(e.g., via sqlops) inside event_route[htable:init].
</para>
<para>
<emphasis>
Default value is 0.
</emphasis>
</para>
<example>
<title>Set <varname>event_callback_mode</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("htable", "event_callback_mode", 1)
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Functions</title>
<section id="htable.f.sht_print">
<title>
<function moreinfo="none">sht_print()</function>
</title>
<para>
Dump content of hash table to L_ERR log level. Intended for debug
purposes.
</para>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
ONREPLY_ROUTE, BRANCH_ROUTE.
</para>
<example>
<title><function>sht_print</function> usage</title>
<programlisting format="linespecific">
...
sht_print();
...
</programlisting>
</example>
</section>
<section id="htable.f.sht_rm">
<title>
<function moreinfo="none">sht_rm(htname, itname)</function>
</title>
<para>
Delete the item with the name 'itname' from hash table 'htname'.
This API function equivaluent to '$sht(htname=>itname) = $null'.
</para>
<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>sht_rm</function> usage</title>
<programlisting format="linespecific">
...
sht_rm("ha", "test"");
...
</programlisting>
</example>
</section>
<section id="htable.f.sht_rm_name_re">
<title>
<function moreinfo="none">sht_rm_name_re(htable=>regexp)</function>
</title>
<para>
Delete all entries in the htable that match the name against
regular expression.
</para>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
ONREPLY_ROUTE, BRANCH_ROUTE.
</para>
<example>
<title><function>sht_rm_name_re</function> usage</title>
<programlisting format="linespecific">
...
sht_rm_name_re("ha=>.*");
...
</programlisting>
</example>
</section>
<section id="htable.f.sht_rm_value_re">
<title>
<function moreinfo="none">sht_rm_value_re(htable=>regexp)</function>
</title>
<para>
Delete all entries in the htable that match the value against
regular expression.
</para>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
ONREPLY_ROUTE, BRANCH_ROUTE.
</para>
<example>
<title><function>sht_rm_value_re</function> usage</title>
<programlisting format="linespecific">
...
sht_rm_value_re("ha=>.*");
...
</programlisting>
</example>
</section>
<section id="htable.f.sht_rm_name">
<title>
<function moreinfo="none">sht_rm_name(htable, op, val)</function>
</title>
<para>
Delete all entries in the htable that match the name against
the val parameter.
</para>
<para>
The op parameter can be:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>re</emphasis> - match the val parameter as regular
expression.
</para>
</listitem>
<listitem>
<para>
<emphasis>sw</emphasis> - match the val parameter as 'starts
with'.
</para>
</listitem>
</itemizedlist>
<para>
All parameters can be static strings or contain variables.
</para>
<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>sht_rm_name</function> usage</title>
<programlisting format="linespecific">
...
sht_rm_name("ha", "re", ".*");
...
</programlisting>
</example>
</section>
<section id="htable.f.sht_rm_value">
<title>
<function moreinfo="none">sht_rm_value(htable, op, val)</function>
</title>
<para>
Delete all entries in the htable that match the value against
the val parameter.
</para>
<para>
The op parameter can be:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis>re</emphasis> - match the val parameter as regular
expression.
</para>
</listitem>
<listitem>
<para>
<emphasis>sw</emphasis> - match the val parameter as 'starts
with'.
</para>
</listitem>
</itemizedlist>
<para>
All parameters can be static strings or contain variables.
</para>
<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>sht_rm_value</function> usage</title>
<programlisting format="linespecific">
...
sht_rm_value("ha", "re", ".*");
...
</programlisting>
</example>
</section>
<section id="htable.f.sht_reset">
<title>
<function moreinfo="none">sht_reset(htable)</function>
</title>
<para>
Delete all entries in the htable. The name of the hash table
can be a dynamic string with variables.
</para>
<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>sht_reset</function> usage</title>
<programlisting format="linespecific">
...
sht_reset("ha$var(x)");
...
</programlisting>
</example>
</section>
<section id="htable.f.sht_lock">
<title>
<function moreinfo="none">sht_lock(htable=>key)</function>
</title>
<para>
Lock the slot in htable corresponding to the key item. Note that
the locking is re-entrant for the process, therefore the lock
and unlock should be done by the same process.
</para>
<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>sht_lock</function> usage</title>
<programlisting format="linespecific">
...
sht_lock("ha=>test");
...
</programlisting>
</example>
</section>
<section id="htable.f.sht_unlock">
<title>
<function moreinfo="none">sht_unlock(htable=>key)</function>
</title>
<para>
Unlock the slot in htable corresponding to the key item. Note that
the locking is re-entrant for the process, therefore the lock
and unlock should be done by the same process.
</para>
<para>
This function can be used from ANY_ROUTE.
</para>
<example>
<title><function>sht_unlock</function> usage</title>
<programlisting format="linespecific">
...
sht_lock("ha=>test");
$sht(ha=>test) = $sht(ha=>test) + 10;
sht_unlock("ha=>test");
...
</programlisting>
</example>
</section>
<section id="htable.f.sht_iterator_start">
<title>
<function moreinfo="none">sht_iterator_start(iname, hname)</function>
</title>
<para>
Start an iterator for hash table named by the value of parameter
hname. The parameter iname is used to identify the iterator. There
can be up to 4 iterators at the same time, with different name.
</para>
<para>
Both parameters can be dynamic strings with variables.