summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2017-06-16 14:12:13 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2017-06-16 14:12:13 +0000
commit1ed754e8da1eda24afc12ff17882b88d2c8bb066 (patch)
tree3a1bf27367033cc1367befca3946f1205766e3ca
parentc9c3e4a7877edfc1cca37831ecc11017565814c3 (diff)
Nuke 'is_bootp' field and just use a #define to check if the lease
has DHO_DHCP_MESSAGE_TYPE info.
-rw-r--r--sbin/dhclient/clparse.c4
-rw-r--r--sbin/dhclient/dhclient.c20
-rw-r--r--sbin/dhclient/dhcpd.h4
3 files changed, 10 insertions, 18 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 4a798b69422..b061b6cfab4 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.112 2017/06/14 16:52:35 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.113 2017/06/16 14:12:12 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -560,7 +560,7 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease,
switch (token) {
case TOK_BOOTP:
- lease->is_bootp = 1;
+ /* 'bootp' is just a comment. See BOOTP_LEASE(). */
break;
case TOK_INTERFACE:
token = next_token(&val, cfile);
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 868ac29b87b..9c0538ef2f5 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.427 2017/06/15 17:06:17 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.428 2017/06/16 14:12:12 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -767,8 +767,8 @@ state_reboot(struct interface_info *ifi)
} else
ifi->active = get_recorded_lease(ifi);
- /* If we don't remember an active lease, go straight to INIT. */
- if (!ifi->active || ifi->active->is_bootp) {
+ /* No active lease, or the lease is BOOTP, go straight to INIT. */
+ if (!ifi->active || BOOTP_LEASE(ifi->active)) {
ifi->state = S_INIT;
state_init(ifi);
return;
@@ -835,7 +835,7 @@ state_selecting(struct interface_info *ifi)
}
/* If it was a BOOTREPLY, we can just take the lease right now. */
- if (!picked->options[DHO_DHCP_MESSAGE_TYPE].len) {
+ if (BOOTP_LEASE(picked)) {
struct option_data *option;
ifi->new = picked;
@@ -1138,13 +1138,6 @@ dhcpoffer(struct interface_info *ifi, struct option_data *options, char *info)
lease = packet_to_lease(ifi, options);
- /*
- * If this lease was acquired through a BOOTREPLY, record that
- * fact.
- */
- if (!options[DHO_DHCP_MESSAGE_TYPE].len)
- lease->is_bootp = 1;
-
/* Figure out when we're supposed to stop selecting. */
stop_selecting = ifi->first_sending + config->select_interval;
@@ -1879,7 +1872,7 @@ lease_as_string(struct interface_info *ifi, char *type,
strlcat(string, type, sizeof(string));
strlcat(string, " {\n", sizeof(string));
- strlcat(string, (lease->is_bootp) ? " bootp;\n" : "", sizeof(string));
+ strlcat(string, BOOTP_LEASE(lease) ? " bootp;\n" : "", sizeof(string));
buf = pretty_print_string(ifi->name, strlen(ifi->name), 1);
if (buf == NULL)
@@ -2355,7 +2348,6 @@ clone_lease(struct client_lease *oldlease)
newlease->renewal = oldlease->renewal;
newlease->rebind = oldlease->rebind;
newlease->is_static = oldlease->is_static;
- newlease->is_bootp = oldlease->is_bootp;
newlease->address = oldlease->address;
newlease->next_server = oldlease->next_server;
memcpy(newlease->ssid, oldlease->ssid, sizeof(newlease->ssid));
@@ -2516,7 +2508,7 @@ compare_lease(struct client_lease *active, struct client_lease *new)
if (active->address.s_addr != new->address.s_addr ||
active->is_static != new->is_static ||
- active->is_bootp != new->is_bootp)
+ BOOTP_LEASE(active) != BOOTP_LEASE(new))
return (1);
if (active->server_name != new->server_name) {
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 4bfa2d81261..cd6645ca589 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.182 2017/06/15 17:06:17 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.183 2017/06/16 14:12:12 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -72,10 +72,10 @@ struct client_lease {
char ssid[32];
uint8_t ssid_len;
unsigned int is_static;
- unsigned int is_bootp;
unsigned int is_invalid;
struct option_data options[256];
};
+#define BOOTP_LEASE(l) ((l)->options[DHO_DHCP_MESSAGE_TYPE].len == 0)
/* Possible states in which the client can be. */
enum dhcp_state {