Ejemplo n.º 1
0
/* find all node matched special tag in tree */
	int
ms_get_tree(struct db_node *node, struct list_t *rt, int flag)
{
	if (!node)
		return 0;
	if (ms_node_is_type(node, flag))
		list_insert(rt,node,NULL);
	ms_get_tree(node->l_left,rt,flag);
	ms_get_tree(node->l_right,rt,flag);
	return rt->count;
}
Ejemplo n.º 2
0
/* make a map-reply */
	int 
_request_reply(void *data, struct communication_fct * fct, \
		struct db_node * rn, struct prefix * pf){
	struct map_entry * e = NULL;
	struct list_entry_t * _iter;
	struct list_t * l = NULL;
	struct pk_rpl_entry *rpk;
	struct pk_req_entry *pke = data;
	struct list_t *overlap;
	struct list_entry_t *nptr;
	
	struct mapping_flags * mflags = (struct mapping_flags *)rn->flags;
	int pe=0;
	
	cp_log(LDEBUG, "Send Map-Reply to ITR\n");
		
	rpk = fct->reply_add(pke);
	
	/*PCD */
	overlap = list_init();
	ms_get_tree(rn,overlap,_MAPP|_MAPP_XTR);
	nptr = overlap->head.next;
	while(nptr != &overlap->tail){
		rn = (struct db_node *)nptr->data;
		/* get the RLOCs */
		l = (struct list_t *)db_node_get_info(rn);
		assert(l);
		_iter = l->head.next;
		pe = 0;
		if( (_fncs & (_FNC_XTR | _FNC_MS)) && lisp_te){
			while(_iter != &l->tail){
				e = (struct map_entry*)_iter->data;
				if(e->pe)
					pe += e->pe->count; 
				else 
					pe++;
				_iter = _iter->next;
			}
			fct->reply_add_record(rpk, &rn->p, mflags->ttl, pe, mflags->version, mflags->A, mflags->act);
		}
		else
			fct->reply_add_record(rpk, &rn->p, mflags->ttl, l->count, mflags->version, mflags->A, mflags->act);
		
		_iter = l->head.next;
		while(_iter != &l->tail){
			e = (struct map_entry*)_iter->data;

			fct->reply_add_locator(rpk, e);
			_iter = _iter->next;
		}
		nptr = nptr->next;
	}
	fct->reply_terminate(rpk);
	return TRUE;	
}