tdhcpleases.c - plan9port - [fork] Plan 9 from user space | |
git clone git://src.adamsgaard.dk/plan9port | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
tdhcpleases.c (777B) | |
--- | |
1 #include <u.h> | |
2 #include <libc.h> | |
3 #include <bio.h> | |
4 #include <ndb.h> | |
5 #include <ip.h> | |
6 #include "dat.h" | |
7 | |
8 extern char *binddir; | |
9 long now; | |
10 char *blog = "ipboot"; | |
11 int minlease = MinLease; | |
12 | |
13 void | |
14 main(void) | |
15 { | |
16 Dir *all; | |
17 int i, nall, fd; | |
18 Binding b; | |
19 | |
20 fmtinstall('E', eipfmt); | |
21 fmtinstall('I', eipfmt); | |
22 fmtinstall('V', eipfmt); | |
23 fmtinstall('M', eipfmt); | |
24 | |
25 fd = open(binddir, OREAD); | |
26 if(fd < 0) | |
27 sysfatal("opening %s: %r", binddir); | |
28 nall = dirreadall(fd, &all); | |
29 if(nall < 0) | |
30 sysfatal("reading %s: %r", binddir); | |
31 close(fd); | |
32 | |
33 b.boundto = 0; | |
34 b.lease = b.offer = 0; | |
35 now = time(0); | |
36 for(i = 0; i < nall; i++){ | |
37 parseip(b.ip, all[i].name); | |
38 if(syncbinding(&b, 0) < 0) | |
39 continue; | |
40 if(b.lease > now) | |
41 print("%I leased by %s until %s", b.ip, b.boundt… | |
42 } | |
43 } |