xref: /freebsd/libexec/bootpd/trylook.c (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
144099b7bSPaul Traina /*
244099b7bSPaul Traina  * trylook.c - test program for lookup.c
344099b7bSPaul Traina  */
444099b7bSPaul Traina 
544099b7bSPaul Traina #include <sys/types.h>
644099b7bSPaul Traina #include <netinet/in.h>
744099b7bSPaul Traina #include <stdio.h>
844099b7bSPaul Traina 
944099b7bSPaul Traina #include "report.h"
1044099b7bSPaul Traina #include "lookup.h"
1144099b7bSPaul Traina 
1244099b7bSPaul Traina extern char *ether_ntoa();
1344099b7bSPaul Traina extern char *inet_ntoa();
1444099b7bSPaul Traina 
1544099b7bSPaul Traina int debug = 0;
1644099b7bSPaul Traina char *progname;
1744099b7bSPaul Traina 
18e08ac58bSPaul Traina void
main(argc,argv)1944099b7bSPaul Traina main(argc, argv)
20e08ac58bSPaul Traina 	int argc;
2144099b7bSPaul Traina 	char **argv;
2244099b7bSPaul Traina {
2344099b7bSPaul Traina 	int i;
2444099b7bSPaul Traina 	struct in_addr in;
2544099b7bSPaul Traina 	char *a;
2644099b7bSPaul Traina 	u_char *hwa;
2744099b7bSPaul Traina 
2844099b7bSPaul Traina 	progname = argv[0];			/* for report */
2944099b7bSPaul Traina 
3044099b7bSPaul Traina 	for (i = 1; i < argc; i++) {
3144099b7bSPaul Traina 
3244099b7bSPaul Traina 		/* Host name */
3344099b7bSPaul Traina 		printf("%s:", argv[i]);
3444099b7bSPaul Traina 
3544099b7bSPaul Traina 		/* IP addr */
3644099b7bSPaul Traina 		if (lookup_ipa(argv[i], &in.s_addr))
3744099b7bSPaul Traina 			a = "?";
3844099b7bSPaul Traina 		else
3944099b7bSPaul Traina 			a = inet_ntoa(in);
4044099b7bSPaul Traina 		printf(" ipa=%s", a);
4144099b7bSPaul Traina 
4244099b7bSPaul Traina 		/* Ether addr */
43e08ac58bSPaul Traina 		printf(" hwa=");
4444099b7bSPaul Traina 		hwa = lookup_hwa(argv[i], 1);
4544099b7bSPaul Traina 		if (!hwa)
46e08ac58bSPaul Traina 			printf("?\n");
47e08ac58bSPaul Traina 		else {
48e08ac58bSPaul Traina 			int i;
49e08ac58bSPaul Traina 			for (i = 0; i < 6; i++)
50e08ac58bSPaul Traina 				printf(":%x", hwa[i] & 0xFF);
51e08ac58bSPaul Traina 			putchar('\n');
52e08ac58bSPaul Traina 		}
5344099b7bSPaul Traina 
5444099b7bSPaul Traina 	}
5544099b7bSPaul Traina 	exit(0);
5644099b7bSPaul Traina }
57