コード例 #1
0
ファイル: resolve.c プロジェクト: miao606/kamailio
/* choose between 2 naptr records, should take into account local
 * preferences too
 * returns 1 if the new record was selected, 0 otherwise */
int naptr_choose (struct naptr_rdata** crt, char* crt_proto,
									struct naptr_rdata* n , char n_proto)
{
#ifdef NAPTR_DBG
	DBG("naptr_choose(o: %d w: %d p:%d , o: %d w:%d p:%d)\n",
			*crt?(int)(*crt)->order:-1, *crt?(int)(*crt)->pref:-1,
			(int)*crt_proto,
			(int)n->order, (int)n->pref, (int)n_proto);
#endif
	if ((*crt==0) || ((*crt_proto!=n_proto) && 
						( naptr_proto_preferred(n_proto, *crt_proto))) )
			goto change;
	if (!naptr_proto_preferred(*crt_proto, n_proto) && 
			((n->order<(*crt)->order) || ((n->order== (*crt)->order) &&
								(n->pref < (*crt)->pref)))){
			goto change;
	}
#ifdef NAPTR_DBG
	DBG("naptr_choose: no change\n");
#endif
	return 0;
change:
#ifdef NAPTR_DBG
	DBG("naptr_choose: changed\n");
#endif
	*crt_proto=n_proto;
	*crt=n;
	return 1;
}
コード例 #2
0
ファイル: resolve.c プロジェクト: btriller/kamailio
/** choose between 2 naptr records, should take into account local
 * preferences too
 * returns 1 if the new record was selected, 0 otherwise */
int naptr_choose (struct naptr_rdata** crt, char* crt_proto,
									struct naptr_rdata* n , char n_proto)
{
	LM_DBG("o:%d w:%d p:%d, o:%d w:%d p:%d\n",
			*crt?(int)(*crt)->order:-1, *crt?(int)(*crt)->pref:-1,
			(int)*crt_proto,
			(int)n->order, (int)n->pref, (int)n_proto);
	if ((*crt==0) || ((*crt_proto!=n_proto) && 
						( naptr_proto_preferred(n_proto, *crt_proto))) )
			goto change;
	if (!naptr_proto_preferred(*crt_proto, n_proto) && 
			((n->order<(*crt)->order) || ((n->order== (*crt)->order) &&
								(n->pref < (*crt)->pref)))){
			goto change;
	}
	LM_DBG("no change\n");
	return 0;
change:
	LM_DBG("changed\n");
	*crt_proto=n_proto;
	*crt=n;
	return 1;
}