X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=src%2Fodhcp6c.c;h=4fefcd70b2c6521005e29316b3c1048bc2e0996a;hb=56920baef21f23307c3df9719914e75fe729e0b8;hp=d70546b366ed4c7ebd47c554922d9ea27cd6860c;hpb=feec1ad5767b977ce47e6738930c99c22ba0ce9c;p=odhcp6c.git diff --git a/src/odhcp6c.c b/src/odhcp6c.c index d70546b..4fefcd7 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -42,6 +42,7 @@ static size_t state_len[_STATE_MAX] = {0}; static volatile int do_signal = 0; static int urandom_fd = -1, allow_slaac_only = 0; static bool bound = false, release = true; +static time_t last_update = 0; int main(_unused int argc, char* const argv[]) @@ -357,9 +358,10 @@ bool odhcp6c_signal_process(void) { if (do_signal == SIGIO) { do_signal = 0; + bool ra_rtnled = ra_rtnl_process(); bool ra_updated = ra_process(); - if (ra_rtnl_process() || (ra_updated && (bound || allow_slaac_only == 0))) + if (ra_rtnled || (ra_updated && (bound || allow_slaac_only == 0))) script_call("ra-updated"); // Immediate process urgent events else if (ra_updated && !bound && allow_slaac_only > 0) script_delay_call("ra-updated", allow_slaac_only); @@ -467,9 +469,7 @@ static void odhcp6c_expire_list(enum odhcp6c_state state, uint32_t elapsed) void odhcp6c_expire(void) { - static time_t last_update = 0; time_t now = odhcp6c_get_milli_time() / 1000; - uint32_t elapsed = (last_update > 0) ? now - last_update : 0; last_update = now; @@ -481,6 +481,12 @@ void odhcp6c_expire(void) } +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);