prime_hash.h

Go to the documentation of this file.
00001 /*
00002  * $Id: prime_hash.h 5107 2008-10-22 11:29:46Z henningw $
00003  *
00004  * Copyright (C) 2007 1&1 Internet AG
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License 
00019  * along with this program; if not, write to the Free Software 
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 
00024 /*!
00025  * \file
00026  * \brief
00027  * Functions for determinung a pseudo random number over a message's
00028  * header field, based on CRC32 or a prime number algorithm.
00029  */
00030 
00031 
00032 #ifndef PRIME_HASH_H
00033 #define PRIME_HASH_H 1
00034 
00035 #include "../../parser/msg_parser.h"
00036 
00037 
00038 /*!
00039  * \brief
00040  * Determines from which part of a message the hash shall be calculated.
00041  * Possible values are:
00042  * 
00043  * - \b shs_call_id     the content of the Call-ID header field
00044  * - \b shs_from_uri    the entire URI in the From header field
00045  * - \b shs_from_user   the username part of the URI in the From header field
00046  * - \b shs_to_uri      the entire URI in the To header field
00047  * - \b shs_to_user     the username part of the URI in the To header field
00048  * - \b shs_error       no hash specified
00049 */
00050 enum hash_source {
00051    shs_call_id = 1,
00052    shs_from_uri,
00053    shs_from_user,
00054    shs_to_uri,
00055    shs_to_user,
00056    shs_error
00057 };
00058 
00059 /*! generic interface for hash functions */
00060 typedef int (*hash_func_t)(struct sip_msg * msg,
00061    enum hash_source source, int denominator);
00062 
00063 
00064 /*!
00065  * \brief CRC32 hash function
00066  * Returns an integer number between 0 and denominator - 1 based on
00067  * the hash source from the msg. The hash algorith is CRC32.
00068 */
00069 int hash_func (struct sip_msg * msg,
00070                          enum hash_source source, int denominator);
00071 
00072 /*!
00073  * \brief prime hash function
00074  * Returns an integer number between 0 and denominator - 1 based on
00075  * the hash source from the msg. Use the prime number algorithm.
00076 */
00077 int prime_hash_func (struct sip_msg * msg,
00078                                enum hash_source source, int denominator);
00079 
00080 #endif

Generated on Thu May 24 08:00:52 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6