mirror of https://github.com/sipwise/kamailio.git
* print config line on transformation errors Change-Id: I5abce44869c5fc47ac9ba9fffa470aef909b692bchanges/45/12145/4
parent
064a6f0186
commit
cf5d9b74b0
@ -0,0 +1,24 @@
|
|||||||
|
From: Victor Seva <vseva@sipwise.com>
|
||||||
|
Date: Tue, 21 Mar 2017 17:28:04 +0100
|
||||||
|
Subject: pv: tr_eval_uri() set error message to debug
|
||||||
|
|
||||||
|
Change-Id: I26b29ae116a2aace78750c2559de8eb7121c6812
|
||||||
|
---
|
||||||
|
modules/pv/pv_trans.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/modules/pv/pv_trans.c b/modules/pv/pv_trans.c
|
||||||
|
index a10f698..c55c3be 100644
|
||||||
|
--- a/modules/pv/pv_trans.c
|
||||||
|
+++ b/modules/pv/pv_trans.c
|
||||||
|
@@ -1147,8 +1147,8 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
/* parse uri -- params only when requested */
|
||||||
|
if(parse_uri(_tr_uri.s, _tr_uri.len, &_tr_parsed_uri)!=0)
|
||||||
|
{
|
||||||
|
- LM_ERR("invalid uri [%.*s]\n", val->rs.len,
|
||||||
|
- val->rs.s);
|
||||||
|
+ LM_DBG("invalid uri [%.*s] (%s:%d)\n", val->rs.len,
|
||||||
|
+ val->rs.s, ZSW(get_cfg_crt_name()), get_cfg_crt_line());
|
||||||
|
if(_tr_uri_params != NULL)
|
||||||
|
{
|
||||||
|
free_params(_tr_uri_params);
|
||||||
@ -0,0 +1,274 @@
|
|||||||
|
From: Daniel-Constantin Mierla <miconda@gmail.com>
|
||||||
|
Date: Mon, 13 Mar 2017 17:47:25 +0100
|
||||||
|
Subject: pv: attempt to print cfg line for string transformation errors
|
||||||
|
|
||||||
|
- 0 is printed when not a transformation in config
|
||||||
|
- requested by GH #1019
|
||||||
|
|
||||||
|
based on 8ce23dda673441541de836e71af9101d8b7894ea
|
||||||
|
|
||||||
|
Change-Id: Ib15aef0290f4c8043ff325e7f24841e75150427d
|
||||||
|
---
|
||||||
|
modules/pv/pv_trans.c | 76 +++++++++++++++++++++++++++++++++------------------
|
||||||
|
1 file changed, 50 insertions(+), 26 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/modules/pv/pv_trans.c b/modules/pv/pv_trans.c
|
||||||
|
index 942803d..a10f698 100644
|
||||||
|
--- a/modules/pv/pv_trans.c
|
||||||
|
+++ b/modules/pv/pv_trans.c
|
||||||
|
@@ -38,6 +38,7 @@
|
||||||
|
#include "../../pvapi.h"
|
||||||
|
#include "../../dset.h"
|
||||||
|
#include "../../basex.h"
|
||||||
|
+#include "../../action.h"
|
||||||
|
|
||||||
|
#include "../../parser/parse_param.h"
|
||||||
|
#include "../../parser/parse_uri.h"
|
||||||
|
@@ -96,7 +97,7 @@ char *tr_set_crt_buffer(void)
|
||||||
|
|
||||||
|
#define tr_string_clone_result do { \
|
||||||
|
if(val->rs.len>TR_BUFFER_SIZE-1) { \
|
||||||
|
- LM_ERR("result is too big\n"); \
|
||||||
|
+ LM_ERR("result is too big (cfg line: %d)\n", get_cfg_crt_line()); \
|
||||||
|
return -1; \
|
||||||
|
} \
|
||||||
|
strncpy(_tr_buffer, val->rs.s, val->rs.len); \
|
||||||
|
@@ -517,7 +518,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
case TR_S_SUBSTR:
|
||||||
|
if(tp==NULL || tp->next==NULL)
|
||||||
|
{
|
||||||
|
- LM_ERR("substr invalid parameters\n");
|
||||||
|
+ LM_ERR("substr invalid parameters (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!(val->flags&PV_VAL_STR))
|
||||||
|
@@ -529,7 +531,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
if(pv_get_spec_value(msg, (pv_spec_p)tp->v.data, &v)!=0
|
||||||
|
|| (!(v.flags&PV_VAL_INT)))
|
||||||
|
{
|
||||||
|
- LM_ERR("substr cannot get p1\n");
|
||||||
|
+ LM_ERR("substr cannot get p1 (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
i = v.ri;
|
||||||
|
@@ -541,7 +544,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
if(pv_get_spec_value(msg, (pv_spec_p)tp->next->v.data, &v)!=0
|
||||||
|
|| (!(v.flags&PV_VAL_INT)))
|
||||||
|
{
|
||||||
|
- LM_ERR("substr cannot get p2\n");
|
||||||
|
+ LM_ERR("substr cannot get p2 (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
j = v.ri;
|
||||||
|
@@ -549,7 +553,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
LM_DBG("i=%d j=%d\n", i, j);
|
||||||
|
if(j<0)
|
||||||
|
{
|
||||||
|
- LM_ERR("substr negative offset\n");
|
||||||
|
+ LM_ERR("substr negative offset (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
val->flags = PV_VAL_STR;
|
||||||
|
@@ -558,7 +563,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
{
|
||||||
|
if(i>=val->rs.len)
|
||||||
|
{
|
||||||
|
- LM_ERR("substr out of range\n");
|
||||||
|
+ LM_ERR("substr out of range (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(i+j>=val->rs.len) j=0;
|
||||||
|
@@ -576,7 +582,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
i = -i;
|
||||||
|
if(i>val->rs.len)
|
||||||
|
{
|
||||||
|
- LM_ERR("substr out of range\n");
|
||||||
|
+ LM_ERR("substr out of range (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(i<j) j=0;
|
||||||
|
@@ -595,7 +602,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
case TR_S_SELECT:
|
||||||
|
if(tp==NULL || tp->next==NULL)
|
||||||
|
{
|
||||||
|
- LM_ERR("select invalid parameters\n");
|
||||||
|
+ LM_ERR("select invalid parameters (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!(val->flags&PV_VAL_STR))
|
||||||
|
@@ -607,7 +615,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
if(pv_get_spec_value(msg, (pv_spec_p)tp->v.data, &v)!=0
|
||||||
|
|| (!(v.flags&PV_VAL_INT)))
|
||||||
|
{
|
||||||
|
- LM_ERR("select cannot get p1\n");
|
||||||
|
+ LM_ERR("select cannot get p1 (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
i = v.ri;
|
||||||
|
@@ -705,7 +714,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
case TR_S_STRIPTAIL:
|
||||||
|
if(tp==NULL)
|
||||||
|
{
|
||||||
|
- LM_ERR("strip invalid parameters\n");
|
||||||
|
+ LM_ERR("strip invalid parameters (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!(val->flags&PV_VAL_STR))
|
||||||
|
@@ -717,7 +727,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
if(pv_get_spec_value(msg, (pv_spec_p)tp->v.data, &v)!=0
|
||||||
|
|| (!(v.flags&PV_VAL_INT)))
|
||||||
|
{
|
||||||
|
- LM_ERR("select cannot get p1\n");
|
||||||
|
+ LM_ERR("select cannot get p1 (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
i = v.ri;
|
||||||
|
@@ -743,7 +754,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
case TR_S_STRIPTO:
|
||||||
|
if(tp==NULL)
|
||||||
|
{
|
||||||
|
- LM_ERR("stripto invalid parameters\n");
|
||||||
|
+ LM_ERR("stripto invalid parameters (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!(val->flags&PV_VAL_STR))
|
||||||
|
@@ -756,7 +768,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
if(pv_get_spec_value(msg, (pv_spec_p)tp->v.data, &v)!=0
|
||||||
|
|| (!(v.flags&PV_VAL_STR)) || v.rs.len<=0)
|
||||||
|
{
|
||||||
|
- LM_ERR("stripto cannot get p1\n");
|
||||||
|
+ LM_ERR("stripto cannot get p1 (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
st = v.rs;
|
||||||
|
@@ -796,7 +809,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
if(pv_get_spec_value(msg, (pv_spec_p)tp->v.data, &v)!=0
|
||||||
|
|| (!(v.flags&PV_VAL_INT)))
|
||||||
|
{
|
||||||
|
- LM_ERR("prefixes cannot get max\n");
|
||||||
|
+ LM_ERR("prefixes cannot get max (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (v.ri > 0 && v.ri < max)
|
||||||
|
@@ -805,7 +819,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
}
|
||||||
|
|
||||||
|
if(max * (max/2 + (subtype==TR_S_PREFIXES_QUOT ? 1 : 3)) > TR_BUFFER_SIZE-1) {
|
||||||
|
- LM_ERR("prefixes buffer too short\n");
|
||||||
|
+ LM_ERR("prefixes buffer too short (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -829,7 +844,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
case TR_S_REPLACE:
|
||||||
|
if(tp==NULL || tp->next==NULL)
|
||||||
|
{
|
||||||
|
- LM_ERR("select invalid parameters\n");
|
||||||
|
+ LM_ERR("select invalid parameters (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!(val->flags&PV_VAL_STR))
|
||||||
|
@@ -842,7 +858,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
if(pv_get_spec_value(msg, (pv_spec_p)tp->v.data, &v)!=0
|
||||||
|
|| (!(v.flags&PV_VAL_STR)) || v.rs.len<=0)
|
||||||
|
{
|
||||||
|
- LM_ERR("replace cannot get p1\n");
|
||||||
|
+ LM_ERR("replace cannot get p1 (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
st = v.rs;
|
||||||
|
@@ -855,7 +872,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
if(pv_get_spec_value(msg, (pv_spec_p)tp->next->v.data, &w)!=0
|
||||||
|
|| (!(w.flags&PV_VAL_STR)) || w.rs.len<=0)
|
||||||
|
{
|
||||||
|
- LM_ERR("replace cannot get p2\n");
|
||||||
|
+ LM_ERR("replace cannot get p2 (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
st2 = w.rs;
|
||||||
|
@@ -884,13 +902,15 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
case TR_S_TIMEFORMAT:
|
||||||
|
if(tp==NULL)
|
||||||
|
{
|
||||||
|
- LM_ERR("timeformat invalid parameters\n");
|
||||||
|
+ LM_ERR("timeformat invalid parameters (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!(val->flags&PV_VAL_INT) && (str2int(&val->rs,
|
||||||
|
(unsigned int*) &val->ri)!=0))
|
||||||
|
{
|
||||||
|
- LM_ERR("value is not numeric\n");
|
||||||
|
+ LM_ERR("value is not numeric (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(tp->type==TR_PARAM_STRING)
|
||||||
|
@@ -900,7 +920,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
if(pv_get_spec_value(msg, (pv_spec_p)tp->v.data, &v)!=0
|
||||||
|
|| (!(v.flags&PV_VAL_STR)) || v.rs.len<=0)
|
||||||
|
{
|
||||||
|
- LM_ERR("timeformat cannot get p1\n");
|
||||||
|
+ LM_ERR("timeformat cannot get p1 (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
st = v.rs;
|
||||||
|
@@ -908,7 +929,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
s = pkg_malloc(st.len + 1);
|
||||||
|
if (s==NULL)
|
||||||
|
{
|
||||||
|
- LM_ERR("no more pkg memory\n");
|
||||||
|
+ LM_ERR("no more pkg memory (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memcpy(s, st.s, st.len);
|
||||||
|
@@ -960,7 +982,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
case TR_S_RM:
|
||||||
|
if(tp==NULL)
|
||||||
|
{
|
||||||
|
- LM_ERR("invalid parameters\n");
|
||||||
|
+ LM_ERR("invalid parameters (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!(val->flags&PV_VAL_STR))
|
||||||
|
@@ -1008,7 +1031,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
if(pv_get_spec_value(msg, (pv_spec_p)tp->v.data, &v)!=0
|
||||||
|
|| (!(v.flags&PV_VAL_STR)) || v.rs.len<=0)
|
||||||
|
{
|
||||||
|
- LM_ERR("cannot get parameter value\n");
|
||||||
|
+ LM_ERR("cannot get parameter value (cfg line: %d)\n",
|
||||||
|
+ get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
st = v.rs;
|
||||||
|
@@ -1063,8 +1087,8 @@ int tr_eval_string(struct sip_msg *msg, tr_param_t *tp, int subtype,
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
- LM_ERR("unknown subtype %d\n",
|
||||||
|
- subtype);
|
||||||
|
+ LM_ERR("unknown subtype %d (cfg line: %d)\n",
|
||||||
|
+ subtype, get_cfg_crt_line());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
Loading…
Reference in new issue