static locator_t * get_locator_with_afi(mapping_t *m, int afi) { glist_t *loct_list = NULL; glist_entry_t *it_list = NULL; glist_entry_t *it_loct = NULL; locator_t *loct = NULL; lisp_addr_t *addr = NULL; int lafi = 0; int afi_type = 0; glist_for_each_entry(it_list,mapping_locators_lists(m)){ loct_list = (glist_t *)glist_entry_data(it_list); locator_list_lafi_type(loct_list,&lafi,&afi_type); if (lafi == LM_AFI_NO_ADDR || (lafi == LM_AFI_IP && afi_type != afi)){ continue; } glist_for_each_entry(it_loct,loct_list){ loct = (locator_t *)glist_entry_data(it_loct); if (locator_state(loct) == DOWN){ continue; } addr = locator_addr(loct); addr = lisp_addr_get_ip_addr(addr); if (lisp_addr_ip_afi (addr) == afi){ return (loct); } }
/* Return the locator from the list that contains the address passed as a * parameter */ locator_t * locator_list_get_locator_with_addr( glist_t *loct_list, lisp_addr_t *addr) { locator_t *locator = NULL; glist_entry_t *it = NULL; if (!loct_list || glist_size(loct_list) == 0 || addr == NULL){ return (NULL); } glist_for_each_entry(it,loct_list){ locator = (locator_t *)glist_entry_data(it); if (lisp_addr_cmp(locator_addr(locator), addr) == 0) { return (locator); } }
/* Return the list the timers of the requested type associated with the object */ glist_t * htable_ptrs_timers_get_timers_of_type(htable_ptrs_t *ptr_ht, void *key, timer_type type) { oor_timer_t *timer; glist_t *set_timers_lst; glist_t *timer_lst; glist_entry_t *timer_it, *timer_it_aux; timer_lst = htable_ptrs_lookup(ptr_ht, key); if (!timer_lst){ return (NULL); } set_timers_lst = glist_new(); glist_for_each_entry_safe(timer_it,timer_it_aux,timer_lst){ timer = (oor_timer_t*)glist_entry_data(timer_it); if (type == oor_timer_type(timer)){ glist_add(timer, set_timers_lst); } }
static void set_rlocs(oor_ctrl_t *ctrl) { iface_t *iface; glist_entry_t *iface_it; glist_remove_all(ctrl->rlocs); glist_remove_all(ctrl->ipv4_rlocs); glist_remove_all(ctrl->ipv6_rlocs); ctrl->supported_afis = NO_AFI_SUPPOT; glist_for_each_entry(iface_it,interface_list){ iface = (iface_t *)glist_entry_data(iface_it); if (iface->ipv4_address && !lisp_addr_is_no_addr(iface->ipv4_address)) { glist_add_tail(iface->ipv4_address, ctrl->ipv4_rlocs); glist_add_tail(iface->ipv4_address, ctrl->rlocs); } if (iface->ipv6_address && !lisp_addr_is_no_addr(iface->ipv6_address)) { glist_add_tail(iface->ipv6_address, ctrl->ipv6_rlocs); glist_add_tail(iface->ipv6_address, ctrl->rlocs); } }
/* extracts a mapping record out of lbuf 'b' and stores it into 'm'. 'm' must * be preallocated. If a locator is probed, a pointer to it is stored in * 'probed'. */ int lisp_msg_parse_mapping_record(lbuf_t *b, mapping_t *m, locator_t **probed) { glist_t *loc_list; glist_entry_t *lit; locator_t *loc; int ret; void *hdr; if (!m) { return(BAD); } hdr = lbuf_data(b); mapping_set_ttl(m, ntohl(MAP_REC_TTL(hdr))); mapping_set_action(m, MAP_REC_ACTION(hdr)); mapping_set_auth(m, MAP_REC_AUTH(hdr)); /* no free is called when destroyed*/ loc_list = glist_new(); ret = lisp_msg_parse_mapping_record_split(b, mapping_eid(m), loc_list, probed); if (ret != GOOD) { goto err; } glist_for_each_entry(lit, loc_list) { loc = glist_entry_data(lit); if ((ret = mapping_add_locator(m, loc)) != GOOD) { locator_del(loc); if (ret != ERR_EXIST){ goto err; } } }