
Go to the source code of this file.
Data Structures | |
| struct | aorToIndexStruct |
| struct | contactToIndexStruct |
| struct | hashSlot |
Typedefs | |
| typedef struct aorToIndexStruct | aorToIndexStruct_t |
| typedef struct contactToIndexStruct | contactToIndexStruct_t |
| typedef struct hashSlot | hashSlot_t |
Functions | |
| int | calculateHashSlot (char *theString, int hashTableSize) |
| aorToIndexStruct_t * | createHashRecord (int userIndex, char *aor) |
| hashSlot_t * | createHashTable (int size) |
| int | deleteHashRecord (hashSlot_t *theTable, char *aor, int hashTableSize) |
| 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) |
This file describes several structure. In general, it was necessary to map between OpenSER's "aor" (Address of Record) and string indexing mechanisms, and the SNMPStats modules integer indexing scheme for users and contacts. While it would have been a more natural fit to use string indexes in the SNMPStats module, SNMP limitations precluded this.
aorToIndexStruct: maps an aor to:
The aorToIndexStruct also contains a numContacts counter. Each time a new contact is associated with the aor (user), the counter is incremented. Each time a contact is dissasociated (due to an expiration), the counter is decremented. When the counter reaches zero the structure will be deleted.
contactToIndexStruct: maps a contact name to:
Definition in file hashTable.h.
| typedef struct aorToIndexStruct aorToIndexStruct_t |
Used to map between an 'aor' (OpenSER index) and a user index. (SNMPStats index). Since each user can have multiple contacts, the structure also has a 'contactIndex', and a reference to the contactToIndexStruct list.
| typedef struct contactToIndexStruct contactToIndexStruct_t |
Used to map between a 'contact' name (OpenSER's index) and a contact index. (SNMPStats Index)
| typedef struct hashSlot hashSlot_t |
| 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().
| int deleteHashRecord | ( | hashSlot_t * | theTable, | |
| char * | aor, | |||
| int | hashTableSize | |||
| ) |
If a record is found with string aor in theTable, it is deleted and its SNMPStats user integer index is returned.
| 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 theRecord into an appropriate place in theTable, when size is given.
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