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"
Go to the source code of this file.
Definition in file dlg_hash.c.
| #define ref_dlg_unsafe | ( | _dlg, | ||
| _cnt | ||||
| ) |
do { \ (_dlg)->ref += (_cnt); \ LM_DBG("ref dlg %p with %d -> %d\n", \ (_dlg),(_cnt),(_dlg)->ref); \ }while(0)
| _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 | ||||
| ) |
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)
| _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().
| struct dlg_cell* build_new_dlg | ( | str * | callid, | |
| str * | from_uri, | |||
| str * | to_uri, | |||
| str * | from_tag, | |||
| str * | req_uri | |||
| ) | [read] |
| callid | dialog callid | |
| from_uri | dialog from uri | |
| to_uri | dialog to uri | |
| from_tag | dialog from tag | |
| req_uri | dialog r-uri |
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().

| void destroy_dlg | ( | struct dlg_cell * | dlg | ) | [inline] |
| 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().


| 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.
| diuid | internal unique id per dialog |
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().


| 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().

| 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().

| 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.
| h_entry | number of the hash table entry | |
| h_id | id of the hash table entry |
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().

| void dlg_ref | ( | dlg_cell_t * | dlg, | |
| unsigned int | cnt | |||
| ) |
| 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().

| void dlg_release | ( | dlg_cell_t * | dlg | ) |
| 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().


| int dlg_set_leg_info | ( | struct dlg_cell * | dlg, | |
| str * | tag, | |||
| str * | rr, | |||
| str * | contact, | |||
| str * | cseq, | |||
| unsigned int | leg | |||
| ) |
| 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 |
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().

| int dlg_set_toroute | ( | dlg_cell_t * | dlg, | |
| str * | route | |||
| ) |
| dlg | dialog | |
| route | name of route |
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().

| void dlg_unref | ( | dlg_cell_t * | dlg, | |
| unsigned int | cnt | |||
| ) |
| 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().

| dlg | dialog | |
| leg | must be either DLG_CALLER_LEG, or DLG_CALLEE_LEG | |
| cseq | CSEQ of caller or callee |
Definition at line 536 of file dlg_hash.c.
References dlg_cell::cseq, _str::len, and _str::s.
Referenced by update_cseqs().

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.
| callid | callid | |
| ftag | from tag | |
| ttag | to tag | |
| dir | direction |
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().


| int init_dlg_table | ( | unsigned int | size | ) |
| size | size of the table |
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] |
| h_entry | hash index in the directory list | |
| callid | callid | |
| ftag | from tag | |
| ttag | to tag | |
| dir | direction |
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().


| static int internal_mi_print_dlg | ( | struct mi_node * | rpl, | |
| struct dlg_cell * | dlg, | |||
| int | with_context | |||
| ) | [inline, static] |
| rpl | MI node that should be filled | |
| dlg | printed dialog | |
| with_context | if 1 then the dialog context will be also printed |
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().


| static int internal_mi_print_dlgs | ( | struct mi_node * | rpl, | |
| int | with_context | |||
| ) | [static] |
| rpl | MI node that should be filled | |
| with_context | if 1 then the dialog context will be also printed |
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().


| void link_dlg | ( | struct dlg_cell * | dlg, | |
| int | n | |||
| ) |
| 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().

| static void log_next_state_dlg | ( | const int | event, | |
| const struct dlg_cell * | dlg | |||
| ) | [inline, static] |
| event | logged event | |
| dlg | dialog data |
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().

| int mi_print_dlg | ( | struct mi_node * | rpl, | |
| struct dlg_cell * | dlg, | |||
| int | with_context | |||
| ) |
| rpl | MI node that should be filled | |
| dlg | printed dialog | |
| with_context | if 1 then the dialog context will be also printed |
Definition at line 1121 of file dlg_hash.c.
References internal_mi_print_dlg().
Referenced by mi_profile_list().


| struct mi_root* mi_print_dlgs | ( | struct mi_root * | cmd_tree, | |
| void * | param | |||
| ) | [read] |
| cmd_tree | MI command tree | |
| param | unused |
Definition at line 1218 of file dlg_hash.c.
References internal_mi_print_dlg(), and internal_mi_print_dlgs().

| struct mi_root* mi_print_dlgs_ctx | ( | struct mi_root * | cmd_tree, | |
| void * | param | |||
| ) | [read] |
| cmd_tree | MI command tree | |
| param | unused |
Definition at line 1255 of file dlg_hash.c.
References internal_mi_print_dlg(), and internal_mi_print_dlgs().

| struct mi_root* mi_terminate_dlgs | ( | struct mi_root * | cmd_tree, | |
| void * | param | |||
| ) | [read] |
Terminate selected dialogs via the MI interface.
| cmd_tree | MI command tree | |
| param | unused |
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.
| 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().


1.7.1