[sr-dev] git:master:10349080: rtpengine: add CRC32 hash algo (#2558)
GitHub
noreply at github.com
Wed Nov 25 18:20:58 CET 2020
Module: kamailio
Branch: master
Commit: 10349080490faabffaf1ab7cc5d591678b8c94dd
URL: https://github.com/kamailio/kamailio/commit/10349080490faabffaf1ab7cc5d591678b8c94dd
Author: Stefan Mititelu <stefan-cristian.mititelu at 1and1.ro>
Committer: GitHub <noreply at github.com>
Date: 2020-11-25T12:20:52-05:00
rtpengine: add CRC32 hash algo (#2558)
---
Modified: src/modules/rtpengine/doc/rtpengine_admin.xml
Modified: src/modules/rtpengine/rtpengine.c
Modified: src/modules/rtpengine/rtpengine.h
---
Diff: https://github.com/kamailio/kamailio/commit/10349080490faabffaf1ab7cc5d591678b8c94dd.diff
Patch: https://github.com/kamailio/kamailio/commit/10349080490faabffaf1ab7cc5d591678b8c94dd.patch
---
diff --git a/src/modules/rtpengine/doc/rtpengine_admin.xml b/src/modules/rtpengine/doc/rtpengine_admin.xml
index db7e7334b9..9647b5a3cc 100644
--- a/src/modules/rtpengine/doc/rtpengine_admin.xml
+++ b/src/modules/rtpengine/doc/rtpengine_admin.xml
@@ -2022,13 +2022,14 @@ modparam("rtpengine", "control_cmd_tos", 144)
<title><varname>hash_algo</varname> (integer)</title>
<para>
Hashing algorithm to be used in node selection algorithm. Now there are 2 possibilities: legacy
- algorithm - 0(very basic hash over callid) or SHA1 - 1(apply sha1 over the callid and calculate hash).
+ algorithm - 0(very basic hash over callid), SHA1 - 1(apply sha1 over the callid and calculate hash) or
+ CRC32 - 2(calculate crc32 sum over the callid).
</para>
<para>
Default value is 0, legacy algorithm.
</para>
<para>
- The values not falling into the range <quote>0-1</quote> are ignored.
+ The values not falling into the range <quote>0-2</quote> are ignored.
</para>
<example>
<title>Set <varname>control_cmd_tos</varname> parameter</title>
@@ -2036,6 +2037,9 @@ modparam("rtpengine", "control_cmd_tos", 144)
...
### use SHA1 instead of legacy algorithm
modparam("rtpengine", "hash_algo", 1)
+
+### use CRC32 instead of legacy algorithm
+modparam("rtpengine", "hash_algo", 2)
...
</programlisting>
</example>
diff --git a/src/modules/rtpengine/rtpengine.c b/src/modules/rtpengine/rtpengine.c
index 7b2573b246..cb7165acd1 100644
--- a/src/modules/rtpengine/rtpengine.c
+++ b/src/modules/rtpengine/rtpengine.c
@@ -2969,6 +2969,9 @@ select_rtpp_node_new(str callid, str viabranch, int do_test, struct rtpp_node **
}
break;
+ case RTP_HASH_CRC32_CALLID:
+ crc32_uint(&callid, &sum);
+ goto retry;
default:
LM_ERR("unknown hashing algo %d\n", hash_algo);
return NULL;
@@ -2986,6 +2989,7 @@ select_rtpp_node_new(str callid, str viabranch, int do_test, struct rtpp_node **
}
retry:
+ LM_DBG("sum is = %u\n", sum);
weight_sum = 0;
lock_get(active_rtpp_set->rset_lock);
diff --git a/src/modules/rtpengine/rtpengine.h b/src/modules/rtpengine/rtpengine.h
index 03999bf22f..81f6cb388c 100644
--- a/src/modules/rtpengine/rtpengine.h
+++ b/src/modules/rtpengine/rtpengine.h
@@ -103,6 +103,6 @@ extern str rtpp_url_col;
extern str rtpp_weight_col;
extern str rtpp_disabled_col;
-enum hash_algo_t { RTP_HASH_CALLID, RTP_HASH_SHA1_CALLID};
+enum hash_algo_t { RTP_HASH_CALLID, RTP_HASH_SHA1_CALLID, RTP_HASH_CRC32_CALLID };
#endif
More information about the sr-dev
mailing list