diff --git a/src/modules/dialog/Makefile b/src/modules/dialog/Makefile index 56442dc0579..95acdfcb23a 100644 --- a/src/modules/dialog/Makefile +++ b/src/modules/dialog/Makefile @@ -9,7 +9,6 @@ LIBS= DEFS+=-DKAMAILIO_MOD_INTERFACE SERLIBPATH=../../lib -SER_LIBS+=$(SERLIBPATH)/kmi/kmi SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1 SER_LIBS+=$(SERLIBPATH)/srutils/srutils include ../../Makefile.modules diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c index eb5bfa5fa69..4879a480ad4 100644 --- a/src/modules/dialog/dialog.c +++ b/src/modules/dialog/dialog.c @@ -60,7 +60,6 @@ #include "../../core/hashes.h" #include "../../core/counters.h" #include "../../core/mem/mem.h" -#include "../../lib/kmi/mi.h" #include "../../core/timer_proc.h" #include "../../core/lvalue.h" #include "../../core/parser/parse_to.h" @@ -313,19 +312,6 @@ static stat_export_t mod_stats[] = { {0,0,0} }; -struct mi_root * mi_dlg_bridge(struct mi_root *cmd_tree, void *param); - -static mi_export_t mi_cmds[] = { - { "dlg_list", mi_print_dlgs, 0, 0, 0}, - { "dlg_list_ctx", mi_print_dlgs_ctx, 0, 0, 0}, - { "dlg_end_dlg", mi_terminate_dlg, 0, 0, 0}, - { "dlg_terminate_dlg", mi_terminate_dlgs, 0, 0, 0}, - { "profile_get_size", mi_get_profile, 0, 0, 0}, - { "profile_list_dlgs", mi_profile_list, 0, 0, 0}, - { "dlg_bridge", mi_dlg_bridge, 0, 0, 0}, - { 0, 0, 0, 0, 0} -}; - static rpc_export_t rpc_methods[]; static pv_export_t mod_items[] = { @@ -350,7 +336,7 @@ struct module_exports exports= { cmds, /* exported functions */ mod_params, /* param exports */ mod_stats, /* exported statistics */ - mi_cmds, /* exported MI functions */ + 0, /* exported MI functions */ mod_items, /* exported pseudo-variables */ 0, /* extra processes */ mod_init, /* module initialization function */ @@ -486,12 +472,6 @@ static int mod_init(void) } #endif - if(register_mi_mod(exports.name, mi_cmds)!=0) - { - LM_ERR("failed to register MI commands\n"); - return -1; - } - if (rpc_register_array(rpc_methods)!=0) { LM_ERR("failed to register RPC commands\n"); return -1; @@ -1438,63 +1418,6 @@ static int fixup_dlg_remote_profile(void** param, int param_no) return 0; } -struct mi_root * mi_dlg_bridge(struct mi_root *cmd_tree, void *param) -{ - str from = {0,0}; - str to = {0,0}; - str op = {0,0}; - str bd = {0,0}; - struct mi_node* node; - - node = cmd_tree->node.kids; - if(node == NULL) - return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); - from = node->value; - if(from.len<=0 || from.s==NULL) - { - LM_ERR("bad From value\n"); - return init_mi_tree( 500, "Bad From value", 14); - } - - node = node->next; - if(node == NULL) - return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); - to = node->value; - if(to.len<=0 || to.s == NULL) - { - return init_mi_tree(500, "Bad To value", 12); - } - - node= node->next; - if(node != NULL) - { - op = node->value; - if(op.len<=0 || op.s==NULL) - { - return init_mi_tree(500, "Bad OP value", 12); - } - if(op.len==1 && *op.s=='.') - { - op.s = NULL; - op.len = 0; - } - node= node->next; - if(node != NULL) - { - bd = node->value; - if(bd.len<=0 || bd.s==NULL) - { - return init_mi_tree(500, "Bad SDP value", 13); - } - } - } - - if(dlg_bridge(&from, &to, &op, &bd)!=0) - return init_mi_tree(500, MI_INTERNAL_ERR_S, MI_INTERNAL_ERR_LEN); - - return init_mi_tree(200, MI_OK_S, MI_OK_LEN); -} - /**************************** RPC functions ******************************/ /*! * \brief Helper method that outputs a dialog via the RPC interface diff --git a/src/modules/dialog/dlg_cb.h b/src/modules/dialog/dlg_cb.h index 9a7a1ec66b8..82afa05a82c 100644 --- a/src/modules/dialog/dlg_cb.h +++ b/src/modules/dialog/dlg_cb.h @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ @@ -71,7 +71,7 @@ typedef str* (*get_dlg_variable_f)( struct dlg_cell* dlg, #define DLGCB_EARLY (1<<8) #define DLGCB_RESPONSE_FWDED (1<<9) #define DLGCB_RESPONSE_WITHIN (1<<10) -#define DLGCB_MI_CONTEXT (1<<11) + #define DLGCB_RPC_CONTEXT (1<<12) #define DLGCB_DESTROY (1<<13) #define DLGCB_SPIRALED (1<<14) diff --git a/src/modules/dialog/dlg_hash.c b/src/modules/dialog/dlg_hash.c index 878bb99afa4..8c5c7a6acb2 100644 --- a/src/modules/dialog/dlg_hash.c +++ b/src/modules/dialog/dlg_hash.c @@ -34,7 +34,6 @@ #include "../../core/dprint.h" #include "../../core/ut.h" #include "../../core/hashes.h" -#include "../../lib/kmi/mi.h" #include "../../core/counters.h" #include "../../core/rand/kam_rand.h" #include "dlg_timer.h" @@ -1176,355 +1175,3 @@ int update_dlg_timeout(dlg_cell_t *dlg, int timeout) return 0; } - -/**************************** MI functions ******************************/ -/*! - * \brief Helper method that output a dialog via the MI interface - * \see mi_print_dlg - * \param rpl MI node that should be filled - * \param dlg printed dialog - * \param with_context if 1 then the dialog context will be also printed - * \return 0 on success, -1 on failure - */ -static inline int internal_mi_print_dlg(struct mi_node *rpl, - struct dlg_cell *dlg, int with_context) -{ - struct mi_node* node= NULL; - struct mi_node* node1 = NULL; - struct mi_attr* attr= NULL; - int len; - char* p; - - node = add_mi_node_child(rpl, 0, "dialog",6 , 0, 0 ); - if (node==0) - goto error; - - attr = addf_mi_attr( node, 0, "hash", 4, "%u:%u", - dlg->h_entry, dlg->h_id ); - if (attr==0) - goto error; - - p= int2str((unsigned long)dlg->state, &len); - node1 = add_mi_node_child( node, MI_DUP_VALUE, "state", 5, p, len); - if (node1==0) - goto error; - - p= int2str((unsigned long)dlg->ref, &len); - node1 = add_mi_node_child( node, MI_DUP_VALUE, "ref_count", 9, p, len); - if (node1==0) - goto error; - - p= int2str((unsigned long)dlg->start_ts, &len); - node1 = add_mi_node_child(node,MI_DUP_VALUE,"timestart",9, p, len); - if (node1==0) - goto error; - - p= int2str((unsigned long)dlg->tl.timeout, &len); - node1 = add_mi_node_child(node,MI_DUP_VALUE, "timeout", 7, p, len); - if (node1==0) - goto error; - - node1 = add_mi_node_child(node, MI_DUP_VALUE, "callid", 6, - dlg->callid.s, dlg->callid.len); - if(node1 == 0) - goto error; - - node1 = add_mi_node_child(node, MI_DUP_VALUE, "from_uri", 8, - dlg->from_uri.s, dlg->from_uri.len); - if(node1 == 0) - goto error; - - node1 = add_mi_node_child(node, MI_DUP_VALUE, "from_tag", 8, - dlg->tag[DLG_CALLER_LEG].s, dlg->tag[DLG_CALLER_LEG].len); - if(node1 == 0) - goto error; - - node1 = add_mi_node_child(node, MI_DUP_VALUE, "caller_contact", 14, - dlg->contact[DLG_CALLER_LEG].s, - dlg->contact[DLG_CALLER_LEG].len); - if(node1 == 0) - goto error; - - node1 = add_mi_node_child(node, MI_DUP_VALUE, "caller_cseq", 11, - dlg->cseq[DLG_CALLER_LEG].s, - dlg->cseq[DLG_CALLER_LEG].len); - if(node1 == 0) - goto error; - - node1 = add_mi_node_child(node, MI_DUP_VALUE,"caller_route_set",16, - dlg->route_set[DLG_CALLER_LEG].s, - dlg->route_set[DLG_CALLER_LEG].len); - if(node1 == 0) - goto error; - - if (dlg->bind_addr[DLG_CALLER_LEG]) { - node1 = add_mi_node_child(node, 0, - "caller_bind_addr",16, - dlg->bind_addr[DLG_CALLER_LEG]->sock_str.s, - dlg->bind_addr[DLG_CALLER_LEG]->sock_str.len); - } else { - node1 = add_mi_node_child(node, 0, - "caller_bind_addr",16,0,0); - } - - if (dlg->bind_addr[DLG_CALLEE_LEG]) { - node1 = add_mi_node_child(node, 0, - "callee_bind_addr",16, - dlg->bind_addr[DLG_CALLEE_LEG]->sock_str.s, - dlg->bind_addr[DLG_CALLEE_LEG]->sock_str.len); - } else { - node1 = add_mi_node_child(node, 0, - "callee_bind_addr",16,0,0); - } - - node1 = add_mi_node_child(node, MI_DUP_VALUE, "to_uri", 6, - dlg->to_uri.s, dlg->to_uri.len); - if(node1 == 0) - goto error; - - node1 = add_mi_node_child(node, MI_DUP_VALUE, "to_tag", 6, - dlg->tag[DLG_CALLEE_LEG].s, dlg->tag[DLG_CALLEE_LEG].len); - if(node1 == 0) - goto error; - - node1 = add_mi_node_child(node, MI_DUP_VALUE, "callee_contact", 14, - dlg->contact[DLG_CALLEE_LEG].s, - dlg->contact[DLG_CALLEE_LEG].len); - if(node1 == 0) - goto error; - - node1 = add_mi_node_child(node, MI_DUP_VALUE, "callee_cseq", 11, - dlg->cseq[DLG_CALLEE_LEG].s, - dlg->cseq[DLG_CALLEE_LEG].len); - if(node1 == 0) - goto error; - - node1 = add_mi_node_child(node, MI_DUP_VALUE,"callee_route_set",16, - dlg->route_set[DLG_CALLEE_LEG].s, - dlg->route_set[DLG_CALLEE_LEG].len); - if(node1 == 0) - goto error; - - if (with_context) { - node1 = add_mi_node_child(node, 0, "context", 7, 0, 0); - if(node1 == 0) - goto error; - run_dlg_callbacks( DLGCB_MI_CONTEXT, - dlg, - NULL, - NULL, - DLG_DIR_NONE, - (void *)node1); - } - return 0; - -error: - LM_ERR("failed to add node\n"); - return -1; -} - - -/*! - * \brief Output a dialog via the MI interface - * \param rpl MI node that should be filled - * \param dlg printed dialog - * \param with_context if 1 then the dialog context will be also printed - * \return 0 on success, -1 on failure - */ -int mi_print_dlg(struct mi_node *rpl, struct dlg_cell *dlg, int with_context) -{ - return internal_mi_print_dlg( rpl, dlg, with_context); -} - -/*! - * \brief Helper function that output all dialogs via the MI interface - * \see mi_print_dlgs - * \param rpl MI node that should be filled - * \param with_context if 1 then the dialog context will be also printed - * \return 0 on success, -1 on failure - */ -static int internal_mi_print_dlgs(struct mi_node *rpl, int with_context) -{ - struct dlg_cell *dlg; - unsigned int i; - - LM_DBG("printing %i dialogs\n", d_table->size); - - for( i=0 ; isize ; i++ ) { - dlg_lock( d_table, &(d_table->entries[i]) ); - - for( dlg=d_table->entries[i].first ; dlg ; dlg=dlg->next ) { - if (internal_mi_print_dlg(rpl, dlg, with_context)!=0) - goto error; - } - dlg_unlock( d_table, &(d_table->entries[i]) ); - } - return 0; - -error: - dlg_unlock( d_table, &(d_table->entries[i]) ); - LM_ERR("failed to print dialog\n"); - return -1; -} - - -static inline struct mi_root* process_mi_params(struct mi_root *cmd_tree, - struct dlg_cell **dlg_p) -{ - struct mi_node* node; - struct dlg_entry *d_entry; - struct dlg_cell *dlg; - str *callid; - str *from_tag; - unsigned int h_entry; - - node = cmd_tree->node.kids; - if (node == NULL) { - /* no parameters at all */ - *dlg_p = NULL; - return NULL; - } - - /* we have params -> get callid and fromtag */ - callid = &node->value; - if(callid->s==NULL || callid->len<=0) - return init_mi_tree(400, MI_SSTR(MI_MISSING_PARM)); - LM_DBG("callid='%.*s'\n", callid->len, callid->s); - - node = node->next; - if ( !node || !node->value.s || !node->value.len) { - from_tag = NULL; - } else { - from_tag = &node->value; - LM_DBG("from_tag='%.*s'\n", from_tag->len, from_tag->s); - if ( node->next!=NULL ) - return init_mi_tree( 400, MI_SSTR(MI_MISSING_PARM)); - } - - h_entry = core_hash( callid, 0, d_table->size); - - d_entry = &(d_table->entries[h_entry]); - dlg_lock( d_table, d_entry); - - for( dlg = d_entry->first ; dlg ; dlg = dlg->next ) { - if (match_downstream_dialog( dlg, callid, from_tag)==1) { - if (dlg->state==DLG_STATE_DELETED) { - *dlg_p = NULL; - break; - } else { - *dlg_p = dlg; - dlg_unlock( d_table, d_entry); - return 0; - } - } - } - dlg_unlock( d_table, d_entry); - - return init_mi_tree( 404, MI_SSTR("Nu such dialog")); -} - - -/*! - * \brief Output all dialogs via the MI interface - * \param cmd_tree MI command tree - * \param param unused - * \return mi node with the dialog information, or NULL on failure - */ -struct mi_root * mi_print_dlgs(struct mi_root *cmd_tree, void *param ) -{ - struct mi_root* rpl_tree= NULL; - struct mi_node* rpl = NULL; - struct dlg_cell* dlg = NULL; - - rpl_tree = process_mi_params( cmd_tree, &dlg); - if (rpl_tree) - /* param error */ - return rpl_tree; - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - if (dlg==NULL) { - if ( internal_mi_print_dlgs(rpl,0)!=0 ) - goto error; - } else { - if ( internal_mi_print_dlg(rpl,dlg,0)!=0 ) - goto error; - } - - return rpl_tree; -error: - free_mi_tree(rpl_tree); - return NULL; -} - - -/*! - * \brief Print a dialog context via the MI interface - * \param cmd_tree MI command tree - * \param param unused - * \return mi node with the dialog information, or NULL on failure - */ -struct mi_root * mi_print_dlgs_ctx(struct mi_root *cmd_tree, void *param ) -{ - struct mi_root* rpl_tree= NULL; - struct mi_node* rpl = NULL; - struct dlg_cell* dlg = NULL; - - rpl_tree = process_mi_params( cmd_tree, &dlg); - if (rpl_tree) - /* param error */ - return rpl_tree; - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - if (dlg==NULL) { - if ( internal_mi_print_dlgs(rpl,1)!=0 ) - goto error; - } else { - if ( internal_mi_print_dlg(rpl,dlg,1)!=0 ) - goto error; - } - - return rpl_tree; -error: - free_mi_tree(rpl_tree); - return NULL; -} - -/*! - * \brief Terminate all or selected dialogs via the MI interface - * \param cmd_tree MI command tree - * \param param unused - * \return mi node with the dialog information, or NULL on failure - */ -struct mi_root * mi_terminate_dlgs(struct mi_root *cmd_tree, void *param ) -{ - struct mi_root* rpl_tree= NULL; - struct dlg_cell* dlg = NULL; - str headers = {0, 0}; - - rpl_tree = process_mi_params( cmd_tree, &dlg); - if (rpl_tree) - /* param error */ - return rpl_tree; - if (dlg==NULL) - return init_mi_tree( 400, MI_SSTR(MI_MISSING_PARM)); - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - if (dlg_bye_all(dlg, &headers)!=0) - goto error; - return rpl_tree; -error: - free_mi_tree(rpl_tree); - return NULL; -} - - diff --git a/src/modules/dialog/dlg_hash.h b/src/modules/dialog/dlg_hash.h index aa687f0a85f..63e64d53e8c 100644 --- a/src/modules/dialog/dlg_hash.h +++ b/src/modules/dialog/dlg_hash.h @@ -31,7 +31,6 @@ #define _DIALOG_DLG_HASH_H_ #include "../../core/locking.h" -#include "../../lib/kmi/mi.h" #include "../../core/timer.h" #include "../../core/atomic_ops.h" #include "dlg_timer.h" @@ -431,31 +430,6 @@ void next_state_dlg(dlg_cell_t *dlg, int event, int *old_state, int *new_state, int *unref); -/*! - * \brief Output all dialogs via the MI interface - * \param cmd_tree MI root node - * \param param unused - * \return a mi node with the dialog information, or NULL on failure - */ -struct mi_root * mi_print_dlgs(struct mi_root *cmd, void *param ); - - -/*! - * \brief Print a dialog context via the MI interface - * \param cmd_tree MI command tree - * \param param unused - * \return mi node with the dialog information, or NULL on failure - */ -struct mi_root * mi_print_dlgs_ctx(struct mi_root *cmd, void *param ); - -/*! - * \brief Terminate selected dialogs via the MI interface - * \param cmd_tree MI command tree - * \param param unused - * \return mi node with the dialog information, or NULL on failure - */ -struct mi_root * mi_terminate_dlgs(struct mi_root *cmd_tree, void *param ); - /*! * \brief Check if a dialog structure matches to a SIP message dialog * \param dlg dialog structure @@ -602,13 +576,4 @@ int dlg_clean_run(ticks_t ti); int update_dlg_timeout(dlg_cell_t *, int); -/*! - * \brief Output a dialog via the MI interface - * \param rpl MI node that should be filled - * \param dlg printed dialog - * \param with_context if 1 then the dialog context will be also printed - * \return 0 on success, -1 on failure - */ -int mi_print_dlg(struct mi_node *rpl, dlg_cell_t *dlg, int with_context); - #endif diff --git a/src/modules/dialog/dlg_profile.c b/src/modules/dialog/dlg_profile.c index fc12cef8fbb..fa3d2e857c7 100644 --- a/src/modules/dialog/dlg_profile.c +++ b/src/modules/dialog/dlg_profile.c @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ @@ -980,176 +980,6 @@ int dlg_set_timeout_by_profile(struct dlg_profile_table *profile, return 0; } -/****************************** MI commands *********************************/ - -/*! - * \brief Output a profile via MI interface - * \param cmd_tree MI command tree - * \param param unused - * \return MI root output on success, NULL on failure - */ -struct mi_root * mi_get_profile(struct mi_root *cmd_tree, void *param) -{ - struct mi_node* node; - struct mi_root* rpl_tree= NULL; - struct mi_node* rpl = NULL; - struct mi_attr* attr; - struct dlg_profile_table *profile; - str *value; - str *profile_name; - unsigned int size; - int len; - char *p; - - node = cmd_tree->node.kids; - if (node==NULL || !node->value.s || !node->value.len) - return init_mi_tree( 400, MI_SSTR(MI_MISSING_PARM)); - profile_name = &node->value; - - if (node->next) { - node = node->next; - if (!node->value.s || !node->value.len) - return init_mi_tree( 400, MI_SSTR(MI_BAD_PARM)); - if (node->next) - return init_mi_tree( 400, MI_SSTR(MI_MISSING_PARM)); - value = &node->value; - } else { - value = NULL; - } - - /* search for the profile */ - profile = search_dlg_profile( profile_name ); - if (profile==NULL) - return init_mi_tree( 404, MI_SSTR("Profile not found")); - - size = get_profile_size( profile , value ); - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - node = add_mi_node_child(rpl, MI_DUP_VALUE, "profile", 7, NULL, 0); - if (node==0) { - free_mi_tree(rpl_tree); - return NULL; - } - - attr = add_mi_attr(node, MI_DUP_VALUE, "name", 4, - profile->name.s, profile->name.len); - if(attr == NULL) { - goto error; - } - - if (value) { - attr = add_mi_attr(node, MI_DUP_VALUE, "value", 5, value->s, value->len); - } else { - attr = add_mi_attr(node, MI_DUP_VALUE, "value", 5, NULL, 0); - } - if(attr == NULL) { - goto error; - } - - p= int2str((unsigned long)size, &len); - attr = add_mi_attr(node, MI_DUP_VALUE, "count", 5, p, len); - if(attr == NULL) { - goto error; - } - - return rpl_tree; -error: - free_mi_tree(rpl_tree); - return NULL; -} - - -/*! - * \brief List the profiles via MI interface - * \param cmd_tree MI command tree - * \param param unused - * \return MI root output on success, NULL on failure - */ -struct mi_root * mi_profile_list(struct mi_root *cmd_tree, void *param ) -{ - struct mi_node* node; - struct mi_root* rpl_tree= NULL; - struct mi_node* rpl = NULL; - struct dlg_profile_table *profile; - struct dlg_profile_hash *ph; - str *profile_name; - str *value; - unsigned int i; - - node = cmd_tree->node.kids; - if (node==NULL || !node->value.s || !node->value.len) - return init_mi_tree( 400, MI_SSTR(MI_MISSING_PARM)); - profile_name = &node->value; - - if (node->next) { - node = node->next; - if (!node->value.s || !node->value.len) - return init_mi_tree( 400, MI_SSTR(MI_BAD_PARM)); - if (node->next) - return init_mi_tree( 400, MI_SSTR(MI_MISSING_PARM)); - value = &node->value; - } else { - value = NULL; - } - - /* search for the profile */ - profile = search_dlg_profile( profile_name ); - if (profile==NULL) - return init_mi_tree( 404, MI_SSTR("Profile not found")); - - rpl_tree = init_mi_tree( 200, MI_SSTR(MI_OK)); - if (rpl_tree==0) - return 0; - rpl = &rpl_tree->node; - - /* go through the hash and print the dialogs */ - if (profile->has_value==0 || value==NULL) { - /* no value */ - lock_get( &profile->lock ); - for ( i=0 ; i< profile->size ; i++ ) { - ph = profile->entries[i].first; - if(ph) { - do { - /* print dialog */ - if ( mi_print_dlg( rpl, ph->dlg, 0)!=0 ) - goto error; - /* next */ - ph=ph->next; - }while( ph!=profile->entries[i].first ); - } - } - lock_release( &profile->lock ); - } else { - /* check for value also */ - lock_get( &profile->lock ); - for ( i=0 ; i< profile->size ; i++ ) { - ph = profile->entries[i].first; - if(ph) { - do { - if ( value->len==ph->value.len && - memcmp(value->s,ph->value.s,value->len)==0 ) { - /* print dialog */ - if ( mi_print_dlg( rpl, ph->dlg, 0)!=0 ) - goto error; - } - /* next */ - ph=ph->next; - }while( ph!=profile->entries[i].first ); - } - } - lock_release( &profile->lock ); - } - - return rpl_tree; -error: - free_mi_tree(rpl_tree); - return NULL; -} - /** * json serialization of dialog profiles diff --git a/src/modules/dialog/dlg_req_within.c b/src/modules/dialog/dlg_req_within.c index d598462879b..a67b976137b 100644 --- a/src/modules/dialog/dlg_req_within.c +++ b/src/modules/dialog/dlg_req_within.c @@ -39,7 +39,6 @@ #include "../../core/dset.h" #include "../../modules/tm/dlg.h" #include "../../modules/tm/tm_load.h" -#include "../../lib/kmi/tree.h" #include "../../core/counters.h" #include "dlg_timer.h" #include "dlg_hash.h" @@ -501,70 +500,6 @@ int dlg_send_ka(dlg_cell_t *dlg, int dir) } - -/*parameters from MI: h_entry, h_id of the requested dialog*/ -struct mi_root * mi_terminate_dlg(struct mi_root *cmd_tree, void *param ){ - - struct mi_node* node; - unsigned int h_entry, h_id; - struct dlg_cell * dlg = NULL; - str mi_extra_hdrs = {NULL,0}; - int status, msg_len; - char *msg; - - - if( d_table ==NULL) - goto end; - - node = cmd_tree->node.kids; - h_entry = h_id = 0; - - if (node==NULL || node->next==NULL) - return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); - - if (!node->value.s|| !node->value.len|| strno2int(&node->value,&h_entry)<0) - goto error; - - node = node->next; - if ( !node->value.s || !node->value.len || strno2int(&node->value,&h_id)<0) - goto error; - - if (node->next) { - node = node->next; - if (node->value.len && node->value.s) - mi_extra_hdrs = node->value; - } - - LM_DBG("h_entry %u h_id %u\n", h_entry, h_id); - - dlg = dlg_lookup(h_entry, h_id); - - // lookup_dlg has incremented the reference count - - if(dlg){ - if(dlg_bye_all(dlg,(mi_extra_hdrs.len>0)?&mi_extra_hdrs:NULL)<0) { - status = 500; - msg = MI_DLG_OPERATION_ERR; - msg_len = MI_DLG_OPERATION_ERR_LEN; - } else { - status = 200; - msg = MI_OK_S; - msg_len = MI_OK_LEN; - } - - dlg_release(dlg); - - return init_mi_tree(status, msg, msg_len); - } - -end: - return init_mi_tree(404, MI_DIALOG_NOT_FOUND, MI_DIALOG_NOT_FOUND_LEN); - -error: - return init_mi_tree( 400, MI_BAD_PARM_S, MI_BAD_PARM_LEN); - -} - int dlg_bye(struct dlg_cell *dlg, str *hdrs, int side) { str all_hdrs = { 0, 0 }; diff --git a/src/modules/dialog/doc/dialog_admin.xml b/src/modules/dialog/doc/dialog_admin.xml index 9eabd44d2a0..926cc0db6c1 100644 --- a/src/modules/dialog/doc/dialog_admin.xml +++ b/src/modules/dialog/doc/dialog_admin.xml @@ -10,34 +10,34 @@ - + &adminguide; - +
Overview - Kamailio can behave as a stateful proxy through the TM module. However, - "stateful" in this context refers to transaction + Kamailio can behave as a stateful proxy through the TM module. However, + "stateful" in this context refers to transaction state, not dialog state. Certain applications may benefit from an awareness of "calls" in the proxy, not just SIP transactions. - For example, a common need is to limit the number of calls that can - be made concurrently by an endpoint, account, user group, etc. In order - to count the number of calls in progress, it is necessary for the proxy - to be aware of whole dialogs, not just transactions, and to provide some - means of programmatically classifying these dialogs. This is just one - common application discussed for illustrative purposes; there are many others. + For example, a common need is to limit the number of calls that can + be made concurrently by an endpoint, account, user group, etc. In order + to count the number of calls in progress, it is necessary for the proxy + to be aware of whole dialogs, not just transactions, and to provide some + means of programmatically classifying these dialogs. This is just one + common application discussed for illustrative purposes; there are many others. The dialog module provides dialog awareness for the &kamailio; proxy. It's functionality is to keep track of the current dialogs, to offer information - about them (e.g. how many dialogs are active), and to manage various + about them (e.g. how many dialogs are active), and to manage various characteristics of dialogs. The module exports several functions that can be used directly from the configuration route script as well as functions for the RPC interface. - This module also provides a API foundation on which to build + This module also provides a API foundation on which to build more complex dialog-oriented functionality in other &kamailio; modules.
@@ -2122,262 +2122,21 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)");
- MI Commands - -
- <varname>dlg_list</varname> - - Lists the description of a dialog or of all dialogs (calls). If only - one dialogs is to be listed, the dialog identifiers are to be passed - as parameter (callid and fromtag). - - - Name: dlg_list - - Parameters: - - - callid (optional) - callid if a single - dialog to be listed. - - - from_tag (optional, but cannot be present - without the callid parameter) - from tag (as per initial request) - of the dialog to be listed. Note that if the from_tag is not - specified, only dialogs created by a request without a from tag - are matched, which will only occur with broken clients and is - thus a very rare situation. - - - - MI FIFO Command Format: - - - :dlg_list:_reply_fifo_file_ - _empty_line_ - - - :dlg_list:_reply_fifo_file_ - abcdrssfrs122444@192.168.1.1 - AAdfeEFF33 - -
- -
- <varname>dlg_list_ctx</varname> - - The same as the dlg_list but including in the dialog - description the associated context from modules sitting on top of - the dialog module. - - - Name: dlg_list_ctx - - Parameters: see dlg_list - - - MI FIFO Command Format: - - - :dlg_list_ctx:_reply_fifo_file_ - _empty_line_ - -
- -
- <varname>dlg_end_dlg</varname> - - Terminates a confirmed dialog by sending BYE requests in both directions. - - - Name: dlg_end_dlg - - Parameters: - - - h_entry - hash entry of the dialog in the - internal dialog table - - - h_id - hash id of the dialog on the hash - entry - - - extra_hdrs - (optional) string containg - extra headers (full format) to be added to the BYE requests. - - - - The values for the h_entry and h_id can be get via the dlg_list - MI command. - - - Note: Works only for confirmed dialogs. - - - MI FIFO Command Format: - - - :dlg_end_dlg:_reply_fifo_file_ - 342 - 56 - _empty_line_ - -
- -
- <varname>dlg_terminate_dlg</varname> - - Terminates a singe dialog, identified by a Call-ID. - - - Name: dlg_terminate_dlg - - Parameters: - - - callid - callid of the dialog to be terminated. - - - from_tag (optional, but cannot be present - without the callid parameter) - from tag (as per initial request) - of the dialog to be terminated. Note that if the from_tag is not - specified, only dialogs created by a request without a from tag - are matched, which will only occur with broken clients and is - thus a very rare situation. - - - - Note: Works only for confirmed dialogs. - - - MI FIFO Command Format: - - - :dlg_terminate_dlg:_reply_fifo_file_ - abcdrssfrs122444@192.168.1.1 - AAdfeEFF33 - -
- -
- <varname>profile_get_size</varname> - - Returns the number of dialogs belonging to a profile. If the profile - supports values, the check can be reinforced to take into account a - specific value - how many dialogs were inserted into the profile with - a specific value. If no value is passed, only the simply belonging of - the dialog to the profile is checked. Note that if the profile does not - supports values, this will be silently discarded. - - - Name: profile_get_size - - Parameters: - - - profile - name of the profile to get the - value for. - - - value (optional)- string value to - further restrict the check; - - - - MI FIFO Command Format: - - - :profile_get_size:_reply_fifo_file_ - inbound_calls - _empty_line_ - -
- -
- <varname>profile_list_dlgs</varname> - - Lists all the dialogs belonging to a profile. If the profile - supports values, the check can be reinforced to take into account a - specific value - list only the dialogs that were inserted into the - profile with that specific value. If no value is passed, all dialogs - belonging to the profile will be listed. Note that if the profile does - not supports values, this will be silently discarded. - - - Name: profile_list_dlgs - - Parameters: - - - profile - name of the profile to list the - dialog for. - - - value (optional)- string value to - further restrict the check; - - - - MI FIFO Command Format: - - - :profile_list_dlgs:_reply_fifo_file_ - inbound_calls - _empty_line_ - -
- -
- <varname>dlg_bridge</varname> - - Bridge two SIP addresses in a call using INVITE(hold)-REFER-BYE - mechanism. - - - Name: dlg_bridge - - Parameters: - - - from - SIP address to initiate the call - - - to - SIP address to refer 'from' to - - - op (optional) - outbound proxy SIP address - - - - MI FIFO Command Format: - - - :dlg_bridge:_reply_fifo_file_ - from - to - op - _empty_line_ - -
- -
- - -
- Exported RPC Functions -
- <varname>dlg.list</varname> - Lists the description of all dialogs (calls). + RPC Commands +
+ dlg.list + Lists the description of all dialogs (active calls). Name: dlg.list RPC Command Format: - kamcmd dlg_list +... +&kamcmd; dlg_list +...
-
- <varname>dlg.list_ctx</varname> +
+ dlg.list_ctx The same as the dlg_list but including in the dialog description the associated context from modules sitting on top of @@ -2386,12 +2145,14 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); Name: dlg.list_ctx RPC Command Format: - kamcmd dlg.list_ctx +... +&kamcmd; dlg.list_ctx +...
-
- <varname>dlg.dlg_list</varname> +
+ dlg.dlg_list Lists the description of one dialog. The dialog identifiers are to be passed as parameter (callid and optionally fromtag). @@ -2409,14 +2170,15 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - kamcmd dlg.list abcdrssfrs122444@192.168.1.1 AAdfeEFF33 - - - serctl dlg.list abcdrssfrs122444@192.168.1.1 +... +&kamcmd; dlg.list abcdrssfrs122444@192.168.1.1 AAdfeEFF33 +... +&kamcmd; dlg.list abcdrssfrs122444@192.168.1.1 +...
-
- <varname>dlg.dlg_list_ctx</varname> +
+ dlg.dlg_list_ctx The same as the dlg.list_ctx but including in the dialog description the associated context from modules sitting on top of @@ -2427,14 +2189,15 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - kamcmd dlg.list_ctx abcdrssfrs122444@192.168.1.1 AAdfeEFF33 - - - serctl dlg.list_ctx abcdrssfrs122444@192.168.1.1 +... +&kamcmd; dlg.list_ctx abcdrssfrs122444@192.168.1.1 AAdfeEFF33 +... +&kamcmd; dlg.list_ctx abcdrssfrs122444@192.168.1.1 +...
-
- <varname>dlg.terminate_dlg</varname> +
+ dlg.terminate_dlg Terminates an ongoing dialog by sending BYE in both directions, matching the dialog on call-id, from tag and to tag. @@ -2487,11 +2250,13 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - kamcmd dlg.end_dlg 342 56 +... +&kamcmd; dlg.end_dlg 342 56 +...
-
- <varname>dlg.profile_get_size</varname> +
+ dlg.profile_get_size Returns the number of dialogs belonging to a profile. If the profile supports values, the check can be reinforced to take into account a @@ -2514,12 +2279,14 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - kamcmd dlg.dlg.profile_get_size inbound_calls +... +&kamcmd; dlg.dlg.profile_get_size inbound_calls +...
-
- <varname>dlg.profile_list</varname> +
+ dlg.profile_list Lists all the dialogs belonging to a profile. If the profile supports values, the check can be reinforced to take into account a @@ -2542,12 +2309,14 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - kamcmd dlg.profile_list inbound_calls +... +&kamcmd; dlg.profile_list inbound_calls +...
-
- <varname>dlg.bridge_dlg</varname> +
+ dlg.bridge_dlg Bridge two SIP addresses into a call using INVITE(hold)-REFER-BYE mechanism. @@ -2567,15 +2336,16 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)"); RPC Command Format: - kamcmd dlg.list from to op +... +&kamcmd; dlg.list _from_ _to_ _op_ +...
-
- Exported pseudo-variables + Exported Variables
<varname>$DLG_count</varname> @@ -2637,7 +2407,7 @@ dlg_remote_profile("add", "caller", "test", "$sruid", "$var(exp)");
<varname>$dlg_var(key)</varname> - This is a read/write variable that can be used to store + This is a read/write variable that can be used to store custom values assigned with a dialog (e.g. the URI of a billing-server, an assigned emergency-server). This pseudo-variable will be available only for subsequential diff --git a/src/modules/dialog/doc/dialog_devel.xml b/src/modules/dialog/doc/dialog_devel.xml index 8687e89a2ef..108673e295f 100644 --- a/src/modules/dialog/doc/dialog_devel.xml +++ b/src/modules/dialog/doc/dialog_devel.xml @@ -10,7 +10,7 @@ - + &develguide;
Available Functions @@ -81,8 +81,8 @@ - DLGCB_EXPIRED - called when the - dialog expires without receiving a BYE - it's a per dialog + DLGCB_EXPIRED - called when the + dialog expires without receiving a BYE - it's a per dialog type. @@ -105,8 +105,8 @@ - DLGCB_MI_CONTEXT - called when the - mi dlg_list_ctx command is invoked - it's a per dialog type. + DLGCB_RPC_CONTEXT - called when the + rpc dlg_list_ctx command is invoked - it's a per dialog type. @@ -122,8 +122,8 @@ - dialog_cb cb - callback function to be - called. Prototype is: void (dialog_cb) + dialog_cb cb - callback function to be + called. Prototype is: void (dialog_cb) (struct dlg_cell* dlg, int type, struct dlg_cb_params * params);