? dhcpleased.conf Index: dhcpleased.conf.5 =================================================================== RCS file: /cvs/src/sbin/dhcpleased/dhcpleased.conf.5,v retrieving revision 1.13 diff -u -p -r1.13 dhcpleased.conf.5 --- dhcpleased.conf.5 25 Nov 2023 12:00:39 -0000 1.13 +++ dhcpleased.conf.5 29 Jan 2024 08:43:02 -0000 @@ -112,6 +112,10 @@ The default is to send a DHCP host name Send the DHCP vendor class identifier option with a value of .Ar vendor-class-id . The default is to not send a vendor class identifier. +.It Ic lease time Ar lease-time-interval +Send the specified +.Ar lease-time-interval . +The default is to not send a lease time interval. .El .Sh FILES .Bl -tag -width /etc/dhcpleased.conf -compact Index: dhcpleased.h =================================================================== RCS file: /cvs/src/sbin/dhcpleased/dhcpleased.h,v retrieving revision 1.16 diff -u -p -r1.16 dhcpleased.h --- dhcpleased.h 26 Jan 2024 21:14:08 -0000 1.16 +++ dhcpleased.h 29 Jan 2024 08:43:02 -0000 @@ -260,6 +260,7 @@ struct iface_conf { struct in_addr ignore_servers[MAX_SERVERS]; int ignore_servers_len; int prefer_ipv6; + uint32_t lease_time; }; struct dhcpleased_conf { Index: frontend.c =================================================================== RCS file: /cvs/src/sbin/dhcpleased/frontend.c,v retrieving revision 1.33 diff -u -p -r1.33 frontend.c --- frontend.c 26 Jan 2024 21:14:08 -0000 1.33 +++ frontend.c 29 Jan 2024 08:43:02 -0000 @@ -1036,6 +1036,19 @@ build_packet(uint8_t message_type, char sizeof(dhcp_server_identifier)); p += sizeof(dhcp_server_identifier); } + +#ifndef SMALL + if (iface_conf != NULL && iface_conf->lease_time != 0) { + uint8_t dhcp_address_time[] = { DHO_DHCP_LEASE_TIME, 4, + 0, 0, 0, 0}; + uint32_t lease_time = htonl(iface_conf->lease_time); + + memcpy(dhcp_address_time + 2, + &lease_time, sizeof(lease_time)); + memcpy(p, dhcp_address_time, sizeof(dhcp_address_time)); + p += sizeof(dhcp_address_time); + } +#endif /* SMALL */ *p = DHO_END; p += 1; Index: parse.y =================================================================== RCS file: /cvs/src/sbin/dhcpleased/parse.y,v retrieving revision 1.8 diff -u -p -r1.8 parse.y --- parse.y 25 Nov 2023 12:00:39 -0000 1.8 +++ parse.y 29 Jan 2024 08:43:02 -0000 @@ -109,11 +109,13 @@ typedef struct { %} %token DHCP_IFACE ERROR SEND VENDOR CLASS ID CLIENT IGNORE DNS ROUTES HOST NAME -%token NO PREFER IPV6 +%token NO PREFER IPV6 LEASE TIME +%token SECOND MINUTE HOUR DAY WEEK %token STRING %token NUMBER %type string +%type interval interval_unit %% @@ -327,6 +329,31 @@ ifaceoptsl : SEND VENDOR CLASS ID STRING | PREFER IPV6 { iface_conf->prefer_ipv6 = 1; } + | LEASE TIME interval { + if ($3 < 5) { + yyerror("least time is too low"); + YYERROR; + } + if ($3 > (3600 * 24 * 7)) { + yyerror("least time is too high"); + YYERROR; + } + + iface_conf->lease_time = $3; + } + ; + +interval : NUMBER interval_unit { + $$ = $1 * $2; + } + ; + +interval_unit : /* nothing */ { $$ = 1; } + | SECOND { $$ = 1; } + | MINUTE { $$ = 60; } + | HOUR { $$ = 60 * 60; } + | DAY { $$ = 60 * 60 * 24; } + | WEEK { $$ = 60 * 60 * 24 * 7; } ; %% @@ -364,18 +391,30 @@ lookup(char *s) static const struct keywords keywords[] = { {"class", CLASS}, {"client", CLIENT}, + {"day", DAY}, + {"days", DAY}, {"dns", DNS}, {"host", HOST}, + {"hour", HOUR}, + {"hours", HOUR}, {"id", ID}, {"ignore", IGNORE}, {"interface", DHCP_IFACE}, {"ipv6", IPV6}, + {"lease", LEASE}, + {"minute", MINUTE}, + {"minutes", MINUTE}, {"name", NAME}, {"no", NO}, {"prefer", PREFER}, {"routes", ROUTES}, + {"second", SECOND}, + {"seconds", SECOND}, {"send", SEND}, + {"time", TIME}, {"vendor", VENDOR}, + {"week", WEEK}, + {"weeks", WEEK}, }; const struct keywords *p;