aboutsummaryrefslogtreecommitdiff
path: root/libexec/bootpd/trylook.c
blob: 9484d04b6da3d9dc97993f57a25300feaab5f462 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * trylook.c - test program for lookup.c
 *
 * $FreeBSD$
 */

#include <sys/types.h>
#include <netinet/in.h>
#include <stdio.h>

#include "report.h"
#include "lookup.h"

extern char *ether_ntoa();
extern char *inet_ntoa();

int debug = 0;
char *progname;

void
main(argc, argv)
	int argc;
	char **argv;
{
	int i;
	struct in_addr in;
	char *a;
	u_char *hwa;

	progname = argv[0];			/* for report */

	for (i = 1; i < argc; i++) {

		/* Host name */
		printf("%s:", argv[i]);

		/* IP addr */
		if (lookup_ipa(argv[i], &in.s_addr))
			a = "?";
		else
			a = inet_ntoa(in);
		printf(" ipa=%s", a);

		/* Ether addr */
		printf(" hwa=");
		hwa = lookup_hwa(argv[i], 1);
		if (!hwa)
			printf("?\n");
		else {
			int i;
			for (i = 0; i < 6; i++)
				printf(":%x", hwa[i] & 0xFF);
			putchar('\n');
		}

	}
	exit(0);
}