Module: sip-router
Branch: master
Commit: ded63f919ba33f6ddc6c4170166e247bd52cf96a
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ded63f9…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri May 1 13:40:33 2009 +0200
tm: added tm_ctx to collect K extension requirements
- it holds now branch index value used by $T_branch_index
- added function in TM API to access tm_ctx
---
modules/tm/t_fwd.c | 3 ++-
modules/tm/t_lookup.c | 21 +++++++++++++++++++++
modules/tm/t_lookup.h | 24 ++++++++++++++++++++++++
modules/tm/t_reply.c | 2 ++
modules/tm/tm_load.c | 4 ++++
modules/tm/tm_load.h | 5 +++++
6 files changed, 58 insertions(+), 1 deletions(-)
diff --git a/modules/tm/t_fwd.c b/modules/tm/t_fwd.c
index 46ddbfb..97b36c2 100644
--- a/modules/tm/t_fwd.c
+++ b/modules/tm/t_fwd.c
@@ -190,10 +190,11 @@ static char *print_uac_request( struct cell *t, struct sip_msg
*i_req,
if (unlikely(branch_route)) {
/* run branch_route actions if provided */
set_route_type(BRANCH_ROUTE);
-
+ tm_ctx_set_branch_index(branch+1);
if (run_top_route(branch_rt.rlist[branch_route], i_req) < 0) {
LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n");
}
+ tm_ctx_set_branch_index(0);
}
/* run the specific callbacks for this transaction */
diff --git a/modules/tm/t_lookup.c b/modules/tm/t_lookup.c
index 8f59e8a..c8e1c9d 100644
--- a/modules/tm/t_lookup.c
+++ b/modules/tm/t_lookup.c
@@ -1869,3 +1869,24 @@ int t_reset_max_lifetime()
return 1;
}
+#ifdef WITH_TM_CTX
+
+tm_ctx_t _tm_ctx;
+
+tm_ctx_t* tm_ctx_get(void)
+{
+ return &_tm_ctx;
+}
+
+void tm_ctx_init(void)
+{
+ memset(&_tm_ctx, 0, sizeof(tm_ctx_t));
+}
+
+void tm_ctx_set_branch_index(int v)
+{
+ _tm_ctx.branch_index = v;
+}
+
+#endif
+
diff --git a/modules/tm/t_lookup.h b/modules/tm/t_lookup.h
index cb21048..070add5 100644
--- a/modules/tm/t_lookup.h
+++ b/modules/tm/t_lookup.h
@@ -123,4 +123,28 @@ typedef int (*t_get_canceled_ident_f)(struct sip_msg *msg,
unsigned int *hash_index, unsigned int *label);
#endif /* WITH_AS_SUPPORT */
+/**
+ * required by TMX (K/O extensions)
+ */
+#define WITH_TM_CTX
+#ifdef WITH_TM_CTX
+
+typedef struct _tm_ctx {
+ int branch_index;
+} tm_ctx_t;
+
+typedef tm_ctx_t* (*tm_ctx_get_f)(void);
+
+tm_ctx_t* tm_ctx_get(void);
+void tm_ctx_init(void);
+void tm_ctx_set_branch_index(int v);
+
+#else
+
+#define tm_ctx_get()
+#define tm_ctx_init()
+#define tm_ctx_set_branch_index(v)
+
+#endif /* WITH_TM_CTX */
+
#endif
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index e51142c..848cebb 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -1833,6 +1833,7 @@ int reply_received( struct sip_msg *p_msg )
if ( (t==0)||(t==T_UNDEFINED))
goto trans_not_found;
+ tm_ctx_set_branch_index(branch);
cancel_bitmap=0;
msg_status=p_msg->REPLY_STATUS;
@@ -2070,6 +2071,7 @@ int reply_received( struct sip_msg *p_msg )
} /* provisional replies */
done:
+ tm_ctx_set_branch_index(0);
/* we are done with the transaction, so unref it - the reference
* was incremented by t_check() function -bogdan*/
t_unref(p_msg);
diff --git a/modules/tm/tm_load.c b/modules/tm/tm_load.c
index 6f8bba5..afb5e30 100644
--- a/modules/tm/tm_load.c
+++ b/modules/tm/tm_load.c
@@ -233,5 +233,9 @@ int load_tm( struct tm_binds *tmb)
tmb->generate_fromtag = generate_fromtag;
tmb->t_lookup_request = t_lookup_request;
tmb->t_check = t_check;
+
+#ifdef WITH_TM_CTX
+ tmb->tm_ctx_get = tm_ctx_get;
+#endif
return 1;
}
diff --git a/modules/tm/tm_load.h b/modules/tm/tm_load.h
index e3640b7..ec84143 100644
--- a/modules/tm/tm_load.h
+++ b/modules/tm/tm_load.h
@@ -140,6 +140,11 @@ struct tm_binds {
generate_fromtag_f generate_fromtag;
tlookup_request_f t_lookup_request;
tcheck_f t_check;
+#ifdef WITH_TM_CTX
+ tm_ctx_get_f tm_ctx_get;
+#else
+ void* reserved5;
+#endif
};
extern int tm_init;