Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
5b76dc48d7
1 zmenil súbory, kde vykonal 12 pridanie a 2 odobranie
  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:
 			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);
 	}