Skip to content

Commit

Permalink
rtpengine: add CRC32 hash algo (#2558)
Browse files Browse the repository at this point in the history
(cherry picked from commit 1034908)
  • Loading branch information
smititelu committed Nov 26, 2020
1 parent c16b3f7 commit 0bff74a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/modules/rtpengine/doc/rtpengine_admin.xml
Expand Up @@ -2012,20 +2012,24 @@ 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>
<programlisting format="linespecific">
...
### use SHA1 instead of legacy algorithm
modparam("rtpengine", "hash_algo", 1)

### use CRC32 instead of legacy algorithm
modparam("rtpengine", "hash_algo", 2)
...
</programlisting>
</example>
Expand Down
4 changes: 4 additions & 0 deletions src/modules/rtpengine/rtpengine.c
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rtpengine/rtpengine.h
Expand Up @@ -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

0 comments on commit 0bff74a

Please sign in to comment.