Module: kamailio
Branch: master
Commit: ad7df67cfd58713fc0993e2d2365a86d9d6068e1
URL:
https://github.com/kamailio/kamailio/commit/ad7df67cfd58713fc0993e2d2365a86…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-09-12T10:23:55+02:00
pdt: added mode parameter to allow ignoring duplicated prefixes
---
Modified: src/modules/pdt/pdt.c
Modified: src/modules/pdt/pdtree.c
---
Diff:
https://github.com/kamailio/kamailio/commit/ad7df67cfd58713fc0993e2d2365a86…
Patch:
https://github.com/kamailio/kamailio/commit/ad7df67cfd58713fc0993e2d2365a86…
---
diff --git a/src/modules/pdt/pdt.c b/src/modules/pdt/pdt.c
index 22d5f663067..ae28aa1a552 100644
--- a/src/modules/pdt/pdt.c
+++ b/src/modules/pdt/pdt.c
@@ -57,6 +57,7 @@ int pdt_fetch_rows = 1000;
/** structures containing prefix-domain pairs */
pdt_tree_t **_ptree = NULL;
+int _pdt_mode = 0;
/** database connection */
static db1_con_t *db_con = NULL;
@@ -118,6 +119,7 @@ static param_export_t params[] = {
{"char_list", PARAM_STR, &pdt_char_list},
{"fetch_rows", INT_PARAM, &pdt_fetch_rows},
{"check_domain", INT_PARAM, &pdt_check_domain},
+ {"mode", PARAM_INT, &_pdt_mode},
{0, 0, 0}
};
diff --git a/src/modules/pdt/pdtree.c b/src/modules/pdt/pdtree.c
index 7f83132cd40..b211ca6611d 100644
--- a/src/modules/pdt/pdtree.c
+++ b/src/modules/pdt/pdtree.c
@@ -35,6 +35,7 @@
//extern str pdt_char_list = {"1234567890*",11};
extern str pdt_char_list;
+extern int _pdt_mode;
/**
*
*/
@@ -117,9 +118,15 @@ int add_to_tree(pdt_tree_t *pt, str *sp, str *sd)
if(itn0[strpos(pdt_char_list.s, sp->s[l]) % PDT_NODE_SIZE].domain.s
!= NULL) {
- LM_ERR("prefix already allocated [%.*s/[%.*s]\n", sp->len, sp->s,
- sd->len, sd->s);
- return -1;
+ if(_pdt_mode & 1) {
+ LM_DBG("prefix already allocated [%.*s/[%.*s] - ignoring\n",
+ sp->len, sp->s, sd->len, sd->s);
+ return -1;
+ } else {
+ LM_ERR("prefix already allocated [%.*s/[%.*s]\n", sp->len, sp->s,
+ sd->len, sd->s);
+ return -1;
+ }
}
itn0[strpos(pdt_char_list.s, sp->s[l]) % PDT_NODE_SIZE].domain.s =