X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=blobdiff_plain;f=src%2Fodhcp6c.c;h=4c534c17b518a66d74688f9131123b2351c9ecc9;hp=8b5cb54308c8f7224e37c3dbd7d5e1571981d53e;hb=e1540ec55e014e538a92a588675e4156a1bddabe;hpb=da8ad1051e593e9adc6e30319dc33f3cac3189e9 diff --git a/src/odhcp6c.c b/src/odhcp6c.c index 8b5cb54..4c534c1 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -445,7 +445,7 @@ static int usage(void) " -e Write logmessages to stderr\n" " -v Increase logging verbosity\n" " -h Show this help\n\n"; - write(STDERR_FILENO, buf, sizeof(buf)); + fputs(buf, stderr); return 1; } @@ -553,9 +553,9 @@ void* odhcp6c_get_state(enum odhcp6c_state state, size_t *len) } -struct odhcp6c_entry* odhcp6c_find_entry(enum odhcp6c_state state, const struct odhcp6c_entry *new) +static struct odhcp6c_entry* odhcp6c_find_entry(enum odhcp6c_state state, const struct odhcp6c_entry *new) { - size_t len, cmplen = offsetof(struct odhcp6c_entry, target) + new->length / 8; + size_t len, cmplen = offsetof(struct odhcp6c_entry, target) + ((new->length + 7) / 8); struct odhcp6c_entry *start = odhcp6c_get_state(state, &len); struct odhcp6c_entry *x = NULL; @@ -584,14 +584,12 @@ bool odhcp6c_update_entry(enum odhcp6c_state state, struct odhcp6c_entry *new, new->valid - x->valid < min_update_interval && new->preferred >= x->preferred && new->preferred != UINT32_MAX && - new->preferred - x->preferred < min_update_interval && - x->class == new->class) + new->preferred - x->preferred < min_update_interval) return false; x->valid = new->valid; x->preferred = new->preferred; x->t1 = new->t1; x->t2 = new->t2; - x->class = new->class; x->iaid = new->iaid; } else { odhcp6c_add_state(state, new, sizeof(*new)); @@ -654,9 +652,9 @@ uint32_t odhcp6c_elapsed(void) } -void odhcp6c_random(void *buf, size_t len) +int odhcp6c_random(void *buf, size_t len) { - read(urandom_fd, buf, len); + return read(urandom_fd, buf, len); } bool odhcp6c_is_bound(void)