+static void odhcp6c_expire_list(enum odhcp6c_state state, uint32_t elapsed)
+{
+ size_t len;
+ struct odhcp6c_entry *start = odhcp6c_get_state(state, &len);
+ for (struct odhcp6c_entry *c = start; c < &start[len / sizeof(*c)]; ++c) {
+ if (c->t1 < elapsed)
+ c->t1 = 0;
+ else if (c->t1 != UINT32_MAX)
+ c->t1 -= elapsed;
+
+ if (c->t2 < elapsed)
+ c->t2 = 0;
+ else if (c->t2 != UINT32_MAX)
+ c->t2 -= elapsed;
+
+ if (c->preferred < elapsed)
+ c->preferred = 0;
+ else if (c->preferred != UINT32_MAX)
+ c->preferred -= elapsed;
+
+ if (c->valid < elapsed)
+ c->valid = 0;
+ else if (c->valid != UINT32_MAX)
+ c->valid -= elapsed;
+
+ if (!c->valid)
+ odhcp6c_remove_state(state, (c - start) * sizeof(*c), sizeof(*c));
+ }
+}
+
+
+void odhcp6c_expire(void)
+{
+ time_t now = odhcp6c_get_milli_time() / 1000;
+ uint32_t elapsed = (last_update > 0) ? now - last_update : 0;
+ last_update = now;
+
+ odhcp6c_expire_list(STATE_RA_PREFIX, elapsed);
+ odhcp6c_expire_list(STATE_RA_ROUTE, elapsed);
+ odhcp6c_expire_list(STATE_RA_DNS, elapsed);
+ odhcp6c_expire_list(STATE_IA_NA, elapsed);
+ odhcp6c_expire_list(STATE_IA_PD, elapsed);
+}
+
+
+uint32_t odhcp6c_elapsed(void)
+{
+ return odhcp6c_get_milli_time() / 1000 - last_update;
+}
+
+
+void odhcp6c_random(void *buf, size_t len)
+{
+ read(urandom_fd, buf, len);
+}
+
+bool odhcp6c_is_bound(void)
+{
+ return bound;
+}
+