Module: kamailio
Branch: master
Commit: 19d25bacb8d15473e0e9f11a50484ba669430e0c
URL:
https://github.com/kamailio/kamailio/commit/19d25bacb8d15473e0e9f11a50484ba…
Author: Alex Hermann <alex(a)hexla.nl>
Committer: Alex Hermann <alex(a)hexla.nl>
Date: 2019-01-31T19:08:28+01:00
htable: Add RPC htable.flush <htable>
Empties the entire specified hash table
---
Modified: src/modules/htable/doc/htable_admin.xml
Modified: src/modules/htable/htable.c
---
Diff:
https://github.com/kamailio/kamailio/commit/19d25bacb8d15473e0e9f11a50484ba…
Patch:
https://github.com/kamailio/kamailio/commit/19d25bacb8d15473e0e9f11a50484ba…
---
diff --git a/src/modules/htable/doc/htable_admin.xml
b/src/modules/htable/doc/htable_admin.xml
index 708973a045..859f7787ca 100644
--- a/src/modules/htable/doc/htable_admin.xml
+++ b/src/modules/htable/doc/htable_admin.xml
@@ -1390,6 +1390,29 @@ kamcmd htable.dump ipban
...
kamcmd htable.reload ipban
...
+</programlisting>
+ </section>
+ <section id="htable.rpc.flush">
+ <title>
+ <function moreinfo="none">htable.flush
htable</function>
+ </title>
+ <para>
+ Empty the hash table
+ </para>
+ <para>
+ Name: <emphasis>htable.flush</emphasis>
+ </para>
+ <para>Parameters:</para>
+ <itemizedlist>
+ <listitem><para>htable : Name of the hash table to
flush</para></listitem>
+ </itemizedlist>
+ <para>
+ Example:
+ </para>
+<programlisting format="linespecific">
+...
+kamcmd htable.flush ipban
+...
</programlisting>
</section>
<section id="htable.rpc.listTables">
diff --git a/src/modules/htable/htable.c b/src/modules/htable/htable.c
index 1da1ba7928..580e3bc881 100644
--- a/src/modules/htable/htable.c
+++ b/src/modules/htable/htable.c
@@ -1123,6 +1123,10 @@ static const char* htable_stats_doc[2] = {
"Statistics about htables.",
0
};
+static const char* htable_flush_doc[2] = {
+ "Flush hash table.",
+ 0
+};
static const char* htable_reload_doc[2] = {
"Reload hash table.",
0
@@ -1474,6 +1478,25 @@ static void htable_rpc_stats(rpc_t* rpc, void* c)
return;
}
+/*! \brief RPC htable.flush command to empty a hash table */
+static void htable_rpc_flush(rpc_t* rpc, void* c)
+{
+ str htname;
+ ht_t *ht;
+
+ if (rpc->scan(c, "S", &htname) < 1)
+ {
+ rpc->fault(c, 500, "No htable name given");
+ return;
+ }
+ ht = ht_get_table(&htname);
+ if(ht==NULL)
+ {
+ rpc->fault(c, 500, "No such htable");
+ return;
+ }
+ ht_reset_content(ht);
+}
/*! \brief RPC htable.reload command to reload content of a hash table */
static void htable_rpc_reload(rpc_t* rpc, void* c)
@@ -1583,6 +1606,7 @@ rpc_export_t htable_rpc[] = {
{"htable.listTables", htable_rpc_list, htable_list_doc, RET_ARRAY},
{"htable.reload", htable_rpc_reload, htable_reload_doc, 0},
{"htable.stats", htable_rpc_stats, htable_stats_doc, RET_ARRAY},
+ {"htable.flush", htable_rpc_flush, htable_flush_doc, 0},
{0, 0, 0, 0}
};