From bd79c3d337304a96dcce4ae4f97b36143919af10 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 1 Apr 2009 12:36:09 +0000 Subject: dhcpd: remember and record hostnames; optimize get_option dumpleases: show hostnames function old new delta add_lease 230 292 +62 send_offer 403 421 +18 send_ACK 232 249 +17 read_leases 249 258 +9 dumpleases_main 604 609 +5 nobody_responds_to_arp 84 86 +2 udhcp_end_option 32 30 -2 udhcp_get_option 222 171 -51 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 6/2 up/down: 113/-53) Total: 60 bytes --- networking/udhcp/dumpleases.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'networking/udhcp/dumpleases.c') diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c index c0d515d28..1558f8848 100644 --- a/networking/udhcp/dumpleases.c +++ b/networking/udhcp/dumpleases.c @@ -47,8 +47,9 @@ int dumpleases_main(int argc UNUSED_PARAM, char **argv) fd = xopen(file, O_RDONLY); - printf("Mac Address IP-Address Expires %s\n", (opt & OPT_a) ? "at" : "in"); - /* "00:00:00:00:00:00 255.255.255.255 Wed Jun 30 21:49:08 1993" */ + printf("Mac Address IP Address Host Name Expires %s\n", (opt & OPT_a) ? "at" : "in"); + /* "00:00:00:00:00:00 255.255.255.255 ABCDEFGHIJKLMNOPQRS Wed Jun 30 21:49:08 1993" */ + /* "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 */ if (full_read(fd, &written_at, sizeof(written_at)) != sizeof(written_at)) return 0; @@ -64,7 +65,9 @@ int dumpleases_main(int argc UNUSED_PARAM, char **argv) fmt = ":%02x"; } addr.s_addr = lease.yiaddr; - printf(" %-15s ", inet_ntoa(addr)); + /* actually, 15+1 and 19+1, +1 is a space between columns */ + /* lease.hostname is char[20] and is always NUL terminated */ + printf(" %-16s%-20s", inet_ntoa(addr), lease.hostname); expires_abs = ntohl(lease.expires) + written_at; if (expires_abs <= curr) { puts("expired"); -- cgit v1.2.3