-
Notifications
You must be signed in to change notification settings - Fork 585
/
Copy pathprime_hash.h
78 lines (67 loc) · 2.32 KB
/
prime_hash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Copyright (C) 2007 1&1 Internet AG
*
* This file is part of opensips, a free SIP server.
*
* opensips is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* opensips is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*!
* \file
* \brief
* Functions for determinung a pseudo random number over a message's
* header field, based on CRC32 or a prime number algorithm.
*/
#ifndef PRIME_HASH_H
#define PRIME_HASH_H 1
#include "parser/msg_parser.h"
/*!
* \brief
* Determines from which part of a message the hash shall be calculated.
* Possible values are:
*
* - \b shs_call_id the content of the Call-ID header field
* - \b shs_from_uri the entire URI in the From header field
* - \b shs_from_user the username part of the URI in the From header field
* - \b shs_to_uri the entire URI in the To header field
* - \b shs_to_user the username part of the URI in the To header field
* - \b shs_error no hash specified
*/
enum hash_source {
shs_call_id = 1,
shs_from_uri,
shs_from_user,
shs_to_uri,
shs_to_user,
shs_error
};
/*! generic interface for hash functions */
typedef int (*hash_func_t)(struct sip_msg * msg,
enum hash_source source, int denominator);
/*!
* \brief CRC32 hash function
* Returns an integer number between 0 and denominator - 1 based on
* the hash source from the msg. The hash algorith is CRC32.
*/
int hash_func (struct sip_msg * msg,
enum hash_source source, int denominator);
/*!
* \brief prime hash function
* Returns an integer number between 0 and denominator - 1 based on
* the hash source from the msg. Use the prime number algorithm.
*/
int prime_hash_func (struct sip_msg * msg,
enum hash_source source, int denominator);
#endif