Example #1
0
void pa_timer_set_not_before(struct pa_timer *t, hnetd_time_t time, bool relative)
{
	if(relative)
		time += hnetd_time();

	if(t->not_before == time)
		return;

	t->not_before = time;
	if(t->enabled && t->when >= 0)
		pa_timer_update_to(t);
}
Example #2
0
static void __pa_timer_set(struct pa_timer *t, hnetd_time_t time, bool relative, bool earlier)
{
	hnetd_time_t now = hnetd_time();
	if(relative) {
		if(time < t->min_delay)
			time = t->min_delay;
		time += now;
	} else if(time - now < t->min_delay) {
		time = now + t->min_delay;
	}

	if(t->when < 0 || !earlier || t->when > time)
		pa_timer_set_when(t, time);
}
Example #3
0
void prefix_mock(__unused struct iface_user *u, __unused const char *ifname,
		__unused const struct prefix *prefix, __unused const struct prefix *excluded,
		hnetd_time_t valid_until, __unused hnetd_time_t preferred_until,
		__unused const void *dhcpv6_data, __unused size_t dhcpv6_len)
{
	if (valid_until > hnetd_time()) {
		smock_push("prefix_prefix", (void*)prefix);
		smock_push_int64("prefix_valid", valid_until);
		smock_push_int64("prefix_preferred", preferred_until);
		smock_push("dhcpv6_data", (void*)dhcpv6_data);
		smock_push_int("dhcpv6_len", dhcpv6_len);
	} else {
		smock_push_bool("prefix_remove", true);
	}
}
Example #4
0
static inline void pa_timer_update_to(struct pa_timer *t)
{
	if(t->when >= 0) {
		hnetd_time_t when = t->when;
		int delay;
		if(when < t->not_before)
			when = t->not_before;
		delay = TODELAY(when - hnetd_time());
		L_INFO("Scheduling %s in %d ms", t->name, delay);
		uloop_timeout_set(&t->t, delay);
	} else if(t->t.pending) {
		L_INFO("Canceling %s", t->name);
		uloop_timeout_cancel(&t->t);
	}
}
Example #5
0
hnetd_time_t hncp_io_time(hncp o __unused)
{
  return hnetd_time();
}