Sfoglia il codice sorgente

Merge pull request #2544 from lbalaceanu/master

Renaming userblacklist to userblocklist
Lucian Balaceanu 4 anni fa
parent
commit
7563a52eab
34 ha cambiato i file con 1191 aggiunte e 786 eliminazioni
  1. 1 1
      src/Makefile.groups
  2. 9 9
      src/lib/srdb1/schema/globalblocklist.xml
  3. 2 2
      src/lib/srdb1/schema/kamailio-userblocklist.xml
  4. 11 11
      src/lib/srdb1/schema/userblocklist.xml
  5. 0 116
      src/modules/userblacklist/db_userblacklist.c
  6. 0 100
      src/modules/userblacklist/db_userblacklist.h
  7. 1 1
      src/modules/userblocklist/Makefile
  8. 174 174
      src/modules/userblocklist/README
  9. 19 19
      src/modules/userblocklist/db.c
  10. 5 5
      src/modules/userblocklist/db.h
  11. 116 0
      src/modules/userblocklist/db_userblocklist.c
  12. 100 0
      src/modules/userblocklist/db_userblocklist.h
  13. 1 1
      src/modules/userblocklist/doc/Makefile
  14. 2 2
      src/modules/userblocklist/doc/userblocklist.xml
  15. 135 135
      src/modules/userblocklist/doc/userblocklist_admin.xml
  16. 202 202
      src/modules/userblocklist/userblocklist.c
  17. 12 0
      utils/kamctl/db_berkeley/kamailio/globalblocklist
  18. 12 0
      utils/kamctl/db_berkeley/kamailio/userblocklist
  19. 4 4
      utils/kamctl/db_berkeley/kamailio/version
  20. 2 0
      utils/kamctl/db_redis/kamailio/globalblocklist
  21. 2 0
      utils/kamctl/db_redis/kamailio/userblocklist
  22. 23 0
      utils/kamctl/db_sqlite/userblocklist-create.sql
  23. 2 0
      utils/kamctl/dbtext/kamailio/globalblocklist
  24. 2 0
      utils/kamctl/dbtext/kamailio/userblocklist
  25. 2 2
      utils/kamctl/dbtext/kamailio/version
  26. 2 2
      utils/kamctl/kamdbctl.base
  27. 26 0
      utils/kamctl/mongodb/kamailio/globalblocklist.json
  28. 31 0
      utils/kamctl/mongodb/kamailio/userblocklist.json
  29. 23 0
      utils/kamctl/mysql/userblocklist-create.sql
  30. 39 0
      utils/kamctl/oracle/userblocklist-create.sql
  31. 23 0
      utils/kamctl/postgres/userblocklist-create.sql
  32. 104 0
      utils/kamctl/xhttp_pi/pi_framework.xml
  33. 85 0
      utils/kamctl/xhttp_pi/userblocklist-mod
  34. 19 0
      utils/kamctl/xhttp_pi/userblocklist-table

+ 1 - 1
src/Makefile.groups

@@ -30,7 +30,7 @@ mod_list_db=acc alias_db auth_db avpops cfg_db db_text db_flatstore \
 			  db_cluster dialog dispatcher domain drouting group \
 			  htable imc matrix mohqueue msilo mtree p_usrloc pdt permissions \
 			  pipelimit prefix_route registrar sipcapture siptrace speeddial \
-			  sqlops uac uri_db userblacklist usrloc secfilter
+			  sqlops uac uri_db userblocklist usrloc secfilter
 
 
 # - common modules depending on database, using UID db schema

+ 9 - 9
src/lib/srdb1/schema/globalblacklist.xml → src/lib/srdb1/schema/globalblocklist.xml

@@ -7,16 +7,16 @@
 
 ]>
 
-<table id="globalblacklist" xmlns:db="http://docbook.org/ns/docbook">
-    <name>globalblacklist</name>
+<table id="globalblocklist" xmlns:db="http://docbook.org/ns/docbook">
+    <name>globalblocklist</name>
     <version>1</version>
     <type db="mysql">&MYSQL_TABLE_TYPE;</type>
     <description>
-		<db:para>This table is used by the userblacklist module for the global
-			blacklists. More information is available at:
+		<db:para>This table is used by the userblocklist module for the global
+			blocklists. More information is available at:
 			<itemizedlist>
 			<listitem>
-			<ulink url="&KAMAILIO_MOD_DOC;userblacklist.html">&KAMAILIO_MOD_DOC;userblacklist.html</ulink>.
+			<ulink url="&KAMAILIO_MOD_DOC;userblocklist.html">&KAMAILIO_MOD_DOC;userblocklist.html</ulink>.
 			</listitem>
 			</itemizedlist>
         </db:para>
@@ -37,15 +37,15 @@
         <type>string</type>
         <size>&user_len;</size>
         <default/>
-        <description>The prefix that is matched for the blacklist.</description>
+        <description>The prefix that is matched for the blocklist.</description>
     </column>
 
     <column>
-        <name>whitelist</name>
+        <name>allowlist</name>
         <type>char</type>
         <size>1</size>
         <default>0</default>
-        <description>Specify if this a blacklist (0) or a whitelist (1) entry.</description>
+        <description>Specify if this a blocklist (0) or a allowlist (1) entry.</description>
     </column>
 
      <column>
@@ -58,7 +58,7 @@
     </column>
 
     <index>
-        <name>globalblacklist_idx</name>
+        <name>globalblocklist_idx</name>
         <colref linkend="prefix"/>
     </index>
 </table>

+ 2 - 2
src/lib/srdb1/schema/kamailio-userblacklist.xml → src/lib/srdb1/schema/kamailio-userblocklist.xml

@@ -9,6 +9,6 @@
 
 <database xmlns:xi="http://www.w3.org/2001/XInclude">
     <name>USERBLACKLIST Module</name>
-    <xi:include href="userblacklist.xml"/>
-    <xi:include href="globalblacklist.xml"/>
+    <xi:include href="userblocklist.xml"/>
+    <xi:include href="globalblocklist.xml"/>
 </database>

+ 11 - 11
src/lib/srdb1/schema/userblacklist.xml → src/lib/srdb1/schema/userblocklist.xml

@@ -7,17 +7,17 @@
 
 ]>
 
-<table id="userblacklist" xmlns:db="http://docbook.org/ns/docbook">
-    <name>userblacklist</name>
+<table id="userblocklist" xmlns:db="http://docbook.org/ns/docbook">
+    <name>userblocklist</name>
     <version>1</version>
     <type db="mysql">&MYSQL_TABLE_TYPE;</type>
     <description>
 		<db:para>
-			This table is used by the userblacklist module for the user specific
-			blacklists. More information is available at:
+			This table is used by the userblocklist module for the user specific
+			blocklists. More information is available at:
 			<itemizedlist>
 			<listitem>
-			<ulink url="&KAMAILIO_MOD_DOC;userblacklist.html">&KAMAILIO_MOD_DOC;userblacklist.html</ulink>.
+			<ulink url="&KAMAILIO_MOD_DOC;userblocklist.html">&KAMAILIO_MOD_DOC;userblocklist.html</ulink>.
 			</listitem>
 			</itemizedlist>
         </db:para>
@@ -38,7 +38,7 @@
         <type>string</type>
         <size>&user_len;</size>
         <default/>
-        <description>The user that is used for the blacklist lookup.</description>
+        <description>The user that is used for the blocklist lookup.</description>
     </column>
 
     <column id="domain">
@@ -46,7 +46,7 @@
         <type>string</type>
         <size>&domain_len;</size>
         <default/>
-        <description>The domain that is used for the blacklist lookup.</description>
+        <description>The domain that is used for the blocklist lookup.</description>
     </column>
 
     <column id="prefix">
@@ -54,19 +54,19 @@
         <type>string</type>
         <size>&user_len;</size>
         <default/>
-        <description>The prefix that is matched for the blacklist.</description>
+        <description>The prefix that is matched for the blocklist.</description>
     </column>
 
     <column>
-        <name>whitelist</name>
+        <name>allowlist</name>
         <type>char</type>
         <size>1</size>
         <default>0</default>
-        <description>Specify if this a blacklist (0) or a whitelist (1) entry.</description>
+        <description>Specify if this a blocklist (0) or a allowlist (1) entry.</description>
     </column>
 
     <index>
-        <name>userblacklist_idx</name>
+        <name>userblocklist_idx</name>
         <colref linkend="username"/>
         <colref linkend="domain"/>
         <colref linkend="prefix"/>

+ 0 - 116
src/modules/userblacklist/db_userblacklist.c

@@ -1,116 +0,0 @@
-/*!
- * \file
- * \ingroup db
- * \brief Database support for modules.
- *
- * Database support functions for modules.
- *
- * @cond
- * WARNING:
- * This file was autogenerated from the XML source file
- * ../../modules/userblacklist/kamailio-userblacklist.xml.
- * It can be regenerated by running 'make modules' in the db/schema
- * directory of the source code. You need to have xsltproc and
- * docbook-xsl stylesheets installed.
- * ALL CHANGES DONE HERE WILL BE LOST IF THE FILE IS REGENERATED
- * @endcond
- */
-
-#include "db_userblacklist.h"
-
-/* database variables */
-/* TODO assign read-write or read-only URI, introduce a parameter in XML */
-
-//extern str userblacklist_db_url;
-db1_con_t * userblacklist_dbh = NULL;
-db_func_t userblacklist_dbf;
-
-str userblacklist_table = str_init("userblacklist");
-
-/* column names */
-str userblacklist_id_col = str_init("id");
-str userblacklist_username_col = str_init("username");
-str userblacklist_domain_col = str_init("domain");
-str userblacklist_prefix_col = str_init("prefix");
-str userblacklist_whitelist_col = str_init("whitelist");
-
-/* table version */
-const unsigned int userblacklist_version = 1;
-
-str globalblacklist_table = str_init("globalblacklist");
-
-/* column names */
-str globalblacklist_id_col = str_init("id");
-str globalblacklist_prefix_col = str_init("prefix");
-str globalblacklist_whitelist_col = str_init("whitelist");
-str globalblacklist_description_col = str_init("description");
-
-/* table version */
-const unsigned int globalblacklist_version = 1;
-
-
-/*
- * Closes the DB connection.
- */
-void userblacklist_db_close(void) {
-	if (userblacklist_dbh) {
-		userblacklist_dbf.close(userblacklist_dbh);
-		userblacklist_dbh = NULL;
-	}
-}
-
-
-/*!
- * Initialises the DB API, check the table version and closes the connection.
- * This should be called from the mod_init function.
- *
- * \return 0 means ok, -1 means an error occurred.
- */
-int userblacklist_db_init(void) {
-	if (!userblacklist_db_url.s || !userblacklist_db_url.len) {
-		LM_ERR("you have to set the db_url module parameter.\n");
-		return -1;
-	}
-	if (db_bind_mod(&userblacklist_db_url, &userblacklist_dbf) < 0) {
-		LM_ERR("can't bind database module.\n");
-		return -1;
-	}
-	if ((userblacklist_dbh = userblacklist_dbf.init(&userblacklist_db_url)) == NULL) {
-		LM_ERR("can't connect to database.\n");
-		return -1;
-	}
-	if (db_check_table_version(&userblacklist_dbf, userblacklist_dbh,
-			&userblacklist_table, userblacklist_version) < 0) {
-		DB_TABLE_VERSION_ERROR(userblacklist_table);
-		userblacklist_db_close();
-		return -1;
-	}
-	if (db_check_table_version(&userblacklist_dbf, userblacklist_dbh,
-			&globalblacklist_table, globalblacklist_version) < 0) {
-		DB_TABLE_VERSION_ERROR(globalblacklist_table);
-		userblacklist_db_close();
-		return -1;
-	}
-	userblacklist_db_close();
-	return 0;
-}
-
-
-/*!
- * Initialize the DB connection without checking the table version and DB URL.
- * This should be called from child_init. An already existing database
- * connection will be closed, and a new one created.
- *
- * \return 0 means ok, -1 means an error occurred.
- */
-int userblacklist_db_open(void) {
-	if (userblacklist_dbh) {
-		userblacklist_dbf.close(userblacklist_dbh);
-	}
-	if ((userblacklist_dbh = userblacklist_dbf.init(&userblacklist_db_url)) == NULL) {
-		LM_ERR("can't connect to database.\n");
-		return -1;
-	}
-	return 0;
-}
-

+ 0 - 100
src/modules/userblacklist/db_userblacklist.h

@@ -1,100 +0,0 @@
-/*!
- * \file
- * \ingroup db
- * \brief Database support for modules.
- *
- * Database support functions for modules.
- *
- * @cond
- * WARNING:
- * This file was autogenerated from the XML source file
- * ../../modules/userblacklist/kamailio-userblacklist.xml.
- * It can be regenerated by running 'make modules' in the db/schema
- * directory of the source code. You need to have xsltproc and
- * docbook-xsl stylesheets installed.
- * ALL CHANGES DONE HERE WILL BE LOST IF THE FILE IS REGENERATED
- * @endcond
- */
-
-#ifndef db_userblacklist_h
-#define db_userblacklist_h
-
-
-/* necessary includes */
-#include "../../lib/srdb1/db.h"
-#include "../../core/str.h"
-#include "../../core/ut.h"
-
-#include <string.h>
-
-
-/* database variables */
-
-extern str userblacklist_db_url;
-extern db1_con_t * userblacklist_dbh;
-extern db_func_t userblacklist_dbf;
-
-#define userblacklist_DB_URL { "db_url", PARAM_STR, &userblacklist_db_url },
-
-#define userblacklist_DB_TABLE { "userblacklist_table", PARAM_STR, &userblacklist_table },
-
-extern str userblacklist_table;
-
-/* column names */
-extern str userblacklist_id_col;
-extern str userblacklist_username_col;
-extern str userblacklist_domain_col;
-extern str userblacklist_prefix_col;
-extern str userblacklist_whitelist_col;
-#define userblacklist_DB_COLS \
-{ "userblacklist_id_col", PARAM_STR, &userblacklist_id_col }, \
-{ "userblacklist_username_col", PARAM_STR, &userblacklist_username_col }, \
-{ "userblacklist_domain_col", PARAM_STR, &userblacklist_domain_col }, \
-{ "userblacklist_prefix_col", PARAM_STR, &userblacklist_prefix_col }, \
-{ "userblacklist_whitelist_col", PARAM_STR, &userblacklist_whitelist_col }, \
-
-/* table version */
-extern const unsigned int userblacklist_version;
-
-#define globalblacklist_DB_TABLE { "globalblacklist_table", PARAM_STR, &globalblacklist_table },
-
-extern str globalblacklist_table;
-
-/* column names */
-extern str globalblacklist_id_col;
-extern str globalblacklist_prefix_col;
-extern str globalblacklist_whitelist_col;
-extern str globalblacklist_description_col;
-#define globalblacklist_DB_COLS \
-{ "globalblacklist_id_col", PARAM_STR, &globalblacklist_id_col }, \
-{ "globalblacklist_prefix_col", PARAM_STR, &globalblacklist_prefix_col }, \
-{ "globalblacklist_whitelist_col", PARAM_STR, &globalblacklist_whitelist_col }, \
-{ "globalblacklist_description_col", PARAM_STR, &globalblacklist_description_col }, \
-
-/* table version */
-extern const unsigned int globalblacklist_version;
-
-
-/*
- * Closes the DB connection.
- */
-void userblacklist_db_close(void);
-
-/*!
- * Initialises the DB API, check the table version and closes the connection.
- * This should be called from the mod_init function.
- *
- * \return 0 means ok, -1 means an error occurred.
- */
-int userblacklist_db_init(void);
-
-/*!
- * Initialize the DB connection without checking the table version and DB URL.
- * This should be called from child_init. An already existing database
- * connection will be closed, and a new one created.
- *
- * \return 0 means ok, -1 means an error occurred.
- */
-int userblacklist_db_open(void);
-
-#endif

+ 1 - 1
src/modules/userblacklist/Makefile → src/modules/userblocklist/Makefile

@@ -2,7 +2,7 @@
 
 include ../../Makefile.defs
 auto_gen=
-NAME=userblacklist.so
+NAME=userblocklist.so
 LIBS=
 
 SERLIBPATH=../../lib

+ 174 - 174
src/modules/userblacklist/README → src/modules/userblocklist/README

@@ -1,4 +1,4 @@
-userblacklist Module
+userblocklist Module
 
 Edited by
 
@@ -30,40 +30,40 @@ Pawel Kuzak
               3.1. use_domain (integer)
               3.2. match_mode (integer)
               3.3. db_url (String)
-              3.4. userblacklist_table (String)
-              3.5. userblacklist_id_col (string)
-              3.6. userblacklist_username_col (string)
-              3.7. userblacklist_domain_col (string)
-              3.8. userblacklist_prefix_col (string)
-              3.9. userblacklist_whitelist_col (string)
-              3.10. globalblacklist_table (String)
-              3.11. globalblacklist_id_col (string)
-              3.12. globalblacklist_prefix_col (string)
-              3.13. globalblacklist_whitelist_col (string)
-              3.14. globalblacklist_description_col (string)
+              3.4. userblocklist_table (String)
+              3.5. userblocklist_id_col (string)
+              3.6. userblocklist_username_col (string)
+              3.7. userblocklist_domain_col (string)
+              3.8. userblocklist_prefix_col (string)
+              3.9. userblocklist_whitelist_col (string)
+              3.10. globalblocklist_table (String)
+              3.11. globalblocklist_id_col (string)
+              3.12. globalblocklist_prefix_col (string)
+              3.13. globalblocklist_whitelist_col (string)
+              3.14. globalblocklist_description_col (string)
 
         4. Functions
 
-              4.1. check_user_blacklist (string user, string domain,
+              4.1. check_user_blocklist (string user, string domain,
                       string number, string table)
 
               4.2. check_user_whitelist (string user, string domain,
                       string number, string table)
 
-              4.3. check_blacklist ([string table])
+              4.3. check_blocklist ([string table])
               4.4. check_whitelist (string table)
 
         5. RPC Commands
 
-              5.1. userblacklist.reload_blacklist
+              5.1. userblocklist.reload_blocklist
 
         6. MI Commands
 
-              6.1. reload_blacklist
-              6.2. dump_blacklist
-              6.3. check_blacklist prefix
+              6.1. reload_blocklist
+              6.2. dump_blocklist
+              6.3. check_blocklist prefix
               6.4. check_whitelist prefix
-              6.5. check_userblacklist user [domain] prefix
+              6.5. check_userblocklist user [domain] prefix
               6.6. check_userwhitelist user [domain] prefix
 
         7. Installation and Running
@@ -75,30 +75,30 @@ Pawel Kuzak
    1.1. Set use_domain parameter
    1.2. Set match_mode parameter
    1.3. Set db_url parameter
-   1.4. Set userblacklist_table parameter
-   1.5. Set userblacklist_id_col parameter
-   1.6. Set userblacklist_username_col parameter
-   1.7. Set userblacklist_domain_col parameter
-   1.8. Set userblacklist_prefix_col parameter
-   1.9. Set userblacklist_whitelist_col parameter
-   1.10. Set globalblacklist_table parameter
-   1.11. Set globalblacklist_id_col parameter
-   1.12. Set globalblacklist_prefix_col parameter
-   1.13. Set globalblacklist_whitelist_col parameter
-   1.14. Set globalblacklist_description_col parameter
-   1.15. check_user_blacklist usage
+   1.4. Set userblocklist_table parameter
+   1.5. Set userblocklist_id_col parameter
+   1.6. Set userblocklist_username_col parameter
+   1.7. Set userblocklist_domain_col parameter
+   1.8. Set userblocklist_prefix_col parameter
+   1.9. Set userblocklist_whitelist_col parameter
+   1.10. Set globalblocklist_table parameter
+   1.11. Set globalblocklist_id_col parameter
+   1.12. Set globalblocklist_prefix_col parameter
+   1.13. Set globalblocklist_whitelist_col parameter
+   1.14. Set globalblocklist_description_col parameter
+   1.15. check_user_blocklist usage
    1.16. check_user_whitelist usage
-   1.17. check_blacklist usage
+   1.17. check_blocklist usage
    1.18. check_whitelist usage
-   1.19. userblacklist.reload_blacklist usage
-   1.20. reload_blacklist usage
-   1.21. dump_blacklist usage
-   1.22. check_blacklist usage
+   1.19. userblocklist.reload_blocklist usage
+   1.20. reload_blocklist usage
+   1.21. dump_blocklist usage
+   1.22. check_blocklist usage
    1.23. check_whitelist usage
-   1.24. check_userblacklist usage
+   1.24. check_userblocklist usage
    1.25. check_userwhitelist usage
-   1.26. Example database content - globalblacklist table
-   1.27. Example database content - userblacklist table
+   1.26. Example database content - globalblocklist table
+   1.27. Example database content - userblocklist table
 
 Chapter 1. Admin Guide
 
@@ -115,40 +115,40 @@ Chapter 1. Admin Guide
         3.1. use_domain (integer)
         3.2. match_mode (integer)
         3.3. db_url (String)
-        3.4. userblacklist_table (String)
-        3.5. userblacklist_id_col (string)
-        3.6. userblacklist_username_col (string)
-        3.7. userblacklist_domain_col (string)
-        3.8. userblacklist_prefix_col (string)
-        3.9. userblacklist_whitelist_col (string)
-        3.10. globalblacklist_table (String)
-        3.11. globalblacklist_id_col (string)
-        3.12. globalblacklist_prefix_col (string)
-        3.13. globalblacklist_whitelist_col (string)
-        3.14. globalblacklist_description_col (string)
+        3.4. userblocklist_table (String)
+        3.5. userblocklist_id_col (string)
+        3.6. userblocklist_username_col (string)
+        3.7. userblocklist_domain_col (string)
+        3.8. userblocklist_prefix_col (string)
+        3.9. userblocklist_whitelist_col (string)
+        3.10. globalblocklist_table (String)
+        3.11. globalblocklist_id_col (string)
+        3.12. globalblocklist_prefix_col (string)
+        3.13. globalblocklist_whitelist_col (string)
+        3.14. globalblocklist_description_col (string)
 
    4. Functions
 
-        4.1. check_user_blacklist (string user, string domain, string
+        4.1. check_user_blocklist (string user, string domain, string
                 number, string table)
 
         4.2. check_user_whitelist (string user, string domain, string
                 number, string table)
 
-        4.3. check_blacklist ([string table])
+        4.3. check_blocklist ([string table])
         4.4. check_whitelist (string table)
 
    5. RPC Commands
 
-        5.1. userblacklist.reload_blacklist
+        5.1. userblocklist.reload_blocklist
 
    6. MI Commands
 
-        6.1. reload_blacklist
-        6.2. dump_blacklist
-        6.3. check_blacklist prefix
+        6.1. reload_blocklist
+        6.2. dump_blocklist
+        6.3. check_blocklist prefix
         6.4. check_whitelist prefix
-        6.5. check_userblacklist user [domain] prefix
+        6.5. check_userblocklist user [domain] prefix
         6.6. check_userwhitelist user [domain] prefix
 
    7. Installation and Running
@@ -157,25 +157,25 @@ Chapter 1. Admin Guide
 
 1. Overview
 
-   The userblacklist module allows Kamailio to handle blacklists on a per
+   The userblocklist module allows Kamailio to handle blocklists on a per
    user basis. This information is stored in a database table, which is
    queried to decide if the number (more exactly, the request URI user) is
-   blacklisted or not.
+   blocklisted or not.
 
    An additional functionality that this module provides is the ability to
-   handle global blacklists. This lists are loaded on startup into memory,
-   thus providing a better performance than the userblacklist case. These
-   global blacklists are useful to allow only calls to certain
+   handle global blocklists. This lists are loaded on startup into memory,
+   thus providing a better performance than the userblocklist case. These
+   global blocklists are useful to allow only calls to certain
    international destinations, i.e. block all not whitelisted numbers.
-   They could also be used to prevent the blacklisting of important
+   They could also be used to prevent the blocklisting of important
    numbers, as whitelisting is supported too. This is useful for example
    to prevent the customer from blocking emergency call number or service
    hotlines.
 
-   The module exports four functions, check_blacklist, check_whitelist,
-   check_user_blacklist and check_user_whitelist for usage in the
+   The module exports four functions, check_blocklist, check_whitelist,
+   check_user_blocklist and check_user_whitelist for usage in the
    configuration file. Furthermore it provides a MI function to reload the
-   global blacklist cache.
+   global blocklist cache.
 
    Please note that only numerical strings for matching are supported at
    the moment (the used library supports this already, but its not yet
@@ -205,28 +205,28 @@ Chapter 1. Admin Guide
    3.1. use_domain (integer)
    3.2. match_mode (integer)
    3.3. db_url (String)
-   3.4. userblacklist_table (String)
-   3.5. userblacklist_id_col (string)
-   3.6. userblacklist_username_col (string)
-   3.7. userblacklist_domain_col (string)
-   3.8. userblacklist_prefix_col (string)
-   3.9. userblacklist_whitelist_col (string)
-   3.10. globalblacklist_table (String)
-   3.11. globalblacklist_id_col (string)
-   3.12. globalblacklist_prefix_col (string)
-   3.13. globalblacklist_whitelist_col (string)
-   3.14. globalblacklist_description_col (string)
+   3.4. userblocklist_table (String)
+   3.5. userblocklist_id_col (string)
+   3.6. userblocklist_username_col (string)
+   3.7. userblocklist_domain_col (string)
+   3.8. userblocklist_prefix_col (string)
+   3.9. userblocklist_whitelist_col (string)
+   3.10. globalblocklist_table (String)
+   3.11. globalblocklist_id_col (string)
+   3.12. globalblocklist_prefix_col (string)
+   3.13. globalblocklist_whitelist_col (string)
+   3.14. globalblocklist_description_col (string)
 
 3.1. use_domain (integer)
 
-   If set to non-zero value, the domain column in the userblacklist table
+   If set to non-zero value, the domain column in the userblocklist table
    is used.
 
    Default value is “0”.
 
    Example 1.1. Set use_domain parameter
 ...
-modparam("userblacklist", "use_domain", 1)
+modparam("userblocklist", "use_domain", 1)
 ...
 
 3.2. match_mode (integer)
@@ -242,7 +242,7 @@ modparam("userblacklist", "use_domain", 1)
 
    Example 1.2. Set match_mode parameter
 ...
-modparam("userblacklist", "match_mode", 128)
+modparam("userblocklist", "match_mode", 128)
 ...
 
 3.3. db_url (String)
@@ -253,127 +253,127 @@ modparam("userblacklist", "match_mode", 128)
 
    Example 1.3. Set db_url parameter
 ...
-modparam("userblacklist", "db_url", "dbdriver://username:password@dbhost/dbname"
+modparam("userblocklist", "db_url", "dbdriver://username:password@dbhost/dbname"
 )
 ...
 
-3.4. userblacklist_table (String)
+3.4. userblocklist_table (String)
 
-   Name of the userblacklist table for the userblacklist module.
+   Name of the userblocklist table for the userblocklist module.
 
-   Default value is “userblacklist”.
+   Default value is “userblocklist”.
 
-   Example 1.4. Set userblacklist_table parameter
+   Example 1.4. Set userblocklist_table parameter
 ...
-modparam("userblacklist", "userblacklist_table", "userblacklist")
+modparam("userblocklist", "userblocklist_table", "userblocklist")
 ...
 
-3.5. userblacklist_id_col (string)
+3.5. userblocklist_id_col (string)
 
    unique ID
 
-   Example 1.5. Set userblacklist_id_col parameter
+   Example 1.5. Set userblocklist_id_col parameter
 ...
-modparam("userblacklist", "userblacklist_id_col", "id")
+modparam("userblocklist", "userblocklist_id_col", "id")
 ...
 
-3.6. userblacklist_username_col (string)
+3.6. userblocklist_username_col (string)
 
-   The user that is used for the blacklist lookup.
+   The user that is used for the blocklist lookup.
 
-   Example 1.6. Set userblacklist_username_col parameter
+   Example 1.6. Set userblocklist_username_col parameter
 ...
-modparam("userblacklist", "userblacklist_username_col", "username")
+modparam("userblocklist", "userblocklist_username_col", "username")
 ...
 
-3.7. userblacklist_domain_col (string)
+3.7. userblocklist_domain_col (string)
 
-   The domain that is used for the blacklist lookup.
+   The domain that is used for the blocklist lookup.
 
-   Example 1.7. Set userblacklist_domain_col parameter
+   Example 1.7. Set userblocklist_domain_col parameter
 ...
-modparam("userblacklist", "userblacklist_domain_col", "domain")
+modparam("userblocklist", "userblocklist_domain_col", "domain")
 ...
 
-3.8. userblacklist_prefix_col (string)
+3.8. userblocklist_prefix_col (string)
 
-   The prefix that is matched for the blacklist.
+   The prefix that is matched for the blocklist.
 
-   Example 1.8. Set userblacklist_prefix_col parameter
+   Example 1.8. Set userblocklist_prefix_col parameter
 ...
-modparam("userblacklist", "userblacklist_prefix_col", "prefix")
+modparam("userblocklist", "userblocklist_prefix_col", "prefix")
 ...
 
-3.9. userblacklist_whitelist_col (string)
+3.9. userblocklist_whitelist_col (string)
 
-   Specify if this a blacklist (0) or a whitelist (1) entry.
+   Specify if this a blocklist (0) or a whitelist (1) entry.
 
-   Example 1.9. Set userblacklist_whitelist_col parameter
+   Example 1.9. Set userblocklist_whitelist_col parameter
 ...
-modparam("userblacklist", "userblacklist_whitelist_col", "whitelist")
+modparam("userblocklist", "userblocklist_whitelist_col", "whitelist")
 ...
 
-3.10. globalblacklist_table (String)
+3.10. globalblocklist_table (String)
 
-   Name of the globalblacklist table for the userblacklist module. Please
-   note that this table is used when the check_blacklist function is
+   Name of the globalblocklist table for the userblocklist module. Please
+   note that this table is used when the check_blocklist function is
    called with no parameters.
 
-   Default value is “globalblacklist”.
+   Default value is “globalblocklist”.
 
-   Example 1.10. Set globalblacklist_table parameter
+   Example 1.10. Set globalblocklist_table parameter
 ...
-modparam("userblacklist", "globalblacklist_table", "globalblacklist")
+modparam("userblocklist", "globalblocklist_table", "globalblocklist")
 ...
 
-3.11. globalblacklist_id_col (string)
+3.11. globalblocklist_id_col (string)
 
    unique ID
 
-   Example 1.11. Set globalblacklist_id_col parameter
+   Example 1.11. Set globalblocklist_id_col parameter
 ...
-modparam("userblacklist", "globalblacklist_id_col", "id")
+modparam("userblocklist", "globalblocklist_id_col", "id")
 ...
 
-3.12. globalblacklist_prefix_col (string)
+3.12. globalblocklist_prefix_col (string)
 
-   The prefix that is matched for the blacklist.
+   The prefix that is matched for the blocklist.
 
-   Example 1.12. Set globalblacklist_prefix_col parameter
+   Example 1.12. Set globalblocklist_prefix_col parameter
 ...
-modparam("userblacklist", "globalblacklist_prefix_col", "prefix")
+modparam("userblocklist", "globalblocklist_prefix_col", "prefix")
 ...
 
-3.13. globalblacklist_whitelist_col (string)
+3.13. globalblocklist_whitelist_col (string)
 
-   Specify if this a blacklist (0) or a whitelist (1) entry.
+   Specify if this a blocklist (0) or a whitelist (1) entry.
 
-   Example 1.13. Set globalblacklist_whitelist_col parameter
+   Example 1.13. Set globalblocklist_whitelist_col parameter
 ...
-modparam("userblacklist", "globalblacklist_whitelist_col", "whitelist")
+modparam("userblocklist", "globalblocklist_whitelist_col", "whitelist")
 ...
 
-3.14. globalblacklist_description_col (string)
+3.14. globalblocklist_description_col (string)
 
    A comment for the entry.
 
-   Example 1.14. Set globalblacklist_description_col parameter
+   Example 1.14. Set globalblocklist_description_col parameter
 ...
-modparam("userblacklist", "globalblacklist_description_col", "description")
+modparam("userblocklist", "globalblocklist_description_col", "description")
 ...
 
 4. Functions
 
-   4.1. check_user_blacklist (string user, string domain, string number,
+   4.1. check_user_blocklist (string user, string domain, string number,
           string table)
 
    4.2. check_user_whitelist (string user, string domain, string number,
           string table)
 
-   4.3. check_blacklist ([string table])
+   4.3. check_blocklist ([string table])
    4.4. check_whitelist (string table)
 
-4.1.  check_user_blacklist (string user, string domain, string number, string
+4.1.  check_user_blocklist (string user, string domain, string number, string
 table)
 
    Finds the longest prefix that matches the request URI user (or the
@@ -384,11 +384,11 @@ table)
    are optional, the defaults are used if they are omitted. The number
    parameter can be used to check for example against the from URI user.
 
-   Example 1.15. check_user_blacklist usage
+   Example 1.15. check_user_blocklist usage
 ...
 $avp(i:80) = $rU;
 # rewrite the R-URI
-if (!check_user_blacklist("$avp(i:80)", "$avp(i:82)")) {
+if (!check_user_blocklist("$avp(i:80)", "$avp(i:82)")) {
         sl_send_reply("403", "Forbidden");
         exit;
 }
@@ -415,16 +415,16 @@ if (!check_user_whitelist("$avp(i:80)", "$avp(i:82)")) {
 }
 ...
 
-4.3.  check_blacklist ([string table])
+4.3.  check_blocklist ([string table])
 
    Finds the longest prefix that matches the request URI for the given
    table. If a match is found and it is not set to whitelist, false is
    returned. Otherwise, true is returned. If no table is given, then
-   globalblacklist_table is used.
+   globalblocklist_table is used.
 
-   Example 1.17. check_blacklist usage
+   Example 1.17. check_blocklist usage
 ...
-if (!check_blacklist("globalblacklist")) {
+if (!check_blocklist("globalblocklist")) {
         sl_send_reply("403", "Forbidden");
         exit;
 }
@@ -438,7 +438,7 @@ if (!check_blacklist("globalblacklist")) {
 
    Example 1.18. check_whitelist usage
 ...
-if (!check_whitelist("globalblacklist")) {
+if (!check_whitelist("globalblocklist")) {
         sl_send_reply("403", "Forbidden");
         exit;
 }
@@ -446,62 +446,62 @@ if (!check_whitelist("globalblacklist")) {
 
 5. RPC Commands
 
-   5.1. userblacklist.reload_blacklist
+   5.1. userblocklist.reload_blocklist
 
-5.1.  userblacklist.reload_blacklist
+5.1.  userblocklist.reload_blocklist
 
-   Reload the internal global blacklist cache. This is necessary after the
-   database tables for the global blacklist have been changed.
+   Reload the internal global blocklist cache. This is necessary after the
+   database tables for the global blocklist have been changed.
 
-   Example 1.19. userblacklist.reload_blacklist usage
+   Example 1.19. userblocklist.reload_blocklist usage
 ...
-kamcmd userblacklist.reload_blacklist
+kamcmd userblocklist.reload_blocklist
 ...
 
 6. MI Commands
 
-   6.1. reload_blacklist
-   6.2. dump_blacklist
-   6.3. check_blacklist prefix
+   6.1. reload_blocklist
+   6.2. dump_blocklist
+   6.3. check_blocklist prefix
    6.4. check_whitelist prefix
-   6.5. check_userblacklist user [domain] prefix
+   6.5. check_userblocklist user [domain] prefix
    6.6. check_userwhitelist user [domain] prefix
 
-6.1.  reload_blacklist
+6.1.  reload_blocklist
 
-   Reload the internal global blacklist cache. This is necessary after the
-   database tables for the global blacklist have been changed.
+   Reload the internal global blocklist cache. This is necessary after the
+   database tables for the global blocklist have been changed.
 
-   Example 1.20. reload_blacklist usage
+   Example 1.20. reload_blocklist usage
                                         ...
-                                        kamctl fifo reload_blacklist
+                                        kamctl fifo reload_blocklist
                                         ...
 
-6.2.  dump_blacklist
+6.2.  dump_blocklist
 
-   Dumps the default, in memory, global_blacklist content to stdout. Note
-   that a reload_blacklist should be issued before, in order to see the
+   Dumps the default, in memory, global_blocklist content to stdout. Note
+   that a reload_blocklist should be issued before, in order to see the
    latest content of the database.
 
-   Example 1.21. dump_blacklist usage
+   Example 1.21. dump_blocklist usage
                                         ...
-                                        kamctl fifo reload_blacklist
-                                        kamctl fifo dump_blacklist
+                                        kamctl fifo reload_blocklist
+                                        kamctl fifo dump_blocklist
                                         ...
 
-6.3.  check_blacklist prefix
+6.3.  check_blocklist prefix
 
    Searches in the default, in memory, global list. Finds the longest
    prefix that matches the given prefix parameter. Returns true if the
    prefix is found and the whitelist is not set. Returns false otherwise -
    either prefix found and whitelist set or prefix not found. Note that a
-   reload_blacklist should be issued before, in order to check through the
+   reload_blocklist should be issued before, in order to check through the
    latest content of the database.
 
-   Example 1.22. check_blacklist usage
+   Example 1.22. check_blocklist usage
                                         ...
-                                        kamctl fifo reload_blacklist
-                                        kamctl fifo check_blacklist prefix
+                                        kamctl fifo reload_blocklist
+                                        kamctl fifo check_blocklist prefix
                                         ...
 
 6.4.  check_whitelist prefix
@@ -510,16 +510,16 @@ kamcmd userblacklist.reload_blacklist
    prefix that matches the given prefix parameter. Returns true if the
    prefix is found and the whitelist is set. Returns false otherwise -
    either prefix found and whitelist not set or prefix not found. Note
-   that a reload_blacklist should be issued before, in order to check
+   that a reload_blocklist should be issued before, in order to check
    through the latest content of the database.
 
    Example 1.23. check_whitelist usage
                                         ...
-                                        kamctl fifo reload_blacklist
+                                        kamctl fifo reload_blocklist
                                         kamctl fifo check_whitelist prefix
                                         ...
 
-6.5.  check_userblacklist user [domain] prefix
+6.5.  check_userblocklist user [domain] prefix
 
    Searches in the default user list table. Finds the longest prefix for
    the given user@domain that matches the given prefix parameter. Returns
@@ -528,9 +528,9 @@ kamcmd userblacklist.reload_blacklist
    Note that the domain parameter is optional. If not given, the second
    parameter is the considered to be the prefix.
 
-   Example 1.24. check_userblacklist usage
+   Example 1.24. check_userblocklist usage
                                         ...
-                                        kamctl fifo check_userblacklist user [do
+                                        kamctl fifo check_userblocklist user [do
 main] prefix
                                         ...
 
@@ -555,18 +555,18 @@ main] prefix
 
 7.1. Database setup
 
-   Before running Kamailio with the userblacklist module, you have to
-   setup the database table where the module will read the blacklist data.
+   Before running Kamailio with the userblocklist module, you have to
+   setup the database table where the module will read the blocklist data.
    For that, if the table was not created by the installation script or
    you choose to install everything by yourself you can use the
-   userblacklist-create.sql SQL script in the database directories in the
+   userblocklist-create.sql SQL script in the database directories in the
    kamailio/scripts folder as template. Database and table name can be set
    with module parameters so they can be changed, but the name of the
    columns must be as they are in the SQL script. You can also find the
    complete database documentation on the project webpage,
    https://www.kamailio.org/docs/db-tables/kamailio-db-devel.html.
 
-   Example 1.26. Example database content - globalblacklist table
+   Example 1.26. Example database content - globalblocklist table
 ...
 +----+-----------+-----------+
 | id | prefix    | whitelist |
@@ -578,12 +578,12 @@ main] prefix
 +----+-----------+-----------+
 ...
 
-   This table will setup a global blacklist for all numbers, only allowing
+   This table will setup a global blocklist for all numbers, only allowing
    calls starting with “1”. Numbers that starts with “123456” and
-   “123455787” are also blacklisted, because the longest prefix will be
+   “123455787” are also blocklisted, because the longest prefix will be
    matched.
 
-   Example 1.27. Example database content - userblacklist table
+   Example 1.27. Example database content - userblocklist table
 ...
 +----+----------------+-------------+-----------+-----------+
 | id | username       | domain      | prefix    | whitelist |
@@ -598,7 +598,7 @@ main] prefix
 +----+----------------+-------------+-----------+-----------+
 ...
 
-   This table will setup user specific blacklists for certain usernames.
+   This table will setup user specific blocklists for certain usernames.
    For example for user “49721123456788” the prefix “1234” will be not
    allowed, but the number “123456788” is allowed. Additionally a domain
    could be specified that is used for username matching if the

+ 19 - 19
src/modules/userblacklist/db.c → src/modules/userblocklist/db.c

@@ -20,13 +20,13 @@
 
 /*!
  * \file
- * \brief USERBLACKLIST :: database access
- * \ingroup userblacklist
- * - Module: \ref userblacklist
+ * \brief USERBLOCKLIST :: database access
+ * \ingroup userblocklist
+ * - Module: \ref userblocklist
  */
 
 #include "db.h"
-#include "db_userblacklist.h"
+#include "db_userblocklist.h"
 
 #include "../../lib/srdb1/db.h"
 #include "../../core/mem/mem.h"
@@ -45,8 +45,8 @@ extern int match_mode;
 int db_build_userbl_tree(const str *username, const str *domain,
 		const str *dbtable, struct dtrie_node_t *root, int use_domain)
 {
-	db_key_t columns[2] = { &userblacklist_prefix_col, &userblacklist_whitelist_col };
-	db_key_t key[2] = { &userblacklist_username_col, &userblacklist_domain_col };
+	db_key_t columns[2] = { &userblocklist_prefix_col, &userblocklist_allowlist_col };
+	db_key_t key[2] = { &userblocklist_username_col, &userblocklist_domain_col };
 
 	db_val_t val[2];
 	db1_res_t *res;
@@ -60,11 +60,11 @@ int db_build_userbl_tree(const str *username, const str *domain,
 	VAL_STR(val + 1).s = domain->s;
 	VAL_STR(val + 1).len = domain->len;
 
-	if (userblacklist_dbf.use_table(userblacklist_dbh, dbtable) < 0) {
+	if (userblocklist_dbf.use_table(userblocklist_dbh, dbtable) < 0) {
 		LM_ERR("cannot use db table '%.*s'.\n", dbtable->len, dbtable->s);
 		return -1;
 	}
-	if (userblacklist_dbf.query(userblacklist_dbh, key, 0, val, columns,
+	if (userblocklist_dbf.query(userblocklist_dbh, key, 0, val, columns,
 				(!use_domain) ? (1) : (2), 2, 0, &res) < 0) {
 		LM_ERR("error while executing query on db table '%.*s'\n",
 				dbtable->len, dbtable->s);
@@ -79,13 +79,13 @@ int db_build_userbl_tree(const str *username, const str *domain,
 				if ((RES_ROWS(res)[i].values[0].type == DB1_STRING) &&
 					(RES_ROWS(res)[i].values[1].type == DB1_INT)) {
 
-					/* LM_DBG("insert into tree prefix %s, whitelist %d",
+					/* LM_DBG("insert into tree prefix %s, allowlist %d",
 						RES_ROWS(res)[i].values[0].val.string_val,
 						RES_ROWS(res)[i].values[1].val.int_val); */
 					if (RES_ROWS(res)[i].values[1].val.int_val == 0) {
-						nodeflags=(void *)MARK_BLACKLIST;
+						nodeflags=(void *)MARK_BLOCKLIST;
 					} else {
-						nodeflags=(void *)MARK_WHITELIST;
+						nodeflags=(void *)MARK_ALLOWLIST;
 					}
 
 					if (dtrie_insert(root, RES_ROWS(res)[i].values[0].val.string_val,
@@ -101,7 +101,7 @@ int db_build_userbl_tree(const str *username, const str *domain,
 			}
 		}
 	}
-	userblacklist_dbf.free_result(userblacklist_dbh, res);
+	userblocklist_dbf.free_result(userblocklist_dbh, res);
 
 	return n;
 }
@@ -113,17 +113,17 @@ int db_build_userbl_tree(const str *username, const str *domain,
  */
 int db_reload_source(const str *dbtable, struct dtrie_node_t *root)
 {
-	db_key_t columns[2] = { &globalblacklist_prefix_col, &globalblacklist_whitelist_col };
+	db_key_t columns[2] = { &globalblocklist_prefix_col, &globalblocklist_allowlist_col };
 	db1_res_t *res;
 	int i;
 	int n = 0;
 	void *nodeflags;
 
-	if (userblacklist_dbf.use_table(userblacklist_dbh, dbtable) < 0) {
+	if (userblocklist_dbf.use_table(userblocklist_dbh, dbtable) < 0) {
 		LM_ERR("cannot use db table '%.*s'\n", dbtable->len, dbtable->s);
 		return -1;
 	}
-	if (userblacklist_dbf.query(userblacklist_dbh, NULL, NULL, NULL,
+	if (userblocklist_dbf.query(userblocklist_dbh, NULL, NULL, NULL,
 				columns, 0, 2, NULL, &res) < 0) {
 		LM_ERR("error while executing query on db table '%.*s'\n",
 				dbtable->len, dbtable->s);
@@ -138,13 +138,13 @@ int db_reload_source(const str *dbtable, struct dtrie_node_t *root)
 				if ((RES_ROWS(res)[i].values[0].type == DB1_STRING) &&
 					(RES_ROWS(res)[i].values[1].type == DB1_INT)) {
 
-					/* LM_DBG("insert into tree prefix %s, whitelist %d",
+					/* LM_DBG("insert into tree prefix %s, allowlist %d",
 						RES_ROWS(res)[i].values[0].val.string_val,
 						RES_ROWS(res)[i].values[1].val.int_val); */
 					if (RES_ROWS(res)[i].values[1].val.int_val == 0) {
-						nodeflags=(void *)MARK_BLACKLIST;
+						nodeflags=(void *)MARK_BLOCKLIST;
 					} else {
-						nodeflags=(void *)MARK_WHITELIST;
+						nodeflags=(void *)MARK_ALLOWLIST;
 					}
 
 					if (dtrie_insert(root, RES_ROWS(res)[i].values[0].val.string_val,
@@ -160,7 +160,7 @@ int db_reload_source(const str *dbtable, struct dtrie_node_t *root)
 			}
 		}
 	}
-	userblacklist_dbf.free_result(userblacklist_dbh, res);
+	userblocklist_dbf.free_result(userblocklist_dbh, res);
 
 	return n;
 }

+ 5 - 5
src/modules/userblacklist/db.h → src/modules/userblocklist/db.h

@@ -20,9 +20,9 @@
 
 /*!
  * \file
- * \brief USERBLACKLIST :: database access
- * \ingroup userblacklist
- * - Module: \ref userblacklist
+ * \brief USERBLOCKLIST :: database access
+ * \ingroup userblocklist
+ * - Module: \ref userblocklist
  */
 
 #ifndef _DB_H_
@@ -31,8 +31,8 @@
 #include "../../core/sr_module.h"
 #include "../../lib/trie/dtrie.h"
 
-#define MARK_WHITELIST 1
-#define MARK_BLACKLIST 2
+#define MARK_ALLOWLIST 1
+#define MARK_BLOCKLIST 2
 
 int db_build_userbl_tree(const str *user, const str *domain, const str *table, struct dtrie_node_t *root, int use_domain);
 int db_reload_source(const str *table, struct dtrie_node_t *root);

+ 116 - 0
src/modules/userblocklist/db_userblocklist.c

@@ -0,0 +1,116 @@
+/*!
+ * \file
+ * \ingroup db
+ * \brief Database support for modules.
+ *
+ * Database support functions for modules.
+ *
+ * @cond
+ * WARNING:
+ * This file was autogenerated from the XML source file
+ * ../../modules/userblocklist/kamailio-userblocklist.xml.
+ * It can be regenerated by running 'make modules' in the db/schema
+ * directory of the source code. You need to have xsltproc and
+ * docbook-xsl stylesheets installed.
+ * ALL CHANGES DONE HERE WILL BE LOST IF THE FILE IS REGENERATED
+ * @endcond
+ */
+
+#include "db_userblocklist.h"
+
+/* database variables */
+/* TODO assign read-write or read-only URI, introduce a parameter in XML */
+
+//extern str userblocklist_db_url;
+db1_con_t * userblocklist_dbh = NULL;
+db_func_t userblocklist_dbf;
+
+str userblocklist_table = str_init("userblocklist");
+
+/* column names */
+str userblocklist_id_col = str_init("id");
+str userblocklist_username_col = str_init("username");
+str userblocklist_domain_col = str_init("domain");
+str userblocklist_prefix_col = str_init("prefix");
+str userblocklist_allowlist_col = str_init("allowlist");
+
+/* table version */
+const unsigned int userblocklist_version = 1;
+
+str globalblocklist_table = str_init("globalblocklist");
+
+/* column names */
+str globalblocklist_id_col = str_init("id");
+str globalblocklist_prefix_col = str_init("prefix");
+str globalblocklist_allowlist_col = str_init("allowlist");
+str globalblocklist_description_col = str_init("description");
+
+/* table version */
+const unsigned int globalblocklist_version = 1;
+
+
+/*
+ * Closes the DB connection.
+ */
+void userblocklist_db_close(void) {
+	if (userblocklist_dbh) {
+		userblocklist_dbf.close(userblocklist_dbh);
+		userblocklist_dbh = NULL;
+	}
+}
+
+
+/*!
+ * Initialises the DB API, check the table version and closes the connection.
+ * This should be called from the mod_init function.
+ *
+ * \return 0 means ok, -1 means an error occurred.
+ */
+int userblocklist_db_init(void) {
+	if (!userblocklist_db_url.s || !userblocklist_db_url.len) {
+		LM_ERR("you have to set the db_url module parameter.\n");
+		return -1;
+	}
+	if (db_bind_mod(&userblocklist_db_url, &userblocklist_dbf) < 0) {
+		LM_ERR("can't bind database module.\n");
+		return -1;
+	}
+	if ((userblocklist_dbh = userblocklist_dbf.init(&userblocklist_db_url)) == NULL) {
+		LM_ERR("can't connect to database.\n");
+		return -1;
+	}
+	if (db_check_table_version(&userblocklist_dbf, userblocklist_dbh,
+			&userblocklist_table, userblocklist_version) < 0) {
+		DB_TABLE_VERSION_ERROR(userblocklist_table);
+		userblocklist_db_close();
+		return -1;
+	}
+	if (db_check_table_version(&userblocklist_dbf, userblocklist_dbh,
+			&globalblocklist_table, globalblocklist_version) < 0) {
+		DB_TABLE_VERSION_ERROR(globalblocklist_table);
+		userblocklist_db_close();
+		return -1;
+	}
+	userblocklist_db_close();
+	return 0;
+}
+
+
+/*!
+ * Initialize the DB connection without checking the table version and DB URL.
+ * This should be called from child_init. An already existing database
+ * connection will be closed, and a new one created.
+ *
+ * \return 0 means ok, -1 means an error occurred.
+ */
+int userblocklist_db_open(void) {
+	if (userblocklist_dbh) {
+		userblocklist_dbf.close(userblocklist_dbh);
+	}
+	if ((userblocklist_dbh = userblocklist_dbf.init(&userblocklist_db_url)) == NULL) {
+		LM_ERR("can't connect to database.\n");
+		return -1;
+	}
+	return 0;
+}
+

+ 100 - 0
src/modules/userblocklist/db_userblocklist.h

@@ -0,0 +1,100 @@
+/*!
+ * \file
+ * \ingroup db
+ * \brief Database support for modules.
+ *
+ * Database support functions for modules.
+ *
+ * @cond
+ * WARNING:
+ * This file was autogenerated from the XML source file
+ * ../../modules/userblocklist/kamailio-userblocklist.xml.
+ * It can be regenerated by running 'make modules' in the db/schema
+ * directory of the source code. You need to have xsltproc and
+ * docbook-xsl stylesheets installed.
+ * ALL CHANGES DONE HERE WILL BE LOST IF THE FILE IS REGENERATED
+ * @endcond
+ */
+
+#ifndef db_userblocklist_h
+#define db_userblocklist_h
+
+
+/* necessary includes */
+#include "../../lib/srdb1/db.h"
+#include "../../core/str.h"
+#include "../../core/ut.h"
+
+#include <string.h>
+
+
+/* database variables */
+
+extern str userblocklist_db_url;
+extern db1_con_t * userblocklist_dbh;
+extern db_func_t userblocklist_dbf;
+
+#define userblocklist_DB_URL { "db_url", PARAM_STR, &userblocklist_db_url },
+
+#define userblocklist_DB_TABLE { "userblocklist_table", PARAM_STR, &userblocklist_table },
+
+extern str userblocklist_table;
+
+/* column names */
+extern str userblocklist_id_col;
+extern str userblocklist_username_col;
+extern str userblocklist_domain_col;
+extern str userblocklist_prefix_col;
+extern str userblocklist_allowlist_col;
+#define userblocklist_DB_COLS \
+{ "userblocklist_id_col", PARAM_STR, &userblocklist_id_col }, \
+{ "userblocklist_username_col", PARAM_STR, &userblocklist_username_col }, \
+{ "userblocklist_domain_col", PARAM_STR, &userblocklist_domain_col }, \
+{ "userblocklist_prefix_col", PARAM_STR, &userblocklist_prefix_col }, \
+{ "userblocklist_allowlist_col", PARAM_STR, &userblocklist_allowlist_col }, \
+
+/* table version */
+extern const unsigned int userblocklist_version;
+
+#define globalblocklist_DB_TABLE { "globalblocklist_table", PARAM_STR, &globalblocklist_table },
+
+extern str globalblocklist_table;
+
+/* column names */
+extern str globalblocklist_id_col;
+extern str globalblocklist_prefix_col;
+extern str globalblocklist_allowlist_col;
+extern str globalblocklist_description_col;
+#define globalblocklist_DB_COLS \
+{ "globalblocklist_id_col", PARAM_STR, &globalblocklist_id_col }, \
+{ "globalblocklist_prefix_col", PARAM_STR, &globalblocklist_prefix_col }, \
+{ "globalblocklist_allowlist_col", PARAM_STR, &globalblocklist_allowlist_col }, \
+{ "globalblocklist_description_col", PARAM_STR, &globalblocklist_description_col }, \
+
+/* table version */
+extern const unsigned int globalblocklist_version;
+
+
+/*
+ * Closes the DB connection.
+ */
+void userblocklist_db_close(void);
+
+/*!
+ * Initialises the DB API, check the table version and closes the connection.
+ * This should be called from the mod_init function.
+ *
+ * \return 0 means ok, -1 means an error occurred.
+ */
+int userblocklist_db_init(void);
+
+/*!
+ * Initialize the DB connection without checking the table version and DB URL.
+ * This should be called from child_init. An already existing database
+ * connection will be closed, and a new one created.
+ *
+ * \return 0 means ok, -1 means an error occurred.
+ */
+int userblocklist_db_open(void);
+
+#endif

+ 1 - 1
src/modules/userblacklist/doc/Makefile → src/modules/userblocklist/doc/Makefile

@@ -1,4 +1,4 @@
-docs = userblacklist.xml
+docs = userblocklist.xml
 
 docbook_dir = ../../../../doc/docbook
 include $(docbook_dir)/Makefile.module

+ 2 - 2
src/modules/userblacklist/doc/userblacklist.xml → src/modules/userblocklist/doc/userblocklist.xml

@@ -10,7 +10,7 @@
 
 <book xmlns:xi="http://www.w3.org/2001/XInclude">
 	<bookinfo>
-	<title>userblacklist Module</title>
+	<title>userblocklist Module</title>
 	<authorgroup>
 		<editor>
 		<firstname>Henning</firstname>
@@ -31,6 +31,6 @@
 	</copyright>
 	</bookinfo>
 	<toc></toc>
-	<xi:include href="userblacklist_admin.xml"/>
+	<xi:include href="userblocklist_admin.xml"/>
 	
 </book>

+ 135 - 135
src/modules/userblacklist/doc/userblacklist_admin.xml → src/modules/userblocklist/doc/userblocklist_admin.xml

@@ -13,28 +13,28 @@
 	<section>
 	<title>Overview</title>
 	<para>
-	The userblacklist module allows &kamailio; to handle blacklists
+	The userblocklist module allows &kamailio; to handle blocklists
 	on a per user basis. This information is stored in a database
 	table, which is queried to decide if the number (more exactly,
-	the request URI user) is blacklisted or not.
+	the request URI user) is blocklisted or not.
 	</para>
 	<para>
 	An additional functionality that this module provides is the ability
-	to handle global blacklists. This lists are loaded on startup into
-	memory, thus providing a better performance than the userblacklist
-	case. These global blacklists are useful to allow only calls to certain 
-	international destinations, i.e. block all not whitelisted numbers.
-	They could also be used to prevent the blacklisting of important	
-	numbers, as whitelisting is supported too. This is useful for example
+	to handle global blocklists. This lists are loaded on startup into
+	memory, thus providing a better performance than the userblocklist
+	case. These global blocklists are useful to allow only calls to certain 
+	international destinations, i.e. block all not allowlisted numbers.
+	They could also be used to prevent the blocklisting of important	
+	numbers, as allowlisting is supported too. This is useful for example
 	to prevent the customer from blocking emergency call number or service
 	hotlines.
 	</para>
 	<para>
-	The module exports four functions, <function>check_blacklist</function>,
-	<function>check_whitelist</function>,
-	<function>check_user_blacklist</function> and <function>check_user_whitelist</function>
+	The module exports four functions, <function>check_blocklist</function>,
+	<function>check_allowlist</function>,
+	<function>check_user_blocklist</function> and <function>check_user_allowlist</function>
 	for usage in the configuration file. Furthermore it provides a MI function to
-	reload the global blacklist cache.
+	reload the global blocklist cache.
 	</para>
 	<para>
 	Please note that only numerical strings for matching are supported at the
@@ -76,11 +76,11 @@
 
 	<section  xmlns:xi="http://www.w3.org/2001/XInclude">
 	<title>Parameters</title>
-    	<section id="userblacklist.p.use_domain">
+    	<section id="userblocklist.p.use_domain">
 	    <title><varname>use_domain</varname> (integer)</title>
 	    <para>
 			If set to non-zero value, the domain column in the
-			userblacklist table is used.
+			userblocklist table is used.
 	    </para>
 	    <para>
 		    <emphasis>
@@ -91,12 +91,12 @@
 		    <title>Set <varname>use_domain</varname> parameter</title>
 		    <programlisting format="linespecific">
 ...
-modparam("userblacklist", "use_domain", 1)
+modparam("userblocklist", "use_domain", 1)
 ...
 		    </programlisting>
 	    </example>
     </section>
-    <section id="userblacklist.p.match_mode">
+    <section id="userblocklist.p.match_mode">
     	    <title><varname>match_mode</varname> (integer)</title>
 	    <para>
 		The number of individual characters that are used for matching. 
@@ -115,13 +115,13 @@ modparam("userblacklist", "use_domain", 1)
 		    <title>Set <varname>match_mode</varname> parameter</title>
 		    <programlisting format="linespecific">
 ...
-modparam("userblacklist", "match_mode", 128)
+modparam("userblocklist", "match_mode", 128)
 ...
 		    </programlisting>
 	    </example>
     </section>
     
-  <section id="userblacklist.p.db_url">
+  <section id="userblocklist.p.db_url">
     <title><varname>db_url</varname> (String)</title>
     <para>URL to the database containing the data.</para>
     <para>
@@ -131,148 +131,148 @@ modparam("userblacklist", "match_mode", 128)
       <title>Set <varname>db_url</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "db_url", "dbdriver://username:password@dbhost/dbname")
+modparam("userblocklist", "db_url", "dbdriver://username:password@dbhost/dbname")
 ...
 </programlisting>
     </example>
   </section>
   <section>
-    <title><varname>userblacklist_table</varname> (String)</title>
-    <para>Name of the userblacklist table for the userblacklist module.</para>
+    <title><varname>userblocklist_table</varname> (String)</title>
+    <para>Name of the userblocklist table for the userblocklist module.</para>
     <para>
-      <emphasis>Default value is <quote>userblacklist</quote>.</emphasis>
+      <emphasis>Default value is <quote>userblocklist</quote>.</emphasis>
     </para>
     <example>
-      <title>Set <varname>userblacklist_table</varname> parameter</title>
+      <title>Set <varname>userblocklist_table</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "userblacklist_table", "userblacklist")
+modparam("userblocklist", "userblocklist_table", "userblocklist")
 ...
 </programlisting>
     </example>
   </section>
   <section>
-    <title><varname>userblacklist_id_col</varname> (string)</title>
+    <title><varname>userblocklist_id_col</varname> (string)</title>
     <para>unique ID</para>
     <example>
-      <title>Set <varname>userblacklist_id_col</varname> parameter</title>
+      <title>Set <varname>userblocklist_id_col</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "userblacklist_id_col", "id")
+modparam("userblocklist", "userblocklist_id_col", "id")
 ...
 </programlisting>
     </example>
   </section>
   <section>
-    <title><varname>userblacklist_username_col</varname> (string)</title>
-    <para>The user that is used for the blacklist lookup.</para>
+    <title><varname>userblocklist_username_col</varname> (string)</title>
+    <para>The user that is used for the blocklist lookup.</para>
     <example>
-      <title>Set <varname>userblacklist_username_col</varname> parameter</title>
+      <title>Set <varname>userblocklist_username_col</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "userblacklist_username_col", "username")
+modparam("userblocklist", "userblocklist_username_col", "username")
 ...
 </programlisting>
     </example>
   </section>
   <section>
-    <title><varname>userblacklist_domain_col</varname> (string)</title>
-    <para>The domain that is used for the blacklist lookup.</para>
+    <title><varname>userblocklist_domain_col</varname> (string)</title>
+    <para>The domain that is used for the blocklist lookup.</para>
     <example>
-      <title>Set <varname>userblacklist_domain_col</varname> parameter</title>
+      <title>Set <varname>userblocklist_domain_col</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "userblacklist_domain_col", "domain")
+modparam("userblocklist", "userblocklist_domain_col", "domain")
 ...
 </programlisting>
     </example>
   </section>
   <section>
-    <title><varname>userblacklist_prefix_col</varname> (string)</title>
-    <para>The prefix that is matched for the blacklist.</para>
+    <title><varname>userblocklist_prefix_col</varname> (string)</title>
+    <para>The prefix that is matched for the blocklist.</para>
     <example>
-      <title>Set <varname>userblacklist_prefix_col</varname> parameter</title>
+      <title>Set <varname>userblocklist_prefix_col</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "userblacklist_prefix_col", "prefix")
+modparam("userblocklist", "userblocklist_prefix_col", "prefix")
 ...
 </programlisting>
     </example>
   </section>
   <section>
-    <title><varname>userblacklist_whitelist_col</varname> (string)</title>
-    <para>Specify if this a blacklist (0) or a whitelist (1) entry.</para>
+    <title><varname>userblocklist_allowlist_col</varname> (string)</title>
+    <para>Specify if this a blocklist (0) or a allowlist (1) entry.</para>
     <example>
-      <title>Set <varname>userblacklist_whitelist_col</varname> parameter</title>
+      <title>Set <varname>userblocklist_allowlist_col</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "userblacklist_whitelist_col", "whitelist")
+modparam("userblocklist", "userblocklist_allowlist_col", "allowlist")
 ...
 </programlisting>
     </example>
   </section>
   <section>
-    <title><varname>globalblacklist_table</varname> (String)</title>
-    <para>Name of the globalblacklist table for the userblacklist module.
-    Please note that this table is used when the check_blacklist
+    <title><varname>globalblocklist_table</varname> (String)</title>
+    <para>Name of the globalblocklist table for the userblocklist module.
+    Please note that this table is used when the check_blocklist
 	function is called with no parameters.</para>
     <para>
-      <emphasis>Default value is <quote>globalblacklist</quote>.</emphasis>
+      <emphasis>Default value is <quote>globalblocklist</quote>.</emphasis>
     </para>
     <example>
-      <title>Set <varname>globalblacklist_table</varname> parameter</title>
+      <title>Set <varname>globalblocklist_table</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "globalblacklist_table", "globalblacklist")
+modparam("userblocklist", "globalblocklist_table", "globalblocklist")
 ...
 </programlisting>
     </example>
   </section>
   <section>
-    <title><varname>globalblacklist_id_col</varname> (string)</title>
+    <title><varname>globalblocklist_id_col</varname> (string)</title>
     <para>unique ID</para>
     <example>
-      <title>Set <varname>globalblacklist_id_col</varname> parameter</title>
+      <title>Set <varname>globalblocklist_id_col</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "globalblacklist_id_col", "id")
+modparam("userblocklist", "globalblocklist_id_col", "id")
 ...
 </programlisting>
     </example>
   </section>
   <section>
-    <title><varname>globalblacklist_prefix_col</varname> (string)</title>
-    <para>The prefix that is matched for the blacklist.</para>
+    <title><varname>globalblocklist_prefix_col</varname> (string)</title>
+    <para>The prefix that is matched for the blocklist.</para>
     <example>
-      <title>Set <varname>globalblacklist_prefix_col</varname> parameter</title>
+      <title>Set <varname>globalblocklist_prefix_col</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "globalblacklist_prefix_col", "prefix")
+modparam("userblocklist", "globalblocklist_prefix_col", "prefix")
 ...
 </programlisting>
     </example>
   </section>
   <section>
-    <title><varname>globalblacklist_whitelist_col</varname> (string)</title>
-    <para>Specify if this a blacklist (0) or a whitelist (1) entry.</para>
+    <title><varname>globalblocklist_allowlist_col</varname> (string)</title>
+    <para>Specify if this a blocklist (0) or a allowlist (1) entry.</para>
     <example>
-      <title>Set <varname>globalblacklist_whitelist_col</varname> parameter</title>
+      <title>Set <varname>globalblocklist_allowlist_col</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "globalblacklist_whitelist_col", "whitelist")
+modparam("userblocklist", "globalblocklist_allowlist_col", "allowlist")
 ...
 </programlisting>
     </example>
   </section>
 
   <section>
-    <title><varname>globalblacklist_description_col</varname> (string)</title>
+    <title><varname>globalblocklist_description_col</varname> (string)</title>
     <para>A comment for the entry.</para>
     <example>
-      <title>Set <varname>globalblacklist_description_col</varname> parameter</title>
+      <title>Set <varname>globalblocklist_description_col</varname> parameter</title>
       <programlisting format="linespecific">
 ...
-modparam("userblacklist", "globalblacklist_description_col", "description")
+modparam("userblocklist", "globalblocklist_description_col", "description")
 ...
 </programlisting>
     </example>
@@ -281,27 +281,27 @@ modparam("userblacklist", "globalblacklist_description_col", "description")
 </section>
 <section>
 	<title>Functions</title>
-    	<section id="userblacklist.f.check_user_blacklist">
+    	<section id="userblocklist.f.check_user_blocklist">
 	    <title>
-		<function moreinfo="none">check_user_blacklist
+		<function moreinfo="none">check_user_blocklist
 		(string user, string domain, string number, string table)</function>
 	    </title>
 	    <para>
 		Finds the longest prefix that matches the request URI user (or the number
 		parameter) for the given user and domain name in the database.
-		If a match is found and it is not set to whitelist, false is returned.
+		If a match is found and it is not set to allowlist, false is returned.
 		Otherwise, true is returned. Pseudo-variables or AVPs can be used for
 		the user, domain and number parameters. The number and table variables
 		are optional, the defaults are used if they are omitted. The number
 		parameter can be used to check for example against the from URI user.
 	    </para>
 	<example>
-		<title><function>check_user_blacklist</function> usage</title>
+		<title><function>check_user_blocklist</function> usage</title>
 		<programlisting format="linespecific">
 ...
 $avp(i:80) = $rU;
 # rewrite the R-URI
-if (!check_user_blacklist("$avp(i:80)", "$avp(i:82)")) {
+if (!check_user_blocklist("$avp(i:80)", "$avp(i:82)")) {
 	sl_send_reply("403", "Forbidden");
 	exit;
 }
@@ -309,27 +309,27 @@ if (!check_user_blacklist("$avp(i:80)", "$avp(i:82)")) {
 		</programlisting>
 	    </example>
 	</section>
-    	<section id="userblacklist.f.check_user_whitelist">
+    	<section id="userblocklist.f.check_user_allowlist">
 	    <title>
-		<function moreinfo="none">check_user_whitelist
+		<function moreinfo="none">check_user_allowlist
 		(string user, string domain, string number, string table)</function>
 	    </title>
 	    <para>
 		Finds the longest prefix that matches the request URI user (or the number
 		parameter) for the given user and domain name in the database.
-		If a match is found and it is set to whitelist, true is returned.
+		If a match is found and it is set to allowlist, true is returned.
 		Otherwise, false is returned. Pseudo-variables or AVPs can be used for
 		the user, domain and number parameters. The number and table variables
 		are optional, the defaults are used if they are omitted. The number
 		parameter can be used to check for example against the from URI user.
 	    </para>
 	<example>
-		<title><function>check_user_whitelist</function> usage</title>
+		<title><function>check_user_allowlist</function> usage</title>
 		<programlisting format="linespecific">
 ...
 $avp(i:80) = $rU;
 # rewrite the R-URI
-if (!check_user_whitelist("$avp(i:80)", "$avp(i:82)")) {
+if (!check_user_allowlist("$avp(i:80)", "$avp(i:82)")) {
 	# process request
 	exit;
 }
@@ -337,21 +337,21 @@ if (!check_user_whitelist("$avp(i:80)", "$avp(i:82)")) {
 		</programlisting>
 	    </example>
 	</section>
-    	<section id="userblacklist.f.check_blacklist">
+    	<section id="userblocklist.f.check_blocklist">
 	    <title>
-		<function moreinfo="none">check_blacklist ([string table])</function>
+		<function moreinfo="none">check_blocklist ([string table])</function>
 	    </title>
 	    <para>
 		Finds the longest prefix that matches the request URI for the
-		given table. If a match is found and it is not set to whitelist,
+		given table. If a match is found and it is not set to allowlist,
 		false is returned. Otherwise, true is returned. If no table is given, 
-		then globalblacklist_table is used.
+		then globalblocklist_table is used.
 	    </para>
 	<example>
-		<title><function>check_blacklist</function> usage</title>
+		<title><function>check_blocklist</function> usage</title>
 		<programlisting format="linespecific">
 ...
-if (!check_blacklist("globalblacklist")) {
+if (!check_blocklist("globalblocklist")) {
 	sl_send_reply("403", "Forbidden");
 	exit;
 }
@@ -359,20 +359,20 @@ if (!check_blacklist("globalblacklist")) {
 		</programlisting>
 	    </example>
 	</section>
-    	<section id="userblacklist.f.check_whitelist">
+    	<section id="userblocklist.f.check_allowlist">
 	    <title>
-		<function moreinfo="none">check_whitelist (string table)</function>
+		<function moreinfo="none">check_allowlist (string table)</function>
 	    </title>
 	    <para>
 		Finds the longest prefix that matches the request URI for the
-		given table. If a match is found and it is set to whitelist,
+		given table. If a match is found and it is set to allowlist,
 		true is returned. Otherwise, false is returned.
 	    </para>
 	<example>
-		<title><function>check_whitelist</function> usage</title>
+		<title><function>check_allowlist</function> usage</title>
 		<programlisting format="linespecific">
 ...
-if (!check_whitelist("globalblacklist")) {
+if (!check_allowlist("globalblocklist")) {
 	sl_send_reply("403", "Forbidden");
 	exit;
 }
@@ -384,19 +384,19 @@ if (!check_whitelist("globalblacklist")) {
 
 <section>
 	<title>RPC Commands</title>
-		<section id="userblacklist.r.reload_blacklist">
+		<section id="userblocklist.r.reload_blocklist">
 			<title>
-				<function moreinfo="none">userblacklist.reload_blacklist</function>
+				<function moreinfo="none">userblocklist.reload_blocklist</function>
 			</title>
 			<para>
-				Reload the internal global blacklist cache. This is necessary after
-				the database tables for the global blacklist have been changed.
+				Reload the internal global blocklist cache. This is necessary after
+				the database tables for the global blocklist have been changed.
 			</para>
 			<example>
-				<title><function>userblacklist.reload_blacklist</function> usage</title>
+				<title><function>userblocklist.reload_blocklist</function> usage</title>
 				<programlisting format="linespecific">
 ...
-&kamcmd; userblacklist.reload_blacklist
+&kamcmd; userblocklist.reload_blocklist
 ...
 				</programlisting>
 			</example>
@@ -407,17 +407,17 @@ if (!check_whitelist("globalblacklist")) {
 	<title>MI Commands</title>
 		<section>
 			<title>
-				<function moreinfo="none">reload_blacklist</function>
+				<function moreinfo="none">reload_blocklist</function>
 			</title>
 			<para>
-				Reload the internal global blacklist cache. This is necessary after
-				the database tables for the global blacklist have been changed.
+				Reload the internal global blocklist cache. This is necessary after
+				the database tables for the global blocklist have been changed.
 			</para>
 			<example>
-				<title><function>reload_blacklist</function> usage</title>
+				<title><function>reload_blocklist</function> usage</title>
 				<programlisting format="linespecific">
 					...
-					&ctltool; fifo reload_blacklist
+					&ctltool; fifo reload_blocklist
 					...
 				</programlisting>
 	    		</example>
@@ -425,19 +425,19 @@ if (!check_whitelist("globalblacklist")) {
 
 		<section>
 			<title>
-				<function moreinfo="none">dump_blacklist</function>
+				<function moreinfo="none">dump_blocklist</function>
 			</title>
 			<para>
-				Dumps the default, in memory, global_blacklist content to stdout.
-				Note that a reload_blacklist should be issued before, 
+				Dumps the default, in memory, global_blocklist content to stdout.
+				Note that a reload_blocklist should be issued before, 
 				in order to see the latest content of the database.
 			</para>
 			<example>
-				<title><function>dump_blacklist</function> usage</title>
+				<title><function>dump_blocklist</function> usage</title>
 				<programlisting format="linespecific">
 					...
-					&ctltool; fifo reload_blacklist
-					&ctltool; fifo dump_blacklist
+					&ctltool; fifo reload_blocklist
+					&ctltool; fifo dump_blocklist
 					...
 				</programlisting>
 	    		</example>
@@ -445,22 +445,22 @@ if (!check_whitelist("globalblacklist")) {
 
 		<section>
 			<title>
-				<function moreinfo="none">check_blacklist prefix</function>
+				<function moreinfo="none">check_blocklist prefix</function>
 			</title>
 			<para>
 				Searches in the default, in memory, global list. 
 				Finds the longest prefix that matches the given prefix parameter. 
-				Returns true if the prefix is found and the whitelist is <emphasis>not</emphasis> set. 
-				Returns false otherwise - either prefix found and whitelist set or prefix not found. 
-				Note that a reload_blacklist should be issued before, 
+				Returns true if the prefix is found and the allowlist is <emphasis>not</emphasis> set. 
+				Returns false otherwise - either prefix found and allowlist set or prefix not found. 
+				Note that a reload_blocklist should be issued before, 
 				in order to check through the latest content of the database.
 			</para>
 			<example>
-				<title><function>check_blacklist</function> usage</title>
+				<title><function>check_blocklist</function> usage</title>
 				<programlisting format="linespecific">
 					...
-					&ctltool; fifo reload_blacklist
-					&ctltool; fifo check_blacklist prefix
+					&ctltool; fifo reload_blocklist
+					&ctltool; fifo check_blocklist prefix
 					...
 				</programlisting>
 	    		</example>
@@ -468,23 +468,23 @@ if (!check_whitelist("globalblacklist")) {
 
 		<section>
 			<title>
-				<function moreinfo="none">check_whitelist prefix</function>
+				<function moreinfo="none">check_allowlist prefix</function>
 			</title>
 			<para>
 				Searches in the default, in memory, global list. 
 				Finds the longest prefix that matches the given prefix parameter. 
-				Returns true if the prefix is found and the whitelist is set. 
-				Returns false otherwise - either prefix found and whitelist 
+				Returns true if the prefix is found and the allowlist is set. 
+				Returns false otherwise - either prefix found and allowlist 
 				<emphasis>not</emphasis> set or prefix not found. 
-				Note that a reload_blacklist should be issued before, 
+				Note that a reload_blocklist should be issued before, 
 				in order to check through the latest content of the database.
 			</para>
 			<example>
-				<title><function>check_whitelist</function> usage</title>
+				<title><function>check_allowlist</function> usage</title>
 				<programlisting format="linespecific">
 					...
-					&ctltool; fifo reload_blacklist
-					&ctltool; fifo check_whitelist prefix
+					&ctltool; fifo reload_blocklist
+					&ctltool; fifo check_allowlist prefix
 					...
 				</programlisting>
 	    		</example>
@@ -492,21 +492,21 @@ if (!check_whitelist("globalblacklist")) {
 
 		<section>
 			<title>
-				<function moreinfo="none">check_userblacklist user [domain] prefix</function>
+				<function moreinfo="none">check_userblocklist user [domain] prefix</function>
 			</title>
 			<para>
 				Searches in the default user list table.
 				Finds the longest prefix for the given user@domain that matches the given prefix parameter. 
-				Returns true if the prefix is found and the whitelist is <emphasis>not</emphasis> set. 
-				Returns false otherwise - either prefix found and whitelist set or prefix not found. 
+				Returns true if the prefix is found and the allowlist is <emphasis>not</emphasis> set. 
+				Returns false otherwise - either prefix found and allowlist set or prefix not found. 
 				Note that the domain parameter is optional. 
 				If not given, the second parameter is the considered to be the prefix. 
 			</para>
 			<example>
-				<title><function>check_userblacklist</function> usage</title>
+				<title><function>check_userblocklist</function> usage</title>
 				<programlisting format="linespecific">
 					...
-					&ctltool; fifo check_userblacklist user [domain] prefix
+					&ctltool; fifo check_userblocklist user [domain] prefix
 					...
 				</programlisting>
 	    		</example>
@@ -514,22 +514,22 @@ if (!check_whitelist("globalblacklist")) {
 
 		<section>
 			<title>
-				<function moreinfo="none">check_userwhitelist user [domain] prefix</function>
+				<function moreinfo="none">check_userallowlist user [domain] prefix</function>
 			</title>
 			<para>
 				Searches in the default user list table.
 				Finds the longest prefix for the given user@domain that matches the given prefix parameter. 
-				Returns true if the prefix is found and the whitelist is set. 
-				Returns false otherwise - either prefix found and whitelist 
+				Returns true if the prefix is found and the allowlist is set. 
+				Returns false otherwise - either prefix found and allowlist 
 				<emphasis>not</emphasis> set or prefix not found. 
 				Note that the domain parameter is optional. 
 				If not given, the second parameter is the considered to be the prefix. 
 			</para>
 			<example>
-				<title><function>check_userwhitelist</function> usage</title>
+				<title><function>check_userallowlist</function> usage</title>
 				<programlisting format="linespecific">
 					...
-					&ctltool; fifo check_userwhitelist user [domain] prefix
+					&ctltool; fifo check_userallowlist user [domain] prefix
 					...
 				</programlisting>
 	    		</example>
@@ -541,11 +541,11 @@ if (!check_whitelist("globalblacklist")) {
 	<section>
 		<title>Database setup</title>
 		<para>
-			Before running &kamailio; with the userblacklist module,
+			Before running &kamailio; with the userblocklist module,
 			you have to setup the database table where the module will
-			read the blacklist data. For that, if the table was not created
+			read the blocklist data. For that, if the table was not created
 			by the installation script or you choose to install everything
-			by yourself you can use the <emphasis>userblacklist-create.sql</emphasis>
+			by yourself you can use the <emphasis>userblocklist-create.sql</emphasis>
 			<acronym>SQL</acronym> script in the database directories in the 
 			kamailio/scripts folder as template. 
 			Database and table name can be set with module parameters so they 
@@ -556,11 +556,11 @@ if (!check_whitelist("globalblacklist")) {
 		</para>
 
 	<example>
-		<title>Example database content - globalblacklist table</title>
+		<title>Example database content - globalblocklist table</title>
 		<programlisting format="linespecific">
 ...
 +----+-----------+-----------+
-| id | prefix    | whitelist |
+| id | prefix    | allowlist |
 +----+-----------+-----------+
 |  1 |           |         0 |
 |  2 | 1         |         1 |
@@ -571,18 +571,18 @@ if (!check_whitelist("globalblacklist")) {
 		</programlisting>
 	</example>
 	<para>
-		This table will setup a global blacklist for all numbers, only allowing calls
+		This table will setup a global blocklist for all numbers, only allowing calls
 		starting with <quote>1</quote>. Numbers that starts with <quote>123456</quote>
-		and <quote>123455787</quote> are also blacklisted, because the longest prefix
+		and <quote>123455787</quote> are also blocklisted, because the longest prefix
 		will be matched.
 	</para>
 
 	<example>
-		<title>Example database content - userblacklist table</title>
+		<title>Example database content - userblocklist table</title>
 		<programlisting format="linespecific">
 ...
 +----+----------------+-------------+-----------+-----------+
-| id | username       | domain      | prefix    | whitelist |
+| id | username       | domain      | prefix    | allowlist |
 +----+----------------+-------------+-----------+-----------+
 | 23 | 49721123456788 |             | 1234      |         0 |
 | 22 | 49721123456788 |             | 123456788 |         1 |
@@ -596,7 +596,7 @@ if (!check_whitelist("globalblacklist")) {
 		</programlisting>
 	</example>
 	<para>
-		This table will setup user specific blacklists for certain usernames. For example
+		This table will setup user specific blocklists for certain usernames. For example
 		for user <quote>49721123456788</quote> the prefix <quote>1234</quote> will be not
 		allowed, but the number <quote>123456788</quote> is allowed. Additionally a domain
 		could be specified that is used for username matching if the <quote>use_domain</quote>

+ 202 - 202
src/modules/userblacklist/userblacklist.c → src/modules/userblocklist/userblocklist.c

@@ -20,20 +20,20 @@
 
 /*!
  * \file
- * \brief USERBLACKLIST :: module definitions
- * \ingroup userblacklist
- * - Module: \ref userblacklist
+ * \brief USERBLOCKLIST :: module definitions
+ * \ingroup userblocklist
+ * - Module: \ref userblocklist
  */
 
 /*!
- * \defgroup userblacklist USERBLACKLIST :: The Kamailio userblacklist Module
+ * \defgroup userblocklist USERBLOCKLIST :: The Kamailio userblocklist Module
  *
- * The userblacklist module allows Kamailio to handle blacklists on a per user basis.
+ * The userblocklist module allows Kamailio to handle blocklists on a per user basis.
  * This information is stored in a database table, which is queried to decide if the
- * number (more exactly, the request URI user) is blacklisted or not.
+ * number (more exactly, the request URI user) is blocklisted or not.
  * An additional functionality that this module provides is the ability to handle
- * global blacklists. This lists are loaded on startup into memory, thus providing a
- * better performance then in the userblacklist case.
+ * global blocklists. This lists are loaded on startup into memory, thus providing a
+ * better performance then in the userblocklist case.
  */
 
 #include <string.h>
@@ -52,17 +52,17 @@
 
 #include "../../lib/trie/dtrie.h"
 #include "db.h"
-#include "db_userblacklist.h"
+#include "db_userblocklist.h"
 
 MODULE_VERSION
 
 
 #define MAXNUMBERLEN 31
 
-#define BLACKLISTED_S		"blacklisted"
-#define BLACKLISTED_LEN		(sizeof(BLACKLISTED_S)-1)
-#define WHITELISTED_S		"whitelisted"
-#define WHITELISTED_LEN		(sizeof(WHITELISTED_S)-1)
+#define BLOCKLISTED_S		"blocklisted"
+#define BLOCKLISTED_LEN		(sizeof(BLOCKLISTED_S)-1)
+#define ALLOWLISTED_S		"allowlisted"
+#define ALLOWLISTED_LEN		(sizeof(ALLOWLISTED_S)-1)
 #define TRUE_S			"true"
 #define TRUE_LEN		(sizeof(TRUE_S)-1)
 #define FALSE_S			"false"
@@ -75,34 +75,34 @@ typedef struct _avp_check
 } avp_check_t;
 
 
-struct check_blacklist_fs_t {
+struct check_blocklist_fs_t {
 	struct dtrie_node_t *dtrie_root;
 };
 
-str userblacklist_db_url = str_init(DEFAULT_RODB_URL);
+str userblocklist_db_url = str_init(DEFAULT_RODB_URL);
 int use_domain = 0;
 int match_mode = 10; /* numeric */
 static struct dtrie_node_t *gnode = NULL;
 
 /* ---- fixup functions: */
-static int check_blacklist_fixup(void** param, int param_no);
-static int check_user_blacklist_fixup(void** param, int param_no);
-static int check_globalblacklist_fixup(void** param, int param_no);
+static int check_blocklist_fixup(void** param, int param_no);
+static int check_user_blocklist_fixup(void** param, int param_no);
+static int check_globalblocklist_fixup(void** param, int param_no);
 
 /* ---- exported commands: */
-static int check_user_blacklist(sip_msg_t *msg, char* puser,
+static int check_user_blocklist(sip_msg_t *msg, char* puser,
 		char* pdomain, char* pnumber, char* ptable);
-static int check_user_whitelist(sip_msg_t *msg, char* puser,
+static int check_user_allowlist(sip_msg_t *msg, char* puser,
 		char* pdomain, char* pnumber, char* ptable);
-static int check_user_blacklist2(sip_msg_t *msg, char* puser, char* pdomain);
-static int check_user_whitelist2(sip_msg_t *msg, char* puser, char* pdomain);
-static int check_user_blacklist3(sip_msg_t *msg, char* puser, char* pdomain,
+static int check_user_blocklist2(sip_msg_t *msg, char* puser, char* pdomain);
+static int check_user_allowlist2(sip_msg_t *msg, char* puser, char* pdomain);
+static int check_user_blocklist3(sip_msg_t *msg, char* puser, char* pdomain,
 		char* pnumber);
-static int check_user_whitelist3(sip_msg_t *msg, char* puser, char* pdomain,
+static int check_user_allowlist3(sip_msg_t *msg, char* puser, char* pdomain,
 		char* pnumber);
-static int check_blacklist(sip_msg_t *msg, struct check_blacklist_fs_t *arg1);
-static int check_whitelist(sip_msg_t *msg, struct check_blacklist_fs_t *arg1);
-static int check_globalblacklist(sip_msg_t *msg);
+static int check_blocklist(sip_msg_t *msg, struct check_blocklist_fs_t *arg1);
+static int check_allowlist(sip_msg_t *msg, struct check_blocklist_fs_t *arg1);
+static int check_globalblocklist(sip_msg_t *msg);
 
 
 /* ---- module init functions: */
@@ -112,34 +112,34 @@ static int rpc_child_init(void);
 static void mod_destroy(void);
 
 static cmd_export_t cmds[]={
-	{ "check_user_blacklist", (cmd_function)check_user_blacklist2, 2,
-		check_user_blacklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{ "check_user_whitelist", (cmd_function)check_user_whitelist2, 2,
-		check_user_blacklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{ "check_user_blacklist", (cmd_function)check_user_blacklist3, 3,
-		check_user_blacklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{ "check_user_whitelist", (cmd_function)check_user_whitelist3, 3,
-		check_user_blacklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{ "check_user_blacklist", (cmd_function)check_user_blacklist, 4,
-		check_user_blacklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{ "check_user_whitelist", (cmd_function)check_user_whitelist, 4,
-		check_user_blacklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{ "check_blacklist", (cmd_function)check_blacklist, 1,
-		check_blacklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{ "check_whitelist", (cmd_function)check_whitelist, 1,
-		check_blacklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{ "check_blacklist", (cmd_function)check_globalblacklist, 0,
-		check_globalblacklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{ "check_user_blocklist", (cmd_function)check_user_blocklist2, 2,
+		check_user_blocklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{ "check_user_allowlist", (cmd_function)check_user_allowlist2, 2,
+		check_user_blocklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{ "check_user_blocklist", (cmd_function)check_user_blocklist3, 3,
+		check_user_blocklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{ "check_user_allowlist", (cmd_function)check_user_allowlist3, 3,
+		check_user_blocklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{ "check_user_blocklist", (cmd_function)check_user_blocklist, 4,
+		check_user_blocklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{ "check_user_allowlist", (cmd_function)check_user_allowlist, 4,
+		check_user_blocklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{ "check_blocklist", (cmd_function)check_blocklist, 1,
+		check_blocklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{ "check_allowlist", (cmd_function)check_allowlist, 1,
+		check_blocklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
+	{ "check_blocklist", (cmd_function)check_globalblocklist, 0,
+		check_globalblocklist_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE },
 	{ 0, 0, 0, 0, 0, 0}
 };
 
 
 static param_export_t params[] = {
-	userblacklist_DB_URL
-	userblacklist_DB_TABLE
-	globalblacklist_DB_TABLE
-	userblacklist_DB_COLS
-	globalblacklist_DB_COLS
+	userblocklist_DB_URL
+	userblocklist_DB_TABLE
+	globalblocklist_DB_TABLE
+	userblocklist_DB_COLS
+	globalblocklist_DB_COLS
 	{ "use_domain",      INT_PARAM, &use_domain },
 	{ "match_mode",	     INT_PARAM, &match_mode },
 	{ 0, 0, 0 }
@@ -149,18 +149,18 @@ static param_export_t params[] = {
 #ifdef MI_REMOVED
 /* Exported MI functions */
 static mi_export_t mi_cmds[] = {
-	{ "reload_blacklist", mi_reload_blacklist, MI_NO_INPUT_FLAG, 0, mi_child_init },
-	{ "dump_blacklist", mi_dump_blacklist, MI_NO_INPUT_FLAG, 0, 0},
-	{ "check_blacklist", mi_check_blacklist, 0, 0, 0 },
-	{ "check_whitelist", mi_check_whitelist, 0, 0, 0 },
-	{ "check_userblacklist", mi_check_userblacklist, 0, 0, 0 },
-	{ "check_userwhitelist", mi_check_userwhitelist, 0, 0, 0 },
+	{ "reload_blocklist", mi_reload_blocklist, MI_NO_INPUT_FLAG, 0, mi_child_init },
+	{ "dump_blocklist", mi_dump_blocklist, MI_NO_INPUT_FLAG, 0, 0},
+	{ "check_blocklist", mi_check_blocklist, 0, 0, 0 },
+	{ "check_allowlist", mi_check_allowlist, 0, 0, 0 },
+	{ "check_userblocklist", mi_check_userblocklist, 0, 0, 0 },
+	{ "check_userallowlist", mi_check_userallowlist, 0, 0, 0 },
 	{ 0, 0, 0, 0, 0 }
 };
 #endif
 
 struct module_exports exports= {
-	"userblacklist", /* module name */
+	"userblocklist", /* module name */
 	DEFAULT_DLFLAGS, /* dlopen flags */
 	cmds,            /* cmd (cfg function) exports */
 	params,          /* param exports */
@@ -192,7 +192,7 @@ static struct source_list_t *sources = NULL;
 static struct dtrie_node_t *dtrie_root = NULL;
 
 
-static int check_user_blacklist_fixup(void** param, int param_no)
+static int check_user_blocklist_fixup(void** param, int param_no)
 {
 	if (param_no > 0 && param_no <= 4) {
 		if(strlen((char*)*param) == 0 && param_no != 4) {
@@ -220,8 +220,8 @@ static int ki_check_user_list(sip_msg_t *msg, str* suser, str* sdomain,
 
 	if(stable==NULL || stable->len<=0) {
 		/* use default table name */
-		table.len=userblacklist_table.len;
-		table.s=userblacklist_table.s;
+		table.len=userblocklist_table.len;
+		table.s=userblocklist_table.s;
 	} else {
 		table.len = stable->len;
 		table.s = stable->s;
@@ -265,9 +265,9 @@ static int ki_check_user_list(sip_msg_t *msg, str* suser, str* sdomain,
 
 	nodeflags = dtrie_longest_match(dtrie_root, ptr, strlen(ptr), NULL, match_mode);
 	if (nodeflags) {
-		if (*nodeflags == (void *)MARK_WHITELIST) {
-			/* LM_ERR("whitelisted"); */
-			return 1; /* found, but is whitelisted */
+		if (*nodeflags == (void *)MARK_ALLOWLIST) {
+			/* LM_ERR("allowlisted"); */
+			return 1; /* found, but is allowlisted */
 		}
 	} else {
 		if(!listtype) {
@@ -278,7 +278,7 @@ static int ki_check_user_list(sip_msg_t *msg, str* suser, str* sdomain,
 			return -1; /* not found is not ok */
 		}
 	}
-	LM_DBG("entry %s is blacklisted\n", req_number);
+	LM_DBG("entry %s is blocklisted\n", req_number);
 	return -1;
 }
 
@@ -318,69 +318,69 @@ static int check_user_list(sip_msg_t *msg, char* puser, char* pdomain,
 	return ki_check_user_list(msg, &user, &domain, &number, &table, listtype);
 }
 
-static int check_user_whitelist(sip_msg_t *msg, char* puser,
+static int check_user_allowlist(sip_msg_t *msg, char* puser,
 		char* pdomain, char* pnumber, char* ptable)
 {
 	return check_user_list(msg, puser, pdomain, pnumber, ptable, 1);
 }
 
-static int ki_check_user_whitelist_table(sip_msg_t *msg, str* suser,
+static int ki_check_user_allowlist_table(sip_msg_t *msg, str* suser,
 		str* sdomain, str* snumber, str* stable)
 {
 	return ki_check_user_list(msg, suser, sdomain, snumber, stable, 1);
 }
 
-static int check_user_blacklist(sip_msg_t *msg, char* puser,
+static int check_user_blocklist(sip_msg_t *msg, char* puser,
 		char* pdomain, char* pnumber, char* ptable)
 {
 	return check_user_list(msg, puser, pdomain, pnumber, ptable, 0);
 }
 
-static int ki_check_user_blacklist_table(sip_msg_t *msg, str* suser,
+static int ki_check_user_blocklist_table(sip_msg_t *msg, str* suser,
 		str* sdomain, str* snumber, str* stable)
 {
 	return ki_check_user_list(msg, suser, sdomain, snumber, stable, 0);
 }
 
-static int check_user_whitelist2(sip_msg_t *msg, char* puser, char* pdomain)
+static int check_user_allowlist2(sip_msg_t *msg, char* puser, char* pdomain)
 {
 	return check_user_list(msg, puser, pdomain, NULL, NULL, 1);
 }
 
-static int ki_check_user_whitelist(sip_msg_t *msg, str* suser, str* sdomain)
+static int ki_check_user_allowlist(sip_msg_t *msg, str* suser, str* sdomain)
 {
 	return ki_check_user_list(msg, suser, sdomain, NULL, NULL, 1);
 }
 
-static int check_user_blacklist2(sip_msg_t *msg, char* puser, char* pdomain)
+static int check_user_blocklist2(sip_msg_t *msg, char* puser, char* pdomain)
 {
 	return check_user_list(msg, puser, pdomain, NULL, NULL, 0);
 }
 
-static int ki_check_user_blacklist(sip_msg_t *msg, str* suser, str* sdomain)
+static int ki_check_user_blocklist(sip_msg_t *msg, str* suser, str* sdomain)
 {
 	return ki_check_user_list(msg, suser, sdomain, NULL, NULL, 0);
 }
 
-static int check_user_whitelist3(sip_msg_t *msg, char* puser, char* pdomain,
+static int check_user_allowlist3(sip_msg_t *msg, char* puser, char* pdomain,
 		char* pnumber)
 {
 	return check_user_list(msg, puser, pdomain, pnumber, NULL, 1);
 }
 
-static int ki_check_user_whitelist_number(sip_msg_t *msg, str* suser,
+static int ki_check_user_allowlist_number(sip_msg_t *msg, str* suser,
 		str* sdomain, str* snumber)
 {
 	return ki_check_user_list(msg, suser, sdomain, snumber, NULL, 1);
 }
 
-static int check_user_blacklist3(sip_msg_t *msg, char* puser, char* pdomain,
+static int check_user_blocklist3(sip_msg_t *msg, char* puser, char* pdomain,
 		char* pnumber)
 {
 	return check_user_list(msg, puser, pdomain, pnumber, NULL, 0);
 }
 
-static int ki_check_user_blacklist_number(sip_msg_t *msg, str* suser,
+static int ki_check_user_blocklist_number(sip_msg_t *msg, str* suser,
 		str* sdomain, str* snumber)
 {
 	return ki_check_user_list(msg, suser, sdomain, snumber, NULL, 0);
@@ -490,9 +490,9 @@ static int add_source(const char *table)
 }
 
 
-static int check_globalblacklist_fixup(void** param, int param_no)
+static int check_globalblocklist_fixup(void** param, int param_no)
 {
-	char * table = globalblacklist_table.s;
+	char * table = globalblocklist_table.s;
 	if(param_no > 0){
 		LM_ERR("Wrong number of parameters\n");
 		return -1;
@@ -517,10 +517,10 @@ static int check_globalblacklist_fixup(void** param, int param_no)
 	return 0;
 }
 
-static int ki_check_globalblacklist(sip_msg_t *msg)
+static int ki_check_globalblocklist(sip_msg_t *msg)
 {
-	char * table = globalblacklist_table.s;
-	struct check_blacklist_fs_t* arg = NULL;
+	char * table = globalblocklist_table.s;
+	struct check_blocklist_fs_t* arg = NULL;
 	int result;
 
 	if (!table) {
@@ -539,40 +539,40 @@ static int ki_check_globalblacklist(sip_msg_t *msg)
 		return -1;
 	}
 
-	arg = pkg_malloc(sizeof(struct check_blacklist_fs_t));
+	arg = pkg_malloc(sizeof(struct check_blocklist_fs_t));
 	if (!arg) {
 		PKG_MEM_ERROR;
 		return -1;
 	}
-	memset(arg, 0, sizeof(struct check_blacklist_fs_t));
+	memset(arg, 0, sizeof(struct check_blocklist_fs_t));
 	arg->dtrie_root = gnode;
 
-	result = check_blacklist(msg, arg);
+	result = check_blocklist(msg, arg);
 	pkg_free(arg);
 
 	return result;
 }
 
-static int check_globalblacklist(sip_msg_t* msg)
+static int check_globalblocklist(sip_msg_t* msg)
 {
-	static struct check_blacklist_fs_t* arg = NULL;
+	static struct check_blocklist_fs_t* arg = NULL;
 	if(!arg){
-		arg = pkg_malloc(sizeof(struct check_blacklist_fs_t));
+		arg = pkg_malloc(sizeof(struct check_blocklist_fs_t));
 		if (!arg) {
 			PKG_MEM_ERROR;
 			return -1;
 		}
-		memset(arg, 0, sizeof(struct check_blacklist_fs_t));
+		memset(arg, 0, sizeof(struct check_blocklist_fs_t));
 		arg->dtrie_root = gnode;
 	}
-	return check_blacklist(msg, arg);
+	return check_blocklist(msg, arg);
 }
 
-static int check_blacklist_fixup(void **arg, int arg_no)
+static int check_blocklist_fixup(void **arg, int arg_no)
 {
 	char *table = (char *)(*arg);
 	struct dtrie_node_t *node = NULL;
-	struct check_blacklist_fs_t *new_arg;
+	struct check_blocklist_fs_t *new_arg;
 
 	if (arg_no != 1) {
 		LM_ERR("wrong number of parameters\n");
@@ -596,22 +596,22 @@ static int check_blacklist_fixup(void **arg, int arg_no)
 		return -1;
 	}
 
-	new_arg = pkg_malloc(sizeof(struct check_blacklist_fs_t));
+	new_arg = pkg_malloc(sizeof(struct check_blocklist_fs_t));
 	if (!new_arg) {
 		PKG_MEM_ERROR;
 		return -1;
 	}
-	memset(new_arg, 0, sizeof(struct check_blacklist_fs_t));
+	memset(new_arg, 0, sizeof(struct check_blocklist_fs_t));
 	new_arg->dtrie_root = node;
 	*arg=(void*)new_arg;
 
 	return 0;
 }
 
-static int ki_check_blacklist(sip_msg_t *msg, str* stable)
+static int ki_check_blocklist(sip_msg_t *msg, str* stable)
 {
 	struct dtrie_node_t *node = NULL;
-	struct check_blacklist_fs_t* arg = NULL;
+	struct check_blocklist_fs_t* arg = NULL;
 	int result;
 
 	if(stable==NULL || stable->len<=0) {
@@ -632,21 +632,21 @@ static int ki_check_blacklist(sip_msg_t *msg, str* stable)
 		return -1;
 	}
 
-	arg = pkg_malloc(sizeof(struct check_blacklist_fs_t));
+	arg = pkg_malloc(sizeof(struct check_blocklist_fs_t));
 	if (!arg) {
 		PKG_MEM_ERROR;
 		return -1;
 	}
-	memset(arg, 0, sizeof(struct check_blacklist_fs_t));
+	memset(arg, 0, sizeof(struct check_blocklist_fs_t));
 	arg->dtrie_root = node;
 
-	result = check_blacklist(msg, arg);
+	result = check_blocklist(msg, arg);
 	pkg_free(arg);
 
 	return result;
 }
 
-static int check_blacklist(sip_msg_t *msg, struct check_blacklist_fs_t *arg1)
+static int check_blocklist(sip_msg_t *msg, struct check_blocklist_fs_t *arg1)
 {
 	void **nodeflags;
 	char *ptr;
@@ -677,12 +677,12 @@ static int check_blacklist(sip_msg_t *msg, struct check_blacklist_fs_t *arg1)
 	lock_get(lock);
 	nodeflags = dtrie_longest_match(arg1->dtrie_root, ptr, strlen(ptr), NULL, match_mode);
 	if (nodeflags) {
-		if (*nodeflags == (void *)MARK_WHITELIST) {
-			/* LM_DBG("whitelisted"); */
-			ret = 1; /* found, but is whitelisted */
+		if (*nodeflags == (void *)MARK_ALLOWLIST) {
+			/* LM_DBG("allowlisted"); */
+			ret = 1; /* found, but is allowlisted */
 		}
 		else {
-			LM_DBG("entry %s is blacklisted\n", req_number);
+			LM_DBG("entry %s is blocklisted\n", req_number);
 		}
 	}
 	else {
@@ -694,10 +694,10 @@ static int check_blacklist(sip_msg_t *msg, struct check_blacklist_fs_t *arg1)
 	return ret;
 }
 
-static int ki_check_whitelist(sip_msg_t *msg, str* stable)
+static int ki_check_allowlist(sip_msg_t *msg, str* stable)
 {
 	struct dtrie_node_t *node = NULL;
-	struct check_blacklist_fs_t* arg = NULL;
+	struct check_blocklist_fs_t* arg = NULL;
 	int result;
 
 	if(stable==NULL || stable->len<=0) {
@@ -718,21 +718,21 @@ static int ki_check_whitelist(sip_msg_t *msg, str* stable)
 		return -1;
 	}
 
-	arg = pkg_malloc(sizeof(struct check_blacklist_fs_t));
+	arg = pkg_malloc(sizeof(struct check_blocklist_fs_t));
 	if (!arg) {
 		PKG_MEM_ERROR;
 		return -1;
 	}
-	memset(arg, 0, sizeof(struct check_blacklist_fs_t));
+	memset(arg, 0, sizeof(struct check_blocklist_fs_t));
 	arg->dtrie_root = node;
 
-	result = check_whitelist(msg, arg);
+	result = check_allowlist(msg, arg);
 	pkg_free(arg);
 
 	return result;
 }
 
-static int check_whitelist(sip_msg_t *msg, struct check_blacklist_fs_t *arg1)
+static int check_allowlist(sip_msg_t *msg, struct check_blocklist_fs_t *arg1)
 {
 	void **nodeflags;
 	char *ptr;
@@ -763,12 +763,12 @@ static int check_whitelist(sip_msg_t *msg, struct check_blacklist_fs_t *arg1)
 	lock_get(lock);
 	nodeflags = dtrie_longest_match(arg1->dtrie_root, ptr, strlen(ptr), NULL, match_mode);
 	if (nodeflags) {
-		if (*nodeflags == (void *)MARK_WHITELIST) {
-			/* LM_DBG("whitelisted"); */
-			ret = 1; /* found, but is whitelisted */
+		if (*nodeflags == (void *)MARK_ALLOWLIST) {
+			/* LM_DBG("allowlisted"); */
+			ret = 1; /* found, but is allowlisted */
 		}
 		else {
-			LM_DBG("entry %s is blacklisted\n", req_number);
+			LM_DBG("entry %s is blocklisted\n", req_number);
 		}
 	}
 	else {
@@ -888,17 +888,17 @@ static void dump_dtrie_mi(const struct dtrie_node_t *root,
 			return ;
 		}
 
-		/* Resolve the value of the whitelist attribute */
-		if (root->data == (void *)MARK_BLACKLIST) {
+		/* Resolve the value of the allowlist attribute */
+		if (root->data == (void *)MARK_BLOCKLIST) {
 			val = int2str(0, &val_len);
-		} else if (root->data == (void *)MARK_WHITELIST) {
+		} else if (root->data == (void *)MARK_ALLOWLIST) {
 			val = int2str(1, &val_len);
 		}
 
 		/* Add the attribute to the current node */
 		if((add_mi_attr(crt_node, MI_DUP_VALUE,
-				userblacklist_whitelist_col.s,
-				userblacklist_whitelist_col.len,
+				userblocklist_allowlist_col.s,
+				userblocklist_allowlist_col.len,
 				val, val_len)) == 0) {
 			LM_ERR("cannot add attributes to the node\n");
 			return ;
@@ -962,9 +962,9 @@ static struct mi_root * check_list_mi(struct mi_root* cmd, int list_type)
 	if (node)
 		return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
 
-	/* Check that global blacklist exists */
+	/* Check that global blocklist exists */
 	if (!gnode) {
-		LM_ERR("the global blacklist is NULL\n");
+		LM_ERR("the global blocklist is NULL\n");
 		return init_mi_tree(500, MI_INTERNAL_ERR_S, MI_INTERNAL_ERR_LEN);
 	}
 
@@ -985,19 +985,19 @@ static struct mi_root * check_list_mi(struct mi_root* cmd, int list_type)
 	lock_get(lock);
 	nodeflags = dtrie_longest_match(gnode, ptr, strlen(ptr), NULL, match_mode);
 	if (nodeflags) {
-		if (*nodeflags == (void *)MARK_WHITELIST) {
-			LM_DBG("prefix %.*s is whitelisted in table %.*s\n",
-				prefix.len, prefix.s, globalblacklist_table.len, globalblacklist_table.s);
-			ret = MARK_WHITELIST;
-		} else if (*nodeflags == (void *)MARK_BLACKLIST) {
-			LM_DBG("prefix %.*s is blacklisted in table %.*s\n",
-				prefix.len, prefix.s, globalblacklist_table.len, globalblacklist_table.s);
-			ret = MARK_BLACKLIST;
+		if (*nodeflags == (void *)MARK_ALLOWLIST) {
+			LM_DBG("prefix %.*s is allowlisted in table %.*s\n",
+				prefix.len, prefix.s, globalblocklist_table.len, globalblocklist_table.s);
+			ret = MARK_ALLOWLIST;
+		} else if (*nodeflags == (void *)MARK_BLOCKLIST) {
+			LM_DBG("prefix %.*s is blocklisted in table %.*s\n",
+				prefix.len, prefix.s, globalblocklist_table.len, globalblocklist_table.s);
+			ret = MARK_BLOCKLIST;
 		}
 	}
 	else {
 		LM_DBG("prefix %.*s not found in table %.*s\n",
-			prefix.len, prefix.s, globalblacklist_table.len, globalblacklist_table.s);
+			prefix.len, prefix.s, globalblocklist_table.len, globalblocklist_table.s);
 	}
 	lock_release(lock);
 
@@ -1013,21 +1013,21 @@ static struct mi_root * check_list_mi(struct mi_root* cmd, int list_type)
 	val.len = FALSE_LEN;
 
 	switch (list_type) {
-		case MARK_WHITELIST:
-			attr.s = WHITELISTED_S;
-			attr.len = WHITELISTED_LEN;
+		case MARK_ALLOWLIST:
+			attr.s = ALLOWLISTED_S;
+			attr.len = ALLOWLISTED_LEN;
 
-			if (ret == MARK_WHITELIST) {
+			if (ret == MARK_ALLOWLIST) {
 				val.s = TRUE_S;
 				val.len = TRUE_LEN;
 			}
 
 			break;
-		case MARK_BLACKLIST:
-			attr.s = BLACKLISTED_S;
-			attr.len = BLACKLISTED_LEN;
+		case MARK_BLOCKLIST:
+			attr.s = BLOCKLISTED_S;
+			attr.len = BLOCKLISTED_LEN;
 
-			if (ret == MARK_BLACKLIST) {
+			if (ret == MARK_BLOCKLIST) {
 				val.s = TRUE_S;
 				val.len = TRUE_LEN;
 			}
@@ -1103,8 +1103,8 @@ static struct mi_root * check_userlist_mi(struct mi_root* cmd, int list_type)
 	if (node)
 		return init_mi_tree(400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
 
-	/* Build userblacklist dtrie */
-	table = userblacklist_table;
+	/* Build userblocklist dtrie */
+	table = userblocklist_table;
 	LM_DBG("check entry %s for user %.*s@%.*s in table %.*s, use domain=%d\n",
 		req_prefix, user.len, user.s, domain.len, domain.s,
 		table.len, table.s, local_use_domain);
@@ -1129,14 +1129,14 @@ static struct mi_root * check_userlist_mi(struct mi_root* cmd, int list_type)
 	/* Search for a match in dtrie */
 	nodeflags = dtrie_longest_match(dtrie_root, ptr, strlen(ptr), NULL, match_mode);
 	if (nodeflags) {
-		if (*nodeflags == (void *)MARK_WHITELIST) {
-			LM_DBG("user %.*s is whitelisted for prefix %.*s in table %.*s\n",
+		if (*nodeflags == (void *)MARK_ALLOWLIST) {
+			LM_DBG("user %.*s is allowlisted for prefix %.*s in table %.*s\n",
 				user.len, user.s, prefix.len, prefix.s, table.len, table.s);
-			ret = MARK_WHITELIST;
-		} else if (*nodeflags == (void *)MARK_BLACKLIST) {
-			LM_DBG("user %.*s is blacklisted for prefix %.*s in table %.*s\n",
+			ret = MARK_ALLOWLIST;
+		} else if (*nodeflags == (void *)MARK_BLOCKLIST) {
+			LM_DBG("user %.*s is blocklisted for prefix %.*s in table %.*s\n",
 				user.len, user.s, prefix.len, prefix.s, table.len, table.s);
-			ret = MARK_BLACKLIST;
+			ret = MARK_BLOCKLIST;
 		}
 	} else {
 		LM_DBG("user %.*s, prefix %.*s not found in table %.*s\n",
@@ -1156,21 +1156,21 @@ static struct mi_root * check_userlist_mi(struct mi_root* cmd, int list_type)
 	val.len = FALSE_LEN;
 
 	switch (list_type) {
-		case MARK_WHITELIST:
-			attr.s = WHITELISTED_S;
-			attr.len = WHITELISTED_LEN;
+		case MARK_ALLOWLIST:
+			attr.s = ALLOWLISTED_S;
+			attr.len = ALLOWLISTED_LEN;
 
-			if (ret == MARK_WHITELIST) {
+			if (ret == MARK_ALLOWLIST) {
 				val.s = TRUE_S;
 				val.len = TRUE_LEN;
 			}
 
 			break;
-		case MARK_BLACKLIST:
-			attr.s = BLACKLISTED_S;
-			attr.len = BLACKLISTED_LEN;
+		case MARK_BLOCKLIST:
+			attr.s = BLOCKLISTED_S;
+			attr.len = BLOCKLISTED_LEN;
 
-			if (ret == MARK_BLACKLIST) {
+			if (ret == MARK_BLOCKLIST) {
 				val.s = TRUE_S;
 				val.len = TRUE_LEN;
 			}
@@ -1192,28 +1192,28 @@ static struct mi_root * check_userlist_mi(struct mi_root* cmd, int list_type)
 }
 
 
-struct mi_root * mi_reload_blacklist(struct mi_root* cmd, void* param)
+struct mi_root * mi_reload_blocklist(struct mi_root* cmd, void* param)
 {
 	struct mi_root * tmp = NULL;
 	if(reload_sources() == 0) {
 		tmp = init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
 	} else {
-		tmp = init_mi_tree( 500, "cannot reload blacklist", 21);
+		tmp = init_mi_tree( 500, "cannot reload blocklist", 21);
 	}
 
 	return tmp;
 }
 
 
-struct mi_root * mi_dump_blacklist(struct mi_root* cmd, void* param)
+struct mi_root * mi_dump_blocklist(struct mi_root* cmd, void* param)
 {
 	char prefix_buff[MAXNUMBERLEN + 1];
 	int length = 0;
 	struct mi_root *tmp = NULL;
 
-	/* Check that global blacklist exists */
+	/* Check that global blocklist exists */
 	if (!gnode) {
-		LM_ERR("the global blacklist is NULL\n");
+		LM_ERR("the global blocklist is NULL\n");
 		return init_mi_tree(500, MI_INTERNAL_ERR_S, MI_INTERNAL_ERR_LEN);
 	}
 
@@ -1229,31 +1229,31 @@ struct mi_root * mi_dump_blacklist(struct mi_root* cmd, void* param)
 }
 
 
-struct mi_root * mi_check_blacklist(struct mi_root* cmd, void* param)
+struct mi_root * mi_check_blocklist(struct mi_root* cmd, void* param)
 {
-	return check_list_mi(cmd, MARK_BLACKLIST);
+	return check_list_mi(cmd, MARK_BLOCKLIST);
 }
 
 
-struct mi_root * mi_check_whitelist(struct mi_root* cmd, void* param)
+struct mi_root * mi_check_allowlist(struct mi_root* cmd, void* param)
 {
-	return check_list_mi(cmd, MARK_WHITELIST);
+	return check_list_mi(cmd, MARK_ALLOWLIST);
 }
 
 
-struct mi_root * mi_check_userblacklist(struct mi_root* cmd, void* param)
+struct mi_root * mi_check_userblocklist(struct mi_root* cmd, void* param)
 {
-	return check_userlist_mi(cmd, MARK_BLACKLIST);
+	return check_userlist_mi(cmd, MARK_BLOCKLIST);
 }
 
 
-struct mi_root * mi_check_userwhitelist(struct mi_root* cmd, void* param)
+struct mi_root * mi_check_userallowlist(struct mi_root* cmd, void* param)
 {
-	return check_userlist_mi(cmd, MARK_WHITELIST);
+	return check_userlist_mi(cmd, MARK_ALLOWLIST);
 }
 #endif
 
-static void ubl_rpc_reload_blacklist(rpc_t* rpc, void* ctx)
+static void ubl_rpc_reload_blocklist(rpc_t* rpc, void* ctx)
 {
 	if(reload_sources() != 0) {
 		rpc->fault(ctx, 500, "Reload failed");
@@ -1261,14 +1261,14 @@ static void ubl_rpc_reload_blacklist(rpc_t* rpc, void* ctx)
 	}
 }
 
-static const char* ubl_rpc_reload_blacklist_doc[2] = {
-	"Reload user blacklist records.",
+static const char* ubl_rpc_reload_blocklist_doc[2] = {
+	"Reload user blocklist records.",
 	0
 };
 
 rpc_export_t ubl_rpc[] = {
-	{"userblacklist.reload_blacklist", ubl_rpc_reload_blacklist,
-		ubl_rpc_reload_blacklist_doc, 0},
+	{"userblocklist.reload_blocklist", ubl_rpc_reload_blocklist,
+		ubl_rpc_reload_blocklist_doc, 0},
 	{0, 0, 0, 0}
 };
 
@@ -1285,7 +1285,7 @@ static int ubl_rpc_init(void)
 static int mod_init(void)
 {
 	if (ubl_rpc_init()<0) return -1;
-	if (userblacklist_db_init() != 0) return -1;
+	if (userblocklist_db_init() != 0) return -1;
 	if (init_shmlock() != 0) return -1;
 	if (init_source_list() != 0) return -1;
 	return 0;
@@ -1300,31 +1300,31 @@ static int child_init(int rank)
 	return rpc_child_init();
 }
 
-static int userblacklist_child_initialized = 0;
-static int blacklist_child_initialized = 0;
+static int userblocklist_child_initialized = 0;
+static int blocklist_child_initialized = 0;
 
 static int rpc_child_init(void)
 {
-	/* user blacklist init */
-	if(userblacklist_child_initialized)
+	/* user blocklist init */
+	if(userblocklist_child_initialized)
 		return 0;
-	if (userblacklist_db_open() != 0) return -1;
+	if (userblocklist_db_open() != 0) return -1;
 	dtrie_root=dtrie_init(match_mode);
 	if (dtrie_root == NULL) {
 		LM_ERR("could not initialize data");
 		return -1;
 	}
 
-	/* global blacklist init */
-	if (check_globalblacklist_fixup(NULL, 0) != 0) {
+	/* global blocklist init */
+	if (check_globalblocklist_fixup(NULL, 0) != 0) {
 		LM_ERR("could not add global table when init the module");
 	}
 
 	/* because we've added new sources during the fixup */
 	if (reload_sources() != 0) return -1;
 
-	userblacklist_child_initialized = 1;
-	blacklist_child_initialized = 1;
+	userblocklist_child_initialized = 1;
+	blocklist_child_initialized = 1;
 
 	return 0;
 }
@@ -1334,7 +1334,7 @@ static void mod_destroy(void)
 {
 	destroy_source_list();
 	destroy_shmlock();
-	userblacklist_db_close();
+	userblocklist_db_close();
 	dtrie_destroy(&dtrie_root, NULL, match_mode);
 }
 
@@ -1342,49 +1342,49 @@ static void mod_destroy(void)
  *
  */
 /* clang-format off */
-static sr_kemi_t sr_kemi_userblacklist_exports[] = {
-	{ str_init("userblacklist"), str_init("check_user_blacklist"),
-		SR_KEMIP_INT, ki_check_user_blacklist,
+static sr_kemi_t sr_kemi_userblocklist_exports[] = {
+	{ str_init("userblocklist"), str_init("check_user_blocklist"),
+		SR_KEMIP_INT, ki_check_user_blocklist,
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
-	{ str_init("userblacklist"), str_init("check_user_whitelist"),
-		SR_KEMIP_INT, ki_check_user_whitelist,
+	{ str_init("userblocklist"), str_init("check_user_allowlist"),
+		SR_KEMIP_INT, ki_check_user_allowlist,
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
-	{ str_init("userblacklist"), str_init("check_user_blacklist_number"),
-		SR_KEMIP_INT, ki_check_user_blacklist_number,
+	{ str_init("userblocklist"), str_init("check_user_blocklist_number"),
+		SR_KEMIP_INT, ki_check_user_blocklist_number,
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
-	{ str_init("userblacklist"), str_init("check_user_whitelist_number"),
-		SR_KEMIP_INT, ki_check_user_whitelist_number,
+	{ str_init("userblocklist"), str_init("check_user_allowlist_number"),
+		SR_KEMIP_INT, ki_check_user_allowlist_number,
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
-	{ str_init("userblacklist"), str_init("check_user_blacklist_table"),
-		SR_KEMIP_INT, ki_check_user_blacklist_table,
+	{ str_init("userblocklist"), str_init("check_user_blocklist_table"),
+		SR_KEMIP_INT, ki_check_user_blocklist_table,
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
 			SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
-	{ str_init("userblacklist"), str_init("check_user_whitelist_table"),
-		SR_KEMIP_INT, ki_check_user_whitelist_table,
+	{ str_init("userblocklist"), str_init("check_user_allowlist_table"),
+		SR_KEMIP_INT, ki_check_user_allowlist_table,
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
 			SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
-	{ str_init("userblacklist"), str_init("check_whitelist"),
-		SR_KEMIP_INT, ki_check_whitelist,
+	{ str_init("userblocklist"), str_init("check_allowlist"),
+		SR_KEMIP_INT, ki_check_allowlist,
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
-	{ str_init("userblacklist"), str_init("check_blacklist"),
-		SR_KEMIP_INT, ki_check_blacklist,
+	{ str_init("userblocklist"), str_init("check_blocklist"),
+		SR_KEMIP_INT, ki_check_blocklist,
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
-	{ str_init("userblacklist"), str_init("check_global_blacklist"),
-		SR_KEMIP_INT, ki_check_globalblacklist,
+	{ str_init("userblocklist"), str_init("check_global_blocklist"),
+		SR_KEMIP_INT, ki_check_globalblocklist,
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
@@ -1395,6 +1395,6 @@ static sr_kemi_t sr_kemi_userblacklist_exports[] = {
 
 int mod_register(char *path, int *dlflags, void *p1, void *p2)
 {
-	sr_kemi_modules_add(sr_kemi_userblacklist_exports);
+	sr_kemi_modules_add(sr_kemi_userblocklist_exports);
 	return 0;
 }

+ 12 - 0
utils/kamctl/db_berkeley/kamailio/globalblocklist

@@ -0,0 +1,12 @@
+METADATA_COLUMNS
+id(int) prefix(str) allowlist(int) description(str)
+METADATA_KEY
+
+METADATA_READONLY
+0
+METADATA_LOGFLAGS
+0
+METADATA_DEFAULTS
+NIL|''|0|NULL
+globalblocklist|
+globalblocklist|1

+ 12 - 0
utils/kamctl/db_berkeley/kamailio/userblocklist

@@ -0,0 +1,12 @@
+METADATA_COLUMNS
+id(int) username(str) domain(str) prefix(str) allowlist(int)
+METADATA_KEY
+
+METADATA_READONLY
+0
+METADATA_LOGFLAGS
+0
+METADATA_DEFAULTS
+NIL|''|''|''|0
+userblocklist|
+userblocklist|1

+ 4 - 4
utils/kamctl/db_berkeley/kamailio/version

@@ -54,8 +54,8 @@ dr_gw_lists|
 dr_gw_lists|1
 dr_rules|
 dr_rules|3
-globalblacklist|
-globalblacklist|1
+METADATA_DEFAULTS
+NIL|''|0|NULL
 grp|
 grp|2
 htable|
@@ -142,8 +142,8 @@ uid_user_attrs|
 uid_user_attrs|3
 uri|
 uri|1
-userblacklist|
-userblacklist|1
+METADATA_DEFAULTS
+NIL|''|''|''|0
 usr_preferences|
 usr_preferences|2
 watchers|

+ 2 - 0
utils/kamctl/db_redis/kamailio/globalblocklist

@@ -0,0 +1,2 @@
+id/int,prefix/string,allowlist/int,description/string,
+1

+ 2 - 0
utils/kamctl/db_redis/kamailio/userblocklist

@@ -0,0 +1,2 @@
+id/int,username/string,domain/string,prefix/string,allowlist/int,
+1

+ 23 - 0
utils/kamctl/db_sqlite/userblocklist-create.sql

@@ -0,0 +1,23 @@
+CREATE TABLE userblocklist (
+    id INTEGER PRIMARY KEY NOT NULL,
+    username VARCHAR(64) DEFAULT '' NOT NULL,
+    domain VARCHAR(64) DEFAULT '' NOT NULL,
+    prefix VARCHAR(64) DEFAULT '' NOT NULL,
+    allowlist SMALLINT DEFAULT 0 NOT NULL
+);
+
+CREATE INDEX userblocklist_userblocklist_idx ON userblocklist (username, domain, prefix);
+
+INSERT INTO version (table_name, table_version) values ('userblocklist','1');
+
+CREATE TABLE globalblocklist (
+    id INTEGER PRIMARY KEY NOT NULL,
+    prefix VARCHAR(64) DEFAULT '' NOT NULL,
+    allowlist SMALLINT DEFAULT 0 NOT NULL,
+    description VARCHAR(255) DEFAULT NULL
+);
+
+CREATE INDEX globalblocklist_globalblocklist_idx ON globalblocklist (prefix);
+
+INSERT INTO version (table_name, table_version) values ('globalblocklist','1');
+

+ 2 - 0
utils/kamctl/dbtext/kamailio/globalblocklist

@@ -0,0 +1,2 @@
+id(int,auto) prefix(string) allowlist(int) description(string,null) 
+0:globalblocklist:1

+ 2 - 0
utils/kamctl/dbtext/kamailio/userblocklist

@@ -0,0 +1,2 @@
+id(int,auto) username(string) domain(string) prefix(string) allowlist(int) 
+0:userblocklist:1

+ 2 - 2
utils/kamctl/dbtext/kamailio/version

@@ -22,7 +22,7 @@ id(int,auto) table_name(string) table_version(int)
 0:dr_groups:2
 0:dr_gw_lists:1
 0:dr_rules:3
-0:globalblacklist:1
+id(int,auto) prefix(string) whitelist(int) description(string,null) 
 0:grp:2
 0:htable:2
 0:imc_members:1
@@ -66,7 +66,7 @@ id(int,auto) table_name(string) table_version(int)
 0:uid_uri_attrs:2
 0:uid_user_attrs:3
 0:uri:1
-0:userblacklist:1
+id(int,auto) username(string) domain(string) prefix(string) whitelist(int) 
 0:usr_preferences:2
 0:watchers:3
 0:xcap:4

+ 2 - 2
utils/kamctl/kamdbctl.base

@@ -39,7 +39,7 @@ STANDARD_TABLES=${STANDARD_TABLES:-'version acc dbaliases domain domain_attrs
 		usr_preferences aliases silo dialog dialog_vars dispatcher dialplan
 		acc_cdrs topos_d topos_t'}
 EXTRA_TABLES=${EXTRA_TABLES:-'imc_members imc_rooms cpl sip_trace domainpolicy
-		carrierroute carrier_name domain_name carrierfailureroute userblacklist
+		carrierroute carrier_name domain_name carrierfailureroute userblocklist
 		globalblacklist htable purplemap uacreg pl_pipes mtree mtrees
 		sca_subscriptions mohqcalls mohqueues rtpproxy rtpengine
 		dr_gateways dr_rules dr_gw_lists dr_groups secfilter'}
@@ -76,7 +76,7 @@ STANDARD_MODULES=${STANDARD_MODULES:-'standard acc lcr domain group
 PRESENCE_MODULES=${PRESENCE_MODULES:-'presence rls'}
 
 EXTRA_MODULES=${EXTRA_MODULES:-'imc cpl siptrace domainpolicy carrierroute
-		drouting userblacklist htable purple uac pipelimit mtree sca mohqueue
+		drouting userblocklist htable purple uac pipelimit mtree sca mohqueue
 		rtpproxy rtpengine secfilter'}
 
 DBUID_MODULES=${UID_MODULES:-'uid_auth_db uid_avp_db uid_domain uid_gflags

+ 26 - 0
utils/kamctl/mongodb/kamailio/globalblocklist.json

@@ -0,0 +1,26 @@
+{
+  "name": "globalblocklist",
+  "version": 1,
+  "columns": [
+    "id": {
+      "type": "int",
+      "default": null,
+      "null": false
+    },
+    "prefix": {
+      "type": "string",
+      "default": "",
+      "null": false
+    },
+    "allowlist": {
+      "type": "int",
+      "default": 0,
+      "null": false
+    },
+    "description": {
+      "type": "string",
+      "default": null,
+      "null": true
+    }
+  ]
+}

+ 31 - 0
utils/kamctl/mongodb/kamailio/userblocklist.json

@@ -0,0 +1,31 @@
+{
+  "name": "userblocklist",
+  "version": 1,
+  "columns": [
+    "id": {
+      "type": "int",
+      "default": null,
+      "null": false
+    },
+    "username": {
+      "type": "string",
+      "default": "",
+      "null": false
+    },
+    "domain": {
+      "type": "string",
+      "default": "",
+      "null": false
+    },
+    "prefix": {
+      "type": "string",
+      "default": "",
+      "null": false
+    },
+    "allowlist": {
+      "type": "int",
+      "default": 0,
+      "null": false
+    }
+  ]
+}

+ 23 - 0
utils/kamctl/mysql/userblocklist-create.sql

@@ -0,0 +1,23 @@
+CREATE TABLE `userblocklist` (
+    `id` INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
+    `username` VARCHAR(64) DEFAULT '' NOT NULL,
+    `domain` VARCHAR(64) DEFAULT '' NOT NULL,
+    `prefix` VARCHAR(64) DEFAULT '' NOT NULL,
+    `allowlist` TINYINT(1) DEFAULT 0 NOT NULL
+);
+
+CREATE INDEX userblocklist_idx ON userblocklist (`username`, `domain`, `prefix`);
+
+INSERT INTO version (table_name, table_version) values ('userblocklist','1');
+
+CREATE TABLE `globalblocklist` (
+    `id` INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
+    `prefix` VARCHAR(64) DEFAULT '' NOT NULL,
+    `allowlist` TINYINT(1) DEFAULT 0 NOT NULL,
+    `description` VARCHAR(255) DEFAULT NULL
+);
+
+CREATE INDEX globalblocklist_idx ON globalblocklist (`prefix`);
+
+INSERT INTO version (table_name, table_version) values ('globalblocklist','1');
+

+ 39 - 0
utils/kamctl/oracle/userblocklist-create.sql

@@ -0,0 +1,39 @@
+CREATE TABLE userblocklist (
+    id NUMBER(10) PRIMARY KEY,
+    username VARCHAR2(64) DEFAULT '',
+    domain VARCHAR2(64) DEFAULT '',
+    prefix VARCHAR2(64) DEFAULT '',
+    allowlist NUMBER(5) DEFAULT 0 NOT NULL
+);
+
+CREATE OR REPLACE TRIGGER userblocklist_tr
+before insert on userblocklist FOR EACH ROW
+BEGIN
+  auto_id(:NEW.id);
+END userblocklist_tr;
+/
+BEGIN map2users('userblocklist'); END;
+/
+CREATE INDEX ORA_userblocklist_idx  ON userblocklist (username, domain, prefix);
+
+INSERT INTO version (table_name, table_version) values ('userblocklist','1');
+
+CREATE TABLE globalblocklist (
+    id NUMBER(10) PRIMARY KEY,
+    prefix VARCHAR2(64) DEFAULT '',
+    allowlist NUMBER(5) DEFAULT 0 NOT NULL,
+    description VARCHAR2(255) DEFAULT NULL
+);
+
+CREATE OR REPLACE TRIGGER globalblocklist_tr
+before insert on globalblocklist FOR EACH ROW
+BEGIN
+  auto_id(:NEW.id);
+END globalblocklist_tr;
+/
+BEGIN map2users('globalblocklist'); END;
+/
+CREATE INDEX ORA_globalblocklist_idx  ON globalblocklist (prefix);
+
+INSERT INTO version (table_name, table_version) values ('globalblocklist','1');
+

+ 23 - 0
utils/kamctl/postgres/userblocklist-create.sql

@@ -0,0 +1,23 @@
+CREATE TABLE userblocklist (
+    id SERIAL PRIMARY KEY NOT NULL,
+    username VARCHAR(64) DEFAULT '' NOT NULL,
+    domain VARCHAR(64) DEFAULT '' NOT NULL,
+    prefix VARCHAR(64) DEFAULT '' NOT NULL,
+    allowlist SMALLINT DEFAULT 0 NOT NULL
+);
+
+CREATE INDEX userblocklist_userblocklist_idx ON userblocklist (username, domain, prefix);
+
+INSERT INTO version (table_name, table_version) values ('userblocklist','1');
+
+CREATE TABLE globalblocklist (
+    id SERIAL PRIMARY KEY NOT NULL,
+    prefix VARCHAR(64) DEFAULT '' NOT NULL,
+    allowlist SMALLINT DEFAULT 0 NOT NULL,
+    description VARCHAR(255) DEFAULT NULL
+);
+
+CREATE INDEX globalblocklist_globalblocklist_idx ON globalblocklist (prefix);
+
+INSERT INTO version (table_name, table_version) values ('globalblocklist','1');
+

+ 104 - 0
utils/kamctl/xhttp_pi/pi_framework.xml

@@ -950,6 +950,25 @@
 		<column><field>whitelist</field><type>DB1_INT</type></column>
 		<column><field>description</field><type>DB1_STR</type></column>
 	</db_table>
+	<!-- Declaration of userblocklist table-->
+	<db_table id="userblocklist">
+		<table_name>userblocklist</table_name>
+		<db_url_id>mysql</db_url_id>
+		<column><field>id</field><type>DB1_INT</type></column>
+		<column><field>username</field><type>DB1_STR</type></column>
+		<column><field>domain</field><type>DB1_STR</type></column>
+		<column><field>prefix</field><type>DB1_STR</type></column>
+		<column><field>allowlist</field><type>DB1_INT</type></column>
+	</db_table>
+	<!-- Declaration of globalblocklist table-->
+	<db_table id="globalblocklist">
+		<table_name>globalblocklist</table_name>
+		<db_url_id>mysql</db_url_id>
+		<column><field>id</field><type>DB1_INT</type></column>
+		<column><field>prefix</field><type>DB1_STR</type></column>
+		<column><field>allowlist</field><type>DB1_INT</type></column>
+		<column><field>description</field><type>DB1_STR</type></column>
+	</db_table>
 	<!-- Declaration of location table-->
 	<db_table id="location">
 		<table_name>location</table_name>
@@ -4760,6 +4779,91 @@
 			</clause_cols>
 		</cmd>
 	</mod>
+	<!-- userblocklist provisionning -->
+	<mod><mod_name>userblocklist</mod_name>
+		<cmd><cmd_name>show</cmd_name>
+			<db_table_id>userblocklist</db_table_id>
+			<cmd_type>DB1_QUERY</cmd_type>
+			<query_cols>
+				<col><field>id</field><link_cmd>update</link_cmd></col>
+				<col><field>username</field></col>
+				<col><field>domain</field></col>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>add</cmd_name>
+			<db_table_id>userblocklist</db_table_id>
+			<cmd_type>DB1_INSERT</cmd_type>
+			<query_cols>
+				<col><field>username</field></col>
+				<col><field>domain</field></col>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>update</cmd_name>
+			<db_table_id>userblocklist</db_table_id>
+			<cmd_type>DB1_UPDATE</cmd_type>
+			<clause_cols>
+				<col><field>id</field><operator>=</operator></col>
+			</clause_cols>
+			<query_cols>
+				<col><field>username</field></col>
+				<col><field>domain</field></col>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>delete</cmd_name>
+			<db_table_id>userblocklist</db_table_id>
+			<cmd_type>DB1_DELETE</cmd_type>
+			<clause_cols>
+				<col><field>id</field><operator>=</operator></col>
+			</clause_cols>
+		</cmd>
+	</mod>
+	<!-- globalblocklist provisionning -->
+	<mod><mod_name>globalblocklist</mod_name>
+		<cmd><cmd_name>show</cmd_name>
+			<db_table_id>globalblocklist</db_table_id>
+			<cmd_type>DB1_QUERY</cmd_type>
+			<query_cols>
+				<col><field>id</field><link_cmd>update</link_cmd></col>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+				<col><field>description</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>add</cmd_name>
+			<db_table_id>globalblocklist</db_table_id>
+			<cmd_type>DB1_INSERT</cmd_type>
+			<query_cols>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+				<col><field>description</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>update</cmd_name>
+			<db_table_id>globalblocklist</db_table_id>
+			<cmd_type>DB1_UPDATE</cmd_type>
+			<clause_cols>
+				<col><field>id</field><operator>=</operator></col>
+			</clause_cols>
+			<query_cols>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+				<col><field>description</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>delete</cmd_name>
+			<db_table_id>globalblocklist</db_table_id>
+			<cmd_type>DB1_DELETE</cmd_type>
+			<clause_cols>
+				<col><field>id</field><operator>=</operator></col>
+			</clause_cols>
+		</cmd>
+	</mod>
 	<!-- location provisionning -->
 	<mod><mod_name>location</mod_name>
 		<cmd><cmd_name>show</cmd_name>

+ 85 - 0
utils/kamctl/xhttp_pi/userblocklist-mod

@@ -0,0 +1,85 @@
+	<!-- userblocklist provisionning -->
+	<mod><mod_name>userblocklist</mod_name>
+		<cmd><cmd_name>show</cmd_name>
+			<db_table_id>userblocklist</db_table_id>
+			<cmd_type>DB1_QUERY</cmd_type>
+			<query_cols>
+				<col><field>id</field><link_cmd>update</link_cmd></col>
+				<col><field>username</field></col>
+				<col><field>domain</field></col>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>add</cmd_name>
+			<db_table_id>userblocklist</db_table_id>
+			<cmd_type>DB1_INSERT</cmd_type>
+			<query_cols>
+				<col><field>username</field></col>
+				<col><field>domain</field></col>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>update</cmd_name>
+			<db_table_id>userblocklist</db_table_id>
+			<cmd_type>DB1_UPDATE</cmd_type>
+			<clause_cols>
+				<col><field>id</field><operator>=</operator></col>
+			</clause_cols>
+			<query_cols>
+				<col><field>username</field></col>
+				<col><field>domain</field></col>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>delete</cmd_name>
+			<db_table_id>userblocklist</db_table_id>
+			<cmd_type>DB1_DELETE</cmd_type>
+			<clause_cols>
+				<col><field>id</field><operator>=</operator></col>
+			</clause_cols>
+		</cmd>
+	</mod>
+	<!-- globalblocklist provisionning -->
+	<mod><mod_name>globalblocklist</mod_name>
+		<cmd><cmd_name>show</cmd_name>
+			<db_table_id>globalblocklist</db_table_id>
+			<cmd_type>DB1_QUERY</cmd_type>
+			<query_cols>
+				<col><field>id</field><link_cmd>update</link_cmd></col>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+				<col><field>description</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>add</cmd_name>
+			<db_table_id>globalblocklist</db_table_id>
+			<cmd_type>DB1_INSERT</cmd_type>
+			<query_cols>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+				<col><field>description</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>update</cmd_name>
+			<db_table_id>globalblocklist</db_table_id>
+			<cmd_type>DB1_UPDATE</cmd_type>
+			<clause_cols>
+				<col><field>id</field><operator>=</operator></col>
+			</clause_cols>
+			<query_cols>
+				<col><field>prefix</field></col>
+				<col><field>allowlist</field></col>
+				<col><field>description</field></col>
+			</query_cols>
+		</cmd>
+		<cmd><cmd_name>delete</cmd_name>
+			<db_table_id>globalblocklist</db_table_id>
+			<cmd_type>DB1_DELETE</cmd_type>
+			<clause_cols>
+				<col><field>id</field><operator>=</operator></col>
+			</clause_cols>
+		</cmd>
+	</mod>

+ 19 - 0
utils/kamctl/xhttp_pi/userblocklist-table

@@ -0,0 +1,19 @@
+	<!-- Declaration of userblocklist table-->
+	<db_table id="userblocklist">
+		<table_name>userblocklist</table_name>
+		<db_url_id>mysql</db_url_id>
+		<column><field>id</field><type>DB1_INT</type></column>
+		<column><field>username</field><type>DB1_STR</type></column>
+		<column><field>domain</field><type>DB1_STR</type></column>
+		<column><field>prefix</field><type>DB1_STR</type></column>
+		<column><field>allowlist</field><type>DB1_INT</type></column>
+	</db_table>
+	<!-- Declaration of globalblocklist table-->
+	<db_table id="globalblocklist">
+		<table_name>globalblocklist</table_name>
+		<db_url_id>mysql</db_url_id>
+		<column><field>id</field><type>DB1_INT</type></column>
+		<column><field>prefix</field><type>DB1_STR</type></column>
+		<column><field>allowlist</field><type>DB1_INT</type></column>
+		<column><field>description</field><type>DB1_STR</type></column>
+	</db_table>