예제 #1
0
static int w_ds_is_from_list1(struct sip_msg *msg, char *set, char *str2)
{
	int s;
	if(fixup_get_ivalue(msg, (gparam_p)set, &s)!=0)
	{
		LM_ERR("cannot get set id value\n");
		return -1;
	}
	return ds_is_from_list(msg, s);
}
예제 #2
0
static int w_ds_select_domain(struct sip_msg* msg, char* set, char* alg)
{
	int a, s;
	if(msg==NULL)
		return -1;

	if(fixup_get_ivalue(msg, (gparam_p)set, &s)!=0)
	{
		LM_ERR("no dst set value\n");
		return -1;
	}
	if(fixup_get_ivalue(msg, (gparam_p)alg, &a)!=0)
	{
		LM_ERR("no alg value\n");
		return -1;
	}

	return ds_select_dst(msg, s, a, 1/*set host port*/, 1000);
}
예제 #3
0
static int w_msrp_relay_flags(sip_msg_t* msg, char *tflags, char* str2)
{
	int rtflags = 0;

	if(fixup_get_ivalue(msg, (gparam_t *)tflags, &rtflags) != 0) {
		LM_ERR("invalid send flags parameter\n");
		return -1;
	}

	return ki_msrp_relay_flags(msg, rtflags);
}
예제 #4
0
파일: cfgutils.c 프로젝트: lazedo/kamailio
static int m_usleep(struct sip_msg *msg, char *time, char *str2)
{
	int s;
	if(fixup_get_ivalue(msg, (gparam_t*)time, &s)!=0)
	{
		LM_ERR("cannot get time interval value\n");
		return -1;
	}
	sleep_us((unsigned int)s);
	return 1;
}
예제 #5
0
파일: kex_mod.c 프로젝트: 4N7HR4X/kamailio
int w_setdebug(struct sip_msg *msg, char *level, str *s2)
{
	int lval=0;
	if(fixup_get_ivalue(msg, (gparam_p)level, &lval)!=0)
	{
		LM_ERR("no debug level value\n");
		return -1;
	}
	set_local_debug_level(lval);
	return 1;
}
예제 #6
0
/* Check if a given set exist in memory */
static int w_ds_list_exist(struct sip_msg *msg, char *param)
{
	int set;

	if(fixup_get_ivalue(msg, (gparam_p)param, &set) != 0) {
		LM_ERR("cannot get set id param value\n");
		return -1;
	}
	LM_DBG("--- Looking for dispatcher set %d\n", set);
	return ds_list_exist(set);
}
예제 #7
0
/*
 * w_allow_source_address("group") equals to allow_address("group", "$si", "$sp")
 * but is faster.
 */
int w_allow_source_address(struct sip_msg* _msg, char* _addr_group, char* _str2)
{
	int addr_group = 1;

	if(_addr_group!=NULL
			&& fixup_get_ivalue(_msg, (gparam_p)_addr_group, &addr_group) !=0 ) {
		LM_ERR("cannot get group value\n");
		return -1;
	}
	return allow_source_address(_msg, addr_group);
}
예제 #8
0
/**
 * limit checking with creation of pipe if it doesn't exist
 */
static int w_pl_check3(struct sip_msg* msg, char *p1pipe, char *p2alg,
		char *p3limit)
{
	int limit;
	str pipeid = {0, 0};
	str alg = {0, 0};
	pl_pipe_t *pipe = NULL;

	if(msg==NULL)
		return -1;

	if(fixup_get_ivalue(msg, (gparam_t*)p3limit, &limit)!=0 || limit<=0)
	{
		LM_ERR("invalid limit value\n");
		return -1;
	}

	if(fixup_get_svalue(msg, (gparam_t*)p1pipe, &pipeid)!=0
			|| pipeid.s == 0)
	{
		LM_ERR("invalid pipeid parameter");
		return -1;
	}

	if(fixup_get_svalue(msg, (gparam_t*)p2alg, &alg)!=0
			|| alg.s == 0)
	{
		LM_ERR("invalid algoritm parameter");
		return -1;
	}

	pipe = pl_pipe_get(&pipeid, 1);
	if(pipe==NULL)
	{
		LM_DBG("pipe not found [%.*s] - trying to add it\n",
				pipeid.len, pipeid.s);
		if(pl_pipe_add(&pipeid, &alg, limit)<0)
		{
			LM_ERR("failed to add pipe [%.*s]\n",
				pipeid.len, pipeid.s);
			return -2;
		}
		pipe = pl_pipe_get(&pipeid, 1);
		if(pipe==NULL)
		{
			LM_ERR("failed to retrieve pipe [%.*s]\n",
				pipeid.len, pipeid.s);
			return -2;
		}
	}

	return 1;
}
예제 #9
0
int w_setsflag(struct sip_msg *msg, char *flag, char *s2)
{
	int fval=0;
	if(fixup_get_ivalue(msg, (gparam_p)flag, &fval)!=0)
	{
		LM_ERR("no flag value\n");
		return -1;
	}
	if(fval<0 || fval>31)
		return -1;
	return setsflag((flag_t)fval);
}
예제 #10
0
/**
 * check if the subscriber identified by _uri has a valid record in
 * database table _table
 */
static int w_is_subscriber(sip_msg_t *msg, char *_uri, char* _table,
		char *_flags)
{
	str suri;
	str stable;
	int iflags;
	int ret;
	sip_uri_t puri;

	if(msg==NULL || _uri==NULL || _table==NULL || _flags==NULL) {
		LM_ERR("invalid parameters\n");
		return AUTH_ERROR;
	}

	if (get_str_fparam(&suri, msg, (fparam_t*)_uri) < 0) {
		LM_ERR("failed to get uri value\n");
		return -1;
	}

	if (suri.len==0) {
		LM_ERR("invalid uri parameter - empty value\n");
		return -1;
	}
	if(parse_uri(suri.s, suri.len, &puri)<0){
		LM_ERR("invalid uri parameter format\n");
		return -1;
	}

	if (get_str_fparam(&stable, msg, (fparam_t*)_table) < 0) {
		LM_ERR("failed to get table value\n");
		return -1;
	}

	if (stable.len==0) {
		LM_ERR("invalid table parameter - empty value\n");
		return -1;
	}

	if(fixup_get_ivalue(msg, (gparam_p)_flags, &iflags)!=0)
	{
		LM_ERR("invalid flags parameter\n");
		return -1;
	}

	LM_DBG("uri [%.*s] table [%.*s] flags [%d]\n", suri.len, suri.s,
			stable.len,  stable.s, iflags);
	ret = fetch_credentials(msg, &puri.user, (iflags==1)?&puri.host:NULL,
			&stable);

	if(ret>=0)
		return 1;
	return ret;
}
예제 #11
0
파일: cfgutils.c 프로젝트: 4N7HR4X/kamailio
static int m_usleep(struct sip_msg *msg, char *time, char *str2)
{
	int s;
	if(fixup_get_ivalue(msg, (gparam_t*)time, &s)!=0)
	{
		LM_ERR("cannot get time interval value\n");
		return -1;
	}
	LM_DBG("sleep %lu microseconds\n", (unsigned long)time);
	sleep_us((unsigned int)s);
	return 1;
}
예제 #12
0
파일: dialog.c 프로젝트: kingsumos/kamailio
static int w_dlg_set_timeout(struct sip_msg *msg, char *pto, char *phe, char *phi)
{
	int to = 0;
	unsigned int he = 0;
	unsigned int hi = 0;
	dlg_cell_t *dlg = NULL;

	if(fixup_get_ivalue(msg, (gparam_p)pto, &to)!=0)
	{
		LM_ERR("no timeout value\n");
		return -1;
	}
	if(phe!=NULL)
	{
		if(fixup_get_ivalue(msg, (gparam_p)phe, (int*)&he)!=0)
		{
			LM_ERR("no hash entry value value\n");
			return -1;
		}
		if(fixup_get_ivalue(msg, (gparam_p)phi, (int*)&hi)!=0)
		{
			LM_ERR("no hash id value value\n");
			return -1;
		}
		dlg = dlg_lookup(he, hi);
	} else {
		dlg = dlg_get_msg_dialog(msg);
	}

	if(dlg==NULL)
	{
		LM_DBG("no dialog found\n");
		return -1;
	}

	if(update_dlg_timeout(dlg, to) != 0) 
		return -1;

	return 1;
}
예제 #13
0
static int w_ds_is_from_list3(
		struct sip_msg *msg, char *set, char *mode, char *uri)
{
	int vset;
	int vmode;
	str suri;

	if(fixup_get_ivalue(msg, (gparam_t *)set, &vset) != 0) {
		LM_ERR("cannot get set id value\n");
		return -1;
	}
	if(fixup_get_ivalue(msg, (gparam_t *)mode, &vmode) != 0) {
		LM_ERR("cannot get mode value\n");
		return -1;
	}
	if(fixup_get_svalue(msg, (gparam_t *)uri, &suri) != 0) {
		LM_ERR("cannot get uri value\n");
		return -1;
	}

	return ds_is_addr_from_list(msg, vset, &suri, vmode);
}
예제 #14
0
static int w_registered4(struct sip_msg* _m, char* _d, char* _uri, char* _flags, char* _actionflags)
{
	str uri = {0};
	int flags = 0;
	int actionflags = 0;
	if(_uri!=NULL && (fixup_get_svalue(_m, (gparam_p)_uri, &uri)!=0 || uri.len<=0))
	{
		LM_ERR("invalid uri parameter\n");
		return -1;
	}
	if(_flags!=NULL && (fixup_get_ivalue(_m, (fparam_t*)_flags, &flags)) < 0)
	{
		LM_ERR("invalid flags parameter\n");
		return -1;
	}
	if(_actionflags!=NULL && (fixup_get_ivalue(_m, (fparam_t*)_actionflags, &actionflags)) < 0)
	{
		LM_ERR("invalid action flag parameter\n");
		return -1;
	}
	return registered4(_m, (udomain_t*)_d, (uri.len>0)?&uri:NULL, flags, actionflags);
}
예제 #15
0
/*
 * Checks if address/port is found in cached address or
 * subnet table in any group. If yes, returns that group. If not returns -1.
 * Port value 0 in cached address and group table matches any port.
 */
int allow_address_group(struct sip_msg* _msg, char* _addr, char* _port)
{
	int group = -1;

	unsigned int port;
	str ips;
	ip_addr_t *ipa;

	if (_addr==NULL
			|| (fixup_get_svalue(_msg, (gparam_p)_addr, &ips) < 0)) {
		LM_ERR("cannot get value of address pvar\n");
		return -1;
	}
	if (_port==NULL
			|| (fixup_get_ivalue(_msg, (gparam_p)_port, (int*)&port) < 0)) {
		LM_ERR("cannot get value of port pvar\n");
		return -1;
	}

	ipa=strtoipX(&ips);

	if ( ipa ) {
		LM_DBG("looking for <%.*s, %u> in address table\n",
				ips.len, ips.s, port);
		if(addr_hash_table) {
			group = find_group_in_addr_hash_table(*addr_hash_table,
					ipa, port);
			LM_DBG("Found address in group <%d>\n", group);

			if (group != -1) return group;
		}
		if(subnet_table) {
			LM_DBG("looking for <%.*s, %u> in subnet table\n",
					ips.len, ips.s, port);
			group = find_group_in_subnet_table(*subnet_table,
					ipa, port);
			LM_DBG("Found a match of subnet in group <%d>\n", group);
		}
	} else {
		LM_DBG("looking for <%.*s, %u> in domain_name table\n",
				ips.len, ips.s, port);
		if(domain_list_table) {
			group = find_group_in_domain_name_table(*domain_list_table,
					&ips, port);
			LM_DBG("Found a match of domain_name in group <%d>\n", group);
		}
	}

	LM_DBG("Found <%d>\n", group);
	return group;
}
예제 #16
0
파일: lb_data.c 프로젝트: Danfx/opensips
/* Checks, if the IP PORT is a LB destination
 */
int lb_is_dst(struct lb_data *data, struct sip_msg *_m,
				pv_spec_t *pv_ip, gparam_t *pv_port, int group, int active)
{
	pv_value_t val;
	struct ip_addr *ip;
	int port;
	struct lb_dst *dst;
	int k;

	/* get the address to test */
	if (pv_get_spec_value( _m, pv_ip, &val)!=0) {
		LM_ERR("failed to get IP value from PV\n");
		return -1;
	}
	if ( (val.flags&PV_VAL_STR)==0 ) {
		LM_ERR("IP PV val is not string\n");
		return -1;
	}
	if ( (ip=str2ip( &val.rs ))==NULL ) {
		LM_ERR("IP val is not IP <%.*s>\n",val.rs.len,val.rs.s);
		return -1;
	}

	/* get the port to test */
	if (pv_port) {
		if (fixup_get_ivalue(_m, (gparam_p)pv_port, &port) != 0) {
			LM_ERR("failed to get PORT value from PV\n");
			return -1;
		}
	} else {
		port = 0;
	}

	/* and now search !*/
	for( dst=data->dsts ; dst ; dst=dst->next) {
		if ( ((group==-1) || (dst->group==group)) &&  /*group matches*/
		( !active || (active && (dst->flags&LB_DST_STAT_DSBL_FLAG)==0 ) )
		) {
			/* check the IPs */
			for(k=0 ; k<dst->ips_cnt ; k++ ) {
				if ( (dst->ports[k]==0 || port==0 || port==dst->ports[k]) &&
				ip_addr_cmp( ip, &dst->ips[k]) ) {
					/* found */
					return 1;
				}
			}
		}
	}

	return -1;
}
예제 #17
0
/**
 * wrapper for sanity_check() to be used from config file
 */
static int w_sanity_check(sip_msg_t* _msg, char* _msg_check, char* _uri_check)
{
	int ret, msg_check, uri_check;

	if (_msg_check == NULL) {
		msg_check = default_msg_checks;
	} else {
		if(fixup_get_ivalue(_msg, (gparam_t*)_msg_check, &msg_check)<0) {
			LM_ERR("failed to get msg check flags parameter\n");
			return -1;
		}
	}
	if (_uri_check == NULL) {
		uri_check = default_uri_checks;
	} else {
		if(fixup_get_ivalue(_msg, (gparam_t*)_uri_check, &uri_check)<0) {
			LM_ERR("failed to get uri check flags parameter\n");
			return -1;
		}
	}

	if ((msg_check < 1) || (msg_check >= (SANITY_MAX_CHECKS))) {
		LM_ERR("input parameter (%i) outside of valid range <1-%i)\n",
				msg_check, SANITY_MAX_CHECKS);
		return -1;
	}
	if ((uri_check < 1) || (uri_check >= (SANITY_URI_MAX_CHECKS))) {
		LM_ERR("second input parameter (%i) outside of valid range <1-%i\n",
				uri_check, SANITY_URI_MAX_CHECKS);
		return -1;
	}

	ret = sanity_check(_msg, msg_check, uri_check);
	LM_DBG("sanity checks result: %d\n", ret);
	if(_sanity_drop!=0)
		return ret;
	return (ret==SANITY_CHECK_FAILED)?-1:ret;
}
예제 #18
0
int w_isbflagset(struct sip_msg *msg, char *flag, str *idx)
{
	int fval=0;
	int ival=0;
	if(fixup_get_ivalue(msg, (gparam_p)flag, &fval)!=0)
	{
		LM_ERR("no flag value\n");
		return -1;
	}
	if(fval<0 || fval>31)
		return -1;
	if(idx!=0)
	{
		if(fixup_get_ivalue(msg, (gparam_p)idx, &ival)!=0)
		{
			LM_ERR("no idx value\n");
			return -1;
		}
		if(ival<0)
			return -1;
	}
	return isbflagset(ival, (flag_t)fval);
}
예제 #19
0
/*
 * Checks if an entry exists in cached address table that belongs to a
 * given address group and has given ip address and port.  Port value
 * 0 in cached address table matches any port.
 */
int allow_address(struct sip_msg* _msg, char* _addr_group, char* _addr_sp,
		char* _port_sp)
{
	unsigned int port;
	int addr_group;
	str ips;
	struct ip_addr *ipa;

	if(fixup_get_ivalue(_msg, (gparam_p)_addr_group, &addr_group) !=0 ) {
		LM_ERR("cannot get group value\n");
		return -1;
	}

	if (_addr_sp==NULL
			|| (fixup_get_svalue(_msg, (gparam_p)_addr_sp, &ips) < 0)) {
		LM_ERR("cannot get value of address pvar\n");
		return -1;
	}

	ipa=strtoipX(&ips);

	if (_port_sp==NULL
			|| (fixup_get_ivalue(_msg, (gparam_p)_port_sp, (int*)&port) < 0)) {
		LM_ERR("cannot get value of port pvar\n");
		return -1;
	}

	if ( ipa ) {
		if (match_addr_hash_table(*addr_hash_table, addr_group, ipa, port) == 1)
			return 1;
		else
			return match_subnet_table(*subnet_table, addr_group, ipa, port);
	} else {
		return match_domain_name_table(*domain_list_table, addr_group, &ips, port);
	}
}
예제 #20
0
파일: pdt.c 프로젝트: Distrotech/opensips
static int w_prefix2domain_1(struct sip_msg* msg, char* mode, char* str2)
{
	int m;

	if(fixup_get_ivalue(msg, (gparam_p)mode, &m)!=0)
	{
		LM_ERR("no mode value\n");
		return -1;
	}

	if(m!=1 && m!=2)
		m = 0;

	return prefix2domain(msg, m, 0);
}
예제 #21
0
static int w_ds_select_domain_limited(struct sip_msg* msg, char* set, char* alg, char* max_results)
{
	int a, s, m;
	if(msg==NULL)
		return -1;

	if(fixup_get_ivalue(msg, (gparam_p)set, &s)!=0)
	{
		LM_ERR("no dst set value\n");
		return -1;
	}
	if(fixup_get_ivalue(msg, (gparam_p)alg, &a)!=0)
	{
		LM_ERR("no alg value\n");
		return -1;
	}
	if(fixup_get_ivalue(msg, (gparam_p)max_results, &m)!=0)
	{
		LM_ERR("no max results value\n");
		return -1;
	}

	return ds_select_dst(msg, s, a, 1/*set host port*/, m);
}
예제 #22
0
파일: pdt.c 프로젝트: Distrotech/opensips
static int w_prefix2domain_2(struct sip_msg* msg, char* mode, char* sdm)
{
	int m, s;

	if(fixup_get_ivalue(msg, (gparam_p)mode, &m)!=0)
	{
		LM_ERR("no mode value\n");
		return -1;
	}

	if(m!=1 && m!=2)
		m = 0;

	if(fixup_get_ivalue(msg, (gparam_p)sdm, &s)!=0)
	{
		LM_ERR("no multi-domain mode value\n");
		return -1;
	}

	if(s!=1 && s!=2)
		s = 0;

	return prefix2domain(msg, m, s);
}
예제 #23
0
파일: pdt.c 프로젝트: adubovikov/kamailio
static int w_prefix2domain_1(struct sip_msg* msg, char* mode, char* str2)
{
	str sdall={"*",1};
	int md;

	if(fixup_get_ivalue(msg, (gparam_p)mode, &md)!=0)
	{
		LM_ERR("no mode value\n");
		return -1;
	}

	if(md!=1 && md!=2)
		md = 0;

	return pd_translate(msg, &sdall, md, 0);
}
예제 #24
0
static int w_pres_refresh_watchers5(struct sip_msg *msg, char *puri,
		char *pevent, char *ptype, char *furi, char *fname)
{
	str pres_uri, event, file_uri, filename;
	int refresh_type;

	if(fixup_get_svalue(msg, (gparam_p)puri, &pres_uri)!=0)
	{
		LM_ERR("invalid uri parameter");
		return -1;
	}

	if(fixup_get_svalue(msg, (gparam_p)pevent, &event)!=0)
	{
		LM_ERR("invalid event parameter");
		return -1;
	}

	if(fixup_get_ivalue(msg, (gparam_p)ptype, &refresh_type)!=0)
	{
		LM_ERR("no type value\n");
		return -1;
	}

	if(fixup_get_svalue(msg, (gparam_p)furi, &file_uri)!=0)
	{
		LM_ERR("invalid file uri parameter");
		return -1;
	}

	if(fixup_get_svalue(msg, (gparam_p)fname, &filename)!=0)
	{
		LM_ERR("invalid filename parameter");
		return -1;
	}

	if (refresh_type != 2)
	{
		LM_ERR("Wrong number of parameters for type %d\n", refresh_type);
		return -1;
	}

	if(pres_refresh_watchers(&pres_uri, &event, refresh_type, &file_uri, &filename)<0)
		return -1;

	return 1;
}
예제 #25
0
static int w_async_route(struct sip_msg* msg, char* rt, char* sec)
{
	cfg_action_t *act;
	int s;
	str rn;
	int ri;

	if(msg==NULL)
		return -1;

	if(async_workers<=0)
	{
		LM_ERR("no async mod timer workers\n");
		return -1;
	}

	if(fixup_get_svalue(msg, (gparam_t*)rt, &rn)!=0)
	{
		LM_ERR("no async route block name\n");
		return -1;
	}

	if(fixup_get_ivalue(msg, (gparam_t*)sec, &s)!=0)
	{
		LM_ERR("no async interval value\n");
		return -1;
	}

	ri = route_get(&main_rt, rn.s);
	if(ri<0)
	{
		LM_ERR("unable to find route block [%.*s]\n", rn.len, rn.s);
		return -1;
	}
	act = main_rt.rlist[ri];
	if(act==NULL)
	{
		LM_ERR("empty action lists in route block [%.*s]\n", rn.len, rn.s);
		return -1;
	}

	if(async_sleep(msg, s, act)<0)
		return -1;
	/* force exit in config */
	return 0;
}
예제 #26
0
static int t_reply_callid(struct sip_msg* msg, char *cid, char *cseq,
		char *rc, char *rs)
{
	struct cell *trans;
	str cseq_s;
	str callid_s;
	str status_s;
	unsigned int code;

	if(fixup_get_svalue(msg, (gparam_p)cid, &callid_s)<0)
	{
		LM_ERR("cannot get callid\n");
		return -1;
	}

	if(fixup_get_svalue(msg, (gparam_p)cseq, &cseq_s)<0)
	{
		LM_ERR("cannot get cseq\n");
		return -1;
	}

	if(fixup_get_ivalue(msg, (gparam_p)rc, (int*)&code)<0)
	{
		LM_ERR("cannot get reply code\n");
		return -1;
	}

	if(fixup_get_svalue(msg, (gparam_p)rs, &status_s)<0)
	{
		LM_ERR("cannot get reply status\n");
		return -1;
	}

	if(_tmx_tmb.t_lookup_callid(&trans, callid_s, cseq_s) < 0 )
	{
		DBG("Lookup failed - no transaction\n");
		return -1;
	}

	DBG("Now calling internal replay\n");
	if(_tmx_tmb.t_reply_trans(trans, trans->uas.request, code, status_s.s)>0)
		return 1;

	return -1;
}
예제 #27
0
static int w_dlg_isflagset(struct sip_msg *msg, char *flag, str *s2) {
    dlg_ctx_t *dctx;
    int val;

    if (fixup_get_ivalue(msg, (gparam_p) flag, &val) != 0) {
        LM_ERR("no flag value\n");
        return -1;
    }
    if (val < 0 || val > 31)
        return -1;

    if ((dctx = dlg_get_dlg_ctx()) == NULL)
        return -1;

    if (dctx->dlg)
        return (dctx->dlg->sflags & (1 << val)) ? 1 : -1;
    return (dctx->flags & (1 << val)) ? 1 : -1;
}
예제 #28
0
파일: msrp_mod.c 프로젝트: halan/kamailio
static int w_msrp_reply_flags(sip_msg_t* msg, char *tflags, char* str2)
{
	int rtflags = 0;
	msrp_frame_t *mf;
	int ret;
	if(fixup_get_ivalue(msg, (gparam_t*)tflags, &rtflags)!=0)
	{
		LM_ERR("invalid send flags parameter\n");
		return -1;
	}

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

	ret = msrp_env_set_rplflags(mf, rtflags);
	if(ret==0) ret = 1;
	return ret;
}
예제 #29
0
static int w_ds_count(struct sip_msg* msg, char *set, const char *cmp, char *res)
{
	int s = 0;
	gparam_p ret = (gparam_p) res;

	if (fixup_get_ivalue(msg, (gparam_p)set, &s)!=0)
	{
		LM_ERR("No dst set value\n");
		return -1;
	}

	if (ret->type != GPARAM_TYPE_PVS && ret->type != GPARAM_TYPE_PVE)
	{
		LM_ERR("Result must be a pvar!\n");
		return -1;
	}

	return ds_count(msg, s, cmp, ret->v.pvs);
}
예제 #30
0
int cmd_check_addr(struct sip_msg *msg, char *param_cluster, char *param_ip,
					char *param_addr_type)
{
	int cluster_id;
	str ip_str;
	str addr_type_str;
	static str bin_addr_t = str_init("bin");
	static str sip_addr_t = str_init("sip");
	enum node_addr_type check_type;

	if (fixup_get_ivalue(msg, (gparam_p)param_cluster, &cluster_id) < 0) {
		LM_ERR("Failed to fetch cluster id parameter\n");
		return -1;
	}
	if (fixup_get_svalue(msg, (gparam_p)param_ip, &ip_str) < 0) {
		LM_ERR("Failed to fetch ip parameter\n");
		return -1;
	}
	if (param_addr_type &&
		fixup_get_svalue(msg, (gparam_p)param_addr_type, &addr_type_str) < 0) {
		LM_ERR("Failed to fetch address type parameter\n");
		return -1;
	}

	if (param_addr_type) {
		if (!str_strcasecmp(&addr_type_str, &bin_addr_t))
			check_type = NODE_BIN_ADDR;
		else if (!str_strcasecmp(&addr_type_str, &sip_addr_t))
			check_type = NODE_SIP_ADDR;
		else {
			LM_ERR("Bad address type, should be 'bin' or 'sip'\n");
			return -1;
		}
	} else
		check_type = NODE_SIP_ADDR;

	if (clusterer_check_addr(cluster_id, &ip_str, check_type) == 0)
		return -1;
	else
		return 1;
}