trygetea.c revision 13573
1252602Spjd/*
2252602Spjd * trygetea.c - test program for getether.c
3252603Spjd */
4252602Spjd
51553Srgrimes#include <sys/types.h>
61553Srgrimes#include <sys/socket.h>
71553Srgrimes
81553Srgrimes#if defined(SUNOS) || defined(SVR4)
91553Srgrimes#include <sys/sockio.h>
101553Srgrimes#endif
111553Srgrimes
121553Srgrimes#ifdef _AIX32
131553Srgrimes#include <sys/time.h>	/* for struct timeval in net/if.h */
141553Srgrimes#endif
151553Srgrimes#include <net/if.h>				/* for struct ifreq */
161553Srgrimes#include <netinet/in.h>
171553Srgrimes#include <arpa/inet.h>			/* inet_ntoa */
181553Srgrimes
191553Srgrimes#include <netdb.h>
201553Srgrimes#include <stdio.h>
211553Srgrimes#include <ctype.h>
221553Srgrimes#include <errno.h>
231553Srgrimes
241553Srgrimes#include "getether.h"
251553Srgrimes
261553Srgrimesint debug = 0;
271553Srgrimeschar *progname;
281553Srgrimes
291553Srgrimesvoid
301553Srgrimesmain(argc, argv)
311553Srgrimes	int argc;
3230380Scharnier	char **argv;
331553Srgrimes{
341553Srgrimes	u_char ea[16];				/* Ethernet address */
351553Srgrimes	int i;
361553Srgrimes
37117278Scharnier	progname = argv[0];			/* for report */
381553Srgrimes
391553Srgrimes	if (argc < 2) {
40117278Scharnier		printf("need interface name\n");
4130380Scharnier		exit(1);
421553Srgrimes	}
43117278Scharnier	if ((i = getether(argv[1], (char*)ea)) < 0) {
44117278Scharnier		printf("Could not get Ethernet address (rc=%d)\n", i);
45117278Scharnier		exit(1);
46252605Spjd	}
471553Srgrimes	printf("Ether-addr");
481553Srgrimes	for (i = 0; i < 6; i++)
491553Srgrimes		printf(":%x", ea[i] & 0xFF);
501553Srgrimes	printf("\n");
511553Srgrimes
521553Srgrimes	exit(0);
53252603Spjd}
54252603Spjd