presence/hash.h

Go to the documentation of this file.
00001 /*
00002  * $Id: hash.h 2583 2007-08-08 11:33:25Z anca_vamanu $
00003  *
00004  * presence module - presence server implementation
00005  *
00006  * Copyright (C) 2007 Voice Sistem S.R.L.
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  * History:
00025  * --------
00026  *  2007-08-20  initial version (anca)
00027  */
00028 
00029 /*! \file
00030  * \brief Kamailio presence module :: Hash tables
00031  * \ingroup presence 
00032  */
00033 
00034 
00035 
00036 #ifndef PS_HASH_H
00037 #define PS_HASH_H
00038 
00039 #include "../../lock_ops.h"
00040 //#include "presentity.h"
00041 
00042 struct presentity;
00043 #define REMOTE_TYPE   1<<1
00044 #define LOCAL_TYPE    1<<2
00045 
00046 #define PKG_MEM_STR       "pkg"
00047 #define SHARE_MEM         "share"
00048 
00049 #define ERR_MEM(mem_type)  LM_ERR("No more %s memory\n",mem_type);\
00050                   goto error
00051 
00052 #define CONT_COPY(buf, dest, source)\
00053    dest.s= (char*)buf+ size;\
00054    memcpy(dest.s, source.s, source.len);\
00055    dest.len= source.len;\
00056    size+= source.len;
00057 
00058 #define PKG_MEM_TYPE     1<< 1
00059 #define SHM_MEM_TYPE     1<< 2
00060 
00061 /* subscribe hash entry */
00062 struct subscription;
00063 
00064 typedef struct subs_entry
00065 {
00066    struct subscription* entries;
00067    gen_lock_t lock;
00068 }subs_entry_t; 
00069 
00070 typedef subs_entry_t* shtable_t;
00071 
00072 shtable_t new_shtable(int hash_size);
00073 
00074 struct subscription* search_shtable(shtable_t htable, str callid,str to_tag,str from_tag,
00075       unsigned int hash_code);
00076 
00077 int insert_shtable(shtable_t htable, unsigned int hash_code, struct subscription* subs);
00078 
00079 int delete_shtable(shtable_t htable, unsigned int hash_code, str to_tag);
00080 
00081 int update_shtable(shtable_t htable, unsigned int hash_code, struct subscription* subs,
00082       int type);
00083 
00084 struct subscription* mem_copy_subs(struct subscription* s, int mem_type);
00085 
00086 void free_subs_list(struct subscription* s_array, int mem_type, int ic);
00087 
00088 void destroy_shtable(shtable_t htable, int hash_size);
00089 
00090 /* subs htable functions type definitions */
00091 typedef shtable_t (*new_shtable_t)(int hash_size);
00092 
00093 typedef struct subscription* (*search_shtable_t)(shtable_t htable, str callid,str to_tag,
00094       str from_tag, unsigned int hash_code);
00095 
00096 typedef int (*insert_shtable_t)(shtable_t htable, unsigned int hash_code,
00097       struct subscription* subs);
00098 
00099 typedef int (*delete_shtable_t)(shtable_t htable, unsigned int hash_code,
00100       str to_tag);
00101 
00102 typedef int (*update_shtable_t)(shtable_t htable, unsigned int hash_code,
00103       struct subscription* subs, int type);
00104 
00105 typedef void (*destroy_shtable_t)(shtable_t htable, int hash_size);
00106 
00107 typedef struct subscription* (*mem_copy_subs_t)(struct subscription* s, int mem_type);
00108 
00109 
00110 /* presentity hash table */
00111 typedef struct pres_entry
00112 {
00113    str pres_uri;
00114    int event;
00115    int publ_count;
00116    char* sphere;
00117    struct pres_entry* next;
00118 }pres_entry_t;
00119 
00120 typedef struct pres_htable
00121 {
00122    pres_entry_t* entries;
00123    gen_lock_t lock;
00124 }phtable_t;
00125 
00126 phtable_t* new_phtable(void);
00127 
00128 pres_entry_t* search_phtable(str* pres_uri, int event, unsigned int hash_code);
00129 
00130 int insert_phtable(str* pres_uri, int event, char* sphere);
00131 
00132 int update_phtable(struct presentity* presentity, str pres_uri, str body);
00133 
00134 int delete_phtable(str* pres_uri, int event);
00135 
00136 void destroy_phtable(void);
00137 
00138 #endif
00139 

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