|
@@ -31,7 +31,8 @@
|
|
#include "tmx_mod.h"
|
|
#include "tmx_mod.h"
|
|
#include "t_var.h"
|
|
#include "t_var.h"
|
|
|
|
|
|
-struct _pv_tmx_data {
|
|
|
|
|
|
+struct _pv_tmx_data
|
|
|
|
+{
|
|
unsigned int index;
|
|
unsigned int index;
|
|
unsigned int label;
|
|
unsigned int label;
|
|
int branch;
|
|
int branch;
|
|
@@ -56,15 +57,14 @@ int pv_t_copy_msg(struct sip_msg *src, struct sip_msg *dst)
|
|
{
|
|
{
|
|
dst->id = src->id;
|
|
dst->id = src->id;
|
|
dst->rcv = src->rcv;
|
|
dst->rcv = src->rcv;
|
|
- dst->set_global_address=src->set_global_address;
|
|
|
|
- dst->set_global_port=src->set_global_port;
|
|
|
|
|
|
+ dst->set_global_address = src->set_global_address;
|
|
|
|
+ dst->set_global_port = src->set_global_port;
|
|
dst->flags = src->flags;
|
|
dst->flags = src->flags;
|
|
dst->fwd_send_flags = src->fwd_send_flags;
|
|
dst->fwd_send_flags = src->fwd_send_flags;
|
|
dst->rpl_send_flags = src->rpl_send_flags;
|
|
dst->rpl_send_flags = src->rpl_send_flags;
|
|
dst->force_send_socket = src->force_send_socket;
|
|
dst->force_send_socket = src->force_send_socket;
|
|
|
|
|
|
- if (parse_msg(dst->buf, dst->len, dst)!=0)
|
|
|
|
- {
|
|
|
|
|
|
+ if(parse_msg(dst->buf, dst->len, dst) != 0) {
|
|
LM_ERR("parse msg failed\n");
|
|
LM_ERR("parse msg failed\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
@@ -73,50 +73,46 @@ int pv_t_copy_msg(struct sip_msg *src, struct sip_msg *dst)
|
|
|
|
|
|
int pv_t_update_req(struct sip_msg *msg)
|
|
int pv_t_update_req(struct sip_msg *msg)
|
|
{
|
|
{
|
|
- struct cell * t;
|
|
|
|
|
|
+ struct cell *t;
|
|
int branch;
|
|
int branch;
|
|
|
|
|
|
- if(msg==NULL)
|
|
|
|
|
|
+ if(msg == NULL)
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
- if(msg!=FAKED_REPLY && msg->first_line.type!=SIP_REPLY)
|
|
|
|
|
|
+ if(msg != FAKED_REPLY && msg->first_line.type != SIP_REPLY)
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
t = _tmx_tmb.t_gett();
|
|
t = _tmx_tmb.t_gett();
|
|
|
|
|
|
- if(t==NULL || t==T_UNDEFINED)
|
|
|
|
- {
|
|
|
|
- if(msg==FAKED_REPLY)
|
|
|
|
|
|
+ if(t == NULL || t == T_UNDEFINED) {
|
|
|
|
+ if(msg == FAKED_REPLY)
|
|
return 1;
|
|
return 1;
|
|
- branch=-1;
|
|
|
|
- if (_tmx_tmb.t_check(msg, &branch ) == -1)
|
|
|
|
|
|
+ branch = -1;
|
|
|
|
+ if(_tmx_tmb.t_check(msg, &branch) == -1)
|
|
return 1;
|
|
return 1;
|
|
t = _tmx_tmb.t_gett();
|
|
t = _tmx_tmb.t_gett();
|
|
- if ((t == 0) || (t == T_UNDEFINED))
|
|
|
|
|
|
+ if((t == 0) || (t == T_UNDEFINED))
|
|
return 1;
|
|
return 1;
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if(t->uas.request==NULL)
|
|
|
|
|
|
+ if(t->uas.request == NULL)
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
- if (_pv_treq.label == t->label && _pv_treq.index == t->hash_index)
|
|
|
|
|
|
+ if(_pv_treq.label == t->label && _pv_treq.index == t->hash_index)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
/* make a copy */
|
|
/* make a copy */
|
|
- if(_pv_treq.buf==NULL || _pv_treq.buf_size<t->uas.request->len+1)
|
|
|
|
- {
|
|
|
|
- if(_pv_treq.buf!=NULL)
|
|
|
|
|
|
+ if(_pv_treq.buf == NULL || _pv_treq.buf_size < t->uas.request->len + 1) {
|
|
|
|
+ if(_pv_treq.buf != NULL)
|
|
pkg_free(_pv_treq.buf);
|
|
pkg_free(_pv_treq.buf);
|
|
if(_pv_treq.tmsgp)
|
|
if(_pv_treq.tmsgp)
|
|
free_sip_msg(&_pv_treq.msg);
|
|
free_sip_msg(&_pv_treq.msg);
|
|
_pv_treq.tmsgp = NULL;
|
|
_pv_treq.tmsgp = NULL;
|
|
_pv_treq.index = 0;
|
|
_pv_treq.index = 0;
|
|
_pv_treq.label = 0;
|
|
_pv_treq.label = 0;
|
|
- _pv_treq.buf_size = t->uas.request->len+1;
|
|
|
|
- _pv_treq.buf = (char*)pkg_malloc(_pv_treq.buf_size*sizeof(char));
|
|
|
|
- if(_pv_treq.buf==NULL)
|
|
|
|
- {
|
|
|
|
|
|
+ _pv_treq.buf_size = t->uas.request->len + 1;
|
|
|
|
+ _pv_treq.buf = (char *)pkg_malloc(_pv_treq.buf_size * sizeof(char));
|
|
|
|
+ if(_pv_treq.buf == NULL) {
|
|
PKG_MEM_ERROR;
|
|
PKG_MEM_ERROR;
|
|
_pv_treq.buf_size = 0;
|
|
_pv_treq.buf_size = 0;
|
|
return -1;
|
|
return -1;
|
|
@@ -134,8 +130,7 @@ int pv_t_update_req(struct sip_msg *msg)
|
|
_pv_treq.label = t->label;
|
|
_pv_treq.label = t->label;
|
|
|
|
|
|
|
|
|
|
- if(pv_t_copy_msg(t->uas.request, &_pv_treq.msg)!=0)
|
|
|
|
- {
|
|
|
|
|
|
+ if(pv_t_copy_msg(t->uas.request, &_pv_treq.msg) != 0) {
|
|
pkg_free(_pv_treq.buf);
|
|
pkg_free(_pv_treq.buf);
|
|
_pv_treq.buf_size = 0;
|
|
_pv_treq.buf_size = 0;
|
|
_pv_treq.buf = NULL;
|
|
_pv_treq.buf = NULL;
|
|
@@ -150,40 +145,39 @@ int pv_t_update_req(struct sip_msg *msg)
|
|
|
|
|
|
int pv_t_update_rpl(struct sip_msg *msg)
|
|
int pv_t_update_rpl(struct sip_msg *msg)
|
|
{
|
|
{
|
|
- struct cell * t;
|
|
|
|
|
|
+ struct cell *t;
|
|
int branch;
|
|
int branch;
|
|
int cancel;
|
|
int cancel;
|
|
|
|
|
|
- if(msg==NULL)
|
|
|
|
|
|
+ if(msg == NULL)
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
- if(msg==FAKED_REPLY || msg->first_line.type!=SIP_REQUEST)
|
|
|
|
|
|
+ if(msg == FAKED_REPLY || msg->first_line.type != SIP_REQUEST)
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
t = _tmx_tmb.t_gett();
|
|
t = _tmx_tmb.t_gett();
|
|
|
|
|
|
- if(t==NULL || t==T_UNDEFINED)
|
|
|
|
- {
|
|
|
|
- if(_tmx_tmb.t_lookup_request(msg, 0, &cancel)<=0)
|
|
|
|
|
|
+ if(t == NULL || t == T_UNDEFINED) {
|
|
|
|
+ if(_tmx_tmb.t_lookup_request(msg, 0, &cancel) <= 0)
|
|
return 1;
|
|
return 1;
|
|
t = _tmx_tmb.t_gett();
|
|
t = _tmx_tmb.t_gett();
|
|
|
|
|
|
- if(t==NULL || t==T_UNDEFINED)
|
|
|
|
|
|
+ if(t == NULL || t == T_UNDEFINED)
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
- if ( (branch=_tmx_tmb.t_get_picked_branch())<0 )
|
|
|
|
|
|
+ if((branch = _tmx_tmb.t_get_picked_branch()) < 0)
|
|
return 1;
|
|
return 1;
|
|
- if(t->uac[branch].reply==NULL || t->uac[branch].reply==FAKED_REPLY)
|
|
|
|
|
|
+ if(t->uac[branch].reply == NULL || t->uac[branch].reply == FAKED_REPLY)
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
- if (_pv_trpl.label == t->label && _pv_trpl.index == t->hash_index
|
|
|
|
|
|
+ if(_pv_trpl.label == t->label && _pv_trpl.index == t->hash_index
|
|
&& _pv_trpl.branch == branch)
|
|
&& _pv_trpl.branch == branch)
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
/* make a copy */
|
|
/* make a copy */
|
|
- if(_pv_trpl.buf==NULL || _pv_trpl.buf_size<t->uac[branch].reply->len+1)
|
|
|
|
- {
|
|
|
|
- if(_pv_trpl.buf!=NULL)
|
|
|
|
|
|
+ if(_pv_trpl.buf == NULL
|
|
|
|
+ || _pv_trpl.buf_size < t->uac[branch].reply->len + 1) {
|
|
|
|
+ if(_pv_trpl.buf != NULL)
|
|
pkg_free(_pv_trpl.buf);
|
|
pkg_free(_pv_trpl.buf);
|
|
if(_pv_trpl.tmsgp)
|
|
if(_pv_trpl.tmsgp)
|
|
free_sip_msg(&_pv_trpl.msg);
|
|
free_sip_msg(&_pv_trpl.msg);
|
|
@@ -191,10 +185,9 @@ int pv_t_update_rpl(struct sip_msg *msg)
|
|
_pv_trpl.index = 0;
|
|
_pv_trpl.index = 0;
|
|
_pv_trpl.label = 0;
|
|
_pv_trpl.label = 0;
|
|
_pv_trpl.branch = 0;
|
|
_pv_trpl.branch = 0;
|
|
- _pv_trpl.buf_size = t->uac[branch].reply->len+1;
|
|
|
|
- _pv_trpl.buf = (char*)pkg_malloc(_pv_trpl.buf_size*sizeof(char));
|
|
|
|
- if(_pv_trpl.buf==NULL)
|
|
|
|
- {
|
|
|
|
|
|
+ _pv_trpl.buf_size = t->uac[branch].reply->len + 1;
|
|
|
|
+ _pv_trpl.buf = (char *)pkg_malloc(_pv_trpl.buf_size * sizeof(char));
|
|
|
|
+ if(_pv_trpl.buf == NULL) {
|
|
PKG_MEM_ERROR;
|
|
PKG_MEM_ERROR;
|
|
_pv_trpl.buf_size = 0;
|
|
_pv_trpl.buf_size = 0;
|
|
return -1;
|
|
return -1;
|
|
@@ -212,8 +205,7 @@ int pv_t_update_rpl(struct sip_msg *msg)
|
|
_pv_trpl.label = t->label;
|
|
_pv_trpl.label = t->label;
|
|
_pv_trpl.branch = branch;
|
|
_pv_trpl.branch = branch;
|
|
|
|
|
|
- if(pv_t_copy_msg(t->uac[branch].reply, &_pv_trpl.msg)!=0)
|
|
|
|
- {
|
|
|
|
|
|
+ if(pv_t_copy_msg(t->uac[branch].reply, &_pv_trpl.msg) != 0) {
|
|
pkg_free(_pv_trpl.buf);
|
|
pkg_free(_pv_trpl.buf);
|
|
_pv_trpl.buf_size = 0;
|
|
_pv_trpl.buf_size = 0;
|
|
_pv_trpl.buf = NULL;
|
|
_pv_trpl.buf = NULL;
|
|
@@ -229,40 +221,38 @@ int pv_t_update_rpl(struct sip_msg *msg)
|
|
|
|
|
|
int pv_t_update_inv(struct sip_msg *msg)
|
|
int pv_t_update_inv(struct sip_msg *msg)
|
|
{
|
|
{
|
|
- struct cell * t;
|
|
|
|
|
|
+ struct cell *t;
|
|
|
|
|
|
- if(msg==NULL)
|
|
|
|
|
|
+ if(msg == NULL)
|
|
return 1;
|
|
return 1;
|
|
- if (msg->REQ_METHOD!=METHOD_CANCEL)
|
|
|
|
|
|
+ if(msg->REQ_METHOD != METHOD_CANCEL)
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
t = _tmx_tmb.t_lookup_original(msg);
|
|
t = _tmx_tmb.t_lookup_original(msg);
|
|
|
|
|
|
- if(t==NULL || t==T_UNDEFINED)
|
|
|
|
|
|
+ if(t == NULL || t == T_UNDEFINED)
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
- if(t->uas.request==NULL) {
|
|
|
|
|
|
+ if(t->uas.request == NULL) {
|
|
_tmx_tmb.unref_cell(t);
|
|
_tmx_tmb.unref_cell(t);
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
- if (_pv_tinv.label == t->label && _pv_tinv.index == t->hash_index)
|
|
|
|
|
|
+ if(_pv_tinv.label == t->label && _pv_tinv.index == t->hash_index)
|
|
goto done;
|
|
goto done;
|
|
|
|
|
|
/* make a copy */
|
|
/* make a copy */
|
|
- if(_pv_tinv.buf==NULL || _pv_tinv.buf_size<t->uas.request->len+1)
|
|
|
|
- {
|
|
|
|
- if(_pv_tinv.buf!=NULL)
|
|
|
|
|
|
+ if(_pv_tinv.buf == NULL || _pv_tinv.buf_size < t->uas.request->len + 1) {
|
|
|
|
+ if(_pv_tinv.buf != NULL)
|
|
pkg_free(_pv_tinv.buf);
|
|
pkg_free(_pv_tinv.buf);
|
|
if(_pv_tinv.tmsgp)
|
|
if(_pv_tinv.tmsgp)
|
|
free_sip_msg(&_pv_tinv.msg);
|
|
free_sip_msg(&_pv_tinv.msg);
|
|
_pv_tinv.tmsgp = NULL;
|
|
_pv_tinv.tmsgp = NULL;
|
|
_pv_tinv.index = 0;
|
|
_pv_tinv.index = 0;
|
|
_pv_tinv.label = 0;
|
|
_pv_tinv.label = 0;
|
|
- _pv_tinv.buf_size = t->uas.request->len+1;
|
|
|
|
- _pv_tinv.buf = (char*)pkg_malloc(_pv_tinv.buf_size*sizeof(char));
|
|
|
|
- if(_pv_tinv.buf==NULL)
|
|
|
|
- {
|
|
|
|
|
|
+ _pv_tinv.buf_size = t->uas.request->len + 1;
|
|
|
|
+ _pv_tinv.buf = (char *)pkg_malloc(_pv_tinv.buf_size * sizeof(char));
|
|
|
|
+ if(_pv_tinv.buf == NULL) {
|
|
PKG_MEM_ERROR;
|
|
PKG_MEM_ERROR;
|
|
_pv_tinv.buf_size = 0;
|
|
_pv_tinv.buf_size = 0;
|
|
goto error;
|
|
goto error;
|
|
@@ -280,8 +270,7 @@ int pv_t_update_inv(struct sip_msg *msg)
|
|
_pv_tinv.label = t->label;
|
|
_pv_tinv.label = t->label;
|
|
|
|
|
|
|
|
|
|
- if(pv_t_copy_msg(t->uas.request, &_pv_tinv.msg)!=0)
|
|
|
|
- {
|
|
|
|
|
|
+ if(pv_t_copy_msg(t->uas.request, &_pv_tinv.msg) != 0) {
|
|
pkg_free(_pv_tinv.buf);
|
|
pkg_free(_pv_tinv.buf);
|
|
_pv_tinv.buf_size = 0;
|
|
_pv_tinv.buf_size = 0;
|
|
_pv_tinv.buf = NULL;
|
|
_pv_tinv.buf = NULL;
|
|
@@ -300,12 +289,11 @@ error:
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
-int pv_get_t_var_req(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_t_var_req(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
- pv_spec_t *pv=NULL;
|
|
|
|
|
|
+ pv_spec_t *pv = NULL;
|
|
|
|
|
|
- if(!is_route_type(CORE_ONREPLY_ROUTE|TM_ONREPLY_ROUTE)) {
|
|
|
|
|
|
+ if(!is_route_type(CORE_ONREPLY_ROUTE | TM_ONREPLY_ROUTE)) {
|
|
LM_DBG("used in unsupported route block - type %d\n", get_route_type());
|
|
LM_DBG("used in unsupported route block - type %d\n", get_route_type());
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
@@ -313,19 +301,18 @@ int pv_get_t_var_req(struct sip_msg *msg, pv_param_t *param,
|
|
if(pv_t_update_req(msg))
|
|
if(pv_t_update_req(msg))
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
|
|
|
|
- pv = (pv_spec_t*)param->pvn.u.dname;
|
|
|
|
- if(pv==NULL || pv_alter_context(pv))
|
|
|
|
|
|
+ pv = (pv_spec_t *)param->pvn.u.dname;
|
|
|
|
+ if(pv == NULL || pv_alter_context(pv))
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
|
|
|
|
return pv_get_spec_value(&_pv_treq.msg, pv, res);
|
|
return pv_get_spec_value(&_pv_treq.msg, pv, res);
|
|
}
|
|
}
|
|
|
|
|
|
-int pv_get_t_var_rpl(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_t_var_rpl(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
- pv_spec_t *pv=NULL;
|
|
|
|
|
|
+ pv_spec_t *pv = NULL;
|
|
|
|
|
|
- if(!is_route_type(FAILURE_ROUTE|BRANCH_FAILURE_ROUTE)) {
|
|
|
|
|
|
+ if(!is_route_type(FAILURE_ROUTE | BRANCH_FAILURE_ROUTE)) {
|
|
LM_DBG("used in unsupported route block - type %d\n", get_route_type());
|
|
LM_DBG("used in unsupported route block - type %d\n", get_route_type());
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
@@ -333,19 +320,19 @@ int pv_get_t_var_rpl(struct sip_msg *msg, pv_param_t *param,
|
|
if(pv_t_update_rpl(msg))
|
|
if(pv_t_update_rpl(msg))
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
|
|
|
|
- pv = (pv_spec_t*)param->pvn.u.dname;
|
|
|
|
- if(pv==NULL || pv_alter_context(pv))
|
|
|
|
|
|
+ pv = (pv_spec_t *)param->pvn.u.dname;
|
|
|
|
+ if(pv == NULL || pv_alter_context(pv))
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
|
|
|
|
return pv_get_spec_value(&_pv_trpl.msg, pv, res);
|
|
return pv_get_spec_value(&_pv_trpl.msg, pv, res);
|
|
}
|
|
}
|
|
|
|
|
|
-int pv_get_t_var_branch(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_t_var_branch(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
- pv_spec_t *pv=NULL;
|
|
|
|
|
|
+ pv_spec_t *pv = NULL;
|
|
|
|
|
|
- if(!is_route_type(FAILURE_ROUTE|BRANCH_FAILURE_ROUTE|TM_ONREPLY_ROUTE)) {
|
|
|
|
|
|
+ if(!is_route_type(
|
|
|
|
+ FAILURE_ROUTE | BRANCH_FAILURE_ROUTE | TM_ONREPLY_ROUTE)) {
|
|
LM_DBG("used in unsupported route block - type %d\n", get_route_type());
|
|
LM_DBG("used in unsupported route block - type %d\n", get_route_type());
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
@@ -353,17 +340,16 @@ int pv_get_t_var_branch(struct sip_msg *msg, pv_param_t *param,
|
|
if(pv_t_update_rpl(msg))
|
|
if(pv_t_update_rpl(msg))
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
|
|
|
|
- pv = (pv_spec_t*)param->pvn.u.dname;
|
|
|
|
- if(pv==NULL || pv_alter_context(pv))
|
|
|
|
|
|
+ pv = (pv_spec_t *)param->pvn.u.dname;
|
|
|
|
+ if(pv == NULL || pv_alter_context(pv))
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
|
|
|
|
return pv_get_spec_value(&_pv_trpl.msg, pv, res);
|
|
return pv_get_spec_value(&_pv_trpl.msg, pv, res);
|
|
}
|
|
}
|
|
|
|
|
|
-int pv_get_t_var_inv(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_t_var_inv(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
- pv_spec_t *pv=NULL;
|
|
|
|
|
|
+ pv_spec_t *pv = NULL;
|
|
|
|
|
|
if(!is_route_type(REQUEST_ROUTE)) {
|
|
if(!is_route_type(REQUEST_ROUTE)) {
|
|
LM_DBG("used in unsupported route block - type %d\n", get_route_type());
|
|
LM_DBG("used in unsupported route block - type %d\n", get_route_type());
|
|
@@ -373,8 +359,8 @@ int pv_get_t_var_inv(struct sip_msg *msg, pv_param_t *param,
|
|
if(pv_t_update_inv(msg))
|
|
if(pv_t_update_inv(msg))
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
|
|
|
|
- pv = (pv_spec_t*)param->pvn.u.dname;
|
|
|
|
- if(pv==NULL || pv_alter_context(pv))
|
|
|
|
|
|
+ pv = (pv_spec_t *)param->pvn.u.dname;
|
|
|
|
+ if(pv == NULL || pv_alter_context(pv))
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
|
|
|
|
return pv_get_spec_value(&_pv_tinv.msg, pv, res);
|
|
return pv_get_spec_value(&_pv_tinv.msg, pv, res);
|
|
@@ -382,36 +368,36 @@ int pv_get_t_var_inv(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
|
|
int pv_parse_t_var_name(pv_spec_p sp, str *in)
|
|
int pv_parse_t_var_name(pv_spec_p sp, str *in)
|
|
{
|
|
{
|
|
- pv_spec_t *pv=NULL;
|
|
|
|
|
|
+ pv_spec_t *pv = NULL;
|
|
|
|
|
|
- if(in->s==NULL || in->len<=0)
|
|
|
|
|
|
+ if(in->s == NULL || in->len <= 0)
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
- pv = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
|
|
|
|
- if(pv==NULL) {
|
|
|
|
|
|
+ pv = (pv_spec_t *)pkg_malloc(sizeof(pv_spec_t));
|
|
|
|
+ if(pv == NULL) {
|
|
PKG_MEM_ERROR;
|
|
PKG_MEM_ERROR;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
memset(pv, 0, sizeof(pv_spec_t));
|
|
memset(pv, 0, sizeof(pv_spec_t));
|
|
|
|
|
|
- if(pv_parse_spec(in, pv)==NULL)
|
|
|
|
|
|
+ if(pv_parse_spec(in, pv) == NULL)
|
|
goto error;
|
|
goto error;
|
|
|
|
|
|
- sp->pvp.pvn.u.dname = (void*)pv;
|
|
|
|
|
|
+ sp->pvp.pvn.u.dname = (void *)pv;
|
|
sp->pvp.pvn.type = PV_NAME_PVAR;
|
|
sp->pvp.pvn.type = PV_NAME_PVAR;
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
error:
|
|
error:
|
|
LM_ERR("invalid pv name [%.*s]\n", in->len, in->s);
|
|
LM_ERR("invalid pv name [%.*s]\n", in->len, in->s);
|
|
- if(pv!=NULL)
|
|
|
|
|
|
+ if(pv != NULL)
|
|
pkg_free(pv);
|
|
pkg_free(pv);
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
/* item functions */
|
|
/* item functions */
|
|
-int pv_get_tm_branch_idx(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_tm_branch_idx(
|
|
|
|
+ struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
int l = 0;
|
|
int l = 0;
|
|
char *ch = NULL;
|
|
char *ch = NULL;
|
|
@@ -419,7 +405,7 @@ int pv_get_tm_branch_idx(struct sip_msg *msg, pv_param_t *param,
|
|
tm_ctx_t *tcx = 0;
|
|
tm_ctx_t *tcx = 0;
|
|
int idx = T_BR_UNDEFINED;
|
|
int idx = T_BR_UNDEFINED;
|
|
|
|
|
|
- if(msg==NULL || res==NULL)
|
|
|
|
|
|
+ if(msg == NULL || res == NULL)
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
/* statefull replies have the branch_index set */
|
|
/* statefull replies have the branch_index set */
|
|
@@ -427,30 +413,31 @@ int pv_get_tm_branch_idx(struct sip_msg *msg, pv_param_t *param,
|
|
tcx = _tmx_tmb.tm_ctx_get();
|
|
tcx = _tmx_tmb.tm_ctx_get();
|
|
if(tcx != NULL)
|
|
if(tcx != NULL)
|
|
idx = tcx->branch_index;
|
|
idx = tcx->branch_index;
|
|
- } else switch(route_type) {
|
|
|
|
- case BRANCH_ROUTE:
|
|
|
|
- case BRANCH_FAILURE_ROUTE:
|
|
|
|
- /* branch and branch_failure routes have their index set */
|
|
|
|
- tcx = _tmx_tmb.tm_ctx_get();
|
|
|
|
- if(tcx != NULL)
|
|
|
|
- idx = tcx->branch_index;
|
|
|
|
- break;
|
|
|
|
- case REQUEST_ROUTE:
|
|
|
|
- /* take the branch number from the number of added branches */
|
|
|
|
- idx = nr_branches;
|
|
|
|
- break;
|
|
|
|
- case FAILURE_ROUTE:
|
|
|
|
- /* first get the transaction */
|
|
|
|
- t = _tmx_tmb.t_gett();
|
|
|
|
- if ( t == NULL || t == T_UNDEFINED ) {
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
- /* add the currently added branches to the number of
|
|
|
|
|
|
+ } else
|
|
|
|
+ switch(route_type) {
|
|
|
|
+ case BRANCH_ROUTE:
|
|
|
|
+ case BRANCH_FAILURE_ROUTE:
|
|
|
|
+ /* branch and branch_failure routes have their index set */
|
|
|
|
+ tcx = _tmx_tmb.tm_ctx_get();
|
|
|
|
+ if(tcx != NULL)
|
|
|
|
+ idx = tcx->branch_index;
|
|
|
|
+ break;
|
|
|
|
+ case REQUEST_ROUTE:
|
|
|
|
+ /* take the branch number from the number of added branches */
|
|
|
|
+ idx = nr_branches;
|
|
|
|
+ break;
|
|
|
|
+ case FAILURE_ROUTE:
|
|
|
|
+ /* first get the transaction */
|
|
|
|
+ t = _tmx_tmb.t_gett();
|
|
|
|
+ if(t == NULL || t == T_UNDEFINED) {
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ /* add the currently added branches to the number of
|
|
* completed branches in the transaction
|
|
* completed branches in the transaction
|
|
*/
|
|
*/
|
|
- idx = t->nr_of_outgoings + nr_branches;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ idx = t->nr_of_outgoings + nr_branches;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
|
|
ch = sint2str(idx, &l);
|
|
ch = sint2str(idx, &l);
|
|
|
|
|
|
@@ -458,37 +445,40 @@ int pv_get_tm_branch_idx(struct sip_msg *msg, pv_param_t *param,
|
|
res->rs.len = l;
|
|
res->rs.len = l;
|
|
|
|
|
|
res->ri = idx;
|
|
res->ri = idx;
|
|
- res->flags = PV_VAL_STR|PV_VAL_INT|PV_TYPE_INT;
|
|
|
|
|
|
+ res->flags = PV_VAL_STR | PV_VAL_INT | PV_TYPE_INT;
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-int pv_get_tm_reply_ruid(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_tm_reply_ruid(
|
|
|
|
+ struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
struct cell *t;
|
|
struct cell *t;
|
|
tm_ctx_t *tcx = 0;
|
|
tm_ctx_t *tcx = 0;
|
|
int branch;
|
|
int branch;
|
|
|
|
|
|
- if(msg==NULL || res==NULL)
|
|
|
|
|
|
+ if(msg == NULL || res == NULL)
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
/* first get the transaction */
|
|
/* first get the transaction */
|
|
- if (_tmx_tmb.t_check( msg , 0 )==-1) return -1;
|
|
|
|
- if ( (t=_tmx_tmb.t_gett())==0) {
|
|
|
|
|
|
+ if(_tmx_tmb.t_check(msg, 0) == -1)
|
|
|
|
+ return -1;
|
|
|
|
+ if((t = _tmx_tmb.t_gett()) == 0) {
|
|
/* no T */
|
|
/* no T */
|
|
return pv_get_strempty(msg, param, res);
|
|
return pv_get_strempty(msg, param, res);
|
|
} else {
|
|
} else {
|
|
- switch (get_route_type()) {
|
|
|
|
|
|
+ switch(get_route_type()) {
|
|
case FAILURE_ROUTE:
|
|
case FAILURE_ROUTE:
|
|
case BRANCH_FAILURE_ROUTE:
|
|
case BRANCH_FAILURE_ROUTE:
|
|
/* use the reason of the winning reply */
|
|
/* use the reason of the winning reply */
|
|
- if ( (branch=_tmx_tmb.t_get_picked_branch())<0 ) {
|
|
|
|
|
|
+ if((branch = _tmx_tmb.t_get_picked_branch()) < 0) {
|
|
LM_CRIT("no picked branch (%d) for a final response"
|
|
LM_CRIT("no picked branch (%d) for a final response"
|
|
- " in MODE_ONFAILURE\n", branch);
|
|
|
|
|
|
+ " in MODE_ONFAILURE\n",
|
|
|
|
+ branch);
|
|
return pv_get_strempty(msg, param, res);
|
|
return pv_get_strempty(msg, param, res);
|
|
}
|
|
}
|
|
- LM_DBG("reply ruid is [%.*s]\n", t->uac[branch].ruid.len, t->uac[branch].ruid.s);
|
|
|
|
|
|
+ LM_DBG("reply ruid is [%.*s]\n", t->uac[branch].ruid.len,
|
|
|
|
+ t->uac[branch].ruid.s);
|
|
return pv_get_strval(msg, param, res, &t->uac[branch].ruid);
|
|
return pv_get_strval(msg, param, res, &t->uac[branch].ruid);
|
|
break;
|
|
break;
|
|
case TM_ONREPLY_ROUTE:
|
|
case TM_ONREPLY_ROUTE:
|
|
@@ -497,10 +487,11 @@ int pv_get_tm_reply_ruid(struct sip_msg *msg, pv_param_t *param,
|
|
return pv_get_strempty(msg, param, res);
|
|
return pv_get_strempty(msg, param, res);
|
|
}
|
|
}
|
|
branch = tcx->branch_index;
|
|
branch = tcx->branch_index;
|
|
- if(branch<0 || branch>=t->nr_of_outgoings) {
|
|
|
|
|
|
+ if(branch < 0 || branch >= t->nr_of_outgoings) {
|
|
return pv_get_strempty(msg, param, res);
|
|
return pv_get_strempty(msg, param, res);
|
|
}
|
|
}
|
|
- LM_DBG("reply ruid is [%.*s]\n", t->uac[branch].ruid.len, t->uac[branch].ruid.s);
|
|
|
|
|
|
+ LM_DBG("reply ruid is [%.*s]\n", t->uac[branch].ruid.len,
|
|
|
|
+ t->uac[branch].ruid.s);
|
|
return pv_get_strval(msg, param, res, &t->uac[branch].ruid);
|
|
return pv_get_strval(msg, param, res, &t->uac[branch].ruid);
|
|
default:
|
|
default:
|
|
LM_ERR("unsupported route_type %d\n", get_route_type());
|
|
LM_ERR("unsupported route_type %d\n", get_route_type());
|
|
@@ -509,17 +500,17 @@ int pv_get_tm_reply_ruid(struct sip_msg *msg, pv_param_t *param,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-int pv_get_tm_reply_code(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_tm_reply_code(
|
|
|
|
+ struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
struct cell *t;
|
|
struct cell *t;
|
|
int code;
|
|
int code;
|
|
int branch;
|
|
int branch;
|
|
|
|
|
|
- if(msg==NULL || res==NULL)
|
|
|
|
|
|
+ if(msg == NULL || res == NULL)
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
- switch (get_route_type()) {
|
|
|
|
|
|
+ switch(get_route_type()) {
|
|
case CORE_ONREPLY_ROUTE:
|
|
case CORE_ONREPLY_ROUTE:
|
|
case TM_ONREPLY_ROUTE:
|
|
case TM_ONREPLY_ROUTE:
|
|
/* use the status of the current reply */
|
|
/* use the status of the current reply */
|
|
@@ -528,12 +519,13 @@ int pv_get_tm_reply_code(struct sip_msg *msg, pv_param_t *param,
|
|
}
|
|
}
|
|
|
|
|
|
/* first get the transaction */
|
|
/* first get the transaction */
|
|
- if (_tmx_tmb.t_check( msg , 0 )==-1) return -1;
|
|
|
|
- if ( (t=_tmx_tmb.t_gett())==0) {
|
|
|
|
|
|
+ if(_tmx_tmb.t_check(msg, 0) == -1)
|
|
|
|
+ return -1;
|
|
|
|
+ if((t = _tmx_tmb.t_gett()) == 0) {
|
|
/* no T */
|
|
/* no T */
|
|
code = 0;
|
|
code = 0;
|
|
} else {
|
|
} else {
|
|
- switch (get_route_type()) {
|
|
|
|
|
|
+ switch(get_route_type()) {
|
|
case REQUEST_ROUTE:
|
|
case REQUEST_ROUTE:
|
|
case BRANCH_ROUTE:
|
|
case BRANCH_ROUTE:
|
|
/* use the status of the last sent reply */
|
|
/* use the status of the last sent reply */
|
|
@@ -542,9 +534,10 @@ int pv_get_tm_reply_code(struct sip_msg *msg, pv_param_t *param,
|
|
case FAILURE_ROUTE:
|
|
case FAILURE_ROUTE:
|
|
case BRANCH_FAILURE_ROUTE:
|
|
case BRANCH_FAILURE_ROUTE:
|
|
/* use the status of the winning reply */
|
|
/* use the status of the winning reply */
|
|
- if ( (branch=_tmx_tmb.t_get_picked_branch())<0 ) {
|
|
|
|
|
|
+ if((branch = _tmx_tmb.t_get_picked_branch()) < 0) {
|
|
LM_CRIT("no picked branch (%d) for a final response"
|
|
LM_CRIT("no picked branch (%d) for a final response"
|
|
- " in MODE_ONFAILURE\n", branch);
|
|
|
|
|
|
+ " in MODE_ONFAILURE\n",
|
|
|
|
+ branch);
|
|
code = 0;
|
|
code = 0;
|
|
} else {
|
|
} else {
|
|
code = t->uac[branch].last_received;
|
|
code = t->uac[branch].last_received;
|
|
@@ -564,24 +557,24 @@ done:
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-int pv_get_tm_reply_reason(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_tm_reply_reason(
|
|
|
|
+ struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
struct cell *t;
|
|
struct cell *t;
|
|
struct sip_msg *reply;
|
|
struct sip_msg *reply;
|
|
int branch = -1;
|
|
int branch = -1;
|
|
int vref = 0;
|
|
int vref = 0;
|
|
|
|
|
|
- if(msg==NULL || res==NULL)
|
|
|
|
|
|
+ if(msg == NULL || res == NULL)
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
/* first get the transaction */
|
|
/* first get the transaction */
|
|
t = _tmx_tmb.t_find(msg, &branch, &vref);
|
|
t = _tmx_tmb.t_find(msg, &branch, &vref);
|
|
- if (t==T_NULL_CELL || t==T_UNDEFINED) {
|
|
|
|
|
|
+ if(t == T_NULL_CELL || t == T_UNDEFINED) {
|
|
/* no T */
|
|
/* no T */
|
|
return pv_get_strempty(msg, param, res);
|
|
return pv_get_strempty(msg, param, res);
|
|
} else {
|
|
} else {
|
|
- switch (get_route_type()) {
|
|
|
|
|
|
+ switch(get_route_type()) {
|
|
case CORE_ONREPLY_ROUTE:
|
|
case CORE_ONREPLY_ROUTE:
|
|
if(vref) {
|
|
if(vref) {
|
|
/* t_find() above has the side effect of setting T and
|
|
/* t_find() above has the side effect of setting T and
|
|
@@ -597,13 +590,14 @@ int pv_get_tm_reply_reason(struct sip_msg *msg, pv_param_t *param,
|
|
break;
|
|
break;
|
|
case FAILURE_ROUTE:
|
|
case FAILURE_ROUTE:
|
|
/* use the reason of the winning reply */
|
|
/* use the reason of the winning reply */
|
|
- if ( (branch=_tmx_tmb.t_get_picked_branch())<0 ) {
|
|
|
|
|
|
+ if((branch = _tmx_tmb.t_get_picked_branch()) < 0) {
|
|
LM_CRIT("no picked branch (%d) for a final response"
|
|
LM_CRIT("no picked branch (%d) for a final response"
|
|
- " in MODE_ONFAILURE\n", branch);
|
|
|
|
|
|
+ " in MODE_ONFAILURE\n",
|
|
|
|
+ branch);
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
reply = t->uac[branch].reply;
|
|
reply = t->uac[branch].reply;
|
|
- if (reply == FAKED_REPLY) {
|
|
|
|
|
|
+ if(reply == FAKED_REPLY) {
|
|
res->rs.s = error_text(t->uac[branch].last_received);
|
|
res->rs.s = error_text(t->uac[branch].last_received);
|
|
res->rs.len = strlen(res->rs.s);
|
|
res->rs.len = strlen(res->rs.s);
|
|
} else {
|
|
} else {
|
|
@@ -621,25 +615,26 @@ int pv_get_tm_reply_reason(struct sip_msg *msg, pv_param_t *param,
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-int pv_get_tm_reply_last_received(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_tm_reply_last_received(
|
|
|
|
+ struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
struct cell *t;
|
|
struct cell *t;
|
|
tm_ctx_t *tcx = 0;
|
|
tm_ctx_t *tcx = 0;
|
|
int code;
|
|
int code;
|
|
|
|
|
|
- if(msg==NULL || res==NULL)
|
|
|
|
|
|
+ if(msg == NULL || res == NULL)
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
/* Only for TM reply route */
|
|
/* Only for TM reply route */
|
|
- if (get_route_type() != TM_ONREPLY_ROUTE) {
|
|
|
|
|
|
+ if(get_route_type() != TM_ONREPLY_ROUTE) {
|
|
LM_ERR("unsupported route_type %d\n", get_route_type());
|
|
LM_ERR("unsupported route_type %d\n", get_route_type());
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
/* first get the transaction */
|
|
/* first get the transaction */
|
|
- if (_tmx_tmb.t_check( msg , 0 )==-1) return -1;
|
|
|
|
- if ( (t=_tmx_tmb.t_gett())==0) {
|
|
|
|
|
|
+ if(_tmx_tmb.t_check(msg, 0) == -1)
|
|
|
|
+ return -1;
|
|
|
|
+ if((t = _tmx_tmb.t_gett()) == 0) {
|
|
/* no T */
|
|
/* no T */
|
|
LM_ERR("could not get transaction\n");
|
|
LM_ERR("could not get transaction\n");
|
|
return -1;
|
|
return -1;
|
|
@@ -655,61 +650,66 @@ int pv_get_tm_reply_last_received(struct sip_msg *msg, pv_param_t *param,
|
|
/* get the last received reply code */
|
|
/* get the last received reply code */
|
|
code = t->uac[tcx->branch_index].last_received;
|
|
code = t->uac[tcx->branch_index].last_received;
|
|
|
|
|
|
- LM_DBG("reply code is <%d>\n",code);
|
|
|
|
|
|
+ LM_DBG("reply code is <%d>\n", code);
|
|
|
|
|
|
- res->rs.s = int2str( code, &res->rs.len);
|
|
|
|
|
|
+ res->rs.s = int2str(code, &res->rs.len);
|
|
|
|
|
|
res->ri = code;
|
|
res->ri = code;
|
|
- res->flags = PV_VAL_STR|PV_VAL_INT|PV_TYPE_INT;
|
|
|
|
|
|
+ res->flags = PV_VAL_STR | PV_VAL_INT | PV_TYPE_INT;
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
int pv_parse_t_name(pv_spec_p sp, str *in)
|
|
int pv_parse_t_name(pv_spec_p sp, str *in)
|
|
{
|
|
{
|
|
- if(sp==NULL || in==NULL || in->len<=0)
|
|
|
|
|
|
+ if(sp == NULL || in == NULL || in->len <= 0)
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
- switch(in->len)
|
|
|
|
- {
|
|
|
|
|
|
+ switch(in->len) {
|
|
case 3:
|
|
case 3:
|
|
if(strncmp(in->s, "uri", 3) == 0)
|
|
if(strncmp(in->s, "uri", 3) == 0)
|
|
sp->pvp.pvn.u.isname.name.n = 6;
|
|
sp->pvp.pvn.u.isname.name.n = 6;
|
|
- else goto error;
|
|
|
|
|
|
+ else
|
|
|
|
+ goto error;
|
|
break;
|
|
break;
|
|
case 4:
|
|
case 4:
|
|
if(strncmp(in->s, "ruid", 4) == 0)
|
|
if(strncmp(in->s, "ruid", 4) == 0)
|
|
sp->pvp.pvn.u.isname.name.n = 7;
|
|
sp->pvp.pvn.u.isname.name.n = 7;
|
|
- else goto error;
|
|
|
|
|
|
+ else
|
|
|
|
+ goto error;
|
|
break;
|
|
break;
|
|
case 5:
|
|
case 5:
|
|
if(strncmp(in->s, "flags", 5) == 0)
|
|
if(strncmp(in->s, "flags", 5) == 0)
|
|
sp->pvp.pvn.u.isname.name.n = 5;
|
|
sp->pvp.pvn.u.isname.name.n = 5;
|
|
- else goto error;
|
|
|
|
|
|
+ else
|
|
|
|
+ goto error;
|
|
break;
|
|
break;
|
|
case 8:
|
|
case 8:
|
|
- if(strncmp(in->s, "id_label", 8)==0)
|
|
|
|
|
|
+ if(strncmp(in->s, "id_label", 8) == 0)
|
|
sp->pvp.pvn.u.isname.name.n = 0;
|
|
sp->pvp.pvn.u.isname.name.n = 0;
|
|
- else if(strncmp(in->s, "id_index", 8)==0)
|
|
|
|
|
|
+ else if(strncmp(in->s, "id_index", 8) == 0)
|
|
sp->pvp.pvn.u.isname.name.n = 1;
|
|
sp->pvp.pvn.u.isname.name.n = 1;
|
|
- else goto error;
|
|
|
|
|
|
+ else
|
|
|
|
+ goto error;
|
|
break;
|
|
break;
|
|
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)
|
|
|
|
|
|
+ else if(strncmp(in->s, "reply_type", 10) == 0)
|
|
sp->pvp.pvn.u.isname.name.n = 3;
|
|
sp->pvp.pvn.u.isname.name.n = 3;
|
|
- else if(strncmp(in->s, "id_label_n", 10)==0)
|
|
|
|
|
|
+ else if(strncmp(in->s, "id_label_n", 10) == 0)
|
|
sp->pvp.pvn.u.isname.name.n = 8;
|
|
sp->pvp.pvn.u.isname.name.n = 8;
|
|
- else if(strncmp(in->s, "id_index_n", 10)==0)
|
|
|
|
|
|
+ else if(strncmp(in->s, "id_index_n", 10) == 0)
|
|
sp->pvp.pvn.u.isname.name.n = 9;
|
|
sp->pvp.pvn.u.isname.name.n = 9;
|
|
- 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 = 4;
|
|
sp->pvp.pvn.u.isname.name.n = 4;
|
|
- else if(strncmp(in->s, "reply_reason", 12)==0)
|
|
|
|
|
|
+ else if(strncmp(in->s, "reply_reason", 12) == 0)
|
|
sp->pvp.pvn.u.isname.name.n = 10;
|
|
sp->pvp.pvn.u.isname.name.n = 10;
|
|
- else goto error;
|
|
|
|
|
|
+ else
|
|
|
|
+ goto error;
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
goto error;
|
|
goto error;
|
|
@@ -722,20 +722,17 @@ int pv_parse_t_name(pv_spec_p sp, str *in)
|
|
error:
|
|
error:
|
|
LM_ERR("unknown PV name %.*s\n", in->len, in->s);
|
|
LM_ERR("unknown PV name %.*s\n", in->len, in->s);
|
|
return -1;
|
|
return -1;
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-int pv_get_t(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_t(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
tm_cell_t *t;
|
|
tm_cell_t *t;
|
|
|
|
|
|
- if(msg==NULL || param==NULL)
|
|
|
|
|
|
+ if(msg == NULL || param == NULL)
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
/* aliases to old TM pvs */
|
|
/* aliases to old TM pvs */
|
|
- switch(param->pvn.u.isname.name.n)
|
|
|
|
- {
|
|
|
|
|
|
+ switch(param->pvn.u.isname.name.n) {
|
|
case 2:
|
|
case 2:
|
|
return pv_get_tm_reply_code(msg, param, res);
|
|
return pv_get_tm_reply_code(msg, param, res);
|
|
case 4:
|
|
case 4:
|
|
@@ -745,31 +742,30 @@ int pv_get_t(struct sip_msg *msg, pv_param_t *param,
|
|
}
|
|
}
|
|
|
|
|
|
t = _tmx_tmb.t_gett();
|
|
t = _tmx_tmb.t_gett();
|
|
- if(t==NULL || t==T_UNDEFINED) {
|
|
|
|
|
|
+ if(t == NULL || t == T_UNDEFINED) {
|
|
/* no T */
|
|
/* no T */
|
|
- if(param->pvn.u.isname.name.n==8 || param->pvn.u.isname.name.n==9) {
|
|
|
|
|
|
+ if(param->pvn.u.isname.name.n == 8 || param->pvn.u.isname.name.n == 9) {
|
|
/* id_label_n or id_index_n - attempt to create transaction */
|
|
/* id_label_n or id_index_n - attempt to create transaction */
|
|
- if(_tmx_tmb.t_newtran(msg)<0) {
|
|
|
|
|
|
+ if(_tmx_tmb.t_newtran(msg) < 0) {
|
|
LM_ERR("cannot create the transaction\n");
|
|
LM_ERR("cannot create the transaction\n");
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
t = _tmx_tmb.t_gett();
|
|
t = _tmx_tmb.t_gett();
|
|
- if (t==NULL || t==T_UNDEFINED) {
|
|
|
|
|
|
+ if(t == NULL || t == T_UNDEFINED) {
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- switch(param->pvn.u.isname.name.n)
|
|
|
|
- {
|
|
|
|
|
|
+ switch(param->pvn.u.isname.name.n) {
|
|
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:
|
|
case 3:
|
|
- if(get_route_type()==FAILURE_ROUTE) {
|
|
|
|
- if(_tmx_tmb.t_get_picked_branch()<0 )
|
|
|
|
|
|
+ if(get_route_type() == FAILURE_ROUTE) {
|
|
|
|
+ if(_tmx_tmb.t_get_picked_branch() < 0)
|
|
return pv_get_uintval(msg, param, res, 0);
|
|
return pv_get_uintval(msg, param, res, 0);
|
|
- if(t->uac[_tmx_tmb.t_get_picked_branch()].reply==FAKED_REPLY)
|
|
|
|
|
|
+ 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, 1);
|
|
}
|
|
}
|
|
return pv_get_uintval(msg, param, res, 0);
|
|
return pv_get_uintval(msg, param, res, 0);
|
|
@@ -782,30 +778,31 @@ int pv_get_t(struct sip_msg *msg, pv_param_t *param,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-int pv_get_t_branch(struct sip_msg *msg, pv_param_t *param,
|
|
|
|
- pv_value_t *res)
|
|
|
|
|
|
+int pv_get_t_branch(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
|
|
{
|
|
{
|
|
tm_ctx_t *tcx = 0;
|
|
tm_ctx_t *tcx = 0;
|
|
tm_cell_t *t;
|
|
tm_cell_t *t;
|
|
int branch;
|
|
int branch;
|
|
|
|
|
|
- if ((msg == NULL) || (param == NULL)) return -1;
|
|
|
|
|
|
+ if((msg == NULL) || (param == NULL))
|
|
|
|
+ return -1;
|
|
|
|
|
|
t = _tmx_tmb.t_gett();
|
|
t = _tmx_tmb.t_gett();
|
|
- if ((t == NULL) || (t == T_UNDEFINED)) {
|
|
|
|
|
|
+ if((t == NULL) || (t == T_UNDEFINED)) {
|
|
/* no T */
|
|
/* no T */
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
|
|
|
|
switch(param->pvn.u.isname.name.n) {
|
|
switch(param->pvn.u.isname.name.n) {
|
|
case 5: /* $T_branch(flags) */
|
|
case 5: /* $T_branch(flags) */
|
|
- switch (get_route_type()) {
|
|
|
|
|
|
+ switch(get_route_type()) {
|
|
case FAILURE_ROUTE:
|
|
case FAILURE_ROUTE:
|
|
case BRANCH_FAILURE_ROUTE:
|
|
case BRANCH_FAILURE_ROUTE:
|
|
/* use the reason of the winning reply */
|
|
/* use the reason of the winning reply */
|
|
- if ((branch=_tmx_tmb.t_get_picked_branch()) < 0) {
|
|
|
|
|
|
+ if((branch = _tmx_tmb.t_get_picked_branch()) < 0) {
|
|
LM_CRIT("no picked branch (%d) for a final response"
|
|
LM_CRIT("no picked branch (%d) for a final response"
|
|
- " in MODE_ONFAILURE\n", branch);
|
|
|
|
|
|
+ " in MODE_ONFAILURE\n",
|
|
|
|
+ branch);
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -821,14 +818,14 @@ int pv_get_t_branch(struct sip_msg *msg, pv_param_t *param,
|
|
LM_ERR("unsupported route_type %d\n", get_route_type());
|
|
LM_ERR("unsupported route_type %d\n", get_route_type());
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
- if(branch<0 || branch>=t->nr_of_outgoings) {
|
|
|
|
|
|
+ if(branch < 0 || branch >= t->nr_of_outgoings) {
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
LM_DBG("branch flags is [%u]\n", t->uac[branch].branch_flags);
|
|
LM_DBG("branch flags is [%u]\n", t->uac[branch].branch_flags);
|
|
return pv_get_uintval(msg, param, res, t->uac[branch].branch_flags);
|
|
return pv_get_uintval(msg, param, res, t->uac[branch].branch_flags);
|
|
break;
|
|
break;
|
|
case 6: /* $T_branch(uri) */
|
|
case 6: /* $T_branch(uri) */
|
|
- if (get_route_type() != TM_ONREPLY_ROUTE) {
|
|
|
|
|
|
+ if(get_route_type() != TM_ONREPLY_ROUTE) {
|
|
LM_ERR("$T_branch(uri) - unsupported route_type %d\n",
|
|
LM_ERR("$T_branch(uri) - unsupported route_type %d\n",
|
|
get_route_type());
|
|
get_route_type());
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
@@ -838,7 +835,7 @@ int pv_get_t_branch(struct sip_msg *msg, pv_param_t *param,
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
branch = tcx->branch_index;
|
|
branch = tcx->branch_index;
|
|
- if(branch<0 || branch>=t->nr_of_outgoings) {
|
|
|
|
|
|
+ if(branch < 0 || branch >= t->nr_of_outgoings) {
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
}
|
|
}
|
|
return pv_get_strval(msg, param, res, &t->uac[branch].uri);
|
|
return pv_get_strval(msg, param, res, &t->uac[branch].uri);
|
|
@@ -849,12 +846,12 @@ int pv_get_t_branch(struct sip_msg *msg, pv_param_t *param,
|
|
tcx = _tmx_tmb.tm_ctx_get();
|
|
tcx = _tmx_tmb.tm_ctx_get();
|
|
if(tcx == NULL)
|
|
if(tcx == NULL)
|
|
return pv_get_null(msg, param, res);
|
|
return pv_get_null(msg, param, res);
|
|
- return pv_get_strval(msg, param, res, &t->uac[tcx->branch_index].ruid);
|
|
|
|
- break;
|
|
|
|
|
|
+ return pv_get_strval(
|
|
|
|
+ msg, param, res, &t->uac[tcx->branch_index].ruid);
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
return pv_get_tm_reply_ruid(msg, param, res);
|
|
return pv_get_tm_reply_ruid(msg, param, res);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|