-/* $OpenBSD: clparse.c,v 1.151 2017/12/03 20:53:28 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.152 2017/12/07 19:03:15 krw Exp $ */
/* Parser for dhclient config and lease files. */
new_parse(path_dhclient_conf);
- TAILQ_INIT(&config->static_leases);
TAILQ_INIT(&config->reject_list);
/* Set some defaults. */
void
parse_client_statement(FILE *cfile, char *name, int nested)
{
- struct client_lease *lp;
char *val;
int i, token;
;
break;
case TOK_LEASE:
- if (nested == 1) {
- parse_warn("expecting statement.");
- skip_to_semi(cfile);
- } else if (parse_client_lease_statement(cfile, name, &lp) == 1)
- add_lease(&config->static_leases, lp);
+ skip_to_semi(cfile);
break;
case TOK_LINK_TIMEOUT:
if (parse_lease_time(cfile, &config->link_timeout) == 1)
-/* $OpenBSD: dhclient.c,v 1.536 2017/12/06 13:57:27 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.537 2017/12/07 19:03:15 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
time_t lease_expiry(struct client_lease *);
time_t lease_renewal(struct client_lease *);
time_t lease_rebind(struct client_lease *);
-int lease_is_static(struct client_lease *);
struct client_lease *packet_to_lease(struct interface_info *,
struct option_data *);
void take_charge(struct interface_info *, int);
void set_default_client_identifier(struct interface_info *);
struct client_lease *get_recorded_lease(struct interface_info *);
-struct client_lease *get_static_lease(struct interface_info *);
#define ROUNDUP(a) \
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
free_client_lease(lease);
}
}
- if (lease_is_static(ifi->active) == 0 && seen == 0)
+ if (seen == 0)
TAILQ_INSERT_HEAD(&ifi->leases, ifi->active, next);
/* Write out new leases file. */
log_info("%s: no acceptable DHCPOFFERS received", log_procname);
ifi->offer = get_recorded_lease(ifi);
- if (ifi->offer == NULL)
- ifi->offer = get_static_lease(ifi);
-
if (ifi->offer != NULL) {
ifi->state = S_REQUESTING;
bind_lease(ifi);
{
int i;
- /* Static leases are forever. */
- if (lease == NULL || lease_is_static(lease))
+ if (lease == NULL)
return;
free(lease->interface);
return lp;
}
-struct client_lease *
-get_static_lease(struct interface_info *ifi)
-{
- char ifname[IF_NAMESIZE];
- time_t cur_time;
- struct client_lease *lp;
- int i;
-
- time(&cur_time);
-
- /* Run through the list of leases and see if one can be used. */
- i = DHO_DHCP_CLIENT_IDENTIFIER;
- TAILQ_FOREACH(lp, &config->static_leases, next) {
- if (lp->ssid_len != ifi->ssid_len)
- continue;
- if (memcmp(lp->ssid, ifi->ssid, lp->ssid_len) != 0)
- continue;
- if ((lp->options[i].len != 0) && ((lp->options[i].len !=
- config->send_options[i].len) ||
- memcmp(lp->options[i].data, config->send_options[i].data,
- lp->options[i].len)))
- continue;
- if (addressinuse(ifi->name, lp->address, ifname) != 0 &&
- strncmp(ifname, ifi->name, IF_NAMESIZE) != 0)
- continue;
-
- break;
- }
-
- if (lp != NULL)
- time(&lp->epoch);
-
- return lp;
-}
void
set_default_client_identifier(struct interface_info *ifi)
return lease->epoch + rebind;
}
-
-int
-lease_is_static(struct client_lease *lease)
-{
- struct client_lease *lp;
-
- TAILQ_FOREACH(lp, &config->static_leases, next) {
- if (lp == lease)
- return 1;
- }
-
- return 0;
-}
-.\" $OpenBSD: dhclient.conf.5,v 1.36 2017/10/20 13:04:50 krw Exp $
+.\" $OpenBSD: dhclient.conf.5,v 1.37 2017/12/07 19:03:15 krw Exp $
.\"
.\" Copyright (c) 1997 The Internet Software Consortium.
.\" All rights reserved.
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
.\" Enterprises, see ``http://www.vix.com''.
.\"
-.Dd $Mdocdate: October 20 2017 $
+.Dd $Mdocdate: December 7 2017 $
.Dt DHCLIENT.CONF 5
.Os
.Sh NAME
.Ar declaration
only to the named interface.
.Ar interface
-declarations cannot be nested and cannot contain
-.Ar lease
-declarations.
-.It Ic lease No { Ar declaration ; ... ; No }
-Define a lease that can be used when no lease is obtained from a server.
-See
-.Xr dhclient.leases 5
-for the complete description of the
-.Ic lease
-format.
+declarations cannot be nested.
.It Ic reject Ar ip-address ;
Discard leases from the specified address.
If more than one