/* vi: set sw=4 ts=4: */
/*
 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
 */
#include <getopt.h>

#include "common.h"
#include "dhcpd.h"

int dumpleases_main(int argc, char **argv);
int dumpleases_main(int argc, char **argv)
{
	int fd;
	int i;
	unsigned opt;
	time_t expires;
	const char *file = LEASES_FILE;
	struct dhcpOfferedAddr lease;
	struct in_addr addr;

	enum {
		OPT_a	= 0x1,	// -a
		OPT_r	= 0x2,	// -r
		OPT_f	= 0x4,	// -f
	};
#if ENABLE_GETOPT_LONG
	static const struct option options[] = {
		{ "absolute", no_argument, 0, 'a' },
		{ "remaining", no_argument, 0, 'r' },
		{ "file", required_argument, 0, 'f' },
		{ NULL, 0, 0, 0 }
	};

	applet_long_options = options;
#endif
	opt_complementary = "=0:?:a--r:r--a";
	opt = getopt32(argc, argv, "arf:", &file);

	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" */
	while (full_read(fd, &lease, sizeof(lease)) == sizeof(lease)) {
		printf(":%02x"+1, lease.chaddr[0]);
		for (i = 1; i < 6; i++) {
			printf(":%02x", lease.chaddr[i]);
		}
		addr.s_addr = lease.yiaddr;
		printf(" %-15s ", inet_ntoa(addr));
		expires = ntohl(lease.expires);
		if (!(opt & OPT_a)) { /* no -a */
			if (!expires)
				puts("expired");
			else {
				unsigned d, h, m;
				d = expires / (24*60*60); expires %= (24*60*60);
				h = expires / (60*60); expires %= (60*60);
				m = expires / 60; expires %= 60;
				if (d) printf("%u days ", d);
				printf("%02u:%02u:%02u\n", h, m, (unsigned)expires);
			}
		} else /* -a */
			fputs(ctime(&expires), stdout);
	}
	/* close(fd); */

	return 0;
}
