aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ip/dhcpd/dhcpleases.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-12-26 04:48:52 +0000
committerrsc <devnull@localhost>2005-12-26 04:48:52 +0000
commit87a52e0485d3281ebea6bf4b725aa8023690e96f (patch)
tree0abc2d2ddb875196177231639d3cb4519e814b9d /src/cmd/ip/dhcpd/dhcpleases.c
parent35d26aa32167e84326cdb745c0e906393b8de71d (diff)
downloadplan9port-87a52e0485d3281ebea6bf4b725aa8023690e96f.tar.gz
plan9port-87a52e0485d3281ebea6bf4b725aa8023690e96f.tar.bz2
plan9port-87a52e0485d3281ebea6bf4b725aa8023690e96f.zip
new goodies
Diffstat (limited to 'src/cmd/ip/dhcpd/dhcpleases.c')
-rwxr-xr-xsrc/cmd/ip/dhcpd/dhcpleases.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/cmd/ip/dhcpd/dhcpleases.c b/src/cmd/ip/dhcpd/dhcpleases.c
new file mode 100755
index 00000000..71719649
--- /dev/null
+++ b/src/cmd/ip/dhcpd/dhcpleases.c
@@ -0,0 +1,43 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include <ndb.h>
+#include <ip.h>
+#include "dat.h"
+
+extern char *binddir;
+ long now;
+ char *blog = "ipboot";
+ int minlease = MinLease;
+
+void
+main(void)
+{
+ Dir *all;
+ int i, nall, fd;
+ Binding b;
+
+ fmtinstall('E', eipfmt);
+ fmtinstall('I', eipfmt);
+ fmtinstall('V', eipfmt);
+ fmtinstall('M', eipfmt);
+
+ fd = open(binddir, OREAD);
+ if(fd < 0)
+ sysfatal("opening %s: %r", binddir);
+ nall = dirreadall(fd, &all);
+ if(nall < 0)
+ sysfatal("reading %s: %r", binddir);
+ close(fd);
+
+ b.boundto = 0;
+ b.lease = b.offer = 0;
+ now = time(0);
+ for(i = 0; i < nall; i++){
+ parseip(b.ip, all[i].name);
+ if(syncbinding(&b, 0) < 0)
+ continue;
+ if(b.lease > now)
+ print("%I leased by %s until %s", b.ip, b.boundto, ctime(b.lease));
+ }
+}