#include <stdlib.h>
#include <string.h>
#include "hashTable.h"
#include "../../dprint.h"
#include "../../mem/mem.h"
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "openserSIPRegUserTable.h"

Go to the source code of this file.
Functions | |
| int | calculateHashSlot (char *theString, int hashTableSize) |
| aorToIndexStruct_t * | createHashRecord (int userIndex, char *aor) |
| hashSlot_t * | createHashTable (int size) |
| void | deleteUser (hashSlot_t *theTable, char *aor, int hashTableSize) |
| aorToIndexStruct_t * | findHashRecord (hashSlot_t *theTable, char *aor, int size) |
| void | insertHashRecord (hashSlot_t *theTable, aorToIndexStruct_t *theRecord, int size) |
| void | printHashSlot (hashSlot_t *theTable, int index) |
For an overview of its structures, please see hashTable.h
Potential Performance Improvements: Pass the length of the aor strings around everywhere, so we don't have to calculate it ourselves.
Definition in file hashTable.c.
| int calculateHashSlot | ( | char * | theString, | |
| int | hashTableSize | |||
| ) |
Calculates and returns a hash index to a hash table. The index is calculated by summing up all the characters specified with theString, and using the hashTableSize as the modulus.
Definition at line 60 of file hashTable.c.
Referenced by deleteUser(), findHashRecord(), and insertHashRecord().
| aorToIndexStruct_t* createHashRecord | ( | int | userIndex, | |
| char * | aor | |||
| ) |
Returns a aorToIndexStruct_t, holding the given 'userIndex' and 'aor'. The structure is used to map between the "aor" (OpenSER's way of indexing users/contacts), and the SNMPStats user and contact integer indexes.
NOTE: that this record does not make a copy of aor, but instead points directly to the parameter. Therefore make sure that aor is not on the stack, and is not going to disappear before this record is deleted.
Definition at line 250 of file hashTable.c.
References aorToIndexStruct::aor, aorToIndexStruct::aorLength, LM_ERR, NULL, aorToIndexStruct::numContacts, pkg_malloc, and aorToIndexStruct::userIndex.
Referenced by updateUser().
| hashSlot_t* createHashTable | ( | int | size | ) |
Returns a chunk of memory large enough to store 'size' hashSlot's. The table will contain mappings between OpenSER's "aor" user/contact indexing scheme, and SNMPStats integer indexing scheme
Definition at line 110 of file hashTable.c.
References hashTable, LM_ERR, NULL, and pkg_malloc.
Referenced by initInterprocessBuffers().
| void deleteUser | ( | hashSlot_t * | theTable, | |
| char * | aor, | |||
| int | hashTableSize | |||
| ) |
This function will search the provided hash table for an entry indexed by 'aor'. If an entry is found then:
Definition at line 168 of file hashTable.c.
References aorToIndexStruct::aor, aorToIndexStruct::aorLength, calculateHashSlot(), deleteRegUserRow(), hashSlot::first, hashSlot::last, aorToIndexStruct::next, NULL, aorToIndexStruct::numContacts, pkg_free, aorToIndexStruct::prev, and aorToIndexStruct::userIndex.
Referenced by executeInterprocessBufferCmd().
| aorToIndexStruct_t* findHashRecord | ( | hashSlot_t * | theTable, | |
| char * | aor, | |||
| int | size | |||
| ) |
Searches the hash table specified as theTable, of size 'size', for a record indexed with 'aor'. If a match is found, then an aorToIndextStruct_t structure is returned.
This function is called to discover the map between OpenSER's "aor" (Address of Records) indexing scheme, and the SNMPStats modules integer indexing scheme for its contact/user data.
Returns: the aorToIndexStruct_t mapping structure if a match was found, or NULL otherwise.
Definition at line 84 of file hashTable.c.
References aorToIndexStruct::aor, aorToIndexStruct::aorLength, calculateHashSlot(), hashSlot::first, aorToIndexStruct::next, and NULL.
Referenced by executeInterprocessBufferCmd(), openserSIPRegUserLookupTable_set_action(), and updateUser().
| void insertHashRecord | ( | hashSlot_t * | theTable, | |
| aorToIndexStruct_t * | theRecord, | |||
| int | size | |||
| ) |
Inserts the record specified with 'theRecord' into our hash table.
Definition at line 130 of file hashTable.c.
References aorToIndexStruct::aor, calculateHashSlot(), hashSlot::first, hashSlot::last, aorToIndexStruct::next, NULL, and aorToIndexStruct::prev.
Referenced by updateUser().
| void printHashSlot | ( | hashSlot_t * | theTable, | |
| int | index | |||
| ) |
Debugging function. Prints off an entire hash slot.
Definition at line 278 of file hashTable.c.
References aorToIndexStruct::aor, hashSlot::first, LM_ERR, aorToIndexStruct::next, NULL, and aorToIndexStruct::userIndex.
1.5.6