xref: /freebsd/libexec/bootpd/trylook.c (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
1 /*
2  * trylook.c - test program for lookup.c
3  */
4 
5 #include <sys/types.h>
6 #include <netinet/in.h>
7 #include <stdio.h>
8 
9 #include "report.h"
10 #include "lookup.h"
11 
12 extern char *ether_ntoa();
13 extern char *inet_ntoa();
14 
15 int debug = 0;
16 char *progname;
17 
18 void
19 main(argc, argv)
20 	int argc;
21 	char **argv;
22 {
23 	int i;
24 	struct in_addr in;
25 	char *a;
26 	u_char *hwa;
27 
28 	progname = argv[0];			/* for report */
29 
30 	for (i = 1; i < argc; i++) {
31 
32 		/* Host name */
33 		printf("%s:", argv[i]);
34 
35 		/* IP addr */
36 		if (lookup_ipa(argv[i], &in.s_addr))
37 			a = "?";
38 		else
39 			a = inet_ntoa(in);
40 		printf(" ipa=%s", a);
41 
42 		/* Ether addr */
43 		printf(" hwa=");
44 		hwa = lookup_hwa(argv[i], 1);
45 		if (!hwa)
46 			printf("?\n");
47 		else {
48 			int i;
49 			for (i = 0; i < 6; i++)
50 				printf(":%x", hwa[i] & 0xFF);
51 			putchar('\n');
52 		}
53 
54 	}
55 	exit(0);
56 }
57