Skip to content

Commit

Permalink
Rewrite and simplify dhcpleasectl(8).
Browse files Browse the repository at this point in the history
With this

dhcpleasectl em0

does the same as

dhclient em0

used to do. To please people's muscle memory one can be aliased to the other.

earlier version OK benno

with lots of help massaging the output & OK deraadt
  • Loading branch information
fobser committed Sep 15, 2021
1 parent 51ea623 commit a86df30
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 430 deletions.
17 changes: 6 additions & 11 deletions sbin/dhcpleased/engine.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: engine.c,v 1.26 2021/09/15 06:08:01 florian Exp $ */
/* $OpenBSD: engine.c,v 1.27 2021/09/15 15:18:23 florian Exp $ */

/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
Expand Down Expand Up @@ -591,16 +591,11 @@ engine_showinfo_ctl(struct imsg *imsg, uint32_t if_index)

switch (imsg->hdr.type) {
case IMSG_CTL_SHOW_INTERFACE_INFO:
if (if_index == 0) {
LIST_FOREACH (iface, &dhcpleased_interfaces, entries)
send_interface_info(iface, imsg->hdr.pid);
} else {
if ((iface = get_dhcpleased_iface_by_id(if_index)) !=
NULL)
send_interface_info(iface, imsg->hdr.pid);
}
engine_imsg_compose_frontend(IMSG_CTL_END, imsg->hdr.pid, NULL,
0);
if ((iface = get_dhcpleased_iface_by_id(if_index)) != NULL)
send_interface_info(iface, imsg->hdr.pid);
else
engine_imsg_compose_frontend(IMSG_CTL_END,
imsg->hdr.pid, NULL, 0);
break;
default:
log_debug("%s: error handling imsg", __func__);
Expand Down
4 changes: 2 additions & 2 deletions usr.sbin/dhcpleasectl/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# $OpenBSD: Makefile,v 1.1 2021/02/26 16:16:37 florian Exp $
# $OpenBSD: Makefile,v 1.2 2021/09/15 15:18:23 florian Exp $

PROG= dhcpleasectl
SRCS= dhcpleasectl.c parser.c
SRCS= dhcpleasectl.c

MAN= dhcpleasectl.8

Expand Down
43 changes: 18 additions & 25 deletions usr.sbin/dhcpleasectl/dhcpleasectl.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" $OpenBSD: dhcpleasectl.8,v 1.2 2021/08/23 18:09:05 florian Exp $
.\" $OpenBSD: dhcpleasectl.8,v 1.3 2021/09/15 15:18:23 florian Exp $
.\"
.\" Copyright (c) 2021 Florian Obser <florian@openbsd.org>
.\" Copyright (c) 2016 Kenneth R Westerback <kwesterback@gmail.com>
Expand All @@ -16,54 +16,47 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: August 23 2021 $
.Dd $Mdocdate: September 15 2021 $
.Dt DHCPLEASECTL 8
.Os
.Sh NAME
.Nm dhcpleasectl
.Nd control the dhcpleased daemon
.Sh SYNOPSIS
.Nm
.Op Fl l
.Op Fl s Ar socket
.Ar command
.Op Ar argument ...
.Op Fl w Ar maxwait
.Ar interfacename
.Sh DESCRIPTION
The
.Nm
program controls the
program instructs the
.Xr dhcpleased 8
daemon.
daemon to request a new lease.
.Pp
The following options are available:
.Bl -tag -width Ds
.It Fl l
List the configured lease on
.Ar interfacename
instead of requesting a new lease.
.It Fl s Ar socket
Use
.Ar socket
instead of the default
.Pa /dev/dhcpleased.sock
to communicate with
.Xr dhcpleased 8 .
.El
.Pp
The following commands are available:
.Bl -tag -width Ds
.It Cm log brief
Disable verbose debug logging.
.It Cm log verbose
Enable verbose debug logging.
.It Cm send request Ar interfacename
Send a DHCP request on interface
.Ar interfacename
to force a renew of the lease.
.It Cm show interface Op Ar interfacename
Display status about network interfaces.
If
.It Fl w Ar maxwait
Specify the maximum number of seconds to wait for
.Ar interfacename
is specified, only information relative to
.Ar interfacename
is shown.
Otherwise information on all interfaces is shown.
to be configured.
The default is to wait 10 seconds unless
.Fl l
is specified.
.El
.Pp
.Sh FILES
.Bl -tag -width "/dev/dhcpleased.sockXX" -compact
.It Pa /dev/dhcpleased.sock
Expand Down
Loading

0 comments on commit a86df30

Please sign in to comment.