Module: kamailio
Branch: master
Commit: b5ea290be4a5f92cd24dd39cbefe2987ed577d19
URL:
https://github.com/kamailio/kamailio/commit/b5ea290be4a5f92cd24dd39cbefe298…
Author: Victor Seva <vseva(a)sipwise.com>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2023-06-14T11:25:28+02:00
cfgt: skip_unknown modparam
If enabled, value different from 0, cfgt will not generate the report
of any message that doesn't match the callid_prefix.
---
Modified: src/modules/cfgt/cfgt_int.c
Modified: src/modules/cfgt/cfgt_mod.c
Modified: src/modules/cfgt/doc/cfgt_admin.xml
---
Diff:
https://github.com/kamailio/kamailio/commit/b5ea290be4a5f92cd24dd39cbefe298…
Patch:
https://github.com/kamailio/kamailio/commit/b5ea290be4a5f92cd24dd39cbefe298…
---
diff --git a/src/modules/cfgt/cfgt_int.c b/src/modules/cfgt/cfgt_int.c
index 2509b3eb6e7..2480f4b66f1 100644
--- a/src/modules/cfgt/cfgt_int.c
+++ b/src/modules/cfgt/cfgt_int.c
@@ -43,6 +43,7 @@ cfgt_hash_p _cfgt_uuid = NULL;
str cfgt_hdr_prefix = {"NGCP%", 5};
str cfgt_basedir = {"/tmp", 4};
int cfgt_mask = CFGT_DP_ALL;
+int cfgt_skip_unknown = 0;
int not_sip = 0;
int _cfgt_get_filename(int msgid, str uuid, str *dest, int *dir);
@@ -385,6 +386,10 @@ void cfgt_save_node(cfgt_node_p node)
str dest = STR_NULL;
int dir = 0;
struct stat sb;
+ if(cfgt_skip_unknown && strncmp(_cfgt_node->uuid.s, "unknown", 7)
== 0) {
+ LM_DBG("skip unknown\n");
+ return;
+ }
if(_cfgt_get_filename(node->msgid, node->uuid, &dest, &dir) < 0) {
LM_ERR("can't build filename\n");
return;
@@ -658,6 +663,9 @@ int cfgt_process_route(struct sip_msg *msg, struct action *a)
LM_ERR("node empty\n");
return -1;
}
+ if(cfgt_skip_unknown && strncmp(_cfgt_node->uuid.s, "unknown", 7)
== 0) {
+ return 0;
+ }
if(a->rname == NULL) {
LM_DBG("no routename. type:%d\n", a->type);
return 0;
@@ -806,6 +814,10 @@ int cfgt_post(struct sip_msg *msg, unsigned int flags, void *bar)
str flowname = STR_NULL;
if(_cfgt_node) {
+ if(cfgt_skip_unknown
+ && strncmp(_cfgt_node->uuid.s, "unknown", 7) == 0) {
+ return 1;
+ }
LM_DBG("dump last flow\n");
if(_cfgt_node->route == NULL
&& strncmp(_cfgt_node->uuid.s, "unknown", 7) == 0)
@@ -844,6 +856,10 @@ int cfgt_msgout(sr_event_param_t *evp)
}
if(_cfgt_node) {
+ if(cfgt_skip_unknown
+ && strncmp(_cfgt_node->uuid.s, "unknown", 7) == 0) {
+ return 0;
+ }
jobj = srjson_CreateStr(&_cfgt_node->jdoc, buf->s, buf->len);
if(jobj == NULL) {
LM_ERR("cannot create json object\n");
diff --git a/src/modules/cfgt/cfgt_mod.c b/src/modules/cfgt/cfgt_mod.c
index 728d22813c8..7dec36ae064 100644
--- a/src/modules/cfgt/cfgt_mod.c
+++ b/src/modules/cfgt/cfgt_mod.c
@@ -42,6 +42,7 @@ unsigned int init_flag = 0;
extern int cfgt_mask;
extern str cfgt_basedir;
extern str cfgt_hdr_prefix;
+extern int cfgt_skip_unknown;
/* clang-format off */
/*! \brief
* Exported functions
@@ -58,6 +59,7 @@ static param_export_t params[] = {
{"basedir", PARAM_STR, &cfgt_basedir},
{"mask", INT_PARAM, &cfgt_mask},
{"callid_prefix", PARAM_STR, &cfgt_hdr_prefix},
+ {"skip_unknown", INT_PARAM, &cfgt_skip_unknown},
{0, 0, 0}
};
diff --git a/src/modules/cfgt/doc/cfgt_admin.xml b/src/modules/cfgt/doc/cfgt_admin.xml
index 2a2b158e57d..84d3df612e6 100644
--- a/src/modules/cfgt/doc/cfgt_admin.xml
+++ b/src/modules/cfgt/doc/cfgt_admin.xml
@@ -143,6 +143,26 @@ modparam("cfgt", "mask", 12)
# using '%' as delimiter
modparam("cfgt", "callid_prefix", "TEST-ID%")
...
+</programlisting>
+ </example>
+ </section>
+ <section id="cfg.p.skip_unknown">
+ <title><varname>skip_unknown</varname> (int)</title>
+ <para>
+ If enabled, value different from 0, cfgt will not generate the report
+ of any message that doesn't match the callid_prefix.
+ </para>
+ <para>
+ <emphasis>
+ Default value is <quote>0</quote>, false.
+ </emphasis>
+ </para>
+ <example>
+ <title>Set <varname>skip_unknown</varname> parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("cfgt", "skip_unknown", "1")
+...
</programlisting>
</example>
</section>