Defines | Functions | Variables

dlg_hash.c File Reference

Functions related to dialog creation and searchingModule: dialog :: Kamailio dialog module. More...

#include <stdlib.h>
#include <string.h>
#include "../../dprint.h"
#include "../../ut.h"
#include "../../hashes.h"
#include "../../lib/kmi/mi.h"
#include "dlg_timer.h"
#include "dlg_var.h"
#include "dlg_hash.h"
#include "dlg_profile.h"
#include "dlg_req_within.h"
#include "dlg_db_handler.h"
Include dependency graph for dlg_hash.c:

Go to the source code of this file.

Defines

Functions

Variables


Detailed Description

Definition in file dlg_hash.c.


Define Documentation

#define ref_dlg_unsafe (   _dlg,
  _cnt 
)
Value:
do { \
                (_dlg)->ref += (_cnt); \
                LM_DBG("ref dlg %p with %d -> %d\n", \
                        (_dlg),(_cnt),(_dlg)->ref); \
        }while(0)
Parameters:
_dlg dialog
_cnt increment for the reference counter

Definition at line 83 of file dlg_hash.c.

Referenced by dlg_lookup(), dlg_ref(), internal_get_dlg(), link_dlg(), and next_state_dlg().

#define unref_dlg_unsafe (   _dlg,
  _cnt,
  _d_entry 
)
Value:
do { \
                if((_dlg)->ref <= 0 ) { \
                        LM_WARN("invalid unref'ing dlg %p with ref %d by %d\n",\
                                        (_dlg),(_dlg)->ref,(_cnt));\
                        break; \
                } \
                (_dlg)->ref -= (_cnt); \
                LM_DBG("unref dlg %p with %d -> %d\n",\
                        (_dlg),(_cnt),(_dlg)->ref);\
                if ((_dlg)->ref<0) {\
                        LM_CRIT("bogus ref %d with cnt %d for dlg %p [%u:%u] "\
                                "with clid '%.*s' and tags '%.*s' '%.*s'\n",\
                                (_dlg)->ref, _cnt, _dlg,\
                                (_dlg)->h_entry, (_dlg)->h_id,\
                                (_dlg)->callid.len, (_dlg)->callid.s,\
                                (_dlg)->tag[DLG_CALLER_LEG].len,\
                                (_dlg)->tag[DLG_CALLER_LEG].s,\
                                (_dlg)->tag[DLG_CALLEE_LEG].len,\
                                (_dlg)->tag[DLG_CALLEE_LEG].s); \
                }\
                if ((_dlg)->ref<=0) { \
                        unlink_unsafe_dlg( _d_entry, _dlg);\
                        LM_DBG("ref <=0 for dialog %p\n",_dlg);\
                        destroy_dlg(_dlg);\
                }\
        }while(0)
Parameters:
_dlg dialog
_cnt decrement for the reference counter
_d_entry dialog entry

Definition at line 97 of file dlg_hash.c.

Referenced by dlg_unref(), and next_state_dlg().


Function Documentation

struct dlg_cell* build_new_dlg ( str callid,
str from_uri,
str to_uri,
str from_tag,
str req_uri 
) [read]
Parameters:
callid dialog callid
from_uri dialog from uri
to_uri dialog to uri
from_tag dialog from tag
req_uri dialog r-uri
Returns:
created dialog structure on success, NULL otherwise

Definition at line 419 of file dlg_hash.c.

References dlg_cell::from_uri, dlg_cell::req_uri, _str::s, dlg_table::size, and dlg_cell::to_uri.

Referenced by dlg_new_dialog().

Here is the caller graph for this function:

void destroy_dlg ( struct dlg_cell dlg  )  [inline]
Parameters:
dlg destroyed dialog

Definition at line 310 of file dlg_hash.c.

References dlg_cell::callid, dlg_cell::cbs, dlg_cell::cseq, destroy_linkers(), DLG_CALLEE_LEG, DLG_CALLER_LEG, DLG_DIR_NONE, dlg_cell::h_entry, dlg_cell::h_id, _str::len, dlg_cell::profile_links, dlg_cell::ref, remove_dialog_timer(), _str::s, dlg_cell::tag, dlg_cell::tl, dlg_cell::toroute_name, and dlg_cell::vars.

Referenced by destroy_dlg_table().

Here is the call graph for this function:

Here is the caller graph for this function:

dlg_cell_t* dlg_get_by_iuid ( dlg_iuid_t diuid  ) 

Search and return dialog in the global list by iuid.

Note that the caller is responsible for decrementing (or reusing) the reference counter by one again if a dialog has been found.

Parameters:
diuid internal unique id per dialog
Returns:
dialog structure on success, NULL on failure

Definition at line 610 of file dlg_hash.c.

References dlg_lookup(), dlg_iuid::h_entry, and dlg_iuid::h_id.

Referenced by dlg_ka_run(), dlg_onreply(), dlg_ontdestroy(), dlg_seq_onreply_helper(), dlg_terminated_confirmed(), and unref_dlg_from_cb().

Here is the call graph for this function:

Here is the caller graph for this function:

int dlg_ka_add ( dlg_cell_t dlg  ) 

Definition at line 129 of file dlg_hash.c.

References DLG_IFLAG_KA_SRC, dlg_cell::h_entry, dlg_cell::h_id, and dlg_cell::iflags.

Referenced by dlg_onroute().

Here is the caller graph for this function:

int dlg_ka_run ( ticks_t  ti  ) 

Definition at line 164 of file dlg_hash.c.

References DLG_CALLEE_LEG, DLG_CALLER_LEG, dlg_get_by_iuid(), DLG_IFLAG_KA_DST, DLG_IFLAG_KA_SRC, and dlg_release().

Here is the call graph for this function:

dlg_cell_t* dlg_lookup ( unsigned int  h_entry,
unsigned int  h_id 
)

Note that the caller is responsible for decrementing (or reusing) the reference counter by one again iff a dialog has been found.

Parameters:
h_entry number of the hash table entry
h_id id of the hash table entry
Returns:
dialog structure on success, NULL on failure

Definition at line 571 of file dlg_hash.c.

References dlg_lock, dlg_unlock, dlg_table::entries, dlg_entry::first, dlg_cell::h_id, dlg_cell::next, ref_dlg_unsafe, and dlg_table::size.

Referenced by dlg_get_by_iuid(), and dlg_onroute().

Here is the caller graph for this function:

void dlg_ref ( dlg_cell_t dlg,
unsigned int  cnt 
)
See also:
ref_dlg_unsafe
Parameters:
dlg dialog
cnt increment for the reference counter

Definition at line 728 of file dlg_hash.c.

References dlg_lock, dlg_unlock, dlg_table::entries, dlg_cell::h_entry, and ref_dlg_unsafe.

Referenced by dlg_new_dialog(), dlg_onreply(), dlg_onroute(), dlg_ontimeout(), dlg_run_event_route(), and dlg_set_tm_waitack().

Here is the caller graph for this function:

void dlg_release ( dlg_cell_t dlg  ) 
See also:
dlg_unref
Parameters:
dlg dialog

Definition at line 763 of file dlg_hash.c.

References dlg_unref().

Referenced by dlg_ka_run(), dlg_new_dialog(), dlg_onreply(), dlg_onreq(), dlg_onroute(), dlg_seq_onreply_helper(), dlg_terminated_confirmed(), is_dlg_in_profile(), is_known_dlg(), set_dlg_profile(), and unset_dlg_profile().

Here is the call graph for this function:

Here is the caller graph for this function:

int dlg_set_leg_info ( struct dlg_cell dlg,
str tag,
str rr,
str contact,
str cseq,
unsigned int  leg 
)
Parameters:
dlg dialog
tag from tag or to tag
rr record-routing information
contact caller or callee contact
cseq CSEQ of caller or callee
leg must be either DLG_CALLER_LEG, or DLG_CALLEE_LEG
Returns:
0 on success, -1 on failure

Definition at line 482 of file dlg_hash.c.

References dlg_cell::contact, dlg_cell::cseq, _str::len, dlg_cell::route_set, _str::s, and dlg_cell::tag.

Referenced by populate_leg_info().

Here is the caller graph for this function:

int dlg_set_toroute ( dlg_cell_t dlg,
str route 
)
Parameters:
dlg dialog
route name of route
Returns:
0 on success, -1 on failure

Definition at line 946 of file dlg_hash.c.

References _str::len, _str::s, dlg_cell::toroute, and dlg_cell::toroute_name.

Referenced by dlg_new_dialog().

Here is the caller graph for this function:

void dlg_unref ( dlg_cell_t dlg,
unsigned int  cnt 
)
See also:
unref_dlg_unsafe
Parameters:
dlg dialog
cnt decrement for the reference counter

Definition at line 746 of file dlg_hash.c.

References dlg_lock, dlg_unlock, dlg_table::entries, dlg_cell::h_entry, and unref_dlg_unsafe.

Referenced by dlg_new_dialog(), dlg_onreply(), dlg_onroute(), dlg_ontdestroy(), dlg_ontimeout(), dlg_release(), dlg_run_event_route(), dlg_set_tm_waitack(), profile_cleanup(), and unref_dlg_from_cb().

Here is the caller graph for this function:

int dlg_update_cseq ( struct dlg_cell dlg,
unsigned int  leg,
str cseq 
)
Parameters:
dlg dialog
leg must be either DLG_CALLER_LEG, or DLG_CALLEE_LEG
cseq CSEQ of caller or callee
Returns:
0 on success, -1 on failure

Definition at line 536 of file dlg_hash.c.

References dlg_cell::cseq, _str::len, and _str::s.

Referenced by update_cseqs().

Here is the caller graph for this function:

struct dlg_cell* get_dlg ( str callid,
str ftag,
str ttag,
unsigned int *  dir 
) [read]

Get dialog that correspond to CallId, From Tag and To Tag. See RFC 3261, paragraph 4. Overview of Operation: "The combination of the To tag, From tag, and Call-ID completely defines a peer-to-peer SIP relationship between [two UAs] and is referred to as a dialog." Note that the caller is responsible for decrementing (or reusing) the reference counter by one again iff a dialog has been found.

Parameters:
callid callid
ftag from tag
ttag to tag
dir direction
Returns:
dialog structure on success, NULL on failure

Definition at line 674 of file dlg_hash.c.

References internal_get_dlg(), _str::len, _str::s, and dlg_table::size.

Referenced by dlg_get_msg_dialog(), dlg_new_dialog(), and dlg_onroute().

Here is the call graph for this function:

Here is the caller graph for this function:

int init_dlg_table ( unsigned int  size  ) 
Parameters:
size size of the table
Returns:
0 on success, -1 on failure

Definition at line 230 of file dlg_hash.c.

References dlg_table::entries, dlg_entry::lock_idx, dlg_table::locks, dlg_table::locks_no, dlg_entry::next_id, and dlg_table::size.

static struct dlg_cell* internal_get_dlg ( unsigned int  h_entry,
str callid,
str ftag,
str ttag,
unsigned int *  dir 
) [static, read]
See also:
get_dlg
Parameters:
h_entry hash index in the directory list
callid callid
ftag from tag
ttag to tag
dir direction
Returns:
dialog structure on success, NULL on failure

Definition at line 630 of file dlg_hash.c.

References dlg_lock, dlg_unlock, dlg_table::entries, dlg_entry::first, _str::len, match_dialog(), dlg_cell::next, ref_dlg_unsafe, and _str::s.

Referenced by get_dlg().

Here is the call graph for this function:

Here is the caller graph for this function:

static int internal_mi_print_dlg ( struct mi_node *  rpl,
struct dlg_cell dlg,
int  with_context 
) [inline, static]
See also:
mi_print_dlg
Parameters:
rpl MI node that should be filled
dlg printed dialog
with_context if 1 then the dialog context will be also printed
Returns:
0 on success, -1 on failure

Definition at line 976 of file dlg_hash.c.

References dlg_cell::callid, dlg_cell::contact, dlg_cell::cseq, DLG_CALLEE_LEG, DLG_CALLER_LEG, DLG_DIR_NONE, dlg_cell::from_uri, dlg_cell::h_entry, dlg_cell::h_id, int2str(), _str::len, dlg_cell::ref, dlg_cell::route_set, _str::s, dlg_cell::start_ts, dlg_cell::state, dlg_cell::tag, dlg_tl::timeout, dlg_cell::tl, and dlg_cell::to_uri.

Referenced by internal_mi_print_dlgs(), mi_print_dlg(), mi_print_dlgs(), and mi_print_dlgs_ctx().

Here is the call graph for this function:

Here is the caller graph for this function:

static int internal_mi_print_dlgs ( struct mi_node *  rpl,
int  with_context 
) [static]
See also:
mi_print_dlgs
Parameters:
rpl MI node that should be filled
with_context if 1 then the dialog context will be also printed
Returns:
0 on success, -1 on failure

Definition at line 1133 of file dlg_hash.c.

References dlg_lock, dlg_unlock, dlg_table::entries, dlg_entry::first, internal_mi_print_dlg(), dlg_cell::next, and dlg_table::size.

Referenced by mi_print_dlgs(), and mi_print_dlgs_ctx().

Here is the call graph for this function:

Here is the caller graph for this function:

void link_dlg ( struct dlg_cell dlg,
int  n 
)
Parameters:
dlg dialog
n extra increments for the reference counter

Definition at line 695 of file dlg_hash.c.

References dlg_lock, dlg_unlock, dlg_table::entries, dlg_entry::first, dlg_cell::h_entry, dlg_cell::h_id, dlg_entry::last, dlg_cell::next, dlg_entry::next_id, dlg_cell::prev, and ref_dlg_unsafe.

Referenced by dlg_new_dialog().

Here is the caller graph for this function:

static void log_next_state_dlg ( const int  event,
const struct dlg_cell dlg 
) [inline, static]
Parameters:
event logged event
dlg dialog data
See also:
next_state_dlg

Definition at line 777 of file dlg_hash.c.

References dlg_cell::callid, DLG_CALLEE_LEG, DLG_CALLER_LEG, dlg_cell::h_entry, dlg_cell::h_id, _str::len, _str::s, dlg_cell::state, and dlg_cell::tag.

Referenced by next_state_dlg().

Here is the caller graph for this function:

int mi_print_dlg ( struct mi_node *  rpl,
struct dlg_cell dlg,
int  with_context 
)
Parameters:
rpl MI node that should be filled
dlg printed dialog
with_context if 1 then the dialog context will be also printed
Returns:
0 on success, -1 on failure

Definition at line 1121 of file dlg_hash.c.

References internal_mi_print_dlg().

Referenced by mi_profile_list().

Here is the call graph for this function:

Here is the caller graph for this function:

struct mi_root* mi_print_dlgs ( struct mi_root *  cmd_tree,
void *  param 
) [read]
Parameters:
cmd_tree MI command tree
param unused
Returns:
mi node with the dialog information, or NULL on failure

Definition at line 1218 of file dlg_hash.c.

References internal_mi_print_dlg(), and internal_mi_print_dlgs().

Here is the call graph for this function:

struct mi_root* mi_print_dlgs_ctx ( struct mi_root *  cmd_tree,
void *  param 
) [read]
Parameters:
cmd_tree MI command tree
param unused
Returns:
mi node with the dialog information, or NULL on failure

Definition at line 1255 of file dlg_hash.c.

References internal_mi_print_dlg(), and internal_mi_print_dlgs().

Here is the call graph for this function:

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

Terminate selected dialogs via the MI interface.

Parameters:
cmd_tree MI command tree
param unused
Returns:
mi node with the dialog information, or NULL on failure

Definition at line 1291 of file dlg_hash.c.

void next_state_dlg ( dlg_cell_t dlg,
int  event,
int *  old_state,
int *  new_state,
int *  unref 
)

This functions implement the main state machine that update a dialog state according a processed event and the current state. If necessary it will delete the processed dialog. The old and new state are also saved for reference.

Parameters:
dlg updated dialog
event current event
old_state old dialog state
new_state new dialog state
unref set to 1 when the dialog was deleted, 0 otherwise

Definition at line 799 of file dlg_hash.c.

References dlg_cell::callid, dlg_cell::dflags, DLG_CALLEE_LEG, DLG_CALLER_LEG, DLG_EVENT_REQ, DLG_EVENT_REQACK, DLG_EVENT_REQBYE, DLG_EVENT_REQPRACK, DLG_EVENT_RPL1xx, DLG_EVENT_RPL2xx, DLG_EVENT_RPL3xx, DLG_EVENT_TDEL, DLG_FLAG_HASBYE, dlg_lock, DLG_STATE_CONFIRMED, DLG_STATE_CONFIRMED_NA, DLG_STATE_DELETED, DLG_STATE_EARLY, DLG_STATE_UNCONFIRMED, dlg_unlock, dlg_table::entries, dlg_cell::h_entry, dlg_cell::h_id, _str::len, log_next_state_dlg(), dlg_cell::ref, ref_dlg_unsafe, _str::s, dlg_cell::state, dlg_cell::tag, and unref_dlg_unsafe.

Referenced by dlg_onreply(), dlg_onroute(), and dlg_ontimeout().

Here is the call graph for this function:

Here is the caller graph for this function: