X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=src%2Fodhcp6c.c;h=dfd99254ca7ff7bb015e000f0fd4730460775499;hb=ba6df2a68fcad5040f3746419aaac2bc3283a33d;hp=2668d949bdedc9050572f3497ab06e62d04b9870;hpb=68300e0f9f318daf5495b5e5ee7d56ad9cff99cf;p=odhcp6c.git diff --git a/src/odhcp6c.c b/src/odhcp6c.c index 2668d94..dfd9925 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -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; @@ -178,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; @@ -252,7 +259,7 @@ int main(_unused int argc, char* const argv[]) pidfile = pidbuf; } - int fd = open(pidfile, O_WRONLY | O_CREAT); + int fd = open(pidfile, O_WRONLY | O_CREAT, 0644); if (fd >= 0) { char buf[8]; int len = snprintf(buf, sizeof(buf), "%i\n", getpid()); @@ -427,7 +434,7 @@ static int usage(void) " -N Mode for requesting addresses [try|force|none]\n" " -P Request IPv6-Prefix (0 = auto)\n" " -F Force IPv6-Prefix\n" - " -V Set vendor-class option. string length must be a multiple of 2\n" + " -V Set vendor-class option (base-16 encoded)\n" #ifdef EXT_BFD_PING " -B Enable BFD ping check\n" #endif @@ -439,7 +446,7 @@ static int usage(void) " -a Don't send Accept Reconfigure option\n" " -f Don't send Client FQDN option\n" " -k Don't send a RELEASE when stopping\n" - " -t Maximum timeout for DHCPv6-SOLICIT (120)\n" + " -t Maximum timeout for DHCPv6-SOLICIT (3600)\n" "\nInvocation options:\n" " -p Set pidfile (/var/run/odhcp6c.pid)\n" " -d Daemonize\n" @@ -585,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;