Module: kamailio
Branch: master
Commit: d14ee2f988945c4ba5fbb732eb849871135a0b13
URL: 
https://github.com/kamailio/kamailio/commit/d14ee2f988945c4ba5fbb732eb849871135a0b13

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-01-05T22:07:11+01:00

pv: added {s.crc32} transformation

---

Modified: src/modules/pv/pv_trans.c
Modified: src/modules/pv/pv_trans.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/d14ee2f988945c4ba5fbb732eb849871135a0b13.diff
Patch: 
https://github.com/kamailio/kamailio/commit/d14ee2f988945c4ba5fbb732eb849871135a0b13.patch

---

diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 14c0567bdc0..9f6def018e6 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -42,6 +42,7 @@
 #include "../../core/basex.h"
 #include "../../core/action.h"
 #include "../../core/hashes.h"
+#include "../../core/crc.h"
 
 #include "../../core/parser/parse_param.h"
 #include "../../core/parser/parse_uri.h"
@@ -203,6 +204,7 @@ int tr_eval_string(
        time_t t;
        uint32_t sz1, sz2;
        struct tm tmv;
+       unsigned int uival;
 
        if(val == NULL || val->flags & PV_VAL_NULL)
                return -1;
@@ -1660,6 +1662,16 @@ int tr_eval_string(
                        val->rs.s[val->rs.len] = '\0';
                        break;
 
+               case TR_S_CRC32:
+                       if(!(val->flags & PV_VAL_STR)) {
+                               val->rs.s = int2str(val->ri, &val->rs.len);
+                       }
+                       crc32_uint(&val->rs, &uival);
+                       val->ri = (long)uival;
+                       val->rs.s = int2str(val->ri, &val->rs.len);
+                       val->flags = PV_TYPE_INT | PV_VAL_INT | PV_VAL_STR;
+                       break;
+
                default:
                        LM_ERR("unknown subtype %d (cfg line: %d)\n", subtype,
                                        get_cfg_crt_line());
@@ -3473,6 +3485,9 @@ char *tr_parse_string(str *in, trans_t *t)
                        goto error;
                }
                goto done;
+       } else if(name.len == 5 && strncasecmp(name.s, "crc32", 5) == 0) {
+               t->subtype = TR_S_CRC32;
+               goto done;
        }
 
        LM_ERR("unknown transformation: %.*s/%.*s/%d!\n", in->len, in->s, 
name.len,
diff --git a/src/modules/pv/pv_trans.h b/src/modules/pv/pv_trans.h
index 10712198d60..822e54c3026 100644
--- a/src/modules/pv/pv_trans.h
+++ b/src/modules/pv/pv_trans.h
@@ -109,7 +109,8 @@ enum _tr_s_subtype
        TR_S_RBEFORE,
        TR_S_RAFTER,
        TR_S_FMTLINES,
-       TR_S_FMTLINET
+       TR_S_FMTLINET,
+       TR_S_CRC32
 };
 enum _tr_uri_subtype
 {

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to