00001 /* 00002 * $Id$ 00003 * 00004 * SNMPStats Module 00005 * Copyright (C) 2006 SOMA Networks, INC. 00006 * Written by: Jeffrey Magder (jmagder@somanetworks.com) 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 it 00011 * 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, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * 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 00023 * USA 00024 * 00025 * History: 00026 * -------- 00027 * 2006-11-23 initial version (jmagder) 00028 */ 00029 00057 #ifndef HASHSLOT_H 00058 #define HASHSLOT_H 00059 00064 typedef struct contactToIndexStruct 00065 { 00066 char *contactName; 00067 00068 int contactIndex; 00069 00070 struct contactToIndexStruct *next; 00071 00072 } contactToIndexStruct_t; 00073 00074 00080 typedef struct aorToIndexStruct 00081 { 00082 /* Pointer to the actual address record in the given SNMP row. */ 00083 char *aor; 00084 int aorLength; 00085 00086 /* Points to the user index, which is used to uniquely identify each 00087 * SNMP row in a table. */ 00088 int userIndex; 00089 00090 /* Each contact needs a unique index, for each user. This value should 00091 * be incremented each time a contact is added. This way, we can know 00092 * what index to use for the next addition to the contactList. */ 00093 int contactIndex; 00094 00095 /* Pointer to the contact list. */ 00096 contactToIndexStruct_t *contactList; 00097 00098 struct aorToIndexStruct *prev; 00099 00100 /* The structure is part of a hash table, so this element is needed so 00101 * that we can point to the next element in the colission slot. */ 00102 struct aorToIndexStruct *next; 00103 00104 /* This counter will be incremented when a new contact is associated 00105 * with this user record, and will be decremented each time an 00106 * associated contact is removed. When the count reaches 0, it is safe 00107 * to remove this record. */ 00108 int numContacts; 00109 00110 } aorToIndexStruct_t; 00111 00112 00113 typedef struct hashSlot 00114 { 00116 int numberOfElements; 00117 00119 struct aorToIndexStruct* first; 00120 00126 struct aorToIndexStruct* last; 00127 00128 } hashSlot_t; 00129 00130 /******************************************************************* 00131 * More detailed function definitions can be found in hashTable.c */ 00132 00133 00142 aorToIndexStruct_t *createHashRecord(int userIndex, char *aor); 00143 00144 00148 hashSlot_t *createHashTable(int size); 00149 00150 00154 int calculateHashSlot(char *theString, int hashTableSize); 00155 00156 00168 aorToIndexStruct_t *findHashRecord(hashSlot_t *theTable, char *aor, int size); 00169 00170 00172 void insertHashRecord(hashSlot_t *theTable, aorToIndexStruct_t *theRecord, int size); 00173 00174 00176 void printHashSlot(hashSlot_t *theTable, int index); 00177 00178 00181 int deleteHashRecord(hashSlot_t *theTable, char *aor, int hashTableSize); 00182 00192 void deleteUser(hashSlot_t *theTable, char *aor, int hashTableSize); 00193 00194 #endif
1.7.1