Module: sip-router Branch: carstenbock/dialog Commit: da19a78a2bdfb85766bc1cb48fabf38c27732991 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=da19a78a...
Author: Carsten Bock lists@bock.info Committer: Carsten Bock lists@bock.info Date: Thu Aug 19 19:38:55 2010 +0200
- Use only call-id to get the h_id; otherwise dlg_list_dlg and dlg_terminate_dlg would require the from-tag, which is marked as optional in the docs - dlg_terminate_dlg does request the call-id to terminate a specific call (terminating all calls require a little more development) - match_downstream_dialog does only match by call-id (see first point)
---
modules_k/dialog/dialog.c | 4 ++-- modules_k/dialog/dlg_hash.c | 31 +++++++------------------------ modules_k/dialog/dlg_hash.h | 20 +++++++++++++------- modules_k/dialog/doc/dialog_admin.xml | 11 ++--------- 4 files changed, 24 insertions(+), 42 deletions(-)
diff --git a/modules_k/dialog/dialog.c b/modules_k/dialog/dialog.c index dbfccb4..677cb41 100644 --- a/modules_k/dialog/dialog.c +++ b/modules_k/dialog/dialog.c @@ -233,7 +233,7 @@ 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_dlgs", mi_terminate_dlgs, 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}, @@ -1201,7 +1201,7 @@ static void internal_rpc_print_single_dlg(rpc_t *rpc, void *c, int with_context)
if (rpc->scan(c, ".S.S", &callid, &from_tag) < 2) return;
- h_entry = core_hash( &callid, &from_tag, d_table->size); + 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 ) { diff --git a/modules_k/dialog/dlg_hash.c b/modules_k/dialog/dlg_hash.c index 80f506f..848ee66 100644 --- a/modules_k/dialog/dlg_hash.c +++ b/modules_k/dialog/dlg_hash.c @@ -240,7 +240,7 @@ struct dlg_cell* build_new_dlg( str *callid, str *from_uri, str *to_uri, memset( dlg, 0, len); dlg->state = DLG_STATE_UNCONFIRMED;
- dlg->h_entry = core_hash( callid, from_tag->len?from_tag:0, d_table->size); + dlg->h_entry = core_hash( callid, 0, d_table->size); LM_DBG("new dialog on hash %u\n",dlg->h_entry);
p = (char*)(dlg+1); @@ -470,7 +470,7 @@ struct dlg_cell* get_dlg( str *callid, str *ftag, str *ttag, unsigned int *dir, { struct dlg_cell *dlg;
- if ((dlg = internal_get_dlg(core_hash(callid, ftag->len?ftag:0, + if ((dlg = internal_get_dlg(core_hash(callid, 0, d_table->size), callid, ftag, ttag, dir, del)) == 0 && (dlg = internal_get_dlg(core_hash(callid, ttag->len ?ttag:0, d_table->size), callid, ftag, ttag, dir, del)) == 0) { @@ -971,7 +971,7 @@ static inline struct mi_root* process_mi_params(struct mi_root *cmd_tree, return init_mi_tree( 400, MI_SSTR(MI_MISSING_PARM)); }
- h_entry = core_hash( callid, from_tag, d_table->size); + h_entry = core_hash( callid, 0, d_table->size);
d_entry = &(d_table->entries[h_entry]); dlg_lock( d_table, d_entry); @@ -1084,32 +1084,15 @@ struct mi_root * mi_terminate_dlgs(struct mi_root *cmd_tree, void *param ) 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==NULL) { - LM_DBG("terminating %i dialogs\n", d_table->size); - - for( i=0 ; i<d_table->size ; i++ ) { - dlg_lock( d_table, &(d_table->entries[i]) ); - - for( dlg=d_table->entries[i].first ; dlg ; dlg=dlg->next ) { - if (dlg_bye_all(dlg, &headers)!=0) - goto error_all; - } - dlg_unlock( d_table, &(d_table->entries[i]) ); - } - } else { - if (dlg_bye_all(dlg, &headers)!=0) - goto error; - } + if (dlg_bye_all(dlg, &headers)!=0) + goto error; return rpl_tree; -error_all: - dlg_unlock( d_table, &(d_table->entries[i]) ); - free_mi_tree(rpl_tree); - return NULL; error: free_mi_tree(rpl_tree); return NULL; diff --git a/modules_k/dialog/dlg_hash.h b/modules_k/dialog/dlg_hash.h index aa70d84..b902fc0 100644 --- a/modules_k/dialog/dlg_hash.h +++ b/modules_k/dialog/dlg_hash.h @@ -328,7 +328,7 @@ struct mi_root * mi_print_dlgs(struct mi_root *cmd, void *param ); struct mi_root * mi_print_dlgs_ctx(struct mi_root *cmd, void *param );
/*! - * \brief Terminate all or selected dialogs via the MI interface + * \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 @@ -435,13 +435,19 @@ static inline int match_dialog(struct dlg_cell *dlg, str *callid, */ static inline int match_downstream_dialog(struct dlg_cell *dlg, str *callid, str *ftag) { - if(dlg==NULL || callid==NULL || ftag==NULL) - return 0; - if (dlg->callid.len!=callid->len || - dlg->tag[DLG_CALLER_LEG].len!=ftag->len || - strncmp(dlg->callid.s,callid->s,callid->len)!=0 || - strncmp(dlg->tag[DLG_CALLER_LEG].s,ftag->s,ftag->len)!=0) + if(dlg==NULL || callid==NULL) return 0; + if (ftag==NULL) { + if (dlg->callid.len!=callid->len || + strncmp(dlg->callid.s,callid->s,callid->len)!=0) + return 0; + } else { + if (dlg->callid.len!=callid->len || + dlg->tag[DLG_CALLER_LEG].len!=ftag->len || + strncmp(dlg->callid.s,callid->s,callid->len)!=0 || + strncmp(dlg->tag[DLG_CALLER_LEG].s,ftag->s,ftag->len)!=0) + return 0; + } return 1; }
diff --git a/modules_k/dialog/doc/dialog_admin.xml b/modules_k/dialog/doc/dialog_admin.xml index 98769f5..bda7e76 100644 --- a/modules_k/dialog/doc/dialog_admin.xml +++ b/modules_k/dialog/doc/dialog_admin.xml @@ -1532,9 +1532,7 @@ if(dlg_get("abcdef", "123", "456")) <section> <title><varname>dlg_terminate_dlgs</varname></title> <para> - Terminates a dialog or of all dialogs (calls). If only - one dialogs is to be terminated, the dialog identifiers are to be passed - as parameter (callid and fromtag). + Terminates a singe dialog, identified by a Call-ID. </para> <para> Name: <emphasis>dlg_terminate_dlgs</emphasis> @@ -1542,8 +1540,7 @@ if(dlg_get("abcdef", "123", "456")) <para>Parameters:</para> <itemizedlist> <listitem><para> - <emphasis>callid</emphasis> (optional) - callid if a single - dialog to be terminated. + <emphasis>callid</emphasis> - callid of the dialog to be terminated. </para></listitem> <listitem><para> <emphasis>from_tag</emphasis> (optional, but cannot be present @@ -1559,10 +1556,6 @@ if(dlg_get("abcdef", "123", "456")) </para> <programlisting format="linespecific"> :dlg_terminate_dlgs:_reply_fifo_file_ - _empty_line_ - </programlisting> - <programlisting format="linespecific"> - :dlg_terminate_dlgs:_reply_fifo_file_ abcdrssfrs122444@192.168.1.1 AAdfeEFF33 </programlisting>
On Thursday 19 August 2010, Carsten Bock wrote:
- { "dlg_terminate_dlgs", mi_terminate_dlgs, 0, 0, 0},
- { "dlg_terminate_dlg", mi_terminate_dlgs, 0, 0, 0},
Hello Carsten,
rename the specific MI command here, was this done intentional? I just wonder, as the documentation still shows the "old" name.
Cheers,
Henning
Hi Henning,
yes, the rename was intentional. The original implementation allowed (at least theoretically) the termination of all calls. However, due to locking, this did not work and instead of spending time on making this work, i've removed the functionality to terminate all calls. Now it only terminates a single call, that's why i renamed that function... I will fix the documentation this week.
Carsten
2010/8/23 Henning Westerholt henning.westerholt@1und1.de
On Thursday 19 August 2010, Carsten Bock wrote:
{ "dlg_terminate_dlgs", mi_terminate_dlgs, 0, 0, 0},
{ "dlg_terminate_dlg", mi_terminate_dlgs, 0, 0, 0},
Hello Carsten,
rename the specific MI command here, was this done intentional? I just wonder, as the documentation still shows the "old" name.
Cheers,
Henning
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
On Monday 23 August 2010, Carsten Bock wrote:
yes, the rename was intentional. The original implementation allowed (at least theoretically) the termination of all calls. However, due to locking, this did not work and instead of spending time on making this work, i've removed the functionality to terminate all calls. Now it only terminates a single call, that's why i renamed that function... I will fix the documentation this week.
Hi Carsten,
thanks for the clarification, it makes more sense now. There is also another function, the dlg_lst which fails to work on a busy server due to PKG memory pool contraints. But it also supports the listing of one call, and its useful for debugging.. :-)
Cheers,
Henning
Hi,
just saw, that i fixed the docs in a separate patch ;-) So: Already done.
Carsten
2010/8/23 Henning Westerholt henning.westerholt@1und1.de:
On Monday 23 August 2010, Carsten Bock wrote:
yes, the rename was intentional. The original implementation allowed (at least theoretically) the termination of all calls. However, due to locking, this did not work and instead of spending time on making this work, i've removed the functionality to terminate all calls. Now it only terminates a single call, that's why i renamed that function... I will fix the documentation this week.
Hi Carsten,
thanks for the clarification, it makes more sense now. There is also another function, the dlg_lst which fails to work on a busy server due to PKG memory pool contraints. But it also supports the listing of one call, and its useful for debugging.. :-)
Cheers,
Henning