Module: sip-router Branch: master Commit: e1068cb0ab4377c9debd9aa0cbc398f6dee5c998 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e1068cb0...
Author: Timo Reimann timo.reimann@1und1.de Committer: Timo Reimann timo.reimann@1und1.de Date: Wed Aug 17 11:04:40 2011 +0200
modules_k/dialog: Add DLGCB_CONFIRMED_NA callback and make DLGCB_CONFIRM fit accordingly.
- Add DLGCB_CONFIRMED_NA callback which is triggered on reception of a 200 OK message (setup-concluding ACK message still pending). - Execute DGLCB_CONFIRMED on reception of a setup-concluding ACK message. - Extend documentation and clarify that DLGCB_REQ_WITHIN does not fire on DLGCB_CONFIRMED. (This is for consistency reasons as BYE requests have their own callback (DLGCB_TERMINATED) as well. Users who wish to track both setup-concluding ACK and other sequential requests must register for both callbacks types now.) - Closes Flyspray issue #143.
---
modules_k/dialog/dlg_cb.h | 23 +++++++++-------- modules_k/dialog/dlg_handlers.c | 43 ++++++++++++++++++++------------- modules_k/dialog/doc/dialog_devel.xml | 12 +++++++- 3 files changed, 48 insertions(+), 30 deletions(-)
diff --git a/modules_k/dialog/dlg_cb.h b/modules_k/dialog/dlg_cb.h index 9c6fa14..80eae7b 100644 --- a/modules_k/dialog/dlg_cb.h +++ b/modules_k/dialog/dlg_cb.h @@ -64,17 +64,18 @@ typedef str* (*get_dlg_variable_f)( struct dlg_cell* dlg, #define DLGCB_LOADED (1<<0) #define DLGCB_CREATED (1<<1) #define DLGCB_FAILED (1<<2) -#define DLGCB_CONFIRMED (1<<3) -#define DLGCB_REQ_WITHIN (1<<4) -#define DLGCB_TERMINATED (1<<5) -#define DLGCB_EXPIRED (1<<6) -#define DLGCB_EARLY (1<<7) -#define DLGCB_RESPONSE_FWDED (1<<8) -#define DLGCB_RESPONSE_WITHIN (1<<9) -#define DLGCB_MI_CONTEXT (1<<10) -#define DLGCB_RPC_CONTEXT (1<<11) -#define DLGCB_DESTROY (1<<12) -#define DLGCB_SPIRALED (1<<13) +#define DLGCB_CONFIRMED_NA (1<<3) +#define DLGCB_CONFIRMED (1<<4) +#define DLGCB_REQ_WITHIN (1<<5) +#define DLGCB_TERMINATED (1<<6) +#define DLGCB_EXPIRED (1<<7) +#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) #define DLGCB_TERMINATED_CONFIRMED (1<<14)
struct dlg_callback { diff --git a/modules_k/dialog/dlg_handlers.c b/modules_k/dialog/dlg_handlers.c index 450fd09..c6cd650 100644 --- a/modules_k/dialog/dlg_handlers.c +++ b/modules_k/dialog/dlg_handlers.c @@ -398,7 +398,7 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param)
if (new_state==DLG_STATE_CONFIRMED_NA && old_state!=DLG_STATE_CONFIRMED_NA && old_state!=DLG_STATE_CONFIRMED ) { - LM_DBG("dialog %p confirmed\n",dlg); + LM_DBG("dialog %p confirmed (ACK pending)\n",dlg);
if (rpl != FAKED_REPLY) { /* get to tag*/ @@ -445,8 +445,8 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param) ref_dlg(dlg,1); }
- /* dialog confirmed */ - run_dlg_callbacks( DLGCB_CONFIRMED, dlg, req, rpl, DLG_DIR_UPSTREAM, 0); + /* dialog confirmed (ACK pending) */ + run_dlg_callbacks( DLGCB_CONFIRMED_NA, dlg, req, rpl, DLG_DIR_UPSTREAM, 0);
if (old_state==DLG_STATE_EARLY) if_update_stat(dlg_enable_stats, early_dlgs, -1); @@ -1168,7 +1168,7 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
if ( (event==DLG_EVENT_REQ || event==DLG_EVENT_REQACK) && new_state==DLG_STATE_CONFIRMED) { - LM_DBG("sequential request successfully processed\n"); + timeout = get_dlg_timeout(req); if (timeout!=default_timeout) { dlg->lifetime = timeout; @@ -1184,20 +1184,29 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param) update_dialog_dbinfo(dlg); }
- /* within dialog request */ - run_dlg_callbacks( DLGCB_REQ_WITHIN, dlg, req, NULL, dir, 0); - - if ( (event!=DLG_EVENT_REQACK) && - (dlg->cbs.types)&DLGCB_RESPONSE_WITHIN ) { - /* ref the dialog as registered into the transaction callback. - * unref will be done when the callback will be destroyed */ - ref_dlg( dlg , 1); - /* register callback for the replies of this request */ - if ( d_tmb.register_tmcb( req, 0, TMCB_RESPONSE_FWDED, - (dir==DLG_DIR_UPSTREAM)?dlg_seq_down_onreply:dlg_seq_up_onreply, - (void*)dlg, unreference_dialog)<0 ) { - LM_ERR("failed to register TMCB (2)\n"); + if (old_state==DLG_STATE_CONFIRMED_NA) { + LM_DBG("confirming ACK successfully processed\n"); + + /* confirming ACK request */ + run_dlg_callbacks( DLGCB_CONFIRMED, dlg, req, NULL, dir, 0); + } else { + LM_DBG("sequential request successfully processed\n"); + + /* within dialog request */ + run_dlg_callbacks( DLGCB_REQ_WITHIN, dlg, req, NULL, dir, 0); + + if ( (event!=DLG_EVENT_REQACK) && + (dlg->cbs.types)&DLGCB_RESPONSE_WITHIN ) { + /* ref the dialog as registered into the transaction callback. + * unref will be done when the callback will be destroyed */ + ref_dlg( dlg , 1); + /* register callback for the replies of this request */ + if ( d_tmb.register_tmcb( req, 0, TMCB_RESPONSE_FWDED, + (dir==DLG_DIR_UPSTREAM)?dlg_seq_down_onreply:dlg_seq_up_onreply, + (void*)dlg, unreference_dialog)<0 ) { + LM_ERR("failed to register TMCB (2)\n"); unref_dlg( dlg , 1); + } } } } diff --git a/modules_k/dialog/doc/dialog_devel.xml b/modules_k/dialog/doc/dialog_devel.xml index f83a05d..0655894 100644 --- a/modules_k/dialog/doc/dialog_devel.xml +++ b/modules_k/dialog/doc/dialog_devel.xml @@ -51,14 +51,22 @@ </para> </listitem> <listitem> - <para><emphasis>DLGCB_CONFIRMED</emphasis> - called when the + <para><emphasis>DLGCB_CONFIRMED_NA</emphasis> - called when the + dialog is confirmed (2xx replied) but the setup-concluding ACK + message from the caller is yet pending - it's a per dialog type. + </para> + </listitem> + <listitem> + <para><emphasis>DLGCB_CONFIRMED</emphasis> - called when the dialog is confirmed (2xx replied) and the setup-concluding ACK message from the caller has been seen - it's a per dialog type. </para> </listitem> <listitem> <para><emphasis>DLGCB_REQ_WITHIN</emphasis> - called when the - dialog matches a sequential request - it's a per dialog type. + dialog matches a sequential request (excluding setup-concluding + ACK messages which are handled in DLGCB_CONFIRMED) - it's a per + dialog type. </para> </listitem> <listitem>