dlg_profile.c File Reference

Profile related functions for the dialog module

Module: dialog. More...

#include "../../mem/shm_mem.h"
#include "../../hash_func.h"
#include "../../dprint.h"
#include "../../ut.h"
#include "../../route.h"
#include "../tm/tm_load.h"
#include "dlg_hash.h"
#include "dlg_profile.h"

Include dependency graph for dlg_profile.c:

Go to the source code of this file.

Defines

#define PROFILE_HASH_SIZE   16

Functions

int add_profile_definitions (char *profiles, unsigned int has_value)
 Add profile definitions to the global list.
static unsigned int calc_hash_profile (str *value, struct dlg_cell *dlg, struct dlg_profile_table *profile)
 Calculate the hash profile from a dialog.
static void destroy_dlg_profile (struct dlg_profile_table *profile)
 Destroy a dialog profile list.
void destroy_dlg_profiles (void)
 Destroy the global dialog profile list.
void destroy_linkers (struct dlg_profile_link *linker)
 Destroy dialog linkers.
static struct dlg_cellget_current_dialog (struct sip_msg *msg)
 Get the current dialog for a message, if exists.
unsigned int get_profile_size (struct dlg_profile_table *profile, str *value)
 Get the size of a profile.
int is_dlg_in_profile (struct sip_msg *msg, struct dlg_profile_table *profile, str *value)
 Check if a dialog belongs to a profile.
static void link_dlg_profile (struct dlg_profile_link *linker, struct dlg_cell *dlg)
 Link a dialog profile.
struct mi_rootmi_get_profile (struct mi_root *cmd_tree, void *param)
 Output a profile via MI interface.
struct mi_rootmi_profile_list (struct mi_root *cmd_tree, void *param)
 List the profiles via MI interface.
static struct dlg_profile_tablenew_dlg_profile (str *name, unsigned int size, unsigned int has_value)
 Creates a new dialog profile.
int profile_cleanup (struct sip_msg *msg, void *param)
 Cleanup a profile.
struct dlg_profile_tablesearch_dlg_profile (str *name)
 Search a dialog profile in the global list.
void set_current_dialog (struct sip_msg *msg, struct dlg_cell *dlg)
 Set the global variables to the current dialog.
int set_dlg_profile (struct sip_msg *msg, str *value, struct dlg_profile_table *profile)
 Set a dialog profile.
int unset_dlg_profile (struct sip_msg *msg, str *value, struct dlg_profile_table *profile)
 Unset a dialog profile.

Variables

static unsigned int current_dlg_msg_id = 0
struct dlg_cellcurrent_dlg_pointer = NULL
static struct dlg_profile_linkcurrent_pending_linkers = NULL
struct tm_binds d_tmb
static struct dlg_profile_tableprofiles = NULL


Detailed Description

Profile related functions for the dialog module

Module: dialog.

Definition in file dlg_profile.c.


Define Documentation

#define PROFILE_HASH_SIZE   16

size of dialog profile hash

Definition at line 48 of file dlg_profile.c.

Referenced by add_profile_definitions().


Function Documentation

int add_profile_definitions ( char *  profiles,
unsigned int  has_value 
)

Add profile definitions to the global list.

See also:
new_dlg_profile
Parameters:
profiles profile name
has_value set to 0 for a profile without value, otherwise it has a value
Returns:
0 on success, -1 on failure

Definition at line 77 of file dlg_profile.c.

References _str::len, LM_DBG, LM_ERR, dlg_profile_table::name, new_dlg_profile(), NULL, PROFILE_HASH_SIZE, _str::s, and trim_spaces_lr.

Referenced by mod_init().

static unsigned int calc_hash_profile ( str value,
struct dlg_cell dlg,
struct dlg_profile_table profile 
) [inline, static]

Calculate the hash profile from a dialog.

See also:
core_hash
Parameters:
value hash source
dlg dialog cell
profile dialog profile table (for hash size)
Returns:
value hash if the value has a value, hash over dialog otherwise

Definition at line 353 of file dlg_profile.c.

References core_hash(), dlg_profile_table::has_value, NULL, and dlg_profile_table::size.

Referenced by get_profile_size(), and link_dlg_profile().

static void destroy_dlg_profile ( struct dlg_profile_table profile  )  [static]

Destroy a dialog profile list.

Parameters:
profile dialog profile

Definition at line 230 of file dlg_profile.c.

References dlg_profile_table::lock, NULL, and shm_free.

Referenced by destroy_dlg_profiles().

void destroy_dlg_profiles ( void   ) 

Destroy the global dialog profile list.

Definition at line 244 of file dlg_profile.c.

References destroy_dlg_profile(), and dlg_profile_table::next.

Referenced by mod_destroy().

void destroy_linkers ( struct dlg_profile_link linker  ) 

static struct dlg_cell* get_current_dialog ( struct sip_msg msg  )  [static, read]

Get the current dialog for a message, if exists.

Parameters:
msg SIP message
Returns:
NULL if called in REQUEST_ROUTE, pointer to dialog ctx otherwise

Definition at line 322 of file dlg_profile.c.

References current_dlg_msg_id, d_tmb, destroy_linkers(), cell::dialog_ctx, sip_msg::id, NULL, REQUEST_ROUTE, route_type, tm_binds::t_gett, and T_UNDEFINED.

Referenced by is_dlg_in_profile(), set_dlg_profile(), and unset_dlg_profile().

unsigned int get_profile_size ( struct dlg_profile_table profile,
str value 
)

int is_dlg_in_profile ( struct sip_msg msg,
struct dlg_profile_table profile,
str value 
)

Check if a dialog belongs to a profile.

Parameters:
msg SIP message
profile dialog profile table
value value
Returns:
1 on success, -1 on failure

Definition at line 564 of file dlg_profile.c.

References d_table, dlg_lock, dlg_unlock, dlg_table::entries, get_current_dialog(), dlg_cell::h_entry, dlg_profile_table::has_value, dlg_profile_link::hash_linker, _str::len, dlg_profile_link::next, NULL, dlg_profile_link::profile, dlg_cell::profile_links, _str::s, and dlg_profile_hash::value.

Referenced by w_is_in_profile().

static void link_dlg_profile ( struct dlg_profile_link linker,
struct dlg_cell dlg 
) [static]

struct mi_root* mi_get_profile ( struct mi_root cmd_tree,
void *  param 
) [read]

Output a profile via MI interface.

Parameters:
cmd_tree MI command tree
param unused
Returns:
MI root output on success, NULL on failure

Definition at line 650 of file dlg_profile.c.

References add_mi_attr(), add_mi_node_child(), free_mi_tree(), get_profile_size(), init_mi_tree(), int2str(), mi_node::kids, _str::len, len, MI_BAD_PARM, MI_DUP_VALUE, MI_MISSING_PARM, MI_OK, MI_SSTR, dlg_profile_table::name, mi_node::next, mi_root::node, NULL, _str::s, search_dlg_profile(), dlg_profile_table::size, and mi_node::value.

struct mi_root* mi_profile_list ( struct mi_root cmd_tree,
void *  param 
) [read]

static struct dlg_profile_table * new_dlg_profile ( str name,
unsigned int  size,
unsigned int  has_value 
) [static, read]

Creates a new dialog profile.

See also:
add_profile_definitions
Parameters:
name profile name
size profile size
has_value set to 0 for a profile without value, otherwise it has a value
Returns:
pointer to the created dialog on success, NULL otherwise

Definition at line 157 of file dlg_profile.c.

References dlg_profile_table::has_value, _str::len, len, LM_ERR, dlg_profile_table::next, NULL, _str::s, search_dlg_profile(), shm_free, and shm_malloc().

Referenced by add_profile_definitions().

int profile_cleanup ( struct sip_msg msg,
void *  param 
)

Cleanup a profile.

Parameters:
msg SIP message
unused 
Returns:
1

Definition at line 300 of file dlg_profile.c.

References current_dlg_msg_id, destroy_linkers(), NULL, and unref_dlg().

Referenced by dlg_new_dialog(), and mod_init().

struct dlg_profile_table* search_dlg_profile ( str name  )  [read]

Search a dialog profile in the global list.

Note:
Linear search, this won't have the best performance for huge profile lists
Parameters:
name searched dialog profile
Returns:
pointer to the profile on success, NULL otherwise

Definition at line 136 of file dlg_profile.c.

References _str::len, dlg_profile_table::name, dlg_profile_table::next, NULL, and _str::s.

Referenced by fixup_profile(), mi_get_profile(), mi_profile_list(), and new_dlg_profile().

void set_current_dialog ( struct sip_msg msg,
struct dlg_cell dlg 
)

Set the global variables to the current dialog.

Parameters:
msg SIP message
dlg dialog cell

Definition at line 419 of file dlg_profile.c.

References current_dlg_msg_id, destroy_linkers(), sip_msg::id, link_dlg_profile(), dlg_profile_link::next, and NULL.

Referenced by dlg_onroute().

int set_dlg_profile ( struct sip_msg msg,
str value,
struct dlg_profile_table profile 
)

Set a dialog profile.

Set the dialog profile.

Parameters:
msg SIP message
value value
profile dialog profile table
Returns:
0 on success, -1 on failure

Definition at line 451 of file dlg_profile.c.

References get_current_dialog(), dlg_profile_table::has_value, dlg_profile_link::hash_linker, _str::len, link_dlg_profile(), LM_CRIT, LM_ERR, dlg_profile_link::next, NULL, dlg_profile_link::profile, REQUEST_ROUTE, route_type, _str::s, shm_malloc(), and dlg_profile_hash::value.

Referenced by w_set_dlg_profile().

int unset_dlg_profile ( struct sip_msg msg,
str value,
struct dlg_profile_table profile 
)

Unset a dialog profile.

Parameters:
msg SIP message
value value
profile dialog profile table
Returns:
1 on success, -1 on failure

Definition at line 504 of file dlg_profile.c.

References d_table, destroy_linkers(), dlg_lock, dlg_unlock, dlg_table::entries, get_current_dialog(), dlg_cell::h_entry, dlg_profile_table::has_value, _str::len, LM_CRIT, dlg_profile_link::next, NULL, dlg_cell::profile_links, REQUEST_ROUTE, route_type, and _str::s.

Referenced by w_unset_dlg_profile().


Variable Documentation

unsigned int current_dlg_msg_id = 0 [static]

global dialog message id

Definition at line 54 of file dlg_profile.c.

Referenced by get_current_dialog(), profile_cleanup(), and set_current_dialog().

struct dlg_cell* current_dlg_pointer = NULL

global dialog

Definition at line 57 of file dlg_profile.c.

Referenced by dlg_new_dialog(), dlg_onreq(), dlg_onroute(), and w_dlg_get().

struct dlg_profile_link* current_pending_linkers = NULL [static]

pending dialog links

Definition at line 60 of file dlg_profile.c.

struct tm_binds d_tmb

tm bindings

Definition at line 100 of file dialog.c.

struct dlg_profile_table* profiles = NULL [static]

global dialog profile list

Definition at line 63 of file dlg_profile.c.


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