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