xref: /netbsd-src/usr.sbin/bootp/bootptest/trygetea.c (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1 /*	$NetBSD: trygetea.c,v 1.4 2002/07/14 00:07:01 wiz Exp $	*/
2 
3 #include <sys/cdefs.h>
4 #ifndef lint
5 __RCSID("$NetBSD: trygetea.c,v 1.4 2002/07/14 00:07:01 wiz Exp $");
6 #endif
7 
8 /*
9  * trygetea.c - test program for getether.c
10  */
11 
12 #include <sys/types.h>
13 #include <sys/socket.h>
14 
15 #if defined(SUNOS) || defined(SVR4)
16 #include <sys/sockio.h>
17 #endif
18 
19 #include <net/if.h>				/* for struct ifreq */
20 #include <netinet/in.h>
21 #include <arpa/inet.h>			/* inet_ntoa */
22 
23 #include <netdb.h>
24 #include <stdio.h>
25 #include <ctype.h>
26 #include <errno.h>
27 
28 int debug = 0;
29 char *progname;
30 
31 int
32 main(int argc, char **argv)
33 {
34 	u_char ea[16];				/* Ethernet address */
35 	int i;
36 
37 	progname = argv[0];			/* for report */
38 
39 	if (argc < 2) {
40 		printf("need interface name\n");
41 		exit(1);
42 	}
43 	if ((i = getether(argv[1], ea)) < 0) {
44 		printf("Could not get Ethernet address (rc=%d)\n", i);
45 		exit(1);
46 	}
47 	printf("Ether-addr");
48 	for (i = 0; i < 6; i++)
49 		printf(":%x", ea[i] & 0xFF);
50 	printf("\n");
51 
52 	exit(0);
53 }
54