Browse code

rtpengine: add CRC32 hash algo (#2558)

(cherry picked from commit 10349080490faabffaf1ab7cc5d591678b8c94dd)

Stefan Mititelu authored on 25/11/2020 17:20:52
Showing 3 changed files
... ...
@@ -2012,13 +2012,14 @@ modparam("rtpengine", "control_cmd_tos", 144)
2012 2012
 		<title><varname>hash_algo</varname> (integer)</title>
2013 2013
 		<para>
2014 2014
 			Hashing algorithm to be used in node selection algorithm. Now there are 2 possibilities: legacy
2015
-			alogrithm - 0(very basic hash over callid) or SHA1 - 1(apply sha1 over the callid and calculate hash).
2015
+			algorithm - 0(very basic hash over callid), SHA1 - 1(apply sha1 over the callid and calculate hash) or
2016
+			CRC32 - 2(calculate crc32 sum over the callid).
2016 2017
 		</para>
2017 2018
 		<para>
2018 2019
 			Default value is 0, legacy algorithm.
2019 2020
 		</para>
2020 2021
 		<para>
2021
-			The values not falling into the range <quote>0-1</quote> .
2022
+			The values not falling into the range <quote>0-2</quote> are ignored.
2022 2023
 		</para>
2023 2024
 		<example>
2024 2025
 		<title>Set <varname>control_cmd_tos</varname> parameter</title>
... ...
@@ -2026,6 +2027,9 @@ modparam("rtpengine", "control_cmd_tos", 144)
2026 2027
 ...
2027 2028
 ### use SHA1 instead of legacy algorithm
2028 2029
 modparam("rtpengine", "hash_algo", 1)
2030
+
2031
+### use CRC32 instead of legacy algorithm
2032
+modparam("rtpengine", "hash_algo", 2)
2029 2033
 ...
2030 2034
 </programlisting>
2031 2035
 		</example>
... ...
@@ -2943,6 +2943,9 @@ select_rtpp_node_new(str callid, str viabranch, int do_test, struct rtpp_node **
2943 2943
 			}
2944 2944
 
2945 2945
 			break;
2946
+		case RTP_HASH_CRC32_CALLID:
2947
+			crc32_uint(&callid, &sum);
2948
+			goto retry;
2946 2949
 		default:
2947 2950
 			LM_ERR("unknown hashing algo %d\n", hash_algo);
2948 2951
 			return NULL;
... ...
@@ -2960,6 +2963,7 @@ select_rtpp_node_new(str callid, str viabranch, int do_test, struct rtpp_node **
2960 2963
 	}
2961 2964
 
2962 2965
 retry:
2966
+	LM_DBG("sum is = %u\n", sum);
2963 2967
 	weight_sum = 0;
2964 2968
 
2965 2969
 	lock_get(active_rtpp_set->rset_lock);
... ...
@@ -102,6 +102,6 @@ extern str rtpp_url_col;
102 102
 extern str rtpp_weight_col;
103 103
 extern str rtpp_disabled_col;
104 104
 
105
-enum hash_algo_t { RTP_HASH_CALLID, RTP_HASH_SHA1_CALLID};
105
+enum hash_algo_t { RTP_HASH_CALLID, RTP_HASH_SHA1_CALLID, RTP_HASH_CRC32_CALLID };
106 106
 
107 107
 #endif