1994-09-30 05:45:07 +00:00
|
|
|
/*
|
|
|
|
* trygetea.c - test program for getether.c
|
1996-09-22 21:56:57 +00:00
|
|
|
*
|
1997-02-22 14:22:49 +00:00
|
|
|
* $Id$
|
1994-09-30 05:45:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
#if defined(SUNOS) || defined(SVR4)
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#endif
|
|
|
|
|
1996-01-23 01:35:04 +00:00
|
|
|
#ifdef _AIX32
|
|
|
|
#include <sys/time.h> /* for struct timeval in net/if.h */
|
|
|
|
#endif
|
1994-09-30 05:45:07 +00:00
|
|
|
#include <net/if.h> /* for struct ifreq */
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h> /* inet_ntoa */
|
|
|
|
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
1996-01-23 01:35:04 +00:00
|
|
|
#include "getether.h"
|
|
|
|
|
1994-09-30 05:45:07 +00:00
|
|
|
int debug = 0;
|
|
|
|
char *progname;
|
|
|
|
|
1996-01-23 01:35:04 +00:00
|
|
|
void
|
1994-09-30 05:45:07 +00:00
|
|
|
main(argc, argv)
|
1996-01-23 01:35:04 +00:00
|
|
|
int argc;
|
1994-09-30 05:45:07 +00:00
|
|
|
char **argv;
|
|
|
|
{
|
|
|
|
u_char ea[16]; /* Ethernet address */
|
|
|
|
int i;
|
|
|
|
|
|
|
|
progname = argv[0]; /* for report */
|
|
|
|
|
|
|
|
if (argc < 2) {
|
|
|
|
printf("need interface name\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
1996-01-23 01:35:04 +00:00
|
|
|
if ((i = getether(argv[1], (char*)ea)) < 0) {
|
1994-09-30 05:45:07 +00:00
|
|
|
printf("Could not get Ethernet address (rc=%d)\n", i);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
printf("Ether-addr");
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
printf(":%x", ea[i] & 0xFF);
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|