[sr-dev] git:master: tmx: $T(reply_type) to solve ambiguity of received or local replies

Daniel-Constantin Mierla miconda at gmail.com
Fri Sep 23 22:19:49 CEST 2011


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri Sep 23 22:08:23 2011 +0200

tmx: $T(reply_type) to solve ambiguity of received or local replies

- it returns 1 in failure route if the reply was local generated (e.g.,
  timeout), otherwise is 0. If there is no transaction, it returns null.
- helps to avoid using $T_rpl(pv) in case of local replies, which returns
  null for any pv, without it is no way to detect if some pv is null value
  itself or the whole reply is not available

---

 modules_k/tmx/t_var.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules_k/tmx/t_var.c b/modules_k/tmx/t_var.c
index 366afe3..da803f0 100644
--- a/modules_k/tmx/t_var.c
+++ b/modules_k/tmx/t_var.c
@@ -461,11 +461,13 @@ int pv_parse_t_name(pv_spec_p sp, str *in)
 		case 10:
 			if(strncmp(in->s, "reply_code", 10)==0)
 				sp->pvp.pvn.u.isname.name.n = 2;
+			else if(strncmp(in->s, "reply_type", 10)==0)
+				sp->pvp.pvn.u.isname.name.n = 3;
 			else goto error;
 		break;
 		case 12:
 			if(strncmp(in->s, "branch_index", 12)==0)
-				sp->pvp.pvn.u.isname.name.n = 3;
+				sp->pvp.pvn.u.isname.name.n = 4;
 			else goto error;
 		break;
 		default:
@@ -495,7 +497,7 @@ int pv_get_t(struct sip_msg *msg,  pv_param_t *param,
 	{
 		case 2:
 			return pv_get_tm_reply_code(msg, param, res);
-		case 3:
+		case 4:
 			return pv_get_tm_branch_idx(msg, param, res);
 	}
 
@@ -508,6 +510,14 @@ int pv_get_t(struct sip_msg *msg,  pv_param_t *param,
 	{
 		case 1:
 			return pv_get_uintval(msg, param, res, t->hash_index);
+		case 3:
+			if(get_route_type()==FAILURE_ROUTE) {
+				if(_tmx_tmb.t_get_picked_branch()<0 )
+					return pv_get_uintval(msg, param, res, 0);
+				if(t->uac[_tmx_tmb.t_get_picked_branch()].reply==FAKED_REPLY)
+					return pv_get_uintval(msg, param, res, 1);
+			}
+			return pv_get_uintval(msg, param, res, 0);
 		default:
 			return pv_get_uintval(msg, param, res, t->label);
 	}




More information about the sr-dev mailing list