void iter_merge_retry_counts(struct delegpt* dp, struct delegpt* old) { struct delegpt_addr* a, *o, *prev; for(a=dp->target_list; a; a = a->next_target) { o = delegpt_find_addr(old, &a->addr, a->addrlen); if(o) { log_addr(VERB_ALGO, "copy attempt count previous dp", &a->addr, a->addrlen); a->attempts = o->attempts; } } prev = NULL; a = dp->usable_list; while(a) { if(a->attempts >= OUTBOUND_MSG_RETRY) { log_addr(VERB_ALGO, "remove from usable list dp", &a->addr, a->addrlen); /* remove from result list */ if(prev) prev->next_usable = a->next_usable; else dp->usable_list = a->next_usable; /* prev stays the same */ a = a->next_usable; continue; } prev = a; a = a->next_usable; } }
int delegpt_add_addr(struct delegpt* dp, struct regional* region, struct sockaddr_storage* addr, socklen_t addrlen, int bogus, int lame, int nodup) { struct delegpt_addr* a; if(nodup) { if((a = delegpt_find_addr(dp, addr, addrlen))) { if(bogus) a->bogus = bogus; if(!lame) a->lame = 0; return 1; } } a = (struct delegpt_addr*)regional_alloc(region, sizeof(struct delegpt_addr)); if(!a) return 0; a->next_target = dp->target_list; dp->target_list = a; a->next_result = 0; a->next_usable = dp->usable_list; dp->usable_list = a; memcpy(&a->addr, addr, addrlen); a->addrlen = addrlen; a->attempts = 0; a->bogus = bogus; a->lame = lame; return 1; }
int delegpt_add_addr_mlc(struct delegpt* dp, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t bogus, uint8_t lame) { struct delegpt_addr* a; log_assert(dp->dp_type_mlc); /* check for duplicates */ if((a = delegpt_find_addr(dp, addr, addrlen))) { if(bogus) a->bogus = bogus; if(!lame) a->lame = 0; return 1; } a = (struct delegpt_addr*)malloc(sizeof(struct delegpt_addr)); if(!a) return 0; a->next_target = dp->target_list; dp->target_list = a; a->next_result = 0; a->next_usable = dp->usable_list; dp->usable_list = a; memcpy(&a->addr, addr, addrlen); a->addrlen = addrlen; a->attempts = 0; a->bogus = bogus; a->lame = lame; a->dnsseclame = 0; return 1; }