summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r--sbin/dhclient/dhclient.c57
1 files changed, 40 insertions, 17 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index f912b65e883..3b235257de6 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.546 2018/01/28 11:29:30 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.547 2018/01/28 23:12:36 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -154,6 +154,7 @@ void send_discover(struct interface_info *);
void send_request(struct interface_info *);
void send_decline(struct interface_info *);
+void process_offer(struct interface_info *, struct option_data *);
void bind_lease(struct interface_info *);
void make_discover(struct interface_info *, struct client_lease *);
@@ -831,19 +832,40 @@ state_selecting(struct interface_info *ifi)
}
void
-dhcpoffer(struct interface_info *ifi, struct option_data *options, char *info)
+dhcpoffer(struct interface_info *ifi, struct option_data *options,
+ const char *src)
{
- struct client_lease *lease;
- time_t cur_time, stop_selecting;
+ if (ifi->state != S_SELECTING) {
+ DPRINTF("%s: unexpected DHCPOFFER from %s - state #%d",
+ log_procname, src, ifi->state);
+ return;
+ }
+
+ log_info("%s: DHCPOFFER from %s", log_procname, src);
+ process_offer(ifi, options);
+}
+void
+bootreply(struct interface_info *ifi, struct option_data *options,
+ const char *src)
+{
if (ifi->state != S_SELECTING) {
- DPRINTF("%s: unexpected %s - state #%d", log_procname, info,
- ifi->state);
+ DPRINTF("%s: unexpected BOOTREPLY from %s - state #%d",
+ log_procname, src, ifi->state);
return;
}
+ log_info("%s: BOOTREPLY from %s", log_procname, src);
+ process_offer(ifi, options);
+}
+
+void
+process_offer(struct interface_info *ifi, struct option_data *options)
+{
+ struct client_lease *lease;
+ time_t cur_time, stop_selecting;
+
time(&cur_time);
- log_info("%s: %s", log_procname, info);
lease = packet_to_lease(ifi, options);
if (lease != NULL) {
@@ -873,7 +895,8 @@ dhcpoffer(struct interface_info *ifi, struct option_data *options, char *info)
}
void
-dhcpack(struct interface_info *ifi, struct option_data *options, char *info)
+dhcpack(struct interface_info *ifi, struct option_data *options,
+ const char *src)
{
struct client_lease *lease;
@@ -881,12 +904,12 @@ dhcpack(struct interface_info *ifi, struct option_data *options, char *info)
ifi->state != S_REQUESTING &&
ifi->state != S_RENEWING &&
ifi->state != S_REBINDING) {
- DPRINTF("%s: unexpected %s - state #%d", log_procname, info,
- ifi->state);
+ DPRINTF("%s: unexpected DHCPACK from %s - state #%d",
+ log_procname, src, ifi->state);
return;
}
- log_info("%s: %s", log_procname, info);
+ log_info("%s: DHCPACK from %s", log_procname, src);
lease = packet_to_lease(ifi, options);
if (lease == NULL) {
@@ -906,24 +929,24 @@ dhcpack(struct interface_info *ifi, struct option_data *options, char *info)
}
void
-dhcpnak(struct interface_info *ifi, struct option_data *options, char *info)
+dhcpnak(struct interface_info *ifi, const char *src)
{
if (ifi->state != S_REBOOTING &&
ifi->state != S_REQUESTING &&
ifi->state != S_RENEWING &&
ifi->state != S_REBINDING) {
- DPRINTF("%s: unexpected %s - state #%d", log_procname, info,
- ifi->state);
+ DPRINTF("%s: unexpected DHCPNAK from %s - state #%d",
+ log_procname, src, ifi->state);
return;
}
if (ifi->active == NULL) {
- DPRINTF("%s: unexpected %s - no active lease", log_procname,
- info);
+ DPRINTF("%s: unexpected DHCPNAK from %s - no active lease",
+ log_procname, src);
return;
}
- log_info("%s: %s", log_procname, info);
+ log_info("%s: DHCPNAK from %s", log_procname, src);
delete_address(ifi->active->address);
/* XXX Do we really want to remove a NAK'd lease from the database? */