[sr-dev] git:5.3:0bff74a1: rtpengine: add CRC32 hash algo (#2558)

Stefan Mititelu stefan-cristian.mititelu at 1and1.ro
Thu Nov 26 08:11:13 CET 2020


Module: kamailio
Branch: 5.3
Commit: 0bff74a16bb991ffe8c6690133414c5c9126bd1f
URL: https://github.com/kamailio/kamailio/commit/0bff74a16bb991ffe8c6690133414c5c9126bd1f

Author: Stefan Mititelu <stefan-cristian.mititelu at 1and1.ro>
Committer: Stefan Mititelu <stefan-cristian.mititelu at 1and1.ro>
Date: 2020-11-26T09:09:58+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/0bff74a16bb991ffe8c6690133414c5c9126bd1f.diff
Patch: https://github.com/kamailio/kamailio/commit/0bff74a16bb991ffe8c6690133414c5c9126bd1f.patch

---

diff --git a/src/modules/rtpengine/doc/rtpengine_admin.xml b/src/modules/rtpengine/doc/rtpengine_admin.xml
index cafd6b6ef4..6c4c932b99 100644
--- a/src/modules/rtpengine/doc/rtpengine_admin.xml
+++ b/src/modules/rtpengine/doc/rtpengine_admin.xml
@@ -2012,13 +2012,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
-			alogrithm - 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> .
+			The values not falling into the range <quote>0-2</quote> are ignored.
 		</para>
 		<example>
 		<title>Set <varname>control_cmd_tos</varname> parameter</title>
@@ -2026,6 +2027,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 8b72e5b675..3044fe4b07 100644
--- a/src/modules/rtpengine/rtpengine.c
+++ b/src/modules/rtpengine/rtpengine.c
@@ -2943,6 +2943,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;
@@ -2960,6 +2963,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 8a29210db2..bea421ee9d 100644
--- a/src/modules/rtpengine/rtpengine.h
+++ b/src/modules/rtpengine/rtpengine.h
@@ -102,6 +102,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