[sr-dev] git:master: tmx: updated for last tm changes

Daniel-Constantin Mierla miconda at gmail.com
Mon Aug 16 18:38:58 CEST 2010


Module: sip-router
Branch: master
Commit: aff441b32d2f87dfeee112432174e6692c4d6f42
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=aff441b32d2f87dfeee112432174e6692c4d6f42

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Mon Aug 16 18:35:45 2010 +0200

tmx: updated for last tm changes

- cancel_uacs() takes new type of paraeters
- reply function takes str* parameters

---

 modules_k/tmx/t_mi.c    |   41 ++++++++++++++++++++---------------------
 modules_k/tmx/tmx_mod.c |   29 +++++++++++++++++------------
 2 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/modules_k/tmx/t_mi.c b/modules_k/tmx/t_mi.c
index 84288df..44c5054 100644
--- a/modules_k/tmx/t_mi.c
+++ b/modules_k/tmx/t_mi.c
@@ -663,6 +663,7 @@ struct mi_root*  mi_tm_uac_dlg(struct mi_root* cmd_tree, void* param)
 */
 struct mi_root* mi_tm_cancel(struct mi_root* cmd_tree, void* param)
 {
+	struct cancel_info cancel_data;
 	struct mi_node *node;
 	struct cell *trans;
 
@@ -676,7 +677,9 @@ struct mi_root* mi_tm_cancel(struct mi_root* cmd_tree, void* param)
 	/* cancel the call */
 	LM_DBG("cancelling transaction %p\n",trans);
 
-	_tmx_tmb.cancel_uacs( trans, ~0/*all branches*/, 0);
+	init_cancel_info(&cancel_data);
+	cancel_data.cancel_bitmap = ~0; /*all branches*/
+	_tmx_tmb.cancel_uacs(trans, &cancel_data, 0);
 
 	_tmx_tmb.unref_cell(trans);
 
@@ -753,11 +756,11 @@ struct mi_root* mi_tm_reply(struct mi_root* cmd_tree, void* param)
 	unsigned int hash_label;
 	unsigned int rpl_code;
 	struct cell *trans;
-	char *reason;
-	char *totag;
-	char *new_hdrs;
-	char *body;
-	str tmp;
+	str reason = {0, 0};
+	str totag = {0, 0};
+	str new_hdrs = {0, 0};
+	str body = {0, 0};
+	str tmp = {0, 0};
 	char *p;
 	int n;
 
@@ -774,49 +777,45 @@ struct mi_root* mi_tm_reply(struct mi_root* cmd_tree, void* param)
 
 	/* reason text (param 2) */
 	node = node->next;
-	reason = as_asciiz(&node->value);
+	reason = node->value;
 
 	/* trans_id (param 3) */
 	node = node->next;
 	tmp = node->value;
 	p = memchr( tmp.s, ':', tmp.len);
-	if ( p==NULL)
+	if(p==NULL)
 		return init_mi_tree( 400, "Invalid trans_id", 16);
 
 	tmp.len = p-tmp.s;
-	if( str2int( &tmp, &hash_index)!=0 )
+	if(str2int(&tmp, &hash_index)!=0)
 		return init_mi_tree( 400, "Invalid index in trans_id", 25);
 
 	tmp.s = p+1;
 	tmp.len = (node->value.s+node->value.len) - tmp.s;
-	if( str2int( &tmp, &hash_label)!=0 )
+	if(str2int(&tmp, &hash_label)!=0)
 		return init_mi_tree( 400, "Invalid label in trans_id", 25);
 
-	if( _tmx_tmb.t_lookup_ident( &trans, hash_index, hash_label)<0 )
+	if(_tmx_tmb.t_lookup_ident( &trans, hash_index, hash_label)<0)
 		return init_mi_tree( 404, "Transaction not found", 21);
 
 	/* to_tag (param 4) */
 	node = node->next;
-	totag = as_asciiz(&node->value);
+	totag = node->value;
 
 	/* new headers (param 5) */
 	node = node->next;
-	if (node->value.len==1 && node->value.s[0]=='.')
-		new_hdrs = 0;
-	else 
-		new_hdrs = as_asciiz(&node->value);
+	if (!(node->value.len==1 && node->value.s[0]=='.'))
+		new_hdrs = node->value;
 
 	/* body (param 5 - optional) */
 	node = node->next;
 	if (node)
-		body = as_asciiz(&node->value);
-	else
-		body = 0;
+		body = node->value;
 
 	/* it's refcounted now, t_reply_with body unrefs for me -- I can 
 	 * continue but may not use T anymore  */
-	n = _tmx_tmb.t_reply_with_body( trans, rpl_code, reason, body,
-			new_hdrs, totag);
+	n = _tmx_tmb.t_reply_with_body(trans, rpl_code, &reason, &body,
+			&new_hdrs, &totag);
 
 	if (n<0)
 		return init_mi_tree( 500, "Reply failed", 12);
diff --git a/modules_k/tmx/tmx_mod.c b/modules_k/tmx/tmx_mod.c
index 420cb30..3714fed 100644
--- a/modules_k/tmx/tmx_mod.c
+++ b/modules_k/tmx/tmx_mod.c
@@ -232,7 +232,7 @@ static int fixup_cancel_branches(void** param, int param_no)
  */
 static int t_cancel_branches(struct sip_msg* msg, char *k, char *s2)
 {
-	branch_bm_t cb = 0;
+	struct cancel_info cancel_data;
 	struct cell *t = 0;
 	tm_ctx_t *tcx = 0;
 	int n=0;
@@ -244,26 +244,30 @@ static int t_cancel_branches(struct sip_msg* msg, char *k, char *s2)
 	if(tcx != NULL)
 		idx = tcx->branch_index;
 	n = (int)(long)k;
+	init_cancel_info(&cancel_data);
 	switch(n) {
 		case 1:
 			/* prepare cancel for every branch except idx */
-			_tmx_tmb.prepare_to_cancel(t, &cb, 1<<idx);
+			_tmx_tmb.prepare_to_cancel(t,
+					&cancel_data.cancel_bitmap, 1<<idx);
 		case 2:
 			if(msg->first_line.u.reply.statuscode>=200)
 				break;
-			cb = 1<<idx;
+			cancel_data.cancel_bitmap = 1<<idx;
 		break;
 		default:
 			if (msg->first_line.u.reply.statuscode>=200)
 				/* prepare cancel for every branch except idx */
-				_tmx_tmb.prepare_to_cancel(t, &cb, 1<<idx);
+				_tmx_tmb.prepare_to_cancel(t,
+						&cancel_data.cancel_bitmap, 1<<idx);
 			else
-				_tmx_tmb.prepare_to_cancel(t, &cb, 0);
+				_tmx_tmb.prepare_to_cancel(t,
+						&cancel_data.cancel_bitmap, 0);
 	}
-	LM_DBG("canceling %d/%d\n", n, (int)cb);
-	if(cb==0)
+	LM_DBG("canceling %d/%d\n", n, (int)cancel_data.cancel_bitmap);
+	if(cancel_data.cancel_bitmap==0)
 		return -1;
-	_tmx_tmb.cancel_uacs(t, cb, 0);
+	_tmx_tmb.cancel_uacs(t, &cancel_data, 0);
 	return 1;
 }
 
@@ -287,12 +291,11 @@ static int fixup_cancel_callid(void** param, int param_no)
 static int t_cancel_callid(struct sip_msg* msg, char *cid, char *cseq, char *flag)
 {
 	struct cell *trans;
-	branch_bm_t cancel_bm;
+	struct cancel_info cancel_data;
 	str cseq_s;
 	str callid_s;
 	int fl;
 
-	cancel_bm=0;
 	fl = -1;
 
 	if(fixup_get_svalue(msg, (gparam_p)cid, &callid_s)<0)
@@ -321,8 +324,10 @@ static int t_cancel_callid(struct sip_msg* msg, char *cid, char *cseq, char *fla
 	DBG("Now calling cancel_uacs\n");
 	if(trans->uas.request && fl>0 && fl<32)
 		setflag(trans->uas.request, fl);
-	_tmx_tmb.prepare_to_cancel(trans, &cancel_bm, 0);
-	_tmx_tmb.cancel_uacs(trans, cancel_bm, 0);
+	init_cancel_info(&cancel_data);
+	cancel_data.cancel_bitmap = 0;
+	_tmx_tmb.prepare_to_cancel(trans, &cancel_data.cancel_bitmap, 0);
+	_tmx_tmb.cancel_uacs(trans, &cancel_data, 0);
 
 	//_tmx_tmb.unref_cell(trans);
 




More information about the sr-dev mailing list