dispatch.c File Reference

Dispatcher :: Dispatch. More...

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../../ut.h"
#include "../../trim.h"
#include "../../dprint.h"
#include "../../action.h"
#include "../../route.h"
#include "../../dset.h"
#include "../../mem/shm_mem.h"
#include "../../parser/parse_uri.h"
#include "../../parser/parse_from.h"
#include "../../usr_avp.h"
#include "../../mi/mi.h"
#include "../../parser/digest/digest.h"
#include "../../resolve.h"
#include "../tm/tm_load.h"
#include "../../db/db.h"
#include "../../db/db_res.h"
#include "../../str.h"
#include "dispatch.h"

Include dependency graph for dispatch.c:

Go to the source code of this file.

Data Structures

struct  _ds_dest
struct  _ds_set

Defines

#define _ds_list   (ds_lists[*crt_idx])
#define _ds_list_nr   (*ds_list_nr)
#define DS_TABLE_VERSION   1
#define DS_TABLE_VERSION2   2
#define DS_TABLE_VERSION3   3

Typedefs

typedef struct _ds_destds_dest_p
typedef struct _ds_dest ds_dest_t
typedef struct _ds_setds_set_p
typedef struct _ds_set ds_set_t

Functions

int add_dest2list (int id, str uri, int flags, int priority, int list_idx, int *setn)
void destroy_list (int)
void ds_check_timer (unsigned int ticks, void *param)
 Timer for checking inactive destinations.
int ds_connect_db (void)
int ds_destroy_list (void)
 called from dispatcher.c: free all
void ds_disconnect_db (void)
unsigned int ds_get_hash (str *x, str *y)
static int ds_get_index (int group, ds_set_p *index)
int ds_hash_authusername (struct sip_msg *msg, unsigned int *hash)
int ds_hash_callid (struct sip_msg *msg, unsigned int *hash)
int ds_hash_fromuri (struct sip_msg *msg, unsigned int *hash)
int ds_hash_pvar (struct sip_msg *msg, unsigned int *hash)
int ds_hash_ruri (struct sip_msg *msg, unsigned int *hash)
int ds_hash_touri (struct sip_msg *msg, unsigned int *hash)
int ds_is_from_list (struct sip_msg *_m, int group)
int ds_load_db (void)
 load groups of destinations from DB
int ds_load_list (char *lfile)
 load groups of destinations from file
int ds_mark_dst (struct sip_msg *msg, int mode)
int ds_next_dst (struct sip_msg *msg, int mode)
static void ds_options_callback (struct cell *t, int type, struct tmcb_params *ps)
 Callback-Function for the OPTIONS-Request This Function is called, as soon as the Transaction is finished (e. g. a Response came in, the timeout was hit, ...).
int ds_print_list (FILE *fout)
int ds_print_mi_list (struct mi_node *rpl)
static int ds_print_sets (void)
int ds_select_dst (struct sip_msg *msg, int set, int alg, int mode)
int ds_set_state (int group, str *address, int state, int type)
static int ds_update_dst (struct sip_msg *msg, str *uri, int mode)
static int get_uri_hash_keys (str *key1, str *key2, str *uri, struct sip_uri *parsed_uri, int flags)
 gets the part of the uri we will use as a key for hashing
int init_data (void)
int init_ds_db (void)
 Initialize and verify DB stuff.
int reindex_dests (int list_idx, int setn)
 compact destinations from sets for fast access

Variables

static int _ds_table_version = DS_TABLE_VERSION
int * crt_idx = NULL
static db_con_tds_db_handle = 0
static db_func_t ds_dbf
int ds_force_dst
int * ds_list_nr = NULL
ds_set_pds_lists = NULL
int * next_idx = NULL


Detailed Description

Dispatcher :: Dispatch.

Definition in file dispatch.c.


Define Documentation

#define _ds_list   (ds_lists[*crt_idx])

#define _ds_list_nr   (*ds_list_nr)

#define DS_TABLE_VERSION   1

Definition at line 72 of file dispatch.c.

Referenced by init_ds_db().

#define DS_TABLE_VERSION2   2

Definition at line 73 of file dispatch.c.

Referenced by ds_load_db(), and init_ds_db().

#define DS_TABLE_VERSION3   3

Definition at line 74 of file dispatch.c.

Referenced by ds_load_db(), and init_ds_db().


Typedef Documentation

typedef struct _ds_dest * ds_dest_p

typedef struct _ds_dest ds_dest_t

typedef struct _ds_set * ds_set_p

typedef struct _ds_set ds_set_t


Function Documentation

int add_dest2list ( int  id,
str  uri,
int  flags,
int  priority,
int  list_idx,
int *  setn 
)

void destroy_list ( int  list_id  ) 

void ds_check_timer ( unsigned int  ticks,
void *  param 
)

Timer for checking inactive destinations.

This timer is regularly fired.

Definition at line 1624 of file dispatch.c.

References _ds_list, _ds_list_nr, _ds_set::dlist, ds_options_callback(), ds_ping_from, ds_ping_method, DS_PROBING_DST, ds_probing_mode, _ds_dest::flags, _ds_set::id, _str::len, LM_DBG, LM_ERR, _ds_set::next, _ds_set::nr, NULL, _str::s, tm_binds::t_request, tmb, and _ds_dest::uri.

Referenced by mod_init().

int ds_connect_db ( void   ) 

Definition at line 453 of file dispatch.c.

References ds_db_url, db_func::init, LM_CRIT, and _str::s.

Referenced by init_ds_db(), and mi_child_init().

int ds_destroy_list ( void   ) 

called from dispatcher.c: free all

Definition at line 627 of file dispatch.c.

References crt_idx, destroy_list(), and shm_free.

Referenced by destroy().

void ds_disconnect_db ( void   ) 

Definition at line 471 of file dispatch.c.

References db_func::close.

Referenced by destroy(), and init_ds_db().

unsigned int ds_get_hash ( str x,
str y 
)

static int ds_get_index ( int  group,
ds_set_p index 
) [inline, static]

Definition at line 1003 of file dispatch.c.

References _ds_list, _ds_set::id, LM_ERR, _ds_set::next, and NULL.

Referenced by ds_select_dst(), and ds_set_state().

int ds_hash_authusername ( struct sip_msg msg,
unsigned int *  hash 
)

int ds_hash_callid ( struct sip_msg msg,
unsigned int *  hash 
)

int ds_hash_fromuri ( struct sip_msg msg,
unsigned int *  hash 
)

int ds_hash_pvar ( struct sip_msg msg,
unsigned int *  hash 
)

Definition at line 975 of file dispatch.c.

References ds_get_hash(), hash_param_model, _str::len, LM_DBG, LM_ERR, NULL, pv_printf_s(), _str::s, and trim().

Referenced by ds_select_dst().

int ds_hash_ruri ( struct sip_msg msg,
unsigned int *  hash 
)

int ds_hash_touri ( struct sip_msg msg,
unsigned int *  hash 
)

int ds_is_from_list ( struct sip_msg _m,
int  group 
)

int ds_load_db ( void   ) 

int ds_load_list ( char *  lfile  ) 

load groups of destinations from file

Definition at line 329 of file dispatch.c.

References _ds_list_nr, add_dest2list(), crt_idx, destroy_list(), ds_print_sets(), id, _str::len, LM_ERR, LM_WARN, next_idx, NULL, priority, reindex_dests(), and _str::s.

Referenced by ds_mi_reload(), and mod_init().

int ds_mark_dst ( struct sip_msg msg,
int  mode 
)

int ds_next_dst ( struct sip_msg msg,
int  mode 
)

static void ds_options_callback ( struct cell t,
int  type,
struct tmcb_params ps 
) [static]

Callback-Function for the OPTIONS-Request This Function is called, as soon as the Transaction is finished (e. g. a Response came in, the timeout was hit, ...).

Definition at line 1566 of file dispatch.c.

References tmcb_params::code, DS_INACTIVE_DST, DS_PROBING_DST, ds_probing_mode, DS_RESET_FAIL_DST, ds_set_state(), group, _str::len, LM_DBG, LM_ERR, tmcb_params::param, _str::s, and cell::to.

Referenced by ds_check_timer().

int ds_print_list ( FILE *  fout  ) 

int ds_print_mi_list ( struct mi_node rpl  ) 

static int ds_print_sets ( void   )  [static]

int ds_select_dst ( struct sip_msg msg,
int  set,
int  alg,
int  mode 
)

int ds_set_state ( int  group,
str address,
int  state,
int  type 
)

static int ds_update_dst ( struct sip_msg msg,
str uri,
int  mode 
) [inline, static]

static int get_uri_hash_keys ( str key1,
str key2,
str uri,
struct sip_uri parsed_uri,
int  flags 
) [inline, static]

gets the part of the uri we will use as a key for hashing

Parameters:
key1 - will be filled with first part of the key (uri user or "" if no user)
key2 - will be filled with the second part of the key (uri host:port)
uri - str with the whole uri
parsed_uri - struct sip_uri pointer with the parsed uri (it must point inside uri). It can be null (in this case the uri will be parsed internally).
flags - if & DS_HASH_USER_ONLY, only the user part of the uri will be used
Returns:
: -1 on error, 0 on success

Definition at line 736 of file dispatch.c.

References DS_HASH_USER_ONLY, sip_uri::host, _str::len, LM_ERR, LM_WARN, parse_uri(), sip_uri::port, sip_uri::port_no, _str::s, SIP_PORT, SIPS_PORT, SIPS_URI_T, sip_uri::type, and sip_uri::user.

Referenced by ds_hash_fromuri(), ds_hash_ruri(), and ds_hash_touri().

int init_data ( void   ) 

Definition at line 136 of file dispatch.c.

References crt_idx, ds_list_nr, init_db_data(), LM_DBG, LM_ERR, next_idx, and shm_malloc().

Referenced by mod_init().

int init_ds_db ( void   ) 

int reindex_dests ( int  list_idx,
int  setn 
)

compact destinations from sets for fast access

Definition at line 288 of file dispatch.c.

References _ds_set::dlist, LM_DBG, LM_ERR, _ds_dest::next, _ds_set::next, NULL, shm_free, and shm_malloc().

Referenced by ds_load_db(), and ds_load_list().


Variable Documentation

int _ds_table_version = DS_TABLE_VERSION [static]

Definition at line 76 of file dispatch.c.

Referenced by ds_load_db(), and init_ds_db().

int* crt_idx = NULL

Definition at line 104 of file dispatch.c.

db_con_t* ds_db_handle = 0 [static]

Definition at line 101 of file dispatch.c.

db_func_t ds_dbf [static]

Definition at line 100 of file dispatch.c.

Definition at line 78 of file dispatcher.c.

Referenced by ds_select_dst().

int* ds_list_nr = NULL

Definition at line 103 of file dispatch.c.

Referenced by init_data().

ds_set_p* ds_lists = NULL

Definition at line 102 of file dispatch.c.

int* next_idx = NULL

Definition at line 105 of file dispatch.c.


Generated on Tue May 22 16:00:38 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6