Exemplo n.º 1
0
int pv_get_dbr(struct sip_msg *msg,  pv_param_t *param,
		pv_value_t *res)
{
	sql_pv_t *spv;
	int row;
	int col;

	spv = (sql_pv_t*)param->pvn.u.dname;

	if(spv->res==NULL)
	{
		spv->res = sql_get_result(&spv->resname);
		if(spv->res==NULL)
			return pv_get_null(msg, param, res);
	}

	switch(spv->type)
	{
		case 1:
			return pv_get_sintval(msg, param, res, spv->res->nrows);
		break;
		case 2:
			return pv_get_sintval(msg, param, res, spv->res->ncols);
		break;
		case 3:
			if(fixup_get_ivalue(msg, &spv->row, &row)!=0)
				return pv_get_null(msg, param, res);
			if(fixup_get_ivalue(msg, &spv->col, &col)!=0)
				return pv_get_null(msg, param, res);
			if(row>=spv->res->nrows)
				return pv_get_null(msg, param, res);
			if(col>=spv->res->ncols)
				return pv_get_null(msg, param, res);
			if(spv->res->vals[row][col].flags&PV_VAL_NULL)
				return pv_get_null(msg, param, res);
			if(spv->res->vals[row][col].flags&PV_VAL_INT)
				return pv_get_sintval(msg, param, res, 
						spv->res->vals[row][col].value.n);
			return pv_get_strval(msg, param, res, 
						&spv->res->vals[row][col].value.s);
		break;
		case 4:
			if(fixup_get_ivalue(msg, &spv->col, &col)!=0)
				return pv_get_null(msg, param, res);
			if(col>=spv->res->ncols)
				return pv_get_null(msg, param, res);
			return pv_get_strval(msg, param, res, 
						&spv->res->cols[col].name);
		break;
	}
	return 0;
}
Exemplo n.º 2
0
static int sipt_get_redirection_number(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
{
	static char sb_s_buf[26];
	str body;
	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);

	if(body.s == NULL)
	{
		LM_INFO("No ISUP Message Found");
		return -1;
	}

	if((body.s[0] != ISUP_ACM) && (body.s[0] != ISUP_CPG))
	{
		LM_DBG("message not an ACM or CPG\n");
		return -1;
	}
	
	isup_get_redirection_number((unsigned char*)body.s, body.len, sb_s_buf);
	
	if (strlen(sb_s_buf) > 0)
	{
		pv_get_strzval(msg, param, res, sb_s_buf);
	} else {
		pv_get_sintval(msg, param, res, -1);
	}
	return 0;
}
Exemplo n.º 3
0
int pv_get_ht_cv(struct sip_msg *msg,  pv_param_t *param,
		pv_value_t *res)
{
	str htname;
	ht_pv_t *hpv;
	int cnt = 0;

	hpv = (ht_pv_t*)param->pvn.u.dname;

	if(hpv->ht==NULL)
	{
		hpv->ht = ht_get_table(&hpv->htname);
		if(hpv->ht==NULL)
			return pv_get_null(msg, param, res);
	}
	if(pv_printf_s(msg, hpv->pve, &htname)!=0)
	{
		LM_ERR("cannot get $ht name\n");
		return -1;
	}
	
	cnt = ht_count_cells_re(&htname, hpv->ht, 1);

	/* integer */
	return pv_get_sintval(msg, param, res, cnt);
}
Exemplo n.º 4
0
/* item functions */
static int bm_get_time_diff(struct sip_msg *msg, pv_param_t *param,
		pv_value_t *res)
{
	if(msg==NULL)
		return -1;
	return pv_get_sintval(msg, param, res, _bm_last_time_diff);
}
Exemplo n.º 5
0
int pv_get_ht_expired_cell(struct sip_msg *msg, pv_param_t *param,
		pv_value_t *res)
{
	if (res == NULL || ht_expired_cell == NULL)
	{
		return -1;
	}

	if (param->pvn.u.isname.name.s.len == 3 &&
		strncmp(param->pvn.u.isname.name.s.s, "key", 3) == 0)
	{
		res->rs = ht_expired_cell->name;
	}
	else if (param->pvn.u.isname.name.s.len == 5 &&
		strncmp(param->pvn.u.isname.name.s.s, "value", 5) == 0)
	{
		if(ht_expired_cell->flags&AVP_VAL_STR) {
			return pv_get_strval(msg, param, res, &ht_expired_cell->value.s);
		} else {
			return pv_get_sintval(msg, param, res, ht_expired_cell->value.n);
		}
	}

	if (res->rs.s == NULL)
		res->flags = PV_VAL_NULL;
	else
		res->flags = PV_VAL_STR;

	return 0;
}
Exemplo n.º 6
0
static int pv_get_mongodb(struct sip_msg *msg,  pv_param_t *param,
		pv_value_t *res)
{
	mongodbc_pv_t *rpv;

	rpv = (mongodbc_pv_t*)param->pvn.u.dname;
	if(rpv->reply==NULL)
	{
		rpv->reply = mongodbc_get_reply(&rpv->rname);
		if(rpv->reply==NULL)
			return pv_get_null(msg, param, res);
	}


	switch(rpv->rkeyid) {
		case 1:
			/* value */
			if(rpv->reply->jsonrpl.s==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_strval(msg, param, res, &rpv->reply->jsonrpl);
		case 2:
			/* info */
			return pv_get_null(msg, param, res);
		case 3:
			/* size */
			return pv_get_null(msg, param, res);
		case 0:
			/* type */
			return pv_get_sintval(msg, param, res, 0);
		default:
			/* We do nothing. */
			return pv_get_null(msg, param, res);
	}
}
Exemplo n.º 7
0
static int pv_get_ws_conid_f(struct sip_msg *msg, pv_param_t *param,
			     pv_value_t *res)
{
    if (msg == NULL) return -1;

    return pv_get_sintval(msg, param, res, msg->rcv.proto_reserved1);
}
Exemplo n.º 8
0
int pv_get_phonenum(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
{
	phonenum_pv_t *gpv;

	if(msg == NULL || param == NULL)
		return -1;

	gpv = (phonenum_pv_t *)param->pvn.u.dname;
	if(gpv == NULL)
		return -1;
	if(gpv->item == NULL)
		return pv_get_null(msg, param, res);
	if(gpv->item->r.record==NULL)
		return pv_get_null(msg, param, res);

	switch(gpv->type) {
		case 1: /* normalized */
			if(gpv->item->r.record->normalized==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_strzval(msg, param, res,
						gpv->item->r.record->normalized);
		case 2: /* ltype */
			if(gpv->item->r.record->ltype==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_strzval(msg, param, res, gpv->item->r.record->ltype);
		case 3: /* ndesc */
			if(gpv->item->r.record->ndesc==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_strzval(msg, param, res, gpv->item->r.record->ndesc);
		case 4: /* error */
			if(gpv->item->r.record->error==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_strzval(msg, param, res, gpv->item->r.record->error);
		case 5: /* cctel */
			return pv_get_sintval(msg, param, res, gpv->item->r.record->cctel);
		case 6: /* valid */
			return pv_get_sintval(msg, param, res, gpv->item->r.record->valid);
		default: /* number */
			if(gpv->item->r.record->number==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_strzval(msg, param, res, gpv->item->r.record->number);
	}
}
Exemplo n.º 9
0
int pv_get_tm_reply_code(struct sip_msg *msg, pv_param_t *param,
		pv_value_t *res)
{
	struct cell *t;
	int code;
	int branch;

	if(msg==NULL || res==NULL)
		return -1;

	switch (get_route_type()) {
		case CORE_ONREPLY_ROUTE:
		case TM_ONREPLY_ROUTE:
			/* use the status of the current reply */
			code = msg->first_line.u.reply.statuscode;
			goto done;
	}

	/* first get the transaction */
	if (_tmx_tmb.t_check( msg , 0 )==-1) return -1;
	if ( (t=_tmx_tmb.t_gett())==0) {
		/* no T */
		code = 0;
	} else {
		switch (get_route_type()) {
			case REQUEST_ROUTE:
			case BRANCH_ROUTE:
				/* use the status of the last sent reply */
				code = t->uas.status;
				break;
			case FAILURE_ROUTE:
			case BRANCH_FAILURE_ROUTE:
				/* use the status of the winning reply */
				if ( (branch=_tmx_tmb.t_get_picked_branch())<0 ) {
					LM_CRIT("no picked branch (%d) for a final response"
							" in MODE_ONFAILURE\n", branch);
					code = 0;
				} else {
					code = t->uac[branch].last_received;
				}
				break;
			default:
				LM_INFO("unsupported route_type %d - code set to 0\n",
						get_route_type());
				code = 0;
		}
	}

done:
	LM_DBG("reply code is <%d>\n", code);
	return pv_get_sintval(msg, param, res, code);

	return 0;
}
Exemplo n.º 10
0
int pv_get_ht_cell(struct sip_msg *msg,  pv_param_t *param,
		pv_value_t *res)
{
	str htname;
	ht_cell_t *htc=NULL;
	ht_pv_t *hpv;

	hpv = (ht_pv_t*)param->pvn.u.dname;

	if(hpv->ht==NULL)
	{
		hpv->ht = ht_get_table(&hpv->htname);
		if(hpv->ht==NULL)
			return pv_get_null(msg, param, res);
	}
	if(pv_printf_s(msg, hpv->pve, &htname)!=0)
	{
		LM_ERR("cannot get $ht name\n");
		return -1;
	}
	htc = ht_cell_pkg_copy(hpv->ht, &htname, _htc_local);
	if(htc==NULL)
	{
		if(hpv->ht->flags==PV_VAL_INT)
			return pv_get_sintval(msg, param, res, hpv->ht->initval.n);
		return pv_get_null(msg, param, res);
	}
	if(_htc_local!=htc)
	{
		ht_cell_pkg_free(_htc_local);
		_htc_local=htc;
	}

	if(htc->flags&AVP_VAL_STR)
		return pv_get_strval(msg, param, res, &htc->value.s);
	
	/* integer */
	return pv_get_sintval(msg, param, res, htc->value.n);
}
Exemplo n.º 11
0
int pv_get_evapi(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
{
	evapi_env_t *evenv;

	if(param==NULL || res==NULL)
		return -1;

	evenv = (evapi_env_t*)msg->date;

	if(evenv==NULL || evenv->conidx<0 || evenv->conidx>=EVAPI_MAX_CLIENTS)
		return pv_get_null(msg, param, res);

	if(_evapi_clients[evenv->conidx].connected==0
			&& _evapi_clients[evenv->conidx].sock <= 0)
		return pv_get_null(msg, param, res);

	switch(param->pvn.u.isname.name.n)
	{
		case 0:
			return pv_get_sintval(msg, param, res, evenv->conidx);
		case 1:
			if(evenv->msg.s==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_strval(msg, param, res, &evenv->msg);
		case 2:
			return pv_get_strzval(msg, param, res,
					_evapi_clients[evenv->conidx].src_addr);
		case 3:
			return pv_get_sintval(msg, param, res,
					_evapi_clients[evenv->conidx].src_port);
		default:
			return pv_get_null(msg, param, res);
	}

	return 0;
}
Exemplo n.º 12
0
int pv_get_time(struct sip_msg *msg, pv_param_t *param,
		pv_value_t *res)
{
	static struct tm stored_ts;
	static time_t stored_t = 0;
	time_t t;

	if(msg==NULL || param==NULL)
		return -1;

	t = time(NULL);
	if (t!=stored_t) {
		stored_t = t;
		if (localtime_r(&t, &stored_ts) == NULL) {
			LM_ERR("unable to break time to attributes\n");
			return -1;
		}
	}

	switch(param->pvn.u.isname.name.n)
	{
		case 1:
			return pv_get_uintval(msg, param, res, (unsigned int)stored_ts.tm_min);
		case 2:
			return pv_get_uintval(msg, param, res, (unsigned int)stored_ts.tm_hour);
		case 3:
			return pv_get_uintval(msg, param, res, (unsigned int)stored_ts.tm_mday);
		case 4:
			return pv_get_uintval(msg, param, res,
					(unsigned int)(stored_ts.tm_mon+1));
		case 5:
			return pv_get_uintval(msg, param, res,
					(unsigned int)(stored_ts.tm_year+1900));
		case 6:
			return pv_get_uintval(msg, param, res,
					(unsigned int)(stored_ts.tm_wday+1));
		case 7:
			return pv_get_uintval(msg, param, res,
					(unsigned int)(stored_ts.tm_yday+1));
		case 8:
			return pv_get_sintval(msg, param, res, stored_ts.tm_isdst);
		default:
			return pv_get_uintval(msg, param, res, (unsigned int)stored_ts.tm_sec);
	}
}
Exemplo n.º 13
0
int pv_get_cfg(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
{
	char *n;

	if(param==NULL)
		return -1;

	switch(param->pvn.u.isname.name.n)
	{
		case 1:
			n = get_cfg_crt_name();
			if(n==0)
				return pv_get_null(msg, param, res);
			return pv_get_strzval(msg, param, res, n);
		default:
			return pv_get_sintval(msg, param, res, get_cfg_crt_line());
	}
}
Exemplo n.º 14
0
int pv_get_iterator_val(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
{
	ht_cell_t *it=NULL;
	if (res == NULL)
	{
		return -1;
	}

	it = ht_iterator_get_current(&param->pvn.u.isname.name.s);
	if(it==NULL) {
		return pv_get_null(msg, param, res);
	}
	if(it->flags&AVP_VAL_STR)
		return pv_get_strval(msg, param, res, &it->value.s);

	/* integer */
	return pv_get_sintval(msg, param, res, it->value.n);
}
Exemplo n.º 15
0
/**
 * return broken-down time attributes
 */
int pv_get_time(struct sip_msg *msg, pv_param_t *param,
		pv_value_t *res)
{
	if(msg==NULL || param==NULL)
		return -1;

	if(msg_ctx_id_match(msg, &_cfgutils_msgid)!=1)
	{
		msg_set_time(msg);
		msg_ctx_id_set(msg, &_cfgutils_msgid);
		if(localtime_r(&msg->tval.tv_sec, &_cfgutils_ts) == NULL)
		{
			LM_ERR("unable to break time to attributes\n");
			return -1;
		}
	}
	
	switch(param->pvn.u.isname.name.n)
	{
		case 1:
			return pv_get_uintval(msg, param, res, (unsigned int)_cfgutils_ts.tm_min);
		case 2:
			return pv_get_uintval(msg, param, res, (unsigned int)_cfgutils_ts.tm_hour);
		case 3:
			return pv_get_uintval(msg, param, res, (unsigned int)_cfgutils_ts.tm_mday);
		case 4:
			return pv_get_uintval(msg, param, res, 
					(unsigned int)(_cfgutils_ts.tm_mon+1));
		case 5:
			return pv_get_uintval(msg, param, res,
					(unsigned int)(_cfgutils_ts.tm_year+1900));
		case 6:
			return pv_get_uintval(msg, param, res, 
					(unsigned int)(_cfgutils_ts.tm_wday+1));
		case 7:
			return pv_get_uintval(msg, param, res, 
					(unsigned int)(_cfgutils_ts.tm_yday+1));
		case 8:
			return pv_get_sintval(msg, param, res, _cfgutils_ts.tm_isdst);
		default:
			return pv_get_uintval(msg, param, res, (unsigned int)_cfgutils_ts.tm_sec);
	}
}
Exemplo n.º 16
0
int pv_xavp_get_value(struct sip_msg *msg, pv_param_t *param,
		pv_value_t *res, sr_xavp_t *avp)
{
	static char _pv_xavp_buf[128];
	str s;

	switch(avp->val.type) {
		case SR_XTYPE_NULL:
			return pv_get_null(msg, param, res);
		break;
		case SR_XTYPE_INT:
			return pv_get_sintval(msg, param, res, avp->val.v.i);
		break;
		case SR_XTYPE_STR:
			return pv_get_strval(msg, param, res, &avp->val.v.s);
		break;
		case SR_XTYPE_TIME:
			if(snprintf(_pv_xavp_buf, 128, "%lu", (long unsigned)avp->val.v.t)<0)
				return pv_get_null(msg, param, res);
		break;
		case SR_XTYPE_LONG:
			if(snprintf(_pv_xavp_buf, 128, "%ld", (long unsigned)avp->val.v.l)<0)
				return pv_get_null(msg, param, res);
		break;
		case SR_XTYPE_LLONG:
			if(snprintf(_pv_xavp_buf, 128, "%lld", avp->val.v.ll)<0)
				return pv_get_null(msg, param, res);
		break;
		case SR_XTYPE_XAVP:
			if(snprintf(_pv_xavp_buf, 128, "<<xavp:%p>>", avp->val.v.xavp)<0)
				return pv_get_null(msg, param, res);
		break;
		case SR_XTYPE_DATA:
			if(snprintf(_pv_xavp_buf, 128, "<<data:%p>>", avp->val.v.data)<0)
				return pv_get_null(msg, param, res);
		break;
		default:
			return pv_get_null(msg, param, res);
	}
	s.s = _pv_xavp_buf;
	s.len = strlen(_pv_xavp_buf);
	return pv_get_strval(msg, param, res, &s);
}
Exemplo n.º 17
0
int pv_get_ht_add(struct sip_msg *msg,  pv_param_t *param,
		pv_value_t *res, int val)
{
	str htname;
	ht_cell_t *htc=NULL;
	ht_pv_t *hpv;

	hpv = (ht_pv_t*)param->pvn.u.dname;

	if(hpv->ht==NULL)
	{
		hpv->ht = ht_get_table(&hpv->htname);
		if(hpv->ht==NULL)
			return pv_get_null(msg, param, res);
	}
	if(pv_printf_s(msg, hpv->pve, &htname)!=0)
	{
		LM_ERR("cannot get $ht name\n");
		return -1;
	}
	htc = ht_cell_value_add(hpv->ht, &htname, val, 1, _htc_local);
	if(htc==NULL)
	{
		return pv_get_null(msg, param, res);
	}
	if(_htc_local!=htc)
	{
		ht_cell_pkg_free(_htc_local);
		_htc_local=htc;
	}

	if(htc->flags&AVP_VAL_STR)
		return pv_get_null(msg, param, res);

	/* integer */
	if (hpv->ht->dmqreplicate>0) {
		if (ht_dmq_replicate_action(HT_DMQ_SET_CELL, &hpv->htname, &htname, 0, &htc->value, 1)!=0) {
			LM_ERR("dmq relication failed\n");
		}
	}	
	return pv_get_sintval(msg, param, res, htc->value.n);
}
Exemplo n.º 18
0
static int sipt_get_called_party_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
{
	str body;
	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);

	if(body.s == NULL)
	{
		LM_INFO("No ISUP Message Found");
		return -1;
	}

	if(body.s[0] != ISUP_IAM)
	{
		LM_DBG("message not an IAM\n");
		return -1;
	}
	
	pv_get_sintval(msg, param, res, isup_get_called_party_nai((unsigned char*)body.s, body.len));
	return 0;
}
Exemplo n.º 19
0
static int sipt_get_redirection_number_nai(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
{
	str body;
	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);

	if(body.s == NULL)
	{
		LM_INFO("No ISUP Message Found");
		return -1;
	}

	if((body.s[0] != ISUP_ACM) && (body.s[0] != ISUP_CPG))
	{
		LM_DBG("message not an ACM or CPG\n");
		return -1;
	}
	
	pv_get_sintval(msg, param, res, isup_get_redirection_number_nai((unsigned char*)body.s, body.len));
	return 0;
}
Exemplo n.º 20
0
static int sipt_get_charge_indicator(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
{
	str body;
	body.s = get_body_part(msg, TYPE_APPLICATION,SUBTYPE_ISUP,&body.len);

	if(body.s == NULL)
	{
		LM_INFO("No ISUP Message Found");
		return -1;
	}

	if(body.s[0] != ISUP_COT && body.s[0] != ISUP_ACM)
	{
		LM_DBG("message not a COT or ACM\n");
		return -1;
	}
	LM_DBG("about to get charge indicator\n");
	
	pv_get_sintval(msg, param, res, isup_get_charging_indicator((unsigned char*)body.s, body.len));
	return 0;
}
Exemplo n.º 21
0
int pv_get_ht_expired_cell(struct sip_msg *msg, pv_param_t *param,
		pv_value_t *res)
{
	if (res == NULL || ht_expired_cell == NULL) {
		return -1;
	}

	switch(param->pvn.u.isname.name.n)
	{
		case 0:
			return pv_get_strval(msg, param, res, &ht_expired_cell->name);
		case 1:
			if(ht_expired_cell->flags&AVP_VAL_STR) {
				return pv_get_strval(msg, param, res, &ht_expired_cell->value.s);
			} else {
				return pv_get_sintval(msg, param, res, ht_expired_cell->value.n);
			}
		default:
			return pv_get_null(msg, param, res);
	}
}
Exemplo n.º 22
0
int pv_get_mq_size(struct sip_msg *msg, pv_param_t *param,
		pv_value_t *res)
{
	int mqs = -1;
	str *in = pv_get_mq_name(msg, &param->pvn.u.isname.name.s);

	if (in == NULL)
	{
		LM_ERR("failed to get mq name\n");
		return -1;
	}

	mqs = _mq_get_csize(in);

	if (mqs < 0)
	{
		LM_ERR("mqueue not found: %.*s\n", in->len, in->s);
		return -1;
	}

	return pv_get_sintval(msg, param, res, mqs);
}
Exemplo n.º 23
0
int pv_get_sqlrows(struct sip_msg *msg,  pv_param_t *param,
		pv_value_t *res)
{
	sql_con_t *con;
	str* sc;

	sc = &param->pvn.u.isname.name.s;
	con = sql_get_connection(sc);
	if(con==NULL)
	{
		LM_ERR("invalid connection [%.*s]\n", sc->len, sc->s);
		return -1;
	}

	if (!DB_CAPABILITY(con->dbf, DB_CAP_AFFECTED_ROWS))
	{
		LM_ERR("con: %p database module does not have DB_CAP_AFFECTED_ROWS [%.*s]\n",
		       con, sc->len, sc->s);
		return -1;
	}

	return pv_get_sintval(msg, param, res, con->dbf.affected_rows(con->dbh));
}
Exemplo n.º 24
0
int pv_get_xcap_uri(struct sip_msg *msg,  pv_param_t *param,
		pv_value_t *res)
{
	pv_xcap_uri_spec_t *pxs = NULL;

	pxs = (pv_xcap_uri_spec_t*)param->pvn.u.dname;
	if(pxs->xus==NULL)
		return -1;

	switch(pxs->ktype) {
		case 0:
		case 1:
			/* get uri */
			if(pxs->xus->xuri.uri.len>0)
				return pv_get_strval(msg, param, res, &pxs->xus->xuri.uri);
		break;
		case 2:
			/* get root */
			if(pxs->xus->xuri.root.len>0)
				return pv_get_strval(msg, param, res, &pxs->xus->xuri.root);
		break;
		case 3:
			/* get auid */
			if(pxs->xus->xuri.auid.len>0)
				return pv_get_strval(msg, param, res, &pxs->xus->xuri.auid);
		break;
		case 4:
			/* get type */
			return pv_get_sintval(msg, param, res, pxs->xus->xuri.type);
		break;
		case 5:
			/* get tree */
			if(pxs->xus->xuri.tree.len>0)
				return pv_get_strval(msg, param, res, &pxs->xus->xuri.tree);
		break;
		case 6:
			/* get xuid */
			if(pxs->xus->xuri.xuid.len>0)
				return pv_get_strval(msg, param, res, &pxs->xus->xuri.xuid);
		break;
		case 7:
			/* get file */
			if(pxs->xus->xuri.file.len>0)
				return pv_get_strval(msg, param, res, &pxs->xus->xuri.file);
		break;
		case 8:
			/* get node */
			if(pxs->xus->xuri.node.len>0)
				return pv_get_strval(msg, param, res, &pxs->xus->xuri.node);
		break;
		case 9:
			/* get target */
			if(pxs->xus->xuri.target.len>0)
				return pv_get_strval(msg, param, res, &pxs->xus->xuri.target);
		break;
		case 10:
			/* get domain */
			if(pxs->xus->xuri.domain.len>0)
				return pv_get_strval(msg, param, res, &pxs->xus->xuri.domain);
		case 11:
			/* get xuri->adoc */
			if(pxs->xus->xuri.adoc.len>0)
				return pv_get_strval(msg, param, res, &pxs->xus->xuri.adoc);
		break;
		break;
		default:
			return pv_get_null(msg, param, res);
	}
	return pv_get_null(msg, param, res);
}
Exemplo n.º 25
0
int pv_get_msrp(sip_msg_t *msg,  pv_param_t *param, pv_value_t *res)
{
	msrp_frame_t *mf;
	msrp_hdr_t *hdr;
	str_array_t *sar;
	msrp_uri_t uri;
	str s;
	char *p;

	mf = msrp_get_current_frame();
	if(mf==NULL || param==NULL)
		return -1;

	sar = NULL;
	hdr = NULL;

	switch(param->pvn.u.isname.name.n)
	{
		case 1:
			s.s   = mf->buf.s;
			s.len = mf->buf.len;
			return pv_get_strval(msg, param, res, &s);
		case 2:
			if(mf->mbody.s==NULL)
				return pv_get_null(msg, param, res);
			s.s   = mf->mbody.s;
			s.len = mf->mbody.len;
			return pv_get_strval(msg, param, res, &s);
		case 3:
			if(mf->fline.msgtypeid==MSRP_REQUEST)
				return pv_get_null(msg, param, res);
			return pv_get_intstrval(msg, param, res,
					MSRP_RPL_CODE(mf->fline.rtypeid),
					&mf->fline.rtype);
		case 4:
			if(mf->hbody.s==NULL)
				return pv_get_null(msg, param, res);
			s.s   = mf->hbody.s;
			s.len = mf->hbody.len;
			return pv_get_strval(msg, param, res, &s);
		case 5:
			hdr = msrp_get_hdr_by_id(mf, MSRP_HDR_MESSAGE_ID);
			if(hdr==NULL)
				return pv_get_null(msg, param, res);
			s.s   = hdr->body.s;
			s.len = hdr->body.len;
			trim(&s);
			return pv_get_strval(msg, param, res, &s);
		case 6:
			if(mf->fline.msgtypeid==MSRP_REPLY)
				return pv_get_null(msg, param, res);
			return pv_get_strintval(msg, param, res, &mf->fline.rtype,
					mf->fline.rtypeid);
		case 7:
			return pv_get_uintval(msg, param, res, mf->buf.len);
		case 8:
			if(msrp_parse_hdr_to_path(mf)<0)
				return pv_get_null(msg, param, res);
			hdr = msrp_get_hdr_by_id(mf, MSRP_HDR_TO_PATH);
			if(hdr==NULL)
				return pv_get_null(msg, param, res);
			sar = (str_array_t*)hdr->parsed.data;
			s = sar->list[0];
			trim(&s);
			if(msrp_parse_uri(s.s, s.len, &uri)<0 || uri.session.len<=0)
				return pv_get_null(msg, param, res);
			s = uri.session;
			trim(&s);
			return pv_get_strval(msg, param, res, &s);
		case 9:
			if(mf->fline.msgtypeid==MSRP_REQUEST || mf->fline.rtext.s==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_strval(msg, param, res, &mf->fline.rtext);
		case 10:
			return pv_get_uintval(msg, param, res, mf->mbody.len);
		case 11:
			s = mf->fline.transaction;
			trim(&s);
			return pv_get_strval(msg, param, res, &s);
		case 12:
			if(msrp_parse_hdr_to_path(mf)<0)
				return pv_get_null(msg, param, res);
			hdr = msrp_get_hdr_by_id(mf, MSRP_HDR_TO_PATH);
			if(hdr==NULL)
				return pv_get_null(msg, param, res);
			sar = (str_array_t*)hdr->parsed.data;
			s = sar->list[0];
			trim(&s);
			return pv_get_strval(msg, param, res, &s);
		case 13:
			if(msrp_parse_hdr_from_path(mf)<0)
				return pv_get_null(msg, param, res);
			hdr = msrp_get_hdr_by_id(mf, MSRP_HDR_FROM_PATH);
			if(hdr==NULL)
				return pv_get_null(msg, param, res);
			sar = (str_array_t*)hdr->parsed.data;
			s = sar->list[0];
			trim(&s);
			return pv_get_strval(msg, param, res, &s);
		case 14:
			if(msrp_parse_hdr_to_path(mf)<0)
				return pv_get_null(msg, param, res);
			hdr = msrp_get_hdr_by_id(mf, MSRP_HDR_TO_PATH);
			if(hdr==NULL)
				return pv_get_null(msg, param, res);
			sar = (str_array_t*)hdr->parsed.data;
			if(sar->size<2)
				return pv_get_null(msg, param, res);
			s = sar->list[1];
			trim(&s);
			return pv_get_strval(msg, param, res, &s);
		case 15:
			if(msrp_parse_hdr_to_path(mf)<0)
				return pv_get_null(msg, param, res);
			hdr = msrp_get_hdr_by_id(mf, MSRP_HDR_TO_PATH);
			if(hdr==NULL)
				return pv_get_null(msg, param, res);
			sar = (str_array_t*)hdr->parsed.data;
			s = sar->list[sar->size-1];
			trim(&s);
			return pv_get_strval(msg, param, res, &s);
		case 16:
			if(msrp_parse_hdr_from_path(mf)<0)
				return pv_get_null(msg, param, res);
			hdr = msrp_get_hdr_by_id(mf, MSRP_HDR_FROM_PATH);
			if(hdr==NULL)
				return pv_get_null(msg, param, res);
			sar = (str_array_t*)hdr->parsed.data;
			s = sar->list[sar->size-1];
			trim(&s);
			return pv_get_strval(msg, param, res, &s);
		case 17:
			if(msrp_parse_hdr_from_path(mf)<0)
				return pv_get_null(msg, param, res);
			hdr = msrp_get_hdr_by_id(mf, MSRP_HDR_FROM_PATH);
			if(hdr==NULL)
				return pv_get_null(msg, param, res);
			sar = (str_array_t*)hdr->parsed.data;
			return pv_get_uintval(msg, param, res, sar->size);
		case 18:
			if(msrp_parse_hdr_to_path(mf)<0)
				return pv_get_null(msg, param, res);
			hdr = msrp_get_hdr_by_id(mf, MSRP_HDR_TO_PATH);
			if(hdr==NULL)
				return pv_get_null(msg, param, res);
			sar = (str_array_t*)hdr->parsed.data;
			return pv_get_uintval(msg, param, res, sar->size-1);
		case 19:
			if(pv_get_buffer_size()<100)
				return pv_get_null(msg, param, res);
			s.s = pv_get_buffer();
			p = s.s;
			if(mf->tcpinfo->rcv->proto==PROTO_TLS)
			{
				memcpy(p, "msrps://", 8);
				p+=8;
			} else {
				memcpy(p, "msrp://", 7);
				p+=7;
			}
			strcpy(p, ip_addr2a(&mf->tcpinfo->rcv->src_ip));
			strcat(p, ":");
			strcat(p, int2str(mf->tcpinfo->rcv->src_port, NULL));
			s.len = strlen(s.s);
			return pv_get_strval(msg, param, res, &s);
		case 20:
			return pv_get_strval(msg, param, res,
					&mf->tcpinfo->rcv->bind_address->sock_str);
		case 21:
			if(mf->tcpinfo->con==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_sintval(msg, param, res, mf->tcpinfo->con->id);
		default:
			return pv_get_null(msg, param, res);
	}

	return 0;
}
Exemplo n.º 26
0
int pv_get_geoip(struct sip_msg *msg, pv_param_t *param,
		pv_value_t *res)
{
	geoip_pv_t *gpv;

	if(msg==NULL || param==NULL)
		return -1;

	gpv = (geoip_pv_t*)param->pvn.u.dname;
	if(gpv==NULL)
		return -1;
	if(gpv->item==NULL)
		return pv_get_null(msg, param, res);

	switch(gpv->type)
	{
		case 1: /* tz */
			if(gpv->item->r.time_zone==NULL)
			{
				if(gpv->item->r.flags&1)
					return pv_get_null(msg, param, res);
				if(gpv->item->r.record==NULL)
					return pv_get_null(msg, param, res);
				gpv->item->r.time_zone
					= (char*)GeoIP_time_zone_by_country_and_region(
						gpv->item->r.record->country_code,
						gpv->item->r.record->region);
				gpv->item->r.flags |= 1;
			}
			return pv_geoip_get_strzval(msg, param, res,
					gpv->item->r.time_zone);
		case 2: /* zip */
			if(gpv->item->r.record==NULL)
				return pv_get_null(msg, param, res);
			return pv_geoip_get_strzval(msg, param, res,
					gpv->item->r.record->postal_code);
		case 3: /* lat */
			if((gpv->item->r.flags&2)==0)
			{
				if(gpv->item->r.record==NULL)
					return pv_get_null(msg, param, res);
				snprintf(gpv->item->r.latitude, 15, "%f",
						gpv->item->r.record->latitude);
				gpv->item->r.flags |= 2;
			}
			return pv_geoip_get_strzval(msg, param, res,
					gpv->item->r.latitude);
		case 4: /* lon */
			if((gpv->item->r.flags&4)==0)
			{
				if(gpv->item->r.record==NULL)
					return pv_get_null(msg, param, res);
				snprintf(gpv->item->r.longitude, 15, "%f",
						gpv->item->r.record->longitude);
				gpv->item->r.flags |= 4;
			}
			return pv_geoip_get_strzval(msg, param, res,
					gpv->item->r.longitude);
		case 5: /* dma */
			if(gpv->item->r.record==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_sintval(msg, param, res,
					gpv->item->r.record->dma_code);
		case 6: /* ips */
		case 7: /* ipe */
			if((gpv->item->r.flags&8)==0)
			{
				gpv->item->r.range = GeoIP_range_by_ip(_handle_GeoIP,
					gpv->item->r.tomatch);
				gpv->item->r.flags |= 8;
			}
			if(gpv->item->r.range==NULL)
				return pv_get_null(msg, param, res);
			if(gpv->type==6)
				return pv_geoip_get_strzval(msg, param, res,
						gpv->item->r.range[0]);
			return pv_geoip_get_strzval(msg, param, res,
					gpv->item->r.range[1]);
		case 8: /* city */
			return pv_geoip_get_strzval(msg, param, res,
					gpv->item->r.record->city);
		case 9: /* area */
			if(gpv->item->r.record==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_sintval(msg, param, res,
					gpv->item->r.record->area_code);
		case 10: /* regc */
			if(gpv->item->r.record==NULL)
				return pv_get_null(msg, param, res);
			return pv_geoip_get_strzval(msg, param, res,
					gpv->item->r.record->region);
		case 11: /* regn */
			if((gpv->item->r.flags&16)==0)
			{
				if(gpv->item->r.record==NULL)
					return pv_get_null(msg, param, res);
				gpv->item->r.region_name
						= (char*)GeoIP_region_name_by_code(
							gpv->item->r.record->country_code,
							gpv->item->r.record->region);
				gpv->item->r.flags |= 16;
			}
			return pv_geoip_get_strzval(msg, param, res,
					gpv->item->r.region_name);
		case 12: /* metro */
			if(gpv->item->r.record==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_sintval(msg, param, res,
					gpv->item->r.record->metro_code);
		case 13: /* contc */
			if(gpv->item->r.record==NULL)
				return pv_get_null(msg, param, res);
			return pv_geoip_get_strzval(msg, param, res,
					gpv->item->r.record->continent_code);
		default: /* cc */
			if(gpv->item->r.record==NULL)
				return pv_get_null(msg, param, res);
			return pv_geoip_get_strzval(msg, param, res,
					gpv->item->r.record->country_code);
	}
}
Exemplo n.º 27
0
/**
 * Runs a JSON-RPC command (request or notification)
 * Params:
 *  dst: destination of the command
 *  cmd: comand to send
 *  id: if present, unique ID of the command, otherwise this is a notification
 *  ret: value returned in case of a request
 *
 * Returns:
 *  -2: communication error
 *  -3: reply error
 *   1: success
 */
static int jsonrpc_handle_cmd(union sockaddr_union *dst, char *cmd, int *id,
		pv_value_t *vret)
{
	int r, fd, ret = -2;
	unsigned int cmd_len;
	struct timeval begin;
	struct pollfd pf;
	int tout_left, total;
	cJSON *obj = NULL, *aux;

	char buffer[JSONRPC_DEFAULT_BUFFER_SIZE + 1/* null terminate */];

	/* connect to the destination */
	fd = jsonrpc_get_fd(dst);
	if (fd < 0) {
		LM_ERR("cannot get a connection to %s:%hu\n", JSONRPC_PRINT(dst));
		return -2;
	}

	/* we have a connection - send the command now */
	cmd_len = strlen(cmd);

	if (tsend_stream(fd, cmd, cmd_len, jrpc_write_timeout) < 0) {
		LM_ERR("cannot send stream to %s:%hu\n", JSONRPC_PRINT(dst));
		goto end;
	}
	
	/* notification - no need to wait for a reply */
	if (!id) {
		ret = 1;
		goto end;
	}

	/* read the reply */
	pf.fd = fd;
	pf.events = POLLIN;

	total = 0;
	gettimeofday(&begin, NULL);
	while (1) {
		/* compute how long we are allowed to block */
		tout_left = jrpc_read_timeout - (get_time_diff(&begin) / 1000);
		if (tout_left <= 0) {
			LM_ERR("read timeout reached (%s:%hu)\n", JSONRPC_PRINT(dst));
			goto end;
		}
		r = poll(&pf, 1, tout_left);
		if (r < 0) {
			if (errno == EINTR)
				continue;
			LM_ERR("poll failed: %s [%d\n", strerror(errno), errno);
			goto end;
		}
		if (pf.revents & POLLIN) {
			/* now we can read */
			r = read(fd, buffer + total, JSONRPC_DEFAULT_BUFFER_SIZE - total);
			if (r < 0) {
				if (errno == EINTR)
					continue;
				LM_ERR("cannot read reply from JSON-RPC server %s:%hu\n",
						JSONRPC_PRINT(dst));
				goto end;
			}
			total += r;
			buffer[total] = '\0';
			/* everything read - try to parse it now */
			obj = cJSON_Parse(buffer);
			if (!obj) {
				LM_DBG("could not parse json [%s] - perhapse we did not "
						"receive all of it, retrying!\n", buffer);
				continue;
			}
			/* yey, we have an object */
			break;
		} else if (pf.revents & POLLERR) {
			/* someting happened with the connection */
			LM_ERR("connection error to %s:%hu - %s:%d\n",
					JSONRPC_PRINT(dst), strerror(errno), errno);
			goto end;
		}
	}

	aux = cJSON_GetObjectItem(obj, "error");
	if (aux) {
		/* return the entire error */
		vret->rs.s = cJSON_Print(aux);
		vret->rs.len = strlen(vret->rs.s);
		vret->flags = PV_VAL_STR;
		LM_DBG("Error got from JSON-RPC: %s!\n", buffer);
		ret = -3;
		goto end;
	}

	aux = cJSON_GetObjectItem(obj, "result");
	if (!aux) {
		LM_WARN("Invalid reply from JSON-RPC: %s!\n", buffer);
		pv_get_null(NULL, NULL, vret);
		ret = -3;
		goto end;
	}

	if (aux->type == cJSON_Number)
		pv_get_sintval(NULL, NULL, vret, aux->valueint);
	else {
		vret->rs.s = cJSON_Print(aux);
		vret->rs.len = strlen(vret->rs.s);
		vret->flags = PV_VAL_STR;
	}

	ret = 1;
end:
	shutdown(fd, SHUT_RDWR);
	close(fd);
	return ret;
}
Exemplo n.º 28
0
int pv_get_branchx_helper(sip_msg_t *msg, pv_param_t *param,
		pv_value_t *res, int btype)
{
	int idx = 0;
	int idxf = 0;
	branch_t *br;

	if(btype==1) {
		br = &_pv_sbranch;
	} else {
		/* get the index */
		if(pv_get_spec_index(msg, param, &idx, &idxf)!=0)
		{
			LM_ERR("invalid index\n");
			return pv_get_null(msg, param, res);
		}
		br = get_sip_branch(idx);
		if(br==NULL) {
			return pv_get_null(msg, param, res);
		}
	}

	/* branch(count) doesn't need a valid branch, everything else does */
	if(br->len == 0 && ( param->pvn.u.isname.name.n != 5/* count*/ ))
	{
		LM_ERR("error accessing branch [%d]\n", idx);
		return pv_get_null(msg, param, res);
	}

	switch(param->pvn.u.isname.name.n)
	{
		case 1: /* dst uri */
			if(br->dst_uri_len==0)
				return pv_get_null(msg, param, res);
			return pv_get_strlval(msg, param, res, br->dst_uri, br->dst_uri_len);
		case 2: /* path */
			if(br->path_len==0)
				return pv_get_null(msg, param, res);
			return pv_get_strlval(msg, param, res, br->path, br->path_len);
		case 3: /* Q */
			if(br->q == Q_UNSPECIFIED)
				return pv_get_null(msg, param, res);
			return pv_get_sintval(msg, param, res, br->q);
		case 4: /* send socket */
			if(br->force_send_socket!=0)
				return pv_get_strval(msg, param, res, &br->force_send_socket->sock_str);
			return pv_get_null(msg, param, res);
		case 5: /* count */
			return pv_get_uintval(msg, param, res, nr_branches);
		case 6: /* flags */
			return pv_get_uintval(msg, param, res, br->flags);
		case 7: /* ruid */
			if(br->ruid_len==0)
				return pv_get_null(msg, param, res);
			return pv_get_strlval(msg, param, res, br->ruid, br->ruid_len);
		case 8: /* location_ua */
			if(br->location_ua_len==0)
				return pv_get_null(msg, param, res);
			return pv_get_strlval(msg, param, res, br->location_ua, br->location_ua_len);
		default:
			/* 0 - uri */
			return pv_get_strlval(msg, param, res, br->uri, br->len);
	}

	return 0;
}
Exemplo n.º 29
0
int pv_get_ulc(struct sip_msg *msg,  pv_param_t *param,
		pv_value_t *res)
{
	regpv_name_t *rp;
	regpv_profile_t *rpp;
	ucontact_t *c;
	int idx;
	int i;

	if(param==NULL)
	{
		LM_ERR("invalid params\n");
		return -1;
	}
	rp = (regpv_name_t*)param->pvn.u.dname;
	if(rp==NULL || rp->rp==NULL)
	{
		LM_DBG("no profile in params\n");
		return pv_get_null(msg, param, res);
	}
	rpp = rp->rp;

	if(rpp->flags==0 || rpp->contacts==NULL)
	{
		LM_DBG("profile not set or no contacts there\n");
		return pv_get_null(msg, param, res);
	}
	/* get index */
	if(pv_get_spec_index(msg, param, &idx, &i)!=0)
	{
		LM_ERR("invalid index\n");
		return -1;
	}

	/* work only with positive indexes by now */
	if(idx<0)
		idx = 0;

	/* get contact */
	i = 0;
	c = rpp->contacts;
	while(rpp)
	{
		if(i == idx)
			break;
		i++;
		c = c->next;
	}
	if(c==NULL)
		return pv_get_null(msg, param, res);

	switch(rp->attr)
	{
		case 0: /* aor */
			return  pv_get_strval(msg, param, res, &rpp->aor);
		break;
		case 1: /* domain */
			return  pv_get_strval(msg, param, res, &rpp->domain);
		break;
		case 2: /* aorhash */
			return pv_get_uintval(msg, param, res, rpp->aorhash);
		break;
		case 3: /* addr */
			return  pv_get_strval(msg, param, res, &c->c);
		break;
		case 4: /* path */
			return  pv_get_strval(msg, param, res, &c->path);
		break;
		case 5: /* received */
			return  pv_get_strval(msg, param, res, &c->received);
		break;
		case 6: /* expires */
			return pv_get_uintval(msg, param, res,
					(unsigned int)c->expires);
		break;
		case 7: /* callid */
			return  pv_get_strval(msg, param, res, &c->callid);
		break;
		case 8: /* q */
			return pv_get_sintval(msg, param, res, (int)c->q);
		break;
		case 9: /* cseq */
			return pv_get_sintval(msg, param, res, c->cseq);
		break;
		case 10: /* flags */
			return pv_get_uintval(msg, param, res, c->flags);
		break;
		case 11: /* cflags */
			return pv_get_uintval(msg, param, res, c->cflags);
		break;
		case 12: /* user agent */
			return  pv_get_strval(msg, param, res, &c->user_agent);
		break;
		case 14: /* socket */
			if(c->sock==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_strval(msg, param, res, &c->sock->sock_str);
		break;
		case 15: /* modified */
			return pv_get_uintval(msg, param, res,
					(unsigned int)c->last_modified);
		break;
		case 16: /* methods */
			return pv_get_uintval(msg, param, res, c->methods);
		break;
		case 17: /* count */
			return pv_get_sintval(msg, param, res, rpp->nrc);
		break;
	}

	return pv_get_null(msg, param, res);
}
Exemplo n.º 30
0
static int pv_get_redisc(struct sip_msg *msg,  pv_param_t *param,
		pv_value_t *res)
{
	redisc_pv_t *rpv;
	str s;
	int pos;

	rpv = (redisc_pv_t*)param->pvn.u.dname;
	if(rpv->reply==NULL)
	{
		rpv->reply = redisc_get_reply(&rpv->rname);
		if(rpv->reply==NULL)
			return pv_get_null(msg, param, res);
	}

	if(rpv->reply->rplRedis==NULL)
		return pv_get_null(msg, param, res);


	if(fixup_get_ivalue(msg, &rpv->pos, &pos)!=0)
		return pv_get_null(msg, param, res);

	switch(rpv->rkeyid) {
		case 1:
			/* value */
			switch(rpv->reply->rplRedis->type) {
				case REDIS_REPLY_STRING:
					if(pos!=-1)
						return pv_get_null(msg, param, res);
					s.len = rpv->reply->rplRedis->len;
					s.s = rpv->reply->rplRedis->str;
					return pv_get_strval(msg, param, res, &s);
				case REDIS_REPLY_INTEGER:
					if(pos!=-1)
						return pv_get_null(msg, param, res);
					return pv_get_sintval(msg, param, res,
									(int)rpv->reply->rplRedis->integer);
				case REDIS_REPLY_ARRAY:
					if(pos<0 || pos>=(int)rpv->reply->rplRedis->elements)
						return pv_get_null(msg, param, res);
					if(rpv->reply->rplRedis->element[pos]==NULL)
						return pv_get_null(msg, param, res);
					switch(rpv->reply->rplRedis->element[pos]->type) {
						case REDIS_REPLY_STRING:
						s.len = rpv->reply->rplRedis->element[pos]->len;
							s.s = rpv->reply->rplRedis->element[pos]->str;
							return pv_get_strval(msg, param, res, &s);
						case REDIS_REPLY_INTEGER:
							return pv_get_sintval(msg, param, res,
										(int)rpv->reply->rplRedis->element[pos]->integer);
						default:
							return pv_get_null(msg, param, res);
					}
				default:
					return pv_get_null(msg, param, res);
			}
		case 2:
			/* info */
			if(rpv->reply->rplRedis->str==NULL)
				return pv_get_null(msg, param, res);
			s.len = rpv->reply->rplRedis->len;
			s.s = rpv->reply->rplRedis->str;
			return pv_get_strval(msg, param, res, &s);
		case 3:
			/* size */
			if(rpv->reply->rplRedis->type == REDIS_REPLY_ARRAY) {
				return pv_get_uintval(msg, param, res,
						(unsigned int)rpv->reply->rplRedis->elements);
			} else {
				return pv_get_null(msg, param, res);
			}
		case 0:
			/* type */
			if(pos==-1)
				return pv_get_sintval(msg, param, res,
								rpv->reply->rplRedis->type);
			if(rpv->reply->rplRedis->type != REDIS_REPLY_ARRAY)
				return pv_get_null(msg, param, res);
			if(pos<0 || pos>=(int)rpv->reply->rplRedis->elements)
				return pv_get_null(msg, param, res);
			if(rpv->reply->rplRedis->element[pos]==NULL)
				return pv_get_null(msg, param, res);
			return pv_get_sintval(msg, param, res,
					rpv->reply->rplRedis->element[pos]->type);
		default:
			/* We do nothing. */
			return pv_get_null(msg, param, res);
	}
}