Module: sip-router
Branch: carstenbock/dialog2
Commit: 606f613a51accee524de02edc789d8d35bf8283d
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=606f613…
Author: Carsten Bock <lists(a)bock.info>
Committer: Carsten Bock <lists(a)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 e19e56b..d52ad94 100644
--- a/modules_k/dialog/dialog.c
+++ b/modules_k/dialog/dialog.c
@@ -232,7 +232,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},
@@ -1200,7 +1200,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(a)192.168.1.1
AAdfeEFF33
</programlisting>