Browse Source

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
Daniel-Constantin Mierla 14 years ago
parent
commit
5b76dc48d7
1 changed files with 12 additions and 2 deletions
  1. 12 2
      modules_k/tmx/t_var.c

+ 12 - 2
modules_k/tmx/t_var.c

@@ -461,11 +461,13 @@ int pv_parse_t_name(pv_spec_p sp, str *in)
 		case 10:
 		case 10:
 			if(strncmp(in->s, "reply_code", 10)==0)
 			if(strncmp(in->s, "reply_code", 10)==0)
 				sp->pvp.pvn.u.isname.name.n = 2;
 				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;
 			else goto error;
 		break;
 		break;
 		case 12:
 		case 12:
 			if(strncmp(in->s, "branch_index", 12)==0)
 			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;
 			else goto error;
 		break;
 		break;
 		default:
 		default:
@@ -495,7 +497,7 @@ int pv_get_t(struct sip_msg *msg,  pv_param_t *param,
 	{
 	{
 		case 2:
 		case 2:
 			return pv_get_tm_reply_code(msg, param, res);
 			return pv_get_tm_reply_code(msg, param, res);
-		case 3:
+		case 4:
 			return pv_get_tm_branch_idx(msg, param, res);
 			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:
 		case 1:
 			return pv_get_uintval(msg, param, res, t->hash_index);
 			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:
 		default:
 			return pv_get_uintval(msg, param, res, t->label);
 			return pv_get_uintval(msg, param, res, t->label);
 	}
 	}