Beispiel #1
0
/*
 * Given a a hostname hash, makes a resolution 
 * call (service=0) and search the main ip entry,
 * storing it to snsd_node dst.
 *
 * Returns:
 * 	0
 * 	-1
 */
int snsd_main_ip(u_int *hname_hash,snsd_node *dst)
{
	snsd_service *ss;
	snsd_prio *sp;
	snsd_node *sn;
	int records;

	ss=andna_resolve_hash(hname_hash,0,0,&records);
	if (!ss) 
		err_ret(ERR_SNDMRF,-1);
	if (!(sp=ss->prio)) {
		goto destroy_return;
	}
	list_for(sp) {
		sn=sp->node;
		list_for(sn) 
			if (sn->flags & SNSD_NODE_MAIN_IP) {
				memcpy(dst,sn,sizeof(snsd_node));
				snsd_service_llist_del(&ss);
				return 0;
			}
	}
	goto destroy_return;
destroy_return:
	snsd_service_llist_del(&ss);
	err_ret(ERR_SNDMRF,-1);
}
Beispiel #2
0
void
lcl_cache_free(lcl_cache * alcl)
{
	if (alcl->hostname)
		xfree(alcl->hostname);
	alcl->snsd_counter = 0;
	if (alcl->service)
		snsd_service_llist_del(&alcl->service);
}