X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=src%2Fodhcp6c.c;h=e81b15f92a5bcfc0a8b54895a336cdf46a8d6ace;hb=24c064ccbf819f85c8709ea60acb3b278377b408;hp=5c433af31e7c90b1fcad9746be36d29734cc6aab;hpb=2037bd1f310239f1982f3bd2f541ba409ee16b6a;p=odhcp6c.git diff --git a/src/odhcp6c.c b/src/odhcp6c.c index 5c433af..e81b15f 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -463,17 +463,23 @@ struct odhcp6c_entry* odhcp6c_find_entry(enum odhcp6c_state state, const struct } -void odhcp6c_update_entry_safe(enum odhcp6c_state state, struct odhcp6c_entry *new, uint32_t safe) +bool odhcp6c_update_entry_safe(enum odhcp6c_state state, struct odhcp6c_entry *new, uint32_t safe) { size_t len; struct odhcp6c_entry *x = odhcp6c_find_entry(state, new); struct odhcp6c_entry *start = odhcp6c_get_state(state, &len); + bool changed = true; if (x && x->valid > new->valid && new->valid < safe) new->valid = safe; if (new->valid > 0) { if (x) { + if (new->valid >= x->valid && new->valid - x->valid < 60 && + new->preferred >= x->preferred && + new->preferred - x->preferred < 60 && + x->class == new->class) + changed = false; x->valid = new->valid; x->preferred = new->preferred; x->class = new->class; @@ -483,12 +489,13 @@ void odhcp6c_update_entry_safe(enum odhcp6c_state state, struct odhcp6c_entry *n } else if (x) { odhcp6c_remove_state(state, (x - start) * sizeof(*x), sizeof(*x)); } + return changed; } -void odhcp6c_update_entry(enum odhcp6c_state state, struct odhcp6c_entry *new) +bool odhcp6c_update_entry(enum odhcp6c_state state, struct odhcp6c_entry *new) { - odhcp6c_update_entry_safe(state, new, 0); + return odhcp6c_update_entry_safe(state, new, 0); }