X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=blobdiff_plain;f=src%2Fodhcp6c.c;h=3eb37a7b41b3cd2807dc07ad0538a8f45ccf8df3;hp=c4ce7d77155a8d1532efe24a263ae5678fa81f52;hb=c291def1cadf58c0aa10c18a53c2fc4d2dee1ad6;hpb=415cfbe06f7b9ee604237f69d475fe0d1953986e diff --git a/src/odhcp6c.c b/src/odhcp6c.c index c4ce7d7..3eb37a7 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -1,5 +1,5 @@ /** - * Copyright (C) 2012-2013 Steven Barth + * Copyright (C) 2012-2014 Steven Barth * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License v2 as published by @@ -61,6 +61,7 @@ int main(_unused int argc, char* const argv[]) uint8_t buf[134]; char *optpos; uint16_t opttype; + uint16_t optlen; enum odhcp6c_ia_mode ia_na_mode = IA_MODE_TRY; enum odhcp6c_ia_mode ia_pd_mode = IA_MODE_NONE; int ia_pd_iaid_index = 0; @@ -76,7 +77,7 @@ int main(_unused int argc, char* const argv[]) int c; unsigned int client_options = DHCPV6_CLIENT_FQDN | DHCPV6_ACCEPT_RECONFIGURE; - while ((c = getopt(argc, argv, "S::N:V:P:FB:c:i:r:Rs:kt:hedp:fa")) != -1) { + while ((c = getopt(argc, argv, "S::N:V:P:FB:c:i:r:Ru:s:kt:hedp:fa")) != -1) { switch (c) { case 'S': allow_slaac_only = (optarg) ? atoi(optarg) : -1; @@ -115,7 +116,7 @@ int main(_unused int argc, char* const argv[]) int prefix_length = strtoul(optarg, &iaid_begin, 10); - if (*iaid_begin != '\0' && *iaid_begin != ',') { + if (*iaid_begin != '\0' && *iaid_begin != ',' && *iaid_begin != ':') { syslog(LOG_ERR, "invalid argument: '%s'", optarg); return 1; } @@ -124,8 +125,10 @@ int main(_unused int argc, char* const argv[]) if (*iaid_begin == ',' && (iaid_len = strlen(iaid_begin)) > 1) memcpy(&prefix.iaid, iaid_begin + 1, iaid_len > 4 ? 4 : iaid_len); + else if (*iaid_begin == ':') + prefix.iaid = htonl((uint32_t)strtoul(&iaid_begin[1], NULL, 16)); else - prefix.iaid = ++ia_pd_iaid_index; + prefix.iaid = htonl(++ia_pd_iaid_index); odhcp6c_add_state(STATE_IA_PD_INIT, &prefix, sizeof(prefix)); @@ -176,6 +179,12 @@ int main(_unused int argc, char* const argv[]) client_options |= DHCPV6_STRICT_OPTIONS; break; + case 'u': + optlen = htons(strlen(optarg)); + odhcp6c_add_state(STATE_USERCLASS, &optlen, 2); + odhcp6c_add_state(STATE_USERCLASS, optarg, strlen(optarg)); + break; + case 's': script = optarg; break; @@ -583,8 +592,10 @@ bool odhcp6c_update_entry_safe(enum odhcp6c_state state, struct odhcp6c_entry *n if (new->valid > 0) { if (x) { - if (new->valid >= x->valid && new->valid - x->valid < 60 && + if (new->valid >= x->valid && new->valid != UINT32_MAX && + new->valid - x->valid < 60 && new->preferred >= x->preferred && + new->preferred != UINT32_MAX && new->preferred - x->preferred < 60 && x->class == new->class) return false;