Module: kamailio Branch: 5.4 Commit: bc1cf60f970c572ecaddf1ea154834d0e41d292e URL: https://github.com/kamailio/kamailio/commit/bc1cf60f970c572ecaddf1ea154834d0...
Author: Stefan Mititelu stefan-cristian.mititelu@1and1.ro Committer: Stefan Mititelu stefan-cristian.mititelu@1and1.ro Date: 2020-11-26T09:13:40+02:00
rtpengine: add CRC32 hash algo (#2558)
(cherry picked from commit 10349080490faabffaf1ab7cc5d591678b8c94dd)
---
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/bc1cf60f970c572ecaddf1ea154834d0... Patch: https://github.com/kamailio/kamailio/commit/bc1cf60f970c572ecaddf1ea154834d0...
---
diff --git a/src/modules/rtpengine/doc/rtpengine_admin.xml b/src/modules/rtpengine/doc/rtpengine_admin.xml index 362fa58910..60d8673a5f 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 95726fa4a1..0a7c3b3b88 100644 --- a/src/modules/rtpengine/rtpengine.c +++ b/src/modules/rtpengine/rtpengine.c @@ -2974,6 +2974,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; @@ -2991,6 +2994,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