13229Spst/*
23229Spst * trylook.c - test program for lookup.c
318471Swosch *
450476Speter * $FreeBSD: releng/10.3/libexec/bootpd/trylook.c 50476 1999-08-28 00:22:10Z peter $
53229Spst */
63229Spst
73229Spst#include <sys/types.h>
83229Spst#include <netinet/in.h>
93229Spst#include <stdio.h>
103229Spst
113229Spst#include "report.h"
123229Spst#include "lookup.h"
133229Spst
143229Spstextern char *ether_ntoa();
153229Spstextern char *inet_ntoa();
163229Spst
173229Spstint debug = 0;
183229Spstchar *progname;
193229Spst
2013572Spstvoid
213229Spstmain(argc, argv)
2213572Spst	int argc;
233229Spst	char **argv;
243229Spst{
253229Spst	int i;
263229Spst	struct in_addr in;
273229Spst	char *a;
283229Spst	u_char *hwa;
293229Spst
303229Spst	progname = argv[0];			/* for report */
313229Spst
323229Spst	for (i = 1; i < argc; i++) {
333229Spst
343229Spst		/* Host name */
353229Spst		printf("%s:", argv[i]);
363229Spst
373229Spst		/* IP addr */
383229Spst		if (lookup_ipa(argv[i], &in.s_addr))
393229Spst			a = "?";
403229Spst		else
413229Spst			a = inet_ntoa(in);
423229Spst		printf(" ipa=%s", a);
433229Spst
443229Spst		/* Ether addr */
4513572Spst		printf(" hwa=");
463229Spst		hwa = lookup_hwa(argv[i], 1);
473229Spst		if (!hwa)
4813572Spst			printf("?\n");
4913572Spst		else {
5013572Spst			int i;
5113572Spst			for (i = 0; i < 6; i++)
5213572Spst				printf(":%x", hwa[i] & 0xFF);
5313572Spst			putchar('\n');
5413572Spst		}
553229Spst
563229Spst	}
573229Spst	exit(0);
583229Spst}
59