Module: sip-router Branch: master Commit: f6a66b4266af7811520c4cc6300a0d9d30411ee5 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f6a66b42...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Apr 27 17:30:33 2009 +0200
dialog: fixes for sip-router
- use TMCB structures for temporary workaround of missing dialog_ctx field (hint by Andrei Pelinescu-Onciul). To be replaced by something more generic and not bound to a specific implementation. - check uac flags for RR
---
modules_k/dialog/dlg_handlers.c | 25 ++++++++++++++++++++----- modules_k/dialog/dlg_handlers.h | 2 ++ modules_k/dialog/dlg_profile.c | 12 +++++++++++- 3 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/modules_k/dialog/dlg_handlers.c b/modules_k/dialog/dlg_handlers.c index 082e835..995cdab 100644 --- a/modules_k/dialog/dlg_handlers.c +++ b/modules_k/dialog/dlg_handlers.c @@ -207,7 +207,9 @@ int populate_leg_info( struct dlg_cell *dlg, struct sip_msg *msg, /* was the 200 OK received or local generated */ skip_recs = dlg->from_rr_nb + ((t->relayed_reply_branch>=0)? - (t->uac[t->relayed_reply_branch].added_rr):0); + ((t->uac[t->relayed_reply_branch].flags&TM_UAC_FLAG_R2)?2: + ((t->uac[t->relayed_reply_branch].flags&TM_UAC_FLAG_RR)?1:0)) + :0); }
if(msg->record_route){ @@ -267,7 +269,7 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param) return; }
- if (type==TMCB_TRANS_DELETED) + if (type==TMCB_DESTROY) event = DLG_EVENT_TDEL; else if (param->code<200) event = DLG_EVENT_RPL1xx; @@ -427,10 +429,15 @@ void unref_new_dialog(void *dialog) struct tmcb_params p;
p.param = (void*)&dialog; - dlg_onreply(0, TMCB_TRANS_DELETED, &p); + dlg_onreply(0, TMCB_DESTROY, &p); }
+void dlg_tmcb_dummy(struct cell* t, int type, struct tmcb_params *param) +{ + return; +} + int dlg_new_dialog(struct sip_msg *msg, struct cell *t) { struct dlg_cell *dlg; @@ -498,7 +505,7 @@ int dlg_new_dialog(struct sip_msg *msg, struct cell *t) }
if ( d_tmb.register_tmcb( msg, t, - TMCB_RESPONSE_PRE_OUT|TMCB_RESPONSE_FWDED, + TMCB_RESPONSE_READY|TMCB_RESPONSE_FWDED, dlg_onreply, (void*)dlg, unref_new_dialog)<0 ) { LM_ERR("failed to register TMCB\n"); goto error; @@ -511,8 +518,16 @@ int dlg_new_dialog(struct sip_msg *msg, struct cell *t) if (_dlg_ctx.to_bye!=0) dlg->dflags |= DLG_FLAG_TOBYE;
- if (t) + if (t) { + if ( d_tmb.register_tmcb( msg, t, TMCB_MAX, + dlg_tmcb_dummy, (void*)dlg, 0)<0 ) { + LM_ERR("failed cache in T the shortcut to dlg\n"); + goto error; + } + } +#if 0 t->dialog_ctx = (void*) dlg; +#endif
run_create_callbacks( dlg, msg);
diff --git a/modules_k/dialog/dlg_handlers.h b/modules_k/dialog/dlg_handlers.h index d777103..9936088 100644 --- a/modules_k/dialog/dlg_handlers.h +++ b/modules_k/dialog/dlg_handlers.h @@ -63,4 +63,6 @@ int pv_get_dlg_lifetime(struct sip_msg *msg, pv_param_t *param,
int pv_get_dlg_status(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); + +void dlg_tmcb_dummy(struct cell* t, int type, struct tmcb_params *param); #endif diff --git a/modules_k/dialog/dlg_profile.c b/modules_k/dialog/dlg_profile.c index 9980423..06c0583 100644 --- a/modules_k/dialog/dlg_profile.c +++ b/modules_k/dialog/dlg_profile.c @@ -42,6 +42,7 @@ #include "../../route.h" #include "../../modules/tm/tm_load.h" #include "dlg_hash.h" +#include "dlg_handlers.h" #include "dlg_profile.h"
@@ -323,6 +324,7 @@ int profile_cleanup( struct sip_msg *msg, void *param ) static struct dlg_cell *get_current_dialog(struct sip_msg *msg) { struct cell *trans; + struct tm_callback* x;
if (route_type==REQUEST_ROUTE) { /* use the per-process static holder */ @@ -338,7 +340,15 @@ static struct dlg_cell *get_current_dialog(struct sip_msg *msg) trans = d_tmb.t_gett(); if (trans==NULL || trans==T_UNDEFINED) return NULL; - return (struct dlg_cell*)trans->dialog_ctx; + x=(struct tm_callback*)(trans->tmcb_hl.first); + while(x){ + membar_depends(); + if (x->types==TMCB_MAX && x->callback==dlg_tmcb_dummy){ + return (struct dlg_cell*)(x->param); + } + x=x->next; + } + return NULL; } }