#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "../../parser/msg_parser.h"
#include "../../dprint.h"
#include "../../error.h"
#include "../../ut.h"
#include "../../mem/mem.h"
#include "../../mem/shm_mem.h"
#include "../../timer.h"
#include "../../locking.h"
#include "../../md5.h"
#include "ring.h"

Go to the source code of this file.
Data Structures | |
| struct | hashtable_entry_t |
| struct | ring_record_t |
Typedefs | |
| typedef struct hashtable_entry_t | hashtable_t [HASHTABLESIZE] |
Functions | |
| static int | contains (str callid) |
| Helper functions that checks if the hash table contains the callid. | |
| static int | conv183 (struct sip_msg *msg) |
| Convert a 180 to a 180 message. | |
| static unsigned int | hash (char *buf, int len) |
| Hash helper function. | |
| static void | insert (str callid) |
| Insert a new entry on the hashtable. | |
| static void | remove_timeout (unsigned int index) |
| Expire entries on the hashtable. | |
| void | ring_destroy_hashtable (void) |
| Destroy the ring hashtable. | |
| int | ring_filter (struct sip_msg *msg, void *bar) |
| Callback function that does the work inside the server. | |
| int | ring_fixup (void **param, int param_no) |
| Fixup function for the ring_insert_callid function. | |
| void | ring_init_hashtable (void) |
| Initialize the ring hashtable in shared memory. | |
| int | ring_insert_callid (struct sip_msg *msg, char *unused1, char *unused2) |
| Inserts callid of message into hashtable. | |
Variables | |
| static hashtable_t * | hashtable = NULL |
Definition in file ring.c.
| typedef struct hashtable_entry_t hashtable_t[HASHTABLESIZE] |
| static int contains | ( | str | callid | ) | [static] |
Helper functions that checks if the hash table contains the callid.
| callid | Call-ID that is searched |
Definition at line 223 of file ring.c.
References ring_record_t::callid, hash, HASHTABLEMASK, _str::len, ring_record_t::next, remove_timeout(), and _str::s.
Referenced by ring_filter(), and ring_insert_callid().
| static int conv183 | ( | struct sip_msg * | msg | ) | [static] |
Convert a 180 to a 180 message.
| msg | SIP message |
Definition at line 242 of file ring.c.
References sip_msg::buf, sip_msg::first_line, sip_msg::len, LM_ERR, NULL, msg_start::reply, msg_start::u, and sip_msg::unparsed.
Referenced by ring_filter().
| static unsigned int hash | ( | char * | buf, | |
| int | len | |||
| ) | [static] |
Hash helper function.
| buf | hashed buffer | |
| len | length of buffer |
Definition at line 152 of file ring.c.
References MD5Final(), MD5Init(), and MD5Update().
| static void insert | ( | str | callid | ) | [static] |
Insert a new entry on the hashtable.
| callid | Call-ID string |
Definition at line 191 of file ring.c.
References ring_record_t::callid, get_ticks(), hash, hashtable, HASHTABLEMASK, _str::len, LM_DBG, MAXCALLIDLEN, MIN, ring_record_t::next, NULL, remove_timeout(), _str::s, shm_malloc(), and ring_record_t::time.
Referenced by ring_insert_callid(), send_publish(), and send_subscribe().
| static void remove_timeout | ( | unsigned int | index | ) | [static] |
Expire entries on the hashtable.
| index | array index that should expired |
Definition at line 175 of file ring.c.
References ring_record_t::callid, get_ticks(), hashtable, LM_DBG, ring_record_t::next, NULL, ring_timeout, shm_free, and ring_record_t::time.
Referenced by contains(), and insert().
| void ring_destroy_hashtable | ( | void | ) |
Destroy the ring hashtable.
Definition at line 127 of file ring.c.
References hashtable, HASHTABLESIZE, hashtable_entry_t::head, ring_record_t::next, NULL, and shm_free.
Referenced by mod_destroy().
| int ring_filter | ( | struct sip_msg * | msg, | |
| void * | bar | |||
| ) |
Callback function that does the work inside the server.
| msg | SIP message | |
| bar | unused |
Definition at line 323 of file ring.c.
References hdr_field::body, sip_msg::callid, contains(), conv183(), sip_msg::first_line, HDR_CALLID_F, _str::len, LM_DBG, LM_ERR, parse_headers(), msg_start::reply, ring_lock, _str::s, SIP_REPLY, msg_start::type, and msg_start::u.
Referenced by mod_init().
| int ring_fixup | ( | void ** | param, | |
| int | param_no | |||
| ) |
Fixup function for the ring_insert_callid function.
| param | unused | |
| param_no | unused |
Definition at line 356 of file ring.c.
References LM_ERR, and ring_timeout.
| void ring_init_hashtable | ( | void | ) |
Initialize the ring hashtable in shared memory.
Definition at line 111 of file ring.c.
References hashtable, HASHTABLESIZE, NULL, and shm_malloc().
Referenced by mod_init().
| int ring_insert_callid | ( | struct sip_msg * | msg, | |
| char * | unused1, | |||
| char * | unused2 | |||
| ) |
Inserts callid of message into hashtable.
Inserts callid of message into hashtable. Any 183 messages with this callid that occur in the next ring_timeout seconds, will be converted to 180.
| msg | SIP message | |
| unused1 | unused | |
| unused2 | unused |
Definition at line 90 of file ring.c.
References hdr_field::body, sip_msg::callid, contains(), HDR_CALLID_F, insert(), LM_ERR, parse_headers(), and ring_lock.
hashtable_t* hashtable = NULL [static] |
global hashtable
Definition at line 72 of file ring.c.
Referenced by insert(), remove_timeout(), ring_destroy_hashtable(), and ring_init_hashtable().
1.5.6