Module: sip-router
Branch: master
Commit: 7a8ad6740c244d48911f0216f6baac4804ea2f3b
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7a8ad67…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sat Feb 25 14:16:53 2012 +0100
dialog: should be ok to use dlg_manage() after transaction was created
---
modules_k/dialog/dialog.c | 24 ++++--------------------
modules_k/dialog/dlg_handlers.c | 37 ++++++++++++++++++++++++++++++++++++-
modules_k/dialog/dlg_handlers.h | 5 +++++
3 files changed, 45 insertions(+), 21 deletions(-)
diff --git a/modules_k/dialog/dialog.c b/modules_k/dialog/dialog.c
index b89eb9b..17d7894 100644
--- a/modules_k/dialog/dialog.c
+++ b/modules_k/dialog/dialog.c
@@ -933,28 +933,12 @@ static int w_dlg_isflagset(struct sip_msg *msg, char *flag, str
*s2)
return (dctx->flags&(1<<val))?1:-1;
}
+/**
+ *
+ */
static int w_dlg_manage(struct sip_msg *msg, char *s1, char *s2)
{
- str tag;
- int backup_mode;
-
- if( (msg->to==NULL && parse_headers(msg, HDR_TO_F,0)<0) ||
msg->to==NULL )
- {
- LM_ERR("bad TO header\n");
- return -1;
- }
- tag = get_to(msg)->tag_value;
- if(tag.s!=0 && tag.len!=0)
- {
- backup_mode = seq_match_mode;
- seq_match_mode = SEQ_MATCH_NO_ID;
- dlg_onroute(msg, NULL, NULL);
- seq_match_mode = backup_mode;
- } else {
- if(dlg_new_dialog(msg, 0, initial_cbs_inscript)!=0)
- return -1;
- }
- return 1;
+ return dlg_manage(msg);
}
static int w_dlg_bye(struct sip_msg *msg, char *side, char *s2)
diff --git a/modules_k/dialog/dlg_handlers.c b/modules_k/dialog/dlg_handlers.c
index 4df4744..e8a7e88 100644
--- a/modules_k/dialog/dlg_handlers.c
+++ b/modules_k/dialog/dlg_handlers.c
@@ -762,7 +762,7 @@ static void unref_new_dialog(void *iuid)
* \param run_initial_cbs if set zero, initial callbacks are not executed
* \return 0 on success, -1 on failure
*/
-int dlg_new_dialog(struct sip_msg *req, struct cell *t, const int run_initial_cbs)
+int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int run_initial_cbs)
{
dlg_cell_t *dlg;
str s;
@@ -1470,3 +1470,38 @@ void dlg_run_event_route(dlg_cell_t *dlg, sip_msg_t *msg, int
ostate, int nstate
dlg_unref(dlg, 1);
}
}
+
+int dlg_manage(sip_msg_t *msg)
+{
+ str tag;
+ int backup_mode;
+ dlg_cell_t *dlg = NULL;
+ tm_cell_t *t = NULL;
+
+ if( (msg->to==NULL && parse_headers(msg, HDR_TO_F,0)<0) ||
msg->to==NULL )
+ {
+ LM_ERR("bad TO header\n");
+ return -1;
+ }
+ tag = get_to(msg)->tag_value;
+ if(tag.s!=0 && tag.len!=0)
+ {
+ backup_mode = seq_match_mode;
+ seq_match_mode = SEQ_MATCH_NO_ID;
+ dlg_onroute(msg, NULL, NULL);
+ seq_match_mode = backup_mode;
+ } else {
+ t = d_tmb.t_gett();
+ if(t==T_UNDEFINED)
+ t = NULL;
+ if(dlg_new_dialog(msg, t, initial_cbs_inscript)!=0)
+ return -1;
+ dlg = dlg_get_ctx_dialog();
+ if(dlg==NULL)
+ return -1;
+ if(t!=NULL)
+ dlg_set_tm_callbacks(t, msg, dlg, spiral_detected);
+ dlg_release(dlg);
+ }
+ return 1;
+}
diff --git a/modules_k/dialog/dlg_handlers.h b/modules_k/dialog/dlg_handlers.h
index 1149241..f296437 100644
--- a/modules_k/dialog/dlg_handlers.h
+++ b/modules_k/dialog/dlg_handlers.h
@@ -177,4 +177,9 @@ dlg_iuid_t *dlg_get_iuid_shm_clone(dlg_cell_t *dlg);
*/
void dlg_iuid_sfree(void *iuid);
+/*!
+ *
+ */
+int dlg_manage(sip_msg_t *msg);
+
#endif